akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right !=NIL){
    x = x->right;
  }
  return x;

}

Node treeSearch(Node u, int k){
  if(u == NIL || k== u->key){
    return u;
  }
  if(k < u->key){
    return treeSearch(u->left,k);
  }
  else return treeSearch(u->right,k);
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL) return treeMinimum(x->right);
  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left ==NIL || z->right ==NIL){
    y =z;
  }
  else {y = treeSuccessor(z);}
  if(y->left != NIL){
    x = y->left;
  }
  else x = y->right;
  if(x != NIL){
    x->parent = y->parent;
  }
  if(y->parent ==NIL){
    root =x;
  }
  else if(y == y->parent->left){
    y->parent->left = x;
  }
  else y->parent->right =x;
  if(y != z){z->key = y->key;}


  }

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x !=NIL){
    y = x;
    if(z->key < x->key){
      x=x->left;
    }
    else {x = x->right;}
  }
    z->parent = y;
    if(y==NIL){
      root = z;
    }
      else if(z->key < y->key){
	y->left = z;
      }
      else {y->right = z; }
    }

void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u != NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for(int i = 0; i < H; i++){
      cin >> S.at(i);
  }

  vector<vector<int>> num(H + 2, vector<int>(W + 2, 0));
  for(int i = 0; i < H; i++){
      for(int j = 0; j < W ; j++){
          if(S.at(i).at(j) == '#'){
              num.at(i).at(j)++;
              num.at(i).at(j+1)++;
              num.at(i).at(j+2)++;
              num.at(i+1).at(j)++;
              num.at(i+1).at(j+2)++;
              num.at(i+2).at(j)++;
              num.at(i+2).at(j+1)++;
              num.at(i+2).at(j+2)++;
          }
      }
  }
  for(int i = 0; i < H; i++){
      for(int j = 0; j < W ; j++){
        if(S.at(i).at(j) == '#') cout << S.at(i).at(j);
        else {
            cout << num.at(i+1).at(j+1);
        }
        if(j == W-1) cout << endl;
      }
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main( void ) {

	double a, b, c, d, e, f, x, y;

	while ( scanf( "%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f ) != EOF ) {

		//printf( "%.3lf %.3lf\n", ( c * e - b * f ) / ( a * e - b * d), ( c * d - a * f ) / ( b * d - a * e) );

		y = ( c * d - a * f ) / ( b * d - e * a );  //x,yについて解くと
                                                    //これらの式が導出できる
        x = ( c - ( b * y ) ) / a;
 
        printf( "%.3lf %.3lf\n", x, y );

	}

	return 0;

}

Measured memory_bytes: 652
#include<iostream>
int main(){
  int n,a,b,c,d,f;
  while(std::cin>>n){
    f=0;
    for(a=0;a<10;a++)
      for(b=0;b<10;b++)
	for(c=0;c<10;c++)
	  for(d=0;d<10;d++)
	    if(a+b+c+d==n)f++;
    std::cout<<f<<"\n";
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b[1000000],c=0;
  cin>>a;
  for(int i=0;i<a;i++) cin>>b[i];
  sort(b,b+a,greater<int>());
  b[0]/=2;
  for(int i=0;i<a;i++) c+=b[i];
  cout<<c<<"\n";
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

class State {
public:
  int _used;
  int _archives;
  State(int used,int archives) :
    _used(used), _archives(archives) {}
  bool operator <(const State& s) const {
    return _archives < s._archives;
  }
  bool operator >(const State& s) const {
    return _archives > s._archives;
  }
};

int open_space[1<<14];
int required_space[1<<14];
int dp[1<<14];

int main(){
  int total_files;
  int init_disk_space;
  while(~scanf("%d %d",&total_files,&init_disk_space)){
    if(total_files == 0 && init_disk_space == 0) break;

    vector<int> diff;
    vector<int> req;
    for(int file_i = 0; file_i < total_files; file_i++){
      int uncompressed,compressed;
      scanf("%d %d",&uncompressed,&compressed);
      diff.push_back(uncompressed - compressed);
      req.push_back(compressed);
    }
    
    memset(open_space,0,sizeof(open_space));
    memset(required_space,0,sizeof(required_space));
    memset(dp,0x3f,sizeof(dp));

    for(int S = 0; S <= (1<<total_files) - 1; S++){
      int open_sum = 0;
      int req_sum = 0;
      for(int file_i = 0; file_i < total_files; file_i++){
        if(S & (1 << file_i)){
          open_sum += diff[file_i];
          req_sum += req[file_i];
        }
      }
      open_space[S] = open_sum;
      required_space[S] = req_sum;
    }

    priority_queue<State,vector<State>,greater<State> > que;
    que.push(State(0,0));
    dp[0] = 0;
    while(!que.empty()){
      State s = que.top();
      que.pop();

      int rev = ((1<<total_files) - 1) & ~(s._used);
      for(int S = 0; S <= rev; S++){
        if(s._used & S) continue;
        if(dp[s._used | S] <= s._archives + 1) continue;
        if(required_space[S] > open_space[s._used] + init_disk_space) continue;
        dp[s._used | S] = s._archives + 1;
        que.push(State(s._used | S,s._archives + 1));
      }
    }

    if(dp[(1<<total_files) - 1] >= INF){
      printf("Impossible\n");
    }
    else{
      printf("%d\n",dp[(1<<total_files) - 1]);
    }
  }
}

Measured memory_bytes: 1544
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramA
    {
        static void Main()
        {
            System.Console.WriteLine(NextInt * NextInt);
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


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

using namespace std;

long long a[100005];

int main() {
	long long n, c, t;
	scanf("%lld %lld %lld", &n, &c, &t);
	for (int i = 0; i < n; ++i) {
		scanf("%lld", a + i);
	}
	long long ans = 0;
	for (int i = 1; i < n; ++i) {
		ans += min(c * (a[i] - a[i - 1]), t);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for(int i = 1, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  int a[M], b[M], c[M];
  int d[N][N];
  REP(i, N) REP(j, N) {
    if(i == j) {
      d[i][j] = 0;
    } else {
      d[i][j] = INF;
    }
  }
  REP(i, M) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    d[a[i]][b[i]] = c[i];
    d[b[i]][a[i]] = c[i];
  }

  REP(k, N) REP(i, N) REP(j, N) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

  ll ans = M;
  REP(p, M) {
    bool hasPath = false;
    REP(s, N) {
      if(d[s][a[p]] + c[p] == d[s][b[p]]) {
        hasPath = true;
      }
    }
    if(hasPath) {
      ans--;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int N;
    cin >> N;
    ll a[N];
    rep(i, N) cin >> a[i];
    int cnt = 0;
    rep(i, N){
        while(i + 1 < N && a[i] == a[i+1]) i++;

        if(i + 1 < N && a[i] < a[i+1]){
            while(i + 1 < N && a[i] <= a[i+1]) i++;
        }else if(i + 1 < N && a[i] > a[i+1]){
            while(i + 1 < N && a[i] >= a[i+1]) i++;
        }
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n,k;
    while(cin>>n>>k,n+k){
        vector<vector<pii>>edge(n,vector<pii>());
        rep(_,k){
            int q;
            cin>>q;
            if(q==1){
                int c,d,e; cin>>c>>d>>e;
                edge[--c].push_back(pii(--d,e));
                edge[d].push_back(pii(c,e));
            }else{
                int to, from; cin>>to>>from;
                --to,--from;
                vector<int>d(n,INF);
                d[to]=0;
                priority_queue<pii,vector<pii>,greater<pii>>que;
                que.push(pii(0,to));
                while(!que.empty()){
                    pii now=que.top(); que.pop();
                    if(now.second==from)break;
                    if(d[now.second]<now.first)continue;
                    for(int i=0; i<edge[now.second].size();i++){
                        pii next=edge[now.second][i];
                        if(d[next.first]<now.first+next.second)continue;
                        que.push(pii(now.first+next.second,next.first));
                        d[next.first]=now.first+next.second;
                    }
                }
                if(d[from]==INF)cout<<-1<<endl;
                else cout<<d[from]<<endl;
            }
        }
    }
}

Measured memory_bytes: 3072
#include <stdio.h>
int f(int x){
    int n = 1;
    for(int i = 2;i <= x;i++)
        n += i;
    return n;
}
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    int x = b-a;
    printf("%d",f(x)-b);
    return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
#define pb push_back
#define __V vector
#define all(x) x.begin(), x.end()
#define oit ostream_iterator
#define mod 1000000007ll
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
}
template<typename X, typename Y>
istream& operator>>(istream& in, pair<X, Y> &a) {
	in >> a.first >> a.second;
	return in;
}
template<typename T>
void getv(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv(vector<T>& v, int n, Ns ... ns) {
	v.resize(n);
	for (auto& i : v)
		getv(i, ns...);
}
template<typename T>
void getv1(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv1(vector<T>& v, int n, Ns ... ns) {
	v.resize(n + 1);
	for (int i = 1; i <= n; i++)
		getv(v[i], ns...);
}
#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
inline void getch(char &x) {
	while (x = getchar_unlocked(), x < 33) {
		;
	}
}
inline void getstr(string &str) {
	str.clear();
	char cur;
	while (cur = getchar_unlocked(), cur < 33) {
		;
	}
	while (cur > 32) {
		str += cur;
		cur = getchar_unlocked();
	}
}
template<typename T> inline bool sc(T &num) {
	bool neg = 0;
	int c;
	num = 0;
	while (c = getchar_unlocked(), c < 33) {
		if (c == EOF)
			return false;
	}
	if (c == '-') {
		neg = 1;
		c = getchar_unlocked();
	}
	for (; c > 47; c = getchar_unlocked())
		num = num * 10 + c - 48;
	if (neg)
		num *= -1;
	return true;
}
typedef unsigned long long ull;
typedef long long ll;
typedef float ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
using AntonTsypko = void;
using arsijo = AntonTsypko;
using god = arsijo;
uniform_real_distribution<double> double_dist(0, 1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
	doin();
	ll n, d;
	cin >> n >> d;
	d = 2*d + 1;
	cout << (n+d-1)/d;
	return 0;
}


Measured memory_bytes: 256
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;

int main()
{
    fast_io
    ll i,t,n,j,k,ans=0;
    string s;
    cin>>s;
    for(i=0; s[i]; i++)
        if(s[i]=='-')
            ans--;
        else
            ans++;

    cout<<ans<<endl;

return 0;
}





Measured memory_bytes: 3540
#include <bits/stdc++.h>
#define lop(i, n) for (int i = 0; i < (n); ++i)
#define tc(t) int t; cin>>t; while(t--)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {

	ios::sync_with_stdio(false);
	cin.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    int a1 = a + b;
    int a2 = a + c;
    int a3 = b + c;
    if (a1 <= a2 && a1 <= a3) {
        cout<<(a1);
    } else if (a2 <= a1 && a2 <= a3) {
        cout<<(a2);
    } else if (a3 <= a1 && a3 <= a2) {
        cout<<(a3);
    }



}

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <typeinfo>

using namespace std;

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

  long long ans=1;
  if(abs(N-M)>1){
    cout << 0 << endl;
    return 0;
  }
  else if(abs(N-M)==1){
    for(int i=N;i>0;i--)  ans=ans*i%1000000007;
    for(int i=M;i>0;i--)  ans=ans*i%1000000007;
  }
  else if(abs(N-M)==0){
    for(int i=N;i>0;i--)  ans=ans*i%1000000007;
    for(int i=M;i>0;i--)  ans=ans*i%1000000007;
    ans=ans*2%1000000007;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
x, y = gets.split(' ').map(&:to_i)
g = []
g << [1, 3, 5, 7, 8, 10, 12]
g << [4, 6, 9, 11]
g << [2]
g.each do |gg|
  if gg.include?(x) && gg.include?(y)
    puts "Yes"
    exit
  end
end
puts "No"

Measured memory_bytes: 1788
n = int(input())
a = [int(i) for i in input().split()]
for i in range(n-1):
  a[i+1] += a[i]
  
from collections import Counter
c = Counter(a)
ans = c[0]
for i,v in c.items():
  ans += v*(v-1)//2
  
print(ans)

Measured memory_bytes: 36628
using System;
using System.Linq;

class Program
{
    static void Main(string[] args) {
        int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        if(s[0] == s[1]) Console.WriteLine(Math.Max(s[0],s[1])*2);
        else Console.WriteLine(Math.Max(s[0],s[1])*2 - 1);
    }
}

Measured memory_bytes: 13268
#include<iostream>

using namespace std;
int main()
{
	int a,b,c,d,e,k;
	int flag=0;
	cin >>a >> b >> c >> d >> e >> k;
	if(b-a>k)
	{
		flag=1;
		cout << ":(" << endl;
	}
	else if(c-a>k)
	{
				flag=1;
		cout << ":(" << endl;
	}
	else if(d-a>k)
	{
				flag=1;
		cout << ":(" << endl;
	}
	else if(e-a>k)
	{		flag=1;
		cout << ":(" << endl;
	}
	if(!flag)
	cout<<"Yay!"<<endl;
	return 0;
 } 



Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
//#define ce(d) cout<<d<<endl;

 
 
int main() {
	
	int N,X;
	cin>>N>>X;
	vector<int> x;
	vector<int> sub(1000000);
	x.push_back(X);
	fy(N){
		int a;
		cin>>a;
		x.push_back(a);
	}
	sort(x.begin(),x.end());
	int mini=1000000000;
	fyg(N+1,1){
		sub.at(y-1)=x.at(y)-x.at(y-1);
		mini=min(mini,sub.at(y-1));
	}
	
	int maxi=1000000000;
	
	fy(N){
		int bb=mini;
 int r = sub.at(y)% bb;
  while(r!=0){
    sub.at(y) = bb;
   bb= r;
    r = sub.at(y) % bb;
  }

		maxi=min(maxi,bb);
		
	}
	
	cout<<maxi<<endl;
	
}

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

#define FOR(x,y,z) for(int x=y,x##_=z;x<=x##_;++x)
#define DOR(x,y,z) for(int x=y,x##_=z;x>=x##_;--x)
#define FOR_(x,y,z,s) for(int x=y,x##_=z;x<=x##_;x+=s)
#define FOR__(x,y,z) for(int x=y,x##_=z;x<=x##_;x<<=1)
#define EOR(x,y) for(int x##_=head[x],y=edge[x##_].e;x##_;y=edge[x##_=edge[x##_].to].e)
#define EGOR(x,y,z) for(int x##_=head[x],y=edge[x##_].e,z=edge[x##_].c;x##_;y=edge[x##_=edge[x##_].to].e,z=edge[x##_].c)

#define clr(x,y) memset(x,y,sizeof(x))
#define szf(x) sizeof(x)
#define min3(x,y,z) min(min(x,y),z)
#define max3(x,y,z) max(max(x,y),z)

#define read2(x,y) read(x),read(y)
#define read3(x,y,z) read(x),read(y),read(z)
#define read4(x,y,z,w) read3(x,y,z),read(w)
#define reads(str) sf("%s",str)

#define ts (*this)
#define sf scanf
#define pf printf

#define ll long long
#define ull unsigned long long
#define db double
#define ct clock_t
#define ck() clock()
#define rd rand()
#define rmx RAND_MAX
#define RD T*(rd*2-rmx)


using namespace std;

template<class T>bool tomin(T &x,T y){return y<x?x=y,1:0;}
template<class T>bool tomax(T &x,T y){return x<y?x=y,1:0;}
template<class T>void read(T &x){
    char c;
    x=0;
    int f=1;
    while(c=getchar(),c<'0'||c>'9')if(c=='-')f=-1;
    do x=(x<<3)+(x<<1)+(c^48);
    while(c=getchar(),c>='0'&&c<='9');
    x*=f;
}

const db Pi=acos(-1);
int main(){
    srand(time(NULL));
    int n,D;
    read2(n,D);
    D=D+D+1;
    pf("%d",(n+D-1)/D);
    return 0;
}


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

#define MAX_SIZE 10100
#define INF (1<<30)
#define NOT_VISITED 0
#define VISITED 1
#define COMPLETE 2

int n;
vector<vector<pair<int, int> > > G(MAX_SIZE);

int d[MAX_SIZE], status[MAX_SIZE];

void dijkstra() {
    for (int i = 0; i < n; i++) {
        d[i] = INF;
        status[i] = NOT_VISITED;
    }
    d[0] = 0;

    priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > pq;

    pq.push(make_pair(0, 0));
    status[0] = VISITED;

    while (!pq.empty()) {
        pair<int, int> next = pq.top();
        pq.pop();
        int u = next.second;
        status[u] = COMPLETE;
        if (d[u] < next.first) continue;
        for (int i = 0; i < (int)G[u].size(); i++) {
            int v = G[u][i].first;
            if (status[v] == COMPLETE) continue;
            if (d[v] > d[u] + G[u][i].second) {
                d[v] = d[u] + G[u][i].second;
                pq.push(make_pair(d[v], v));
                status[v] = VISITED;
            }
        }
    }
    
    return;
}

void print() {
    for (int i = 0; i < n; i++) {
        cout << i << " ";
        if (d[i] == INF) cout << -1;
        else cout << d[i];
        cout << endl;
    }
    return;
}

int main() {
    cin >> n;
    int u, k, v, c;
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            cin >> v >> c;
            G[u].push_back(make_pair(v, c));
        }
    }

    dijkstra();

    print();

    return 0;
}


Measured memory_bytes: 7988
N=int(input())
a=0
b=0
B=0
A=0
count1=0
count2=0
for i in range(N):
    S=input()
    a+=S.count("AB")
    if S[0]=="B"and S[len(S)-1]=="A":
        count1+=1
        if count1==1:
            A+=1
            B+=1
        else:
            b+=1
    elif S[0]=="B":
        B+=1
        count2+=1
    elif S[len(S)-1]=="A":
        A+=1
        count2+=1
if count1>1 and count2==0:
    b=b-1
C=min(A+b,B+b)
print(a+C)

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <cmath>
using namespace std;
int main(){
	cout<<fixed<<setprecision(6);
	double o=acos(-1.0);
	double r;
	cin>>r;
	cout<<r*r*o<<" "<<r*2*o<<endl;

	return 0;
}

Measured memory_bytes: 1288
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int n;
  string s;
  cin >> n >> s;
  int dup = 0;
  for (int i = 1; i < n - 1; ++i) {
    auto x = s.substr(0, i);
    auto y = s.substr(i);
    sort(x.begin(), x.end());
    x.erase(unique(x.begin(), x.end()), x.end());
    sort(y.begin(), y.end());
    y.erase(unique(y.begin(), y.end()), y.end());
    x += y;
    int all_length = x.length();
    sort(x.begin(), x.end());
    x.erase(unique(x.begin(), x.end()), x.end());
    int length = all_length - x.length();
    dup = dup < length ? length : dup;
  }
  cout << dup << endl;
}


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

struct Point {
  int x, y;
  Point(int _x, int _y) : x(_x), y(_y) {}
};

struct Vector {
  int x, y;
  Vector(int _x, int _y) : x(_x), y(_y) {};
  Vector(Point f, Point t) : x(t.x - f.x), y(t.y - f.y) {};
  bool clockwise(Vector v){ return x*v.y<y*v.x; }
};

int n;
vector<Point> v,s;

bool ok(Point p3){
  if(s.size()<=1)return true;
  Point p1=*(s.rbegin()+1);
  Point p2=*s.rbegin();
  // printf("OK (%d,%d) (%d,%d) (%d,%d) %d\n",p1.x,p1.y,p2.x,p2.y,p3.x,p3.y,Vector(p1,p2).cross(Vector(p2,p3))>=0);
  // printf("(%d,%d)->(%d,%d) . (%d,%d)->(%d,%d) = %d\n",p1.x,p1.y,p2.x,p2.y,p2.x,p2.y,p3.x,p3.y,Vector(p1,p2).dot(Vector(p2,p3)));
  return !Vector(p1,p2).clockwise(Vector(p2,p3));
}

void print_stack(){
  for(Point p:s){ printf("(%d,%d) ",p.x,p.y); } printf("\n");
}

void consider(Point p){
  // printf("Consider (%d,%d)\n",p.x,p.y);
  while(!ok(p))s.pop_back();
  s.push_back(p);
  // print_stack();
}

void convex_hull() {
  sort(v.begin(),v.end(),[](const Point& a,const Point& b){
    if(a.y!=b.y)return a.y<b.y;
    return a.x<b.x;
  });
  for(int i=0;i<v.size();++i)consider(v[i]);
  for(int i=v.size()-2;i>=0;--i)consider(v[i]);
  s.pop_back();
}

int main() {
  cin>>n;
  for(int i=0;i<n;++i){
    int x,y;cin>>x>>y;
    v.push_back(Point(x,y));
  }
  convex_hull();
  cout<<s.size()<<endl;
  for(int i=0;i<s.size();++i){
    cout<<s[i].x<<" "<<s[i].y<<endl;
  }
}

Measured memory_bytes: 4792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> order_set;
const ll mod = 1e9 + 7, p = 115211;
const ll N = 2.5e3 + 5, M = 101;
const ld pi = acos(-1);

ll power(ll x, unsigned 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;
}


int main() 
{ 
    FAST;
   // freopen("input.in","r",stdin);
   // freopen("output.out","w",stdout);
    ll a, b;
    cin >> a >> b;
    set <ll> s1, s2;
    for(ll i=2;i<=sqrt(a);i++) {
        if(a % i == 0) {
            s1.insert(i);
            while(a % i == 0) {
                a /= i;
            }
        }
    }
    if(a != 1) {
        s1.insert(a);
    }
    for(ll i=2;i<=sqrt(b);i++) {
        if(b % i == 0) {
            s2.insert(i);
            while(b % i == 0) {
                b /= i;
            }
        }
    }
    if(b != 1) {
        s2.insert(b);
    }
    ll c = 1;
    for(auto it=s1.begin();it!=s1.end();it++) {
        if(s2.count(*it) == 1) {
            c++;
        }
    }
    cout << c;
    return 0;
}


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

using namespace std;

using P = pair<int, int>;
using i64 = int64_t;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;


i64 count(const string& s) {
    i64 ret{0};
    if (s.size() == 1) return 0;
    if (s[0]=='R' && s[1]=='R') ++ret;
    for (std::size_t i=1; i<s.size()-1; ++i) {
        if (s[i] == 'L') {
            if (s[i-1]=='L') ++ret;
        } else {
            if (s[i+1]=='R') ++ret;
        }
    }
    if (s[s.size()-1]=='L' && s[s.size()-2]=='L') ++ret;
    return ret;
}

P count2(const string& s) {
    P ret = make_pair(0,0);
    if (s.size()==1) return ret;

    char remain{false};
    for (int i=1; i<s.size(); ++i) {
        if (s[i] != s[i-1]) {
            if (!remain) {
                remain = true;
                continue;
            }
            if (s[i]=='L') ++(ret.second);
            else ++(ret.first);
        }
    }
    return ret;
}


int main(int argc, char **argv) {
    int n, k;
    cin >> n >> k;
    string str;
    cin >> str;
    i64 cnt = count(str);
//cout << cnt << endl;
    P cnt2 = count2(str);
    int mx = max(cnt2.first, cnt2.second);
//cout << mx << endl;
    if (mx >= k) {
        cnt += k*2;
    } else {
        cnt += mx*2;
        if (str[0] != str.back()) ++cnt;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a,b,c,d; cin>>a>>b>>c>>d;
  	if(a+b==c+d){
    	cout<<"Balanced"<<endl;
    }else if(a+b>c+d){
    	cout<<"Left"<<endl;
    }else if(a+b<c+d){
    	cout<<"Right"<<endl;
    }
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, C) = readLine()!!.split(" ").map { it.toLong() }
    val N = n.toInt()
    val x = LongArray(N)
    val v = LongArray(N)
    (0 until N).forEach {
        val (a, b) = readLine()!!.split(" ").map { it.toLong() }
        x[it] = a
        v[it] = b
    }

    var max = 0L
    var cal = 0L
    var position = 0L
    // Start to right
    val r = LongArray(N)
    for (i in 0 until N) {
        val move = x[i] - position
        cal = cal + v[i] - move
        position = x[i]
        max = Math.max(max, cal)
        r[i] = max
    }

    val l = LongArray(N)
    max = 0L
    cal = 0L
    position = C
    for (i in N - 1 downTo  0) {
        val move = position - x[i]
        cal = cal + v[i] - move
        position = x[i]
        max = Math.max(max, cal)
        l[i] = max
    }

    var answer = Math.max(r[N - 1], l[0])
    // Start to left
    for (i in 0 until N - 1) {
        answer = Math.max(answer, r[i] + l[i + 1] - x[i])
    }
    for (i in N - 1 downTo  1) {
        answer = Math.max(answer, l[i] + r[i-1] - (C - x[i]))
    }

    println(answer)
}


Measured memory_bytes: 60624
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long int ll;
int N;
ll A[2009];
ll dp[2009][4018];
int main()
{
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d",&A[i]);
	}
	for(int i=0;i<=N;i++){
		for(int j=0;j<N;j++){
			dp[i][j]=-1;
		}
	}
	for(int j=0;j<N;j++){
		dp[0][j]=0;
	}
	/*
	for(int i=0;i<N;i++){
		if(i==0){
			if(A[1]>A[N-1]){
				dp[2][0]=A[0];
			}
			else{
				dp[2][N-1]=A[0];
			}
		}
		else if(i==N-1){
			if(A[0]>A[N-2]){
				dp[2][N-1]=A[N-1];
			}
			else{
				dp[2][N-1]=A[N-1];
			}
		}
		else{
			if(A[i+1]>A[i-1]){
				dp[2][i]=A[i];
			}
			else{
				dp[2][i-1]=A[i];
			}
		}
	}*/
	for(int i=0;i+2<=N;i++){
		for(int j=0;j<N;j++){
			if(dp[i][j]==-1)continue;
			//[j,j+i)
			
			//get A[j-1]
			if(A[(j+N-2)%N]>A[(j+i)%N]){
				dp[i+2][(j+N-2)%N]=max(dp[i+2][(j+N-2)%N],dp[i][j]+A[(j+N-1)%N]);
			}
			else{
				dp[i+2][(j+N-1)%N]=max(dp[i+2][(j+N-1)%N],dp[i][j]+A[(j+N-1)%N]);
			}
			//get A[j+i]
			if(A[(j+N-1)%N]>A[(j+i+1)%N]){
				dp[i+2][(j+N-1)%N]=max(dp[i+2][(j+N-1)%N],dp[i][j]+A[(j+i)%N]);
			}
			else{
				dp[i+2][j]=max(dp[i+2][j],dp[i][j]+A[(j+i)%N]);
			}
		}
	}
	if(N&1){
		//dp[N-1][j]
		for(int j=0;j<N;j++){
			dp[N][j]=dp[N-1][j]+A[(j+N-1)%N];
		}
	}
	/*
	for(int i=0;i<=N;i++){
		for(int j=0;j<N;j++){
			printf("%d ",dp[i][j]);
		}
		printf("\n");
	}*/
	ll ans=0;
	for(int i=0;i<N;i++){
		ans=max(ans,dp[N][i]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 42424
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), K = sc.nextInt();
		char[] S = sc.next().toCharArray();
		S[K - 1] -= 'A' - 'a';
		System.out.println(String.valueOf(S));
	}
}

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

int main() {
    int n, k;cin >> n >> k;
    vector<int> e(n);
    for(int i = 0;i < n;i++){
        int p;cin >> p;
        e[i] = p + 1;
    }
    ll sum = 0;
    for(int i = 0;i < k;i++)sum += e[i];
    ll m = sum;
    for (int i = k; i < n; i++)
    {
        m = max(m, sum);
        sum = sum + e[i] - e[i-k];
    }
    m = max(sum, m);
    if(m%2 == 0)cout << m/2 << endl;
    else cout << m/2 << ".5" << endl;
    
    return 0;
}

Measured memory_bytes: 4052
import javax.xml.crypto.Data;
    import java.math.BigDecimal;
    import java.util.*;
    import java.io.*;

    public class Main {

        public static void main(String[] args) throws IOException {

            //入力
            //BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            FastScanner sc = new FastScanner();
            int N = sc.nextInt();

            //出力
            long[] L = new long[87];
            L[0] = 2; L[1] = 1;
            for (int i = 2; i < 87 ; i++) L[i] = L[i - 1] + L[i - 2];
            System.out.println(L[N]);
        }

    }


    class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            }else{
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }else if(b == -1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
    }


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define STREP(i, s) for (int(i) = 0; (s)[(i)]; (i)++)
#define REP(i, a, b) for (int(i) = int(a); (i) <= int(b); (i)++)
#define ALL(c) begin(c), end(c)
#define SIZE(c) int((c).size())
#define INF 0x3f3f3f3f
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define F first
#define S second

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int n, st, res, a[100011];

int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  REP(i, 1, n) cin >> a[i];
  REP(i, 2, n) {
    if (!st) {
      if (a[i] > a[i-1]) st = 1, res++;
      else if (a[i] < a[i-1]) st = -1, res++;
    } else {
      if (st == 1) {
        if (a[i] < a[i-1]) st = 0;
      } else {
        if (a[i] > a[i-1]) st = 0;
      }
    }
  }
  if (!st) res++;
  cout << res << '\n';
}

Measured memory_bytes: 640
fun main(args: Array<String>) = yorukatsu13b()

fun yorukatsu13b() {
    val n = readLine()!!.toInt()
    val sList = (1..n).map { readLine()!!.toInt() }

    val sum = sList.sum()
    val answer = if (sum % 10 != 0) sum else {
        sum - (sList.filterNot { it % 10 == 0 }.min() ?: return println(0))
    }

    println(answer)
}


Measured memory_bytes: 33940
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

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

    int ansd = n / 100;
    int d1 = n / 10 % 10;
    int d2 = n % 10;
    if (d1 > ansd || (d1 == ansd && d2 > ansd)) ++ansd;

    cout << ansd << ansd << ansd << endl;

    return 0;
}


Measured memory_bytes: 256
/*
貪欲
後ろから見る
DP
順位表をチェック
二分探索


*/
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<tuple>
using namespace std;
#define INF 3e18+7
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<double,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());

vector<int> V[110000];

int dfs(int x){
    //cout<<x<<endl;
    int m=0;
    vector<int> S;
    for(int i=0;i<(int)V[x].size();i++){
        int next=V[x][i];
        S.push_back(dfs(next));
    }
    int n=(int)S.size();
    if(n==0) return 1;
    sort(S.begin(),S.end());
    for(int i=0;i<(int)S.size()-1;i++){
        if(S[i]>=S[i+1]) S[i+1]=S[i]+1;
    }
    
    return S[n-1]+1;

}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int N; cin>>N;
    for(int i=2;i<=N;i++){
        int a;
        cin>>a;
        V[a].push_back(i);
    }
    cout<<dfs(1)-1<<endl;;
}

Measured memory_bytes: 18432
//by Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<s32>
#define p32 pair<int,int>
#define p64 pair<ll,ll>
#define fi first
#define se second
#define ln '\n'
#define debug(x) cout << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream& operator<<(ostream& out, const pair<T,U>& p){
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename ...Args>
void print_container(const ContainerType<ValueType, Args...>& c){
	cout << "{ ";
	for(const auto& v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

struct median{
	ll ans,suml,sumr,sum;
	priority_queue<int,vector<int>> mx;
	priority_queue<int,vector<int>,greater<int>> mn;
	median()
	{
		ans = suml = sumr = 0,sum = 0;
	}
	void insert(ll item){
		sum += item;
		if(item > ans){
			mn.push(item);
			sumr += item;
		}
		else{
			mx.push(item);
			suml += item;
		}
		if(((int)mx.size() - (int)mn.size()) > 1){
			ll temp = mx.top();
			mx.pop();
			suml -= temp;
			mn.push(temp);
			sumr += temp;
		}
		if(((int)mn.size() - (int)mx.size()) > 1){
			ll temp = mn.top();
			mn.pop();
			sumr -= temp;
			mx.push(temp);
			suml += temp;
		}
		if((mx.size() + mn.size()) % 2 == 1){
			if(mn.size() > mx.size()){
				ll temp = mn.top();
				mn.pop();
				sumr -= temp;
				mx.push(temp);
				suml += temp;
			}
		}
		if(ans == 0)
			ans = item;
		else
			ans = mx.top();
	}
	ll getMedian(){
		return ans;
	}
	ll LeftSum(){
		return suml;
	}
	ll RightSum(){
		return sumr;
	}
	ll LeftSize(){
		return (ll)mx.size();
	}
	ll RightSize(){
		return (ll)mn.size();
	}
};

int main()
{
	FASTIO;
	int q;
	cin >> q;
	median M;
	ll sumb = 0;
	while(q--){
		int t;
		cin >> t;
		if(t == 1){
			ll a,b;
			cin >> a >> b;
			M.insert(a);
			sumb += b;
		}
		else{
			ll gi = M.RightSum() - M.LeftSum() + (M.LeftSize() - M.RightSize()) * M.getMedian();
			ll fi = gi + sumb;
			cout << M.getMedian() << " " << fi << ln;
		}
	}
	return 0;
}


Measured memory_bytes: 3452
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    string s,t;
    cin >> s >> t;
    int ans = 0;
    REP(i,s.size()) {
        if (s[i] != t[i]) ans++;
    }
    cout << ans << '\n';

    return 0;
}

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

int main(){
  int N,M;
  cin >>N>>M;
  vector<int> H(N);
  for (int i=0; i<N;i++){
    cin >> H.at(i);
  }
  vector<int> x(N,1);
  for (int j=0;j<M;j++){
    int A,B;
    cin>>A>>B;
    if (H.at(A-1)>H.at(B-1)){
     x.at(B-1)=0;
    }
    else if(H.at(A-1)==H.at(B-1)){
     x.at(A-1)=0;
     x.at(B-1)=0;
    }
    else{
     x.at(A-1)=0;
    }
  }
  
  int count=0;
  for (int k=0;k<N;k++){
    if (x.at(k)==1){
      count++;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 4048
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using ll = unsigned long long;
using namespace std;

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

    vector<int> x(n), y(n), h(n);

    int cand = -1;
    for(int i = 0 ; i < n; ++i) {
        cin >> x[i] >> y[i] >> h[i];
        if (h[i] > 0) {
            cand = i;
        }
    }
    
    for(int xi = 0; xi <= 100; ++xi) {
        for(int yi = 0; yi <= 100; ++yi) {
            int hcand = h[cand] + abs(xi - x[cand]) + abs(yi - y[cand]);
            bool ok = true;

            for (int i = 0; i < n; ++i) {
                if (h[i] > 0 && hcand - h[i] != abs(xi - x[i]) + abs(yi - y[i])) {
                    ok = false;
                }

                if (h[i] == 0 && hcand > abs(xi-x[i]) + abs(yi - y[i])) {
                    ok = false;
                }
            }
        
            if (ok) {
                cout << xi << " " << yi << " " << hcand << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
AB = [0]*N
total = 0
for i in range(N):
  left = -1
  right = N
  while right-left>1:
    mid = left + (right-left)//2
    if A[mid]>=B[i]:
      right = mid
    else:
      left = mid
  AB[i]=right
for i in range(1,N):
  AB[i]+=AB[i-1]
for i in range(N):
  left = -1
  right = N
  while right-left>1:
    mid = left + (right-left)//2
    if B[mid]>=C[i]:
      right = mid
    else:
      left = mid
  if right!=0:
    total+=AB[right-1]
print(total)

Measured memory_bytes: 23328
from functools import reduce
n = int(input())
def r(n, m, l):
    if n == 1:
        return [m * 10 + l[0]]
    return reduce(lambda a, b: a + b, [r(n-1, m * 10 + l[i], l[:i] + l[i + 1:]) for i in range(0, n)])
d = r(n, 0, list(range(1, n+1)))
p = int(reduce(lambda a, b: a + b, input().split()))
q = int(reduce(lambda a, b: a + b, input().split()))
print(abs(d.index(q) - d.index(p)))

Measured memory_bytes: 5960
lis = [1 for i in range(26)]
n = int(input())
s = str(input())
for i in range(n):
  lis[ord(s[i])-ord("a")] += 1
ans = 1
for num in lis:
  ans *= num
  ans %= 10 ** 9 + 7
print(ans-1)

Measured memory_bytes: 3188
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(){
  int W, H;
  cin >> H >> W;
  int a[H][W];

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      char ch;
      cin >> ch;
      if(ch=='.') a[i][j] = 0;
      else a[i][j] = 1; 
    }
  }

  bool h_check[H];
  for(int i=0;i<H;i++) h_check[i] = true;

  bool w_check[H];
  for(int j=0;j<W;j++) w_check[j] = true;


  for(int i=0;i<H;i++){
    int check = 0;
    for(int j=0;j<W;j++) check += a[i][j];

    if(check==0) h_check[i]= false;
  }

   for(int j=0;j<W;j++){
    int check = 0;
    for(int i=0;i<H;i++) check += a[i][j];

    if(check==0) w_check[j] = false;
  }


  for(int i=0;i<H;i++){
    if(h_check[i]){
      for(int j=0;j<W;j++){
        if(w_check[j]){
          if(a[i][j]==1) cout << '#';
          else cout << '.';
        }
      }
      cout <<endl;
    }    
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int d, t, s;
  cin >> d >> t >> s;
  int a=d/s;
  int b=d%s;
  if(b==0){
    if(a<=t){
      cout << "Yes" << endl;
    }
    else cout << "No" << endl;
  }
  else {
    if(a<t) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

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

constexpr int INF = 1e9+9;

int main() {
  int N;
  cin >> N;
  int smallest{INF};
  int negates{};
  long long sum{};

  for (int i{}; i < N; ++i) {
    int A; cin >> A;
    if (A < 0) ++negates;
    A = abs(A);
    smallest = min(smallest, A);
    sum += A;
  }
  if (negates % 2 != 0)
    sum -= smallest * 2;

  cout << sum << endl;
}


Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <tuple>
#include <ctime>
#include <list>
#include <map>
#include <set>

#define REP(i,n) for(int i=0;i<(n);i++)
#define TR(i,x) for(__typeof(x.begin()) i=x.begin();i!=x.end();i++)
#define ALL(x) x.begin(),x.end()
#define SORT(x) sort(ALL(x))
#define CLEAR(x) memset(x,0,sizeof(x))
#define FILL(x,c) memset(x,c,sizeof(x))
#define SIZE(x) (int)(x).size()

#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back

using namespace std;

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

int main() {
    char s[1000];
    scanf("%s", s);
    int c = 0;
    for (int i = 0; s[i]; ++i) {
        if (s[i] == 'C' && c == 0) {
            ++c;
        } else if (s[i] == 'F' && c == 1) {
            ++c;
        }
    }
    puts(c == 2 ? "Yes" : "No");
    return 0;
}


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

int main(){
   int num1,num2;
   cin >> num1 >> num2;

   if (num1 < num2){
      cout << "a < b\n";
   }
   else if (num1 > num2){
      cout << "a > b\n";
   }
   else{
      cout << "a == b\n";
   }

   return 0;
}



Measured memory_bytes: 2956