akhauriyash/Code-Regression huggingface dataset:
import sys
readline = sys.stdin.readline
class Node:
    __slots__ = ['value', 'left', 'right']
    def __init__(self, value = None, left = None, right = None):
        self.value = value
        self.left = left
        self.right = right
class BinTree:
    __slots__ = ['_tree', 'result']
    def __init__(self):
        self._tree = None
    def insert(self, value):
        p = None
        c = self._tree
        while c is not None:
            p = c
            if value < c.value:
                c = c.left
            else:
                c = c.right
        if p is None:
            self._tree = Node(value)
        elif value < p.value:
            p.left = Node(value)
        else:
            p.right = Node(value)
    def find(self, value):
        c = self._tree
        while c is not None:
            if value == c.value:
                return True
            elif value < c.value:
                c = c.left
            else:
                c = c.right
        return False
    def delete(self, value):
        def node_move(p, c, a):
            if p.left == c:
                p.left = a
            else:
                p.right = a
        p = None
        c = self._tree
        while c.value != value:
            p = c
            if c is None:
                return
            if value < c.value:
                c = c.left
            else:
                c = c.right
        if c.left is None:
            node_move(p, c, c.right)
        elif c.right is None:
            node_move(p, c, c.left)
        elif c.right.left is None:
            c.right.left = c.left
            node_move(p, c, c.right)
        else:
            q = c.right
            while q.left.left is not None:
                q = q.left
            c.value = q.left.value
            q.left = q.left.right
        return
    def preoder_walk(self):
        self.result = []
        def preoder(node):
            if node is not None:
                self.result.append(node.value)
                preoder(node.left)
                preoder(node.right)
        preoder(self._tree)
        print(" " + " ".join(map(str, self.result)))
    def inorder_walk(self):
        self.result = []
        def inorder(node):
            if node is not None:
                inorder(node.left)
                self.result.append(node.value)
                inorder(node.right)
        inorder(self._tree)
        print(" " + " ".join(map(str, self.result)))
n = int(input())
tree = BinTree()
for _ in range(n):
    com = readline().split()
    if com[0] == "insert":
        tree.insert(int(com[1]))
    elif com[0] == "find":
        print("yes" if tree.find(int(com[1])) else "no")
    elif com[0] == "delete":
        tree.delete(int(com[1]))
    else:
        tree.inorder_walk()
        tree.preoder_walk()



Measured memory_bytes: 77188
#include<iostream>
#include<cstdio>
#include<string.h>
#include<cmath>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
int N,M,ans=-0x3f3f3f3f;
int a[310][310];
int num[310]={0};
void init()
{
	cin>>N>>M;
	for(int i=1;i<=N;i++)
	for(int j=1;j<=M;j++)
	cin>>a[i][j];
	int v[310];
	for(int i=1;i<=M;i++)
	v[i]=1;
	ans=N;
	int cnt=0;
	while(1)
	{
		memset(num,0,sizeof(num));
		for(int i=1;i<=N;i++)
		{
			for(int j=1;j<=M;j++)
			{
			   if(v[a[i][j]]) 
			   {
			   	 num[a[i][j]]++;
			   	 break;
			   }
		 } 
	   }
	   int MAX=0;
	   for(int i=1;i<=M;i++)
	   {
	   	   MAX=max(MAX,num[i]);
	   }
	   for(int i=1;i<=M;i++)
	   {
	   	 if(num[i]==MAX)
	   	 v[i]=0, cnt++;
	   	 
	   }
	   ans=min(ans,MAX);
	   if(cnt==M)
	   break;
   }
   cout<<ans<<endl;	
}
int main()
{
	//freopen("test.in","r",stdin);
	//freopen("test.out","w",stdout);
	init();
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int>vec(N),dp(N);
  for(int i=0; i<N; i++){
    cin >> vec[i];
  }
  dp[0] = 0,dp[1] = abs(vec[1]-vec[0]);
  for(int i=2; i<N; i++){
    dp[i] = min(dp[i-2]+abs(vec[i]-vec[i-2]),dp[i-1]+abs(vec[i]-vec[i-1]));
  }
  cout << dp[N-1] << endl;
}


Measured memory_bytes: 4052
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
using namespace std;
struct masu{int x,y,tn;};//x,y,ターン
bool ta[1500][1500];
bool used[1500][1500];
bool come[1500][1500];
int dx[6]={1,-1,1,0,0,-1},dy[6]={0,0,1,1,-1,-1};
const int mar=700;
int main(){
	int t,n;
	while(true){
	cin>>t>>n;
	if(n==0&&t==0)break;
	for(int i=0;i<1500;i++)for(int j=0;j<1500;j++)ta[i][j]=0,used[i][j]=0,come[i][j]=0;
	for(int i=0;i<n;i++){
	int tx,ty;
	cin>>tx>>ty;
	tx+=mar,ty+=mar;
	ta[ty][tx]=1;
	}
	int nx,ny;
	cin>>nx>>ny;
	used[ny+mar][nx+mar]=1;
	masu start;
	start.x=nx+mar,start.y=ny+mar,start.tn=0;
	queue<masu>bfs;
	bfs.push(start);
	while(bfs.empty()==false){
	masu tmp=bfs.front();
	bfs.pop();
	int nx=tmp.x,ny=tmp.y,ntn=tmp.tn;
	if(come[ny][nx]==1)continue;
	come[ny][nx]=1;
	used[ny][nx]=1;
	if(ntn+1>t)continue;
		for(int i=0;i<6;i++){
		int nextx=nx+dx[i],nexty=ny+dy[i];
			if(ta[nexty][nextx]==0&&used[nexty][nextx]==0){
			masu next;
			next.x=nx+dx[i],next.y=ny+dy[i];
			next.tn=ntn+1;
			bfs.push(next);
			}
		}
	}
	int ans=0;
	for(int i=0;i<1500;i++){
	for(int j=0;j<1500;j++){
	if(come[i][j]){ans++;}
	}
	}
	cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 7816
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto M = RD;

	writeln(48-M);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
# define ll long long int
#define M 998244353 
#define ff1 first
#define ss second
#define pb push_back  
#define INF 1000000000000
                                        // nestedcode

                                        
ll binpow(ll x, ll y){
	ll ans = 1;
	while(y){
		if(y&1)	ans = (ans*x)%M;
		x = (x*x)%M;
		y>>=1;
	}
	return ans;
}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll ans = (n*(n-1)/2) + (m*(m-1))/2;
    cout<<ans;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
unsigned long long f(unsigned long long n, unsigned long long x) {
    if (n < x) swap(n, x);
    if (n % x == 0) return x * ((n / x) + (n / x) - 1);
    return x * (n / x) + x * (n / x) + f(n - x * (n / x), x);
}
int main() {
    ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    unsigned long long n, x;
    cin >> n >> x;
    cout << n + f(n - x, x);
    return 0;
}


Measured memory_bytes: 256
def main():

    tmp=list(map(int,input().split()))
    X = tmp[2]
    Y = tmp[3]
    xl = list(map(int,input().split()))
    yl = list(map(int,input().split()))

    for i in range(X+2,Y+1):
        if max(xl) < i and i <= min(yl):
            print("No War")
            exit()

    print("War")
        
    
if __name__== "__main__":
    main() 


Measured memory_bytes: 3060
#include <stdio.h>

#define N 100000

typedef struct{
  int p;
  int l;
  int r;
}Node;

int Height(Node*, int);

int main(){

   int i;
   int j;
   int n;
   int id;
   int left;
   int right;
   int depth;
   int sibling;
   int degree;
   int height;
  Node T[N];

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    T[i].p = -1;
    T[i].l = -1;
    T[i].r = -1;
  }
  
  for(i=0;i<n;i++){
    scanf("%d",&id);
    scanf("%d%d",&T[id].l,&T[id].r);
    T[T[id].l].p = id;
    T[T[id].r].p = id;
   }
  
    for(i=0;i<n;i++){
    printf("node %d: parent = %d, ",i,T[i].p);


    sibling =-1;
    
    if(T[i].p!=-1){
         if(T[T[i].p].l != i && T[T[i].p].l != -1) sibling =  T[T[i].p].l;
    else if(T[T[i].p].r != i && T[T[i].p].r != -1) sibling =  T[T[i].p].r;
    }
    
    printf("sibling = %d, ",sibling);

    degree = 0;
    if(T[i].l!=-1) degree++;
    if(T[i].r!=-1) degree++;

    printf("degree = %d, ",degree);
    
        depth=0;
        id=i;
        while(T[id].p != -1){
            depth++;
            id=T[id].p;
        }
        printf("depth = %d, ",depth);

	height = Height(T,i);
	printf("height = %d, ",height);
	
        if(T[i].p==-1) printf("root\n");
        else if(T[i].l==-1 && T[i].r==-1) printf("leaf\n");
        else printf("internal node\n");
 }
  
  return 0;
}

int Height(Node *T, int i){

  int left=0;
  int right=0;
  
    if (T[i].r == -1 && T[i].l == -1) return 0;
    if (T[i].l != -1){
      left =  Height(T,T[i].l)+1;
    }
    if(T[i].r != -1){
      right =  Height(T,T[i].r)+1;
    }
    if(left > right) return left; 
     
    else return right; 
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

enum{
  t = 0,
  f ,
  r ,
  b ,
  l ,
  d,
};

array<int,6> dice = {1,3,5,4,2,6};

void Spin(array<int,6> &D,int dir){
  if(dir == l){//
    swap(D[t],D[r]);
    swap(D[r],D[d]);
    swap(D[d],D[l]);
  }
  else if(dir == r){
    swap(D[t],D[l]);
    swap(D[l],D[d]);
    swap(D[d],D[r]);
  }
  else if(dir == f){
    swap(D[t],D[b]);
    swap(D[b],D[d]);
    swap(D[d],D[f]);
  }
  else if(dir == b){
    swap(D[t],D[f]);
    swap(D[f],D[d]);
    swap(D[d],D[b]);
  }
  else if(dir == d){//leftspin
    swap(D[f],D[r]);
    swap(D[r],D[b]);
    swap(D[b],D[l]);
  }
  else if(dir == t){
    swap(D[f],D[l]);
    swap(D[l],D[b]);
    swap(D[b],D[r]);
  }
}

void MatchDice(array<int,6> &D,int T,int F){
  rep(i,4){
    Spin(D,r);
    if(D[t] == T)break;
  }
  if(D[t] != T){
    rep(i,4){
      Spin(D,f);
      if(D[t] == T)break;
    }
  }
  rep(i,4){
    Spin(D,t);
    if(D[f] == F) break;
  }
}

void ViewDice(array<int,6> D){
  rep(i,6){
    cout << D[i]<< " ";
  }
  cout << endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  array<int,6> di,di2,tmp;
  cin >> di[t] >> di[f] >> di[r] >> di[l] >> di[b] >> di[d];
  cin >> di2[t] >> di2[f] >> di2[r] >> di2[l] >> di2[b] >> di2[d];
  tmp = di2;
  rep(i,6){
    Spin(di2,r);
    rep(j,4){
      Spin(di2,t);
      rep(k,4){
        Spin(di2,r);
        if(di == di2){
          cout << "Yes"<<endl;
          return 0;
        }
      }
    }
  }
  cout << "No"<<endl;
  return 0;
}

Measured memory_bytes: 3228
N = int(input())
D = [list(map(int,input().split()))+[k] for k in range(N)]

T = sorted(D, key = lambda x: x[0]+x[1], reverse = True)
A = sorted(D, key = lambda x: x[1]+x[0], reverse = True)
U = [1 for k in range(N)]

ans = 0
l = 0
m = 0
for k in range(N):
    if k%2 == 0:
        while U[T[l][2]] == 0:
            l += 1
        ans += T[l][0]
        U[T[l][2]] = 0
    else:
        while U[A[m][2]] == 0:
            m += 1
        ans -= A[m][1]
        U[A[m][2]] = 0

print(ans)


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

using namespace std;

#define ll long long
#define F first
#define S second
#define ii pair < int , int >

const int N=30;

int main()
{
    int n;
    scanf("%d",&n);
    if(n>=30){
        printf("Yes");
    }
    else{
        printf("No");
    }
}


Measured memory_bytes: 3716
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;
 
    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);
 
    private int N;
    private int W;
    private int[] w;
    private int[] v;
 
    private Map<String, Long> memo = new HashMap<>();
 
    private void solve(Scanner sc) {
        N = sc.nextInt();
        W = sc.nextInt();
        w = new int[N];
        v = new int[N];
        for (int i = 0; i < N; ++i) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
        }
 
        _out.println(calc(0, 0));
    }
    private long calc(int d, long weight) {
        String key = d + ":" + weight;
        if (d >= N) {
            return 0;
        }
        if (memo.containsKey(key)) {
            return memo.get(key);
        }
 
        long v1 = 0;
        if (weight + w[d] <= W) {
            v1 = calc(d + 1, weight + w[d]) + v[d];
        }
        long v2 = calc(d + 1, weight);
        long vr = Math.max(v1, v2);
        memo.put(key, vr);
        return vr;
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 54964
n,m = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
x,y,inf = [2,5,5,4,5,6,3,7,6],set(),float("inf")
dp,ans = [0,-inf],[]
def f(i,y):
    num = -inf
    for j in y:
        if i>=j: num = max(num,dp[i-j]+1)
    return num 
for i in a: y.add(x[i-1])
for i in range(2,n+1): dp.append(f(i,y))
a,N = sorted(a)[::-1],n
for i in range(dp[n]):
    for j in a:
        if N>=x[j-1] and dp[N-x[j-1]]==dp[N]-1:
            ans.append(str(j))
            N-=x[j-1]
            break
print("".join(ans))

Measured memory_bytes: 3684
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;

class Ph
{
    static void Main()
    {
        string s = Console.ReadLine();
        Console.WriteLine(s.Length == 2 ? s : string.Join("", s.Reverse()));
        return;
        var nmd = Console.ReadLine().Split().Select(int.Parse).ToList();
        var a = Console.ReadLine().Split().Select(int.Parse).ToList();
        int[] swap = Enumerable.Range(0, nmd[0]).ToArray();
        for (int i = a.Count - 1; i >= 0; i--)
        {
            var tmp = swap[a[i] - 1];
            swap[a[i] - 1] = swap[a[i]];
            swap[a[i]] = tmp;
        }

        int[] res = Enumerable.Range(1, nmd[0]).ToArray();
        while (nmd[2] > 0)
        {
            if ((nmd[2] & 1) == 1) res = Operate(res, swap);
            swap = Operate(swap, swap);
            nmd[2] >>= 1;
        }
        Console.WriteLine(string.Join("\n", res));
    }

    static int[] Operate(int[] a, int [] op)
    {
        var res = a.ToArray();
        for (int i = 0; i < op.Length; i++)
        {
            res[i] = a[op[i]];
        }
        return res;
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
#define  B   begin()
#define  E   end()
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;
ll a[N];
int main()
{
    ft
    ll t,i,j,n,m,l,r,x,y;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    if(n==2)
    {
        swap(a[0],a[1]);
        cout<<a[0]<<" "<<a[1]<<"\n";
    }
    else
    {
        x=0;
        for(i=0;i<n;i+=2)
        {
            y=a[i]^a[i+1];
            x^=y;
        }
        for(i=0;i<n;i++)
        {
            cout<<(x^a[i])<<" ";
        }
    }
    return 0;
}



Measured memory_bytes: 5088
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, pair<ll, ll> > p;
 
#define MOD 1000000007
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    ll k;
    cin >> k;

    ll x = 7LL;

    ll ans = 1LL;

    for(int i = 0; i < pow(10, 6); i++) {
        if(x >= k) {
            x %= k;
            if(x == 0LL) {
                break;
            }
        }
        x *= 10LL;
        x += 7LL;
        ans++;
    }

    if(x == 0LL) {
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
const int N=5010;
int n;
int head[N],cnt;
struct edge
{
	int to,next;
}e[N<<1];
const int mod=1000000007;
void adde(int a,int b)
{
	e[++cnt].to=b; e[cnt].next=head[a]; head[a]=cnt;
}
long long f[N][N],g[N];
int sz[N];
void dfs(int u,int fa)
{
	f[u][1]=1;sz[u]=1;
	int tmp[N];
	memset(tmp,0,sizeof(tmp));
	for(int i=head[u];i;i=e[i].next)
	{
		int v=e[i].to;
		if(v==fa)continue;
		dfs(v,u);
		for(int j=sz[u];j>=0;j--)
			for(int k=sz[v];k>=0;k--)
				(tmp[j+k]+=f[u][j]*f[v][k]%mod)%=mod;
		sz[u]+=sz[v];
		for(int j=0;j<=sz[u];j++)
			f[u][j]=tmp[j],tmp[j]=0;
	}
	f[u][0]=0;
	for(int i=1;i<=sz[u];i++)
		(f[u][0]+=mod-f[u][i]*g[i]%mod)%=mod;
}
int main()
{
	scanf("%d",&n);
	int u,v;
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		adde(u,v); adde(v,u);
	}
	g[2]=1;
	for(int i=4;i<=n;i+=2)g[i]=g[i-2]*(i-1)%mod;
	dfs(1,0);
	printf("%lld\n",(mod-f[1][0])%mod);
	return 0;
}

Measured memory_bytes: 274816
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,nn) for(int i=0;i<nn;i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
  int n,x;
  cin >> n >> x;
  int l[110];
  FOR(i,n){
    cin >> l[i]; 
  }
  int ans=1,nowi=0;
  FOR(i,n){
    nowi+=l[i];
    if(nowi<=x){
      ans++;
    }else{
      break;
      
    }
  }
  cout << ans << endl;
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;

#define BIG_NUM 2000000000

using namespace std;

int table_4[24][4],table_5[120][5],index_9,m_data[9] = {0,1,2,3,4,5,6,7,8};
int** table_9;

void calc9(){
	int select_num = 5,num,loc_left[5],loc_right[4],left_index,right_index,left_calc[5],right_calc[4];

	index_9 = 0;

	for(int i = 0; i < 512;i++){
		num = 0;
		for(int k = 0; k < 9; k++){
			if(i & (1 << k))num++;
		}
		if(num != select_num)continue;

		left_index = right_index = 0;

		for(int k = 0; k < 9; k++){
			if(i & (1 << k)){
				loc_left[left_index++] = k;
			}else{
				loc_right[right_index++] = k;
			}
		}

		left_index = right_index = 0;

		left_calc[0] = m_data[loc_left[0]],left_calc[1] = m_data[loc_left[1]],left_calc[2] = m_data[loc_left[2]],left_calc[3] = m_data[loc_left[3]],left_calc[4] = m_data[loc_left[4]];
		right_calc[0] = m_data[loc_right[0]],right_calc[1] = m_data[loc_right[1]],right_calc[2] = m_data[loc_right[2]],right_calc[3] = m_data[loc_right[3]];

		for(int k = 0; k < 120; k++){
			for(int p = 0; p < 24; p++){
				for(int a = 0; a < 4; a++){
					table_9[index_9][a] = left_calc[table_5[k][a]];
					table_9[index_9][5+a] = right_calc[table_4[p][a]];
				}
				table_9[index_9][4] = left_calc[table_5[k][4]];
				index_9++;
			}
		}
	}
}


int main(){

	int index_4 = 0;

	for(int a = 0; a < 4; a++){
		for(int b = 0; b < 4; b++){
			for(int c = 0; c < 4; c++){
				for(int d = 0; d < 4; d++){
					if(a != b && a != c && a != d && b != c && b != d && c != d){
						table_4[index_4][0] = a,table_4[index_4][1] = b,table_4[index_4][2] = c,table_4[index_4][3] = d;
						index_4++;
					}
				}
			}
		}
	}

	int index_5 = 0;

	for(int a = 0; a < 5; a++){
		for(int b = 0; b < 5; b++){
			for(int c = 0; c < 5; c++){
				for(int d = 0; d < 5; d++){
					for(int e = 0; e < 5; e++){
						if(a != b && a != c && a != d && a != e && b != c && b != d && b != e && c != d && c != e && d != e){
							table_5[index_5][0] = a,table_5[index_5][1] = b,table_5[index_5][2] = c,table_5[index_5][3] = d,table_5[index_5][4] = e;
							index_5++;
						}
					}
				}
			}
		}
	}



	table_9 = new int*[362880];
	for(int i = 0; i < 362880; i++){
		table_9[i] = new int[9];
	}

	calc9();

	int K,gates[9],jenny[9],count,score_G,score_J,work[9];
	double ans_J,ans_G;
	scanf("%d",&K);

	for(int loop = 0; loop < K; loop++){
		for(int i = 0; i < 9; i++)scanf("%d",&gates[i]);
		for(int i = 0; i < 9; i++)scanf("%d",&jenny[i]);

		count = 0;
		for(int i = 0; i < 362880; i++){
			score_G = 0,score_J = 0;
			for(int k = 0; k < 9; k++){
				work[k] = jenny[table_9[i][k]];

				if(work[k] > gates[k]){
					score_J += work[k] + gates[k];
				}else{
					score_G += gates[k] + work[k];
				}
			}
			if(score_J > score_G)count++;
		}

		ans_J = (double)count/(double)362880;
		ans_G = 1 - ans_J;

		printf("%.5lf %.5lf\n",ans_G,ans_J);
	}

    return 0;
}

Measured memory_bytes: 22472
#include <bits/stdc++.h>
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 ll INF = 1LL << 60;

int main() {
    int h, w, x; cin >> h >> w >> x;
    int area = h * w / 2;
    cout << area << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<iostream>
#include<cstdio>
using namespace std;
const int big=(1<<30);
int gcd(int a,int b){if(a<b){swap(a,b);}if(b==0){return a;}return gcd(a%b,b);}
int main(void){
	int i,ans=0;
	string nyu;
	cin>>nyu;
	for(i=0;i<nyu.size();i++){
		if(nyu[i]=='p'){ans--;}
		if(i%2==1){ans++;}
	}
	cout<<ans<<endl;
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int ans_water = 0, ans_sugar = 0;
    int A, B, C, D, E, F; cin >> A >> B >> C >> D >> E >> F;
    for(int a = 0; a <= F; a += 100*A){
        for(int b = 0; b+a <= F; b += 100*B){
            int water = b+a;
            int sugar_limit = a*E/100 + b*E/100;
            for(int c = 0; c <= F; c += C){
                for(int d = 0; water+d+c <= F; d += D){
                    int sugar = d+c;
                    if(sugar > sugar_limit) break;
                    else{
                        if(ans_sugar == 0 && ans_water == 0){
                            ans_water = water;
                            ans_sugar = sugar;
                        }
                        else{
                            if(sugar*(ans_sugar + ans_water) >= ans_sugar*(water + sugar)){
                                ans_water = water;
                                ans_sugar = sugar;
                            }
                        }
                    }
                }
            }
        }
    }
    cout << ans_water+ans_sugar << " " << ans_sugar << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  map<string, int> mp;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    mp[s]++;
  }
  int mx = 0;
  for (auto& p : mp) mx = max(p.second, mx);
  vector<string> ans;
  for (auto& p : mp) if (p.second == mx) ans.push_back(p.first);
  sort(ans.begin(), ans.end());
  for (auto& s : ans) cout << s << '\n';
  return 0;
}

Measured memory_bytes: 25584
<?php
  $n = intVal(trim(fgets(STDIN)));
  $arr = [];
  for($i=0; $i<$n; $i++){
    $input=explode(" ", trim(fgets(STDIN)));
    $arr[]= array("city"=>$input[0], "point"=>$input[1], "idx"=>$i+1);
  }
  array_multisort(array_column($arr, "city"), SORT_ASC, array_column($arr, "point"), SORT_DESC, $arr);
  foreach($arr as $a){
    echo $a["idx"] . PHP_EOL;
  }
?>

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  LL N, M;
  cin >> N >> M;
  VL xs(M);
  REP(i,M){
	cin >> xs[i];
	--xs[i];
  }
  VL acc(N+1);
  REP(i,M-1){
	int a = min(xs[i], xs[i+1]);
	int b = max(xs[i], xs[i+1]);
	acc[a]++;
	acc[b]--;
  }

  LL ans = 0, sum = 0;
  REP(i,N-1){
	LL a, b, c;
	cin >> a >> b >> c;
	sum += acc[i];
	ans += min(a*sum, b*sum+c);
  }
  cout << ans << endl;

  return 0;
}

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

int main(){

  string S;
  string T;
  int cnt  = 0;

  cin >> S;
  cin >> T;

for(int i = 0 ; i < S.size(); i++){
  if(S.at(i)== T.at(i)){
    cnt++;
  }
}
if(cnt == S.size()){
  cout << "Yes" << endl;
}
else cout << "No" << endl;
}


Measured memory_bytes: 3632
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int count = 0;
        int[] comd = new int[Math.min(a,b)];
        for(int i = 1; i <= Math.min(a,b); i++){
            if(a%i == 0 && b%i == 0){
                comd[count] = i;
                count++;
            }
        }
        System.out.print(comd[count-k]);
    }
}

Measured memory_bytes: 22100
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;




int main() {
    char s[100005],t[100005];
    int q;
    scanf("%s %s",s,t);
    int ss[100005],tt[100005];
    ss[0]=0;
    tt[0]=0;
    int las=strlen(s),lat=strlen(t);
    for(int i=0;i<=las-1;i++){
        if(s[i]=='A')ss[i+1]=ss[i]+1;
        else ss[i+1]=ss[i]+2;
    }
    for(int i=0;i<=lat-1;i++){
        if(t[i]=='A')tt[i+1]=tt[i]+1;
        else tt[i+1]=tt[i]+2;
    }
    
    scanf("%d",&q);
    for(int i=1;i<=q;i++){
        int a,b,c,d;
        scanf("%d %d %d %d",&a,&b,&c,&d);
        if((399999+(ss[b]-ss[a-1])-(tt[d]-tt[c-1]))%3==0)printf("YES\n");
        else printf("NO\n");
    }
    
    return 0;
}


Measured memory_bytes: 1536
import sys
import math
input = sys.stdin.readline
N, D = map(int, input().split())
A = [0]*N
for i in range(N):
    A[i] = list(map(int, input().split()))

counter = 0
for i in range(N):
    for j in range(i+1, N):
        dist = 0
        for k in range(D):
            dist += abs(A[i][k] - A[j][k])**2
        dist = math.sqrt(dist)
        if dist.is_integer():
            counter += 1
print(counter)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define vi vector<int>
#define Vi vector<vector<int>>
#define ll long long
#define P pair<int,int>
#define vp  vector<P>
#define mod 1000000009
using namespace std;
int main(){
	int a;
	cin>>a;
	cout<<a+a*a+a*a*a<<endl;
	return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<fstream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
long long a,b;
int main()
{
	cin>>a>>b;
	cout<<(a+b)/2+(a+b)%2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map>
#include <map>
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
using namespace std;

int main(){
	char s[100000];

	cin >> s;

	int x,i;

	for (x = 0; s[x] != '\0'; x++);
	
	for (i = 0; i < x; i++) {
		if (i < (x + 1) / 2) {
			s[i] = s[i * 2];
		} else {
			s[i] = ' ';
		}
	}

	cout << s;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ff { ios_base::sync_with_stdio(false);cin.tie(NULL);}
using namespace std;

typedef long long ll;
 ll  pp=1e9+7; 
double pi=3.141592653589793238;
  
 int main() {
        ff;
        ll n;
        cin>>n;
        ll a[n];
        ll s=0;
        for(int i=0;i<n;i++){
            cin>>a[i];
            s=s^a[i];
        }
        for(int i=0;i<n;i++){
            ll z=s^a[i];
            cout<<z<<" ";
        }
        cout<<endl;
		
    return 0;
}

            
		
        
           
  

Measured memory_bytes: 5152
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <algorithm>

using namespace std;

typedef long long int ll;
struct Dijkstra{
  __int128_t INF, MAX_V, threshold;
  vector<vector<__int128_t>> G;
  vector<ll> d;
  priority_queue<__int128_t, vector<__int128_t>, greater<__int128_t>> que; //class, inner, compair
  Dijkstra(ll N): MAX_V(N+1){
    INF = 1LL<<31;
    threshold = INF * INF;
    INF = INF * INF * INF * INF;
    G.resize(N+1);
    d.resize(N+1, INF);
  }
  inline void insert(ll a, ll b, ll c){
    G[a].push_back(c * threshold + b);
  }
  void init(){
    for(int i=0;i<d.size();i++) d[i] = threshold;
  }
  void dijkstra(ll start){
    init();
    d[start]=0;
    que.push(start);
    while(!que.empty()){
      __int128_t now=que.top(); que.pop();
      __int128_t cost = now / threshold;
      __int128_t node = now - cost * threshold;
      if(d[node]<cost) continue;
      for(auto to:G[node]){
        __int128_t to_cost = to / threshold;
        __int128_t to_node = to - to_cost * threshold;
        to_cost += d[node];
        if(d[to_node]>to_cost){
          d[to_node]=to_cost;
          que.push(to_cost * threshold + to_node);
        }
      }
    }
  }
};
int main(){
  int h, w;std::cin >> h >> w;
  array<int, 2> s, e;
  std::cin >> s[0] >> s[1];
  std::cin >> e[0] >> e[1];
  s[0]--, s[1]--, e[0]--, e[1]--;

  vector<string> S(h);
  for(int i=0;i<h;i++) std::cin >> S[i];

  Dijkstra di(h*w);
  for(int x=0;x<h;x++){
    for(int y=0;y<w;y++){
      if(S[x][y]=='#') continue;
      for(int i=-2;i<=2;i++){
        for(int j=-2;j<=2;j++){
          int X = x + i, Y = y + j;
          if(X<0||X>=h||Y<0||Y>=w||S[X][Y]=='#') continue;
          int D = abs(i) + abs(j);
          if(D==0) continue;
          if(D==1) di.insert(x*w + y, X*w + Y, 0);
          else di.insert(x*w + y, X*w + Y, 1);
        }
      }
    }
  }

  di.dijkstra(s[0]*w + s[1]);
  ll ans = di.d[e[0] * w + e[1]];
  if(ans == di.threshold) std::cout << -1 << '\n';
  else std::cout << ans << '\n';
}


Measured memory_bytes: 168404
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <queue>
#include <stack>
#include <deque>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <string>
#include <cmath>
#include <complex>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cstdlib>
#include <cctype>

#define REP(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(int)c.size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(u) (u).rbegin(),(u).rend()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl
#define v_delete(a,b) (a).erase(remove((a).begin(), (a).end(), b), (a).end())
#define v_unique(a) (a).erase(unique((a).begin(), (a).end()), (a).end())
#define VV(T) vector<vector< T > >
#define init(a,b) memset((a), (b), sizeof((a)))
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;


template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
typedef pair<int,int> pii;

inline bool IN(int x, int y, int w, int h)
{
    return 0 <= x && x < w && 0 <= y && y < h;
}


int main()
{
	stack<int>Q;
	int n;
	while(cin >> n){
		if(n){
			Q.push(n);
		}else{
			int t=Q.top();Q.pop();
			cout << t << endl;
		}
	}


}

Measured memory_bytes: 1200
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
string s1,s2;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>s1>>s2;
	reverse(s1.begin(),s1.end());
	if(s1==s2)
	cout<<"YES";
	else
	cout<<"NO";
	return 0;
}


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

 int main() {
   int N;
   cin >> N;
   vector<int> B(N-1);

   for(int i=0;i<N-1;i++) {
     cin >> B[i];
   }

   int total = B[0];

   for(int i=0;i<N-2;i++) {
     if(B[i] < B[i+1]) {
       total += B[i];
     } else {
       total += B[i+1];
     }
   }

   total += B[N-2];

   cout << total << endl;

   return 0;
 }

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    // solver code...
    let s_tmp = read::<String>();
    let t_tmp = read::<String>();

    let s: Vec<char> = s_tmp.chars().collect();
    let t: Vec<char> = t_tmp.chars().collect();
    let mut min_count = s.len() + 1;
    let range: usize = s.len() - t.len() + 1;
    for i in 0..range {
        let mut tmp_count = 0;
        for j in 0..t.len() {
            if s[i+j] != t[j] {
                tmp_count += 1;
            }
        }
        min_count = std::cmp::min(min_count, tmp_count);
    }
    println!("{}", min_count);
}

Measured memory_bytes: 2112
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;

struct edge{int to,cost;};

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

	int a,b;
	string s;
	cin >> a >> b >> s;
	for(int i=0;i<s.size();i++){
		if(i!=a){
			if(s[i]-'0'<0 || s[i]-'0'>9){
				cout << "No\n";
				return 0;
			}
		}else{
			if(s[i] != '-'){
				cout << "No\n";
				return 0;
			}
		}
	}
	cout << "Yes\n";

	return 0;
}

Measured memory_bytes: 256
# Heuristic Search - 8 Queens Problem
def reload_board(B,r,c,diff):
    # ?????¨???????????????????????????????????????????????????????????????????????????????????°????????????
    global Q,NUM
    for i in range(NUM):
        # ????¨???????????????¶???
        B[r][i] += diff
        B[i][c] += diff
        # ????§?45??????????????????????????¶???
        if i < r and c + (r-i) < NUM:
                B[i][c+(r-i)] += diff
        elif r <= i and c - (i-r) >= 0:
                B[i][c-(i-r)] += diff
        # ????§?135??????????????????????????¶???
        if i < r and c - (r-i) >= 0:
                B[i][c-(r-i)] += diff
        elif r <= i and c + (i-r) < NUM:
                B[i][c+(i-r)] += diff

def solve(queens, B, r):
    global NUM,SETROW
    if r >= NUM:
        return True
    if r in SETROW:
        return solve(queens,B,r+1)
    else:
        for c in range(NUM):
            if B[r][c] == 0:
                ifed = True
                queens[r] = c
                reload_board(B,r,c,1)
                if not solve(queens,B,r+1):
                    reload_board(B,r,c,-1)
                else:
                    return True
    return False

def print_board(queens):
    for i in range(NUM):
        for j in range(NUM):
            print('Q' if queens[i] == j else '.', end='')
        print()

NUM = 8
k = int(input())
B = [[0 for _ in range(NUM)] for _ in range(NUM)]
SETROW = []
queens = [-1 for _ in range(NUM)]
for _ in range(k):
    r,c = map(int, input().split())
    reload_board(B,r,c,1)
    SETROW.append(r)
    queens[r] = c

solve(queens,B,0)
print_board(queens)


Measured memory_bytes: 7848
// 入力マクロ
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
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")
    };
}

use std::collections::HashMap;
fn main() {
    input! {
        s: chars, t: chars
    }

    let mut map1 = HashMap::new();
    let mut ans = true;
    for (ss, tt) in (0..s.len()).map(|i| (s[i], t[i])) {
        if let Some(prev) = map1.insert(ss, tt) { if prev != tt { ans = false; break; } }
    }

    let mut map2 = HashMap::new();
    for (ss, tt) in (0..s.len()).map(|i| (t[i], s[i])) {
        if let Some(prev) = map2.insert(ss, tt) { if prev != tt { ans = false; break; } }
    }

    println!("{}", if ans { "Yes" } else { "No" });
}


Measured memory_bytes: 6396
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int x, y;
    cin >> x >> y;

    for (int turu = 0; turu <= x; turu++) {
        const int kame = x - turu;

        if (turu * 2 + kame * 4 == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
#define fst first
#define scd second
int main()
{
	int a, b, c, ans = false;
	scanf("%d%d%d", &a, &b, &c);
	if(a == b && b != c)
	{
		ans = true;
	}
	if(a != b && b == c)
	{
		ans = true;
	}
	if(a == c && a != b)
	{
		ans = true;
	}
	printf(ans ? "Yes\n" : "No\n");
}


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

using namespace std;

int main(){
    int N;
    cin >> N;
    int a[N];
    double avg = 0;

    for(int i=0; i<N; i++){
        cin >> a[i];
        avg += a[i];
    }
    avg /= N;


    int min = 0;
    for(int i=0; i<N; i++){
        if(abs(avg - a[i]) < abs(avg - a[min]))
            min = i;
    }

    cout << min << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
const long long inf = 1LL << 61;
class edge {
public:
	int to, coins; long long cost;
	edge() : to(-1), coins(0), cost(0) {};
	edge(int to_, int coins_, long long cost_) : to(to_), coins(coins_), cost(cost_) {};
};
class state {
public:
	int pos, coins; long long cost;
	state() : pos(-1), coins(0), cost(0) {};
	state(int pos_, int coins_, long long cost_) : pos(pos_), coins(coins_), cost(cost_) {};
	bool operator<(const state& s) const {
		return cost > s.cost;
	}
};
int main() {
	int N, M, S;
	cin >> N >> M >> S;
	vector<vector<edge> > G(N);
	int sum = 0;
	for (int i = 0; i < M; ++i) {
		int a, b, c, d;
		cin >> a >> b >> c >> d; --a, --b;
		G[a].push_back(edge(b, c, d));
		G[b].push_back(edge(a, c, d));
		sum += c;
	}
	vector<int> C(N), D(N);
	for (int i = 0; i < N; ++i) {
		cin >> C[i] >> D[i];
	}
	S = min(S, sum);
	vector<vector<long long> > dist(N, vector<long long>(sum + 1, inf));
	dist[0][S] = 0;
	priority_queue<state> que;
	que.push(state(0, S, 0));
	while (!que.empty()) {
		state u = que.top(); que.pop();
		for (edge e : G[u.pos]) {
			if (u.coins >= e.coins && dist[e.to][u.coins - e.coins] > dist[u.pos][u.coins] + e.cost) {
				dist[e.to][u.coins - e.coins] = dist[u.pos][u.coins] + e.cost;
				que.push(state(e.to, u.coins - e.coins, dist[e.to][u.coins - e.coins]));
			}
		}
		int nxt = min(u.coins + C[u.pos], sum);
		if (dist[u.pos][nxt] > dist[u.pos][u.coins] + D[u.pos]) {
			dist[u.pos][nxt] = dist[u.pos][u.coins] + D[u.pos];
			que.push(state(u.pos, nxt, dist[u.pos][nxt]));
		}
	}
	for (int i = 1; i < N; ++i) {
		long long ans = *min_element(dist[i].begin(), dist[i].end());
		cout << ans << endl;
	}
	return 0;
}

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


#define ll                      long long
#define pii                     pair<int, int>
#define pli                     pair<ll, int>
#define pil                     pair<int, ll>
#define pll                     pair<ll, ll>
#define vi                      vector<int>
#define vll                     vector<ll>
#define vb                      vector<bool>
#define vd                      vector<double>
#define vs                      vector<string>
#define ff                      first
#define ss                      second
#define pb                      push_back
#define eb                      emplace_back
#define ppb                     pop_back
#define pf                      push_front
#define ppf                     pop_front
#define vpii                    vector<pii>
#define umap                    unordered_map
#define all(x)                  x.begin(),x.end()
#define clr(a,b)                memset(a,b,sizeof a)
#define fr(i, n)                for(ll i=0; i<n;++i)
#define fr1(i, n)               for(ll i=1; i<=n; ++i)
#define rfr(i, n)			    for(ll i=n-1; i>=0; --i)
#define precise(x)              cout<<fixed<<setprecision(x)
#define wh						while
#define mp						make_pair
#define le						length()


ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

ll lcm(ll a,ll b) 
{ return (a*b)/__gcd(a,b); }

ll mulpow(ll x,ll y,ll p) 
{ ll res=1; x=x%p;
    while(y>0) 
    { if (y&1) res=(res*x)%p; 
      y=y>>1; x=(x*x)%p; } 
    return res; } 
    
bool inside(ll x,ll y,ll n,ll m)
{
	return(x>=0&&x<n&&y>=0&&y<=m);
}   

/*void dfs(int s)
{
		if(vis[s])return;
		
		vis[s]=true;
		nodes++;
		for(auto u:g[s])
		{
			if(!vis[u])
			{
				dfs(u);	
			}		
		}
}*/






void solve()
{	
string s,t;
cin>>s>>t;

ll n=s.le,ans=0;
	
	fr(i,n)
	{
		if(s[i]!=t[i])ans++;
	}
	cout<<ans<<endl;
}

int main()
{
//	int t;
//	cin>>t;
//	wh(t--)
	{
		solve();
	}
	return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> aa;

  for (int l = 0; l < n; l++) {
    int t;
    cin >> t;
    aa.push_back(t);
  }

  int ans = 0;
  while (1) {
    if (n <= 0) {
      cout << ans << endl;
      return 0;
    }
    if (ans == 0) {
      ans++;
      n -= k;
    }
    else {
      ans++;
      n -= (k - 1);
    }
  }
}

Measured memory_bytes: 892