akhauriyash/Code-Regression huggingface dataset:
import itertools
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

H, W, K = list(map(int, sys.stdin.buffer.readline().split()))
K -= 1

if W == 1:
    print(1)
    exit()

valid_patterns = []
for pattern in itertools.product([True, False], repeat=W - 1):
    ok = True
    for a, b in zip(pattern, pattern[1:]):
        ok &= not (a and b)
    if ok:
        valid_patterns.append(pattern)
through = [0] * W
for pattern in valid_patterns:
    through[0] += pattern[0] is False
    through[-1] += pattern[-1] is False
    for i, (l, r) in enumerate(list(zip(pattern, pattern[1:]))):
        through[i + 1] += not l and not r

# dp[h][w]: 高さ h の左から w 番目の位置に来れるパターン数
dp = np.zeros((H + 1, W), dtype=int)
dp[0][0] = 1
for h in range(1, H + 1):
    dp[h] = dp[h - 1] * through % MOD
    for pattern in valid_patterns:
        for w, p in enumerate(pattern):
            if p:
                dp[h][w] += dp[h - 1][w + 1]
                dp[h][w + 1] += dp[h - 1][w]
        dp[h] %= MOD
print(dp[-1][K] % MOD)


Measured memory_bytes: 12500
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int main() {
  int n = 0, tmp0 = 0, tmp1 = 0;
  int HB = 0, out = 0, point = 0;
  string str;
  scanf("%d", &n);
  // for(tmp0=0;tmp0<3;tmp0++) HB[tmp0]=0;
  while (n) {
    point = 0, HB = 0, out = 0;
    while (out < 3) {
      cin >> str;
      if (str=="OUT") out++;
      else if (str=="HIT") {
        HB++;
        if (HB==4) {
          HB--;
          point++;
        }
      } else if (str=="HOMERUN") {
        point += HB + 1;
        HB = 0;
      }
    }
    printf("%d\n", point);
    n--;
  }
  return 0;
}

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

using namespace std;

typedef long long ll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

	string s;
	cin >> s;

	int n = s.size();

	int t = 0;
	rep(i, n){
		t += s[i] - '0';
		t %= 9;
	}

	if(t == 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

}


Measured memory_bytes: 3740
/*  AC祈願アンコウ
   　／￣＼
   ○    ／￣￣￣＼ヘ
    　 /・　 ・　 ＼>   
    ／￣￣￣＼　　  Ｖ| 
    ｜ ――― ｜　　  ｜|
    ＼＿＿＿／　　  ∧|
    　　＼　　　　／
    　　　￣￣￣￣
*/

#include <bits/stdc++.h>
using namespace std;
 
//#define int ll

typedef int64_t ll;
//static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
#define YESNO(x) puts((x)?"YES":"NO")
#define YesNo(x) puts((x)?"Yes":"No")


signed main(){
    int a[114];
    int n;
    cin >> n;
    REP(i,n) cin >> a[i];

    int ans = 1145141919;

    FOR(i,-100,100+1){
        int tmp = 0;
        REP(k,n){
            tmp += (int) pow(a[k]-i,2);
        }
        ans = min(ans,tmp);
    }

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

    return 0;
}


Measured memory_bytes: 256
import sys
s = input()
s_len = len(s)
s_rev = s[::-1]

if s != s_rev:
  print('No')
  sys.exit()

s_bf_p = int((s_len-1)/2)
s_bf = s[0:s_bf_p]
s_bf_rev = s_bf[::-1]

if s_bf != s_bf_rev:
  print('No')
  sys.exit()

s_af_p = int((s_len+3)/2 - 1)
s_af = s[s_af_p:s_len]
s_af_rev = s_af[::-1]

if s_af != s_af_rev:
  print('No')
  sys.exit()

print('Yes')

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

int main() {
  int a;
  string s;
  cin >> a >> s;
  if (a >= 3200) cout << s << endl;
  else cout << "red" << endl;
  return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define lop(i,n) for(ll i=0;i<n;i++)
#define lop1(i,n) for(ll i=1;i<=n;i++)
#define lopr(i,n) for(ll i=n-1;i>=0;i--)
#define ll long long int
#define pb push_back
#define all(v) v.begin(),v.end()
#define IOS  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl "\n"
#define F first
#define S second	
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define LCM(a,b) (a*b)/__gcd(a,b)
#define mii map<int,int>
#define mll map<ll,ll>
#define ub upper_bound
#define lb lower_bound
#define sz(x) (ll)x.size()
#define ld long double
#define pcnt(x) __builtin_popcountll(x)
const long long I1=1e9;
const long long I2=1e18;
const int32_t M1=1e9+7;
const int32_t M2=998244353;
template<typename T,typename T1>T maxn(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T minn(T &a,T1 b){if(b<a)a=b;return a;}

void solve()
{
  //code begins from here//
  ll n,m,k;
  cin>>n>>m>>k;
  string s[n];
  lop(i,n) cin>>s[i];
  ll ans=0;
  lop(i,(1<<n))
  {
    lop(j,(1<<m))
    {
      ll val=0;
       lop(ii,n)
       {
         lop(jj,m)
         {
            if(s[ii][jj]=='#' && ((1<<ii)&i)==0 && ((1<<jj)&j)==0) val++;
         }
       }
       if(val==k) ans++;
    }
  }
  cout<<ans<<endl;
}

signed main()
{
    IOS;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef MODULO
        initialize();
    #endif
    #ifdef SIEVE
        sieve();
    #endif
    int testcase=1;
    //cin>>testcase;
    while(testcase--) solve();
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>

using namespace std;

int main()
{
    int n,m;
    pair<string, int> card[200];
    vector<int> ans;
    cin >> n;
    int i;
    for(i=0; i<n; i++){
        cin >> card[i].first;
        card[i].second=1;
    }
    cin >> m;
    for(int j=i; j<i+m; j++){
        cin >> card[j].first;
        card[j].second=-1;
    }
    sort(card, card+n+m);
    int tmp=card[0].second;
    string s=card[0].first;
    for(int i=1; i<n+m; i++){
        if(card[i].first==s){
            tmp+=card[i].second;
        }else{
            ans.push_back(tmp);
            s=card[i].first;
            tmp=card[i].second;
        }
    }
    ans.push_back(tmp);
    sort(ans.begin(), ans.end(), greater<int>());
    if(ans[0]<0){
        ans[0]=0;
    }
    cout << ans[0];

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct edge{
  int from, to, cost;
  edge(int a, int b, int c) {
    from = a;
    to = b;
    cost = c;
  }
};

int main() {
  int l;
  cin >> l;
  vector<edge> ans;
  for (int i = 2; i <= 19; i++) {
    ans.push_back(edge(i, i + 1, (1 << (19 - i))));
    ans.push_back(edge(i, i + 1, 0));
  }
  int ll = 0;
  while (l) {
    for (int i = 18; i >= 0; i--) {
      if (l >= (1 << i)) {
        ans.push_back(edge(1, 20 - i, ll));
        l -= (1 << i);
        ll += (1 << i);
        break;
      }
    }
  }
  cout << "20 " << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].from << " " << ans[i].to << " " << ans[i].cost << endl;
  }
  return 0;
}


Measured memory_bytes: 256
// -*- mode:c++; coding:utf-8; indent-tabs-mode:nil; -*-
// ALDS1_2-B

#include <algorithm>
#include <iostream>

static void print_ints(const int as[], const unsigned int n) {
  const char* sep = "";
  for (unsigned int i = 0; i < n; ++i) {
    std::cout << sep << as[i];
    sep = " ";
  }
  std::cout << std::endl;
}

static unsigned int swap_count = 0;

static void print_swap_count(void) {
  std::cout << swap_count << std::endl;
}

inline
static void swap(int& a, int& b) {
  ++swap_count;
  std::swap(a, b);
}

void selection_sort(int as[], const unsigned int n) {
  for (unsigned int i = 0; i < n-1; ++i) {
    unsigned int min_j = i;
    for (unsigned int j = i+1; j < n; ++j) {
      if (as[j] < as[min_j]) {
        min_j = j;
      }
    }
    if (i != min_j) {
      swap(as[i], as[min_j]);
    }
  }
}

int main(void) {
  unsigned int n;
  std::cin >> n;
  int as[n];
  for (unsigned int i = 0; i < n; ++i) {
    std::cin >> as[i];
  }

  selection_sort(as, n);
  print_ints(as, n);
  print_swap_count();

  return 0;
}
// end

Measured memory_bytes: 1168
N, K, Q = map(int, input().split())
l = [0 for i in range(N)]
for i in range(Q):
    A = int(input()) - 1
    l[A] += 1
for i in range(N):
    if K - (Q - l[i]) > 0:
        print("Yes")
    else:
        print("No")

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    char s, t;  cin >> s >> t;
    if (s > t) {
      cout << ">" << '\n';
    } else if (s == t) {
      cout << "=" << '\n';
    } else {
      cout << "<" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
a, b, x = map(int, input().split())
d, mo = divmod(x, 1000)
if mo>500: print(min(d*a+2*b, (d+1)*a, (d*2+2)*b))
elif mo!=0: print(min(d*a+b, (d+1)*a, (d*2+1)*b))
else: print(min(d*a, d*2*b))


Measured memory_bytes: 5596
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char *argv[]) {
  string s;
  char c;
  while (true) {
    cin >> s >> c;
    if (c == 'U') {
      if (s.find('_', 0) == string::npos &&
          'a' <= s[0] && s[0] <= 'z')
        s[0] += ('A'-'a');
      else
        for (int i = 0; i < s.size(); i++)
          if (s[i] == '_') {
            s[i+1] += ('A'-'a');
            s.erase(i, 1);
          } else if (i == 0 && 'a' <= s[0] && s[0] <= 'z') {
            s[i] += ('A'-'a');
          }
      cout << s << endl;
    } else if (c == 'L') {
      if (s.find('_', 0) == string::npos &&
          'A' <= s[0] && s[0] <= 'Z')
        s[0] -= ('A'-'a');
      else
        for (int i = 0; i < s.size(); i++)
          if (s[i] == '_') {
            s[i+1] += ('A'-'a');
            s.erase(i, 1);
          }
      cout << s << endl;
    } else if (c == 'D') {
      for (int i = 0; i < s.size(); i++)
        if (i == 0 && 'A' <= s[i] && s[i] <= 'Z') {
          s[i] -= ('A'-'a');
        } else if ('A' <= s[i] && s[i] <= 'Z') {
          s[i] -= ('A'-'a');
          s.insert(i, 1, '_');
        }
      cout << s << endl;
    } else {
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 1204
#include <stdio.h>

void trace1(int a[],int n)
{
    for(int k = 0;k<n;k++){
        
        if(k>0)
        {
            printf(" ");
        }
        printf("%d",a[k]);
        
    }
    puts("");
    
}

void insertionSort(int a[],int n)
{
    for(int i = 1;i<n;i++)
    {
        int v = a[i];
        int j = i-1;
        while(j>=0&&a[j]>v)
        {
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
        trace1(a,n);
    }
}

int main(){
    
    int n = 0;
    scanf("%d",&n);
    int a[n];
    for(int i = 0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    
    trace1(a,n);
    
    insertionSort(a, n);
    
    return 0;
}


Measured memory_bytes: 2048
/*
* Author: Anmol Choudhary
*/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int ll
const ll mod = 998244353;
const ll maxn = 200005;
const ll mm = 1e+18;
void solve()
{
    double n;
    cin>>n;
    double ans=n*n*n/27.00;
    cout<<fixed<<setprecision(10)<<ans;
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nx;
    }
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define bzero(p, n) memset(p, 0, n)
#define all(a) begin(a),end(a)
template<class T> inline void sort_uniq(T& c) { sort(ALL(c)); c.erase(unique(ALL(c)), c.end()); }
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
inline int powi(int x,int y) {int p=1; while(y--) p*=x; return p;}
inline ll powll(ll x,ll y) {ll p=1; while(y--) p*=x; return p;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
const ll MOD = 1000000007;
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    ll H,W; cin >>H>>W;
    vector<string> a(H); cin >> a;
    vector<vector<ll>> n(H+1, vector<ll>(W+1, 0)) ; 
    
    n[1][1] = 1;
    for (ll i = 1; i <= H; i++) {
        for (ll j = 1; j <= W; j++) {
            if (a[i-1][j-1] != '#')
                n[i][j] += n[i-1][j] + n[i][j - 1];
                n[i][j] %= MOD;
        }
    }

    cout << n[H][W] << endl;
}


Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    char a[12];
    while(cin >> a)
    {
        int len = strlen(a);
        //cout << len << endl;
        for(int i = 0;i < len;i++)
        {
            if(a[i] == 'B')
            {
               // cout << i << "---------" << endl;
                a[i] = 'e';
                for(int j = i - 1;j >= 0;j--)
                {
                    if(a[j] != 'e')
                    {
                        a[j] = 'e';
                        break;
                    }
                }
            }
        }
        for(int i = 0;i < len;i++)
        {
            if(a[i] != 'e')
            cout << a[i];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/*
    Ujjawal Pabreja [cuber_coder]
*/
#include <bits/stdc++.h> 
#include <functional> 
using namespace std;
#define speed_cubing    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define ld              long double
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define in              insert
#define ff              first
#define ss              second
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define sz(c)           (ll)c.size()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define rev             reverse
#define Y				"YES"
#define N 				"NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << endl;
const ll inf = 1e18;  
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll MAX = 1e6 + 1;

inline ll add(ll a,ll b) {return ((a % mod) + (b % mod)) % mod;}
inline ll sub(ll a,ll b) {return ((a % mod) - (b % mod) + mod) % mod;}
inline ll mul(ll a,ll b) {return ((a % mod) * (b % mod)) % mod;}
ll pwr(ll x,ll n){
    if(n == 0){
        return 1;
    }
    if(n&1){
        return mul(x, pwr(mul(x, x), (n - 1) / 2));
    } else {
        return pwr(mul(x, x), n / 2);
    }
}
ll modInv(ll n){ 
    return pwr(n, mod - 2); 
}
ll gcd(ll a,ll b) {
    if(b == 0) {
        return a;
    }
    return gcd(b, a % b);
}
// ====== Useful functions end ======
 
// ====== Global Variables begin ======
ll x[MAX], y[MAX];
// ====== Global Variables end ======

void speed_solve(){
    ll n, m, k;
    cin >> n >> m >> k;
    map <pair<ll,ll>, ll> p;
    rep(i,k){
        ll px, py;
        cin >> px >> py;
        x[px]++, y[py]++;
        p[{px, py}]++;
    }
    ll mxx = maxe(x, x + n + 1), mxy = maxe(y, y + m + 1);
    set <ll> vx, vy;
    rep(i,n + 1) if(x[i] == mxx) vx.in(i);
    rep(i,m + 1) if(y[i] == mxy) vy.in(i);
    ll ans = mxx + mxy - 1;
    for(auto ix : vx){
        for(auto iy : vy){
            if(!p.count({ix, iy})){
                cout << ans + 1 << endl;
                return;
            }
        }
    }
    cout << ans;
}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    speed_cubing;
    ll test_cases = 1;
    // cin >> test_cases;
    rep(i,test_cases){
        // cout << "Case #" << i + 1 << ": ";
        speed_solve();
    }
    return 0;
}

Measured memory_bytes: 55184
# 入力
N = gets.to_i
p = []
q = []
p = gets.split.map(&:to_i)
q = gets.split.map(&:to_i)

arr = []
N.times do |i|
  arr[i] = i+1
end
# 辞書順で全順列(N!こ)を作成
arr = arr.permutation(N).to_a

x,y = 0
arr.each_with_index do |a, i|
  if a == p
    x = i+1
  end
  if a == q
    y = i + 1
  end
end
puts (x-y).abs

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int a, b;
  cin >> a >> b;
  string ans;
  if((a<=8)&&(b<=8)) ans = "Yay!";
  else ans = ":(";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//



int main() {

    string s, t; cin >> s >> t;
    int ans = 0;
    rep(i,s.size()) {
        if (s[i] != t[i]) ++ans;
    }
    out(ans);

    
    return 0;
}









Measured memory_bytes: 3916
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    string s;
    cin >> s;
    reverse(all(s));
    s += '0';
    int n = sz(s);

    auto dp = make_vec<int>(n+1, 2);
    const int inf = 1001001001;
    fill_v<int>(dp, inf);

    dp[0][0] = 0;
    rep(i, n) rep(j, 2) {
        int x = s[i] - '0';
        if (j) x++;
        rep(a, 10) {
            int ni = i+1, nj = 0;
            int b = a - x;
            if (b < 0) {
                nj = 1;
                b += 10;
            }
            chmin(dp[ni][nj], dp[i][j] + a + b);
        }
    }
    int ans = min(dp[n][0], dp[n][1]);
    cout << ans << endl;
}


Measured memory_bytes: 58856
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int sx, sy, tx, ty;
string ans = "", X[] = {"L", "R"}, Y[] = {"D", "U"};

int main()
{
    cin >> sx >> sy >> tx >> ty;
    bool x = sx < tx, y = sy < ty;
    for (int i = 0; i < 2; i++, x = !x, y = !y)
    {
        for (int j = 0; j < abs(sx - tx); j++)
            ans = ans + X[x];
        for (int j = 0; j < abs(sy - ty); j++)
            ans = ans + Y[y];
    }
    for (int i = 0; i < 2; i++, x = !x, y = !y)
    {

        ans = ans + X[!x];
        for (int j = 0; j < abs(sy - ty) + 1; j++)
            ans = ans + Y[y];
        for (int j = 0; j < abs(sx - tx) + 1; j++)
            ans = ans + X[x];
        ans = ans + Y[!y];
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

int main(){
	int N, T, i;
	scanf("%d%d", &N, &T);
	int *t = (int *)malloc(sizeof(int) * N);
	long long int ans = T;
	for(i = 0; i < N; i++){
		scanf("%d", &t[i]);
	}
	for(i = 1; i < N; i++){
		if(t[i] - t[i - 1] > T){
			ans += T;
		}
		else{
			ans += t[i] - t[i - 1];
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999

int h,w;

void shift(vector<string> &data){
    rep(i,h){
        for(int j=w-2;j>=0;j--){
            data[i][j+1] = data[i][j];
        }
    }
    rep(i,h)data[i][0]='.';
}


int main(){
    cin>>h>>w;
    vector<string> data(h);
    rep(i,h){
        cin>>data[i];
    }
    
    int arrived[110][110];
    rep(i,110)rep(j,110)arrived[i][j]=INF;
    rep(i,w){
        rep(j,h){
            rep(k,w){
                if(data[j][k]=='c'){
                    arrived[j][k] = min<ll>(arrived[j][k],i);
                }
            }
        }
        shift(data);
    }
    
    rep(i,h)rep(j,w)if(arrived[i][j]==INF)arrived[i][j]=-1;
    rep(i,h){
        rep(j,w){
            if(j!=0)cout<<" ";
            cout<<arrived[i][j];
        }
        cout<<endl;
    }
}

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

int main() {
	long long n, m; cin >> n >> m;
	if (n > m) {
		long long tmp = n; n = m; m = tmp;
	}

	if (n == 1 && m == 1)cout << 1 << endl;
	else if (n == 1)cout << m - 2 << endl;
	else cout << (n - 2) * (m - 2) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int M[101]={0},cou,a,max=0;
	
	while(scanf("%d",&a)!=EOF){
		M[a]++;
		}
	for(cou=0;cou<100;cou++){
		if(M[cou]>max){
			max=M[cou];
		}
	}
	
	for(cou=0;cou<100;cou++){
		if(M[cou]==max){
			printf("%d\n",cou);
		}
	}

	return 0;
}

Measured memory_bytes: 596
n, k = list(map(int, input().split()))
ans = 0
for i in range(n):
    d = i + 1
    p = 1 / n
    needed = 0
    while d * (2 ** needed) < k:
        needed += 1
    p *= (1 / 2)**needed
    ans += p
print(ans)


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

using namespace std;

int main()
{
	char c;
	cin>>c;
	if(c=='A')
		cout<<"T\n";
	else if(c=='T')
		cout<<"A\n";
	else if(c=='G')
		cout<<"C\n";
	else
		cout<<"G\n";
	return 0;
}

Measured memory_bytes: 256
alf=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]

N=int(input())
S=input()
S2=[]

for s in list(S):
    for i in range(26):
        if alf[i]==s:
            s=alf[i+N]
            S2.append(s)
            s="a"

tmp=""
for i in S2:
    tmp+=i
print(tmp)

Measured memory_bytes: 3316
use std::collections::HashSet;

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 read_vec<T: ::std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    ::std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn check(H: &usize, W: &usize, i: &i32, j: &i32) -> bool {
    *H as i32 > *i && *W as i32 > *j && 0 <= *i && 0 <= *j
}

pub fn main() {
    let HW = read_vec();
    let H: usize = HW[0];
    let W: usize = HW[1];
    let mut Ass = Vec::with_capacity(H);
    for i in 0..H {
        let row: String = read();
        Ass.push(row.chars().collect::<Vec<char>>());
    }
    let mut c = 0;
    let mut poss: HashSet<(usize, usize)> = HashSet::new();
    for i in 0..H {
        for j in 0..W {
            let c = Ass[i][j];
            if c == '#' { poss.insert((i, j)); }
        }
    }
    loop {
        if poss.len() == 0 { break; }
        c += 1;
        println!();
        poss = poss.iter().flat_map(|&(i, j)| {
            let i = i as i32;
            let j = j as i32;
            let a = i + 1;
            let b = j;
            let mut v = Vec::new();
            if check(&H, &W, &a, &b) {
                if Ass[a as usize][b as usize] == '.' {
                    v.push((a as usize, b as usize));
                }
                Ass[a as usize][b as usize]  = '#';
            }
            let a = i - 1;
            let b = j;
            if check(&H, &W, &a, &b) {
                if Ass[a as usize][b as usize] == '.' {
                    v.push((a as usize, b as usize));
                }
                Ass[a as usize][b as usize]  = '#';
            }
            let a = i;
            let b = j + 1;
            if check(&H, &W, &a, &b) {
                if Ass[a as usize][b as usize] == '.' {
                    v.push((a as usize, b as usize));
                }
                Ass[a as usize][b as usize]  = '#';
            }
            let a = i;
            let b = j - 1;
            if check(&H, &W, &a, &b) {
                if Ass[a as usize][b as usize] == '.' {
                    v.push((a as usize, b as usize));
                }
                Ass[a as usize][b as usize]  = '#';
            }
            v
        }).collect();
    }
    println!("{}", c - 1);
}

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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  vector<int> ans(N);

  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'R') cnt++;
    else ans.at(i) += cnt / 2, ans.at(i - 1) += (cnt + 1) / 2, cnt = 0;
  }

  reverse(S.begin(), S.end());
  reverse(ans.begin(), ans.end());

  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'L') cnt++;
    else ans.at(i) += cnt / 2, ans.at(i - 1) += (cnt + 1) / 2, cnt = 0;
  }

  for (int i = N - 1; i >= 0; i--) cout << ans.at(i) << "\n";
}

Measured memory_bytes: 1024
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));
		int n = Integer.parseInt(br.readLine());
		String[] s = br.readLine().split(" ");
		int[] h = new int[n];
		for (int i = 0 ; i < n; i++) 
			h[i] = Integer.parseInt(s[i]);
		
		if (n == 2) {
			System.out.println(h[1]-h[0]);
			return;
		}
		
		int[] dp = new int[n];
		dp[1] = Math.abs(h[1]-h[0]);
		for (int i = 2; i < n; i++) {
			dp[i] = Math.min(dp[i-1] + Math.abs(h[i-1]-h[i]), dp[i-2] + Math.abs(h[i-2]-h[i]));
		}
		System.out.print(dp[n-1]);
	}

}


Measured memory_bytes: 33316
x,k,d = map(int, input().split())
x = abs(x)

cnt = int(x/d)

x -= d*min(cnt, k)

if x > d/2 and cnt < k:
  x = abs(x - d)
  cnt += 1

if (k-cnt) % 2 == 1 and cnt < k:
  x -= d

print(abs(x))

Measured memory_bytes: 9184
import sys
readline = sys.stdin.readline

N = int(readline())

C = [[0] * 19 for i in range(19)]

for i in range(N):
  a = readline().rstrip()
  if "." in a:
    keta = len(a.split(".")[1])
    a = int(a.replace(".","")) * (10 ** (9 - keta))
  else:
    a = int(a) * (10 ** 9)
  cnt2 = 0
  cnt5 = 0
  while a % 2 == 0:
    a //= 2
    cnt2 += 1
  while a % 5 == 0:
    a //= 5
    cnt5 += 1
  C[min(cnt2, 18)][min(cnt5, 18)] += 1

#for c in C:
#  print(c)

ans = 0
# まず、同じグループから2つの数を選ぶ場合の数
for i in range(9, 19):
  for j in range(9, 19):
    n = C[i][j]
    ans += (n * (n - 1)) // 2

# 異なるグループから選ぶ場合の数
ans_diff = 0
for i in range(19):
  for j in range(19):
    for p in range(19):
      for q in range(19):
        if i == p and j == q:
          continue # カウント済
        if i + p < 18 or j + q < 18:
          continue
        ans_diff += C[i][j] * C[p][q]

ans += ans_diff // 2 # 二回カウントしている

print(ans)


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

int abs(int a);

int main(void){
	int n,i;
	int x[100],y[100];
	double Man,Euc,p3;
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&x[i]);
	for(i=0;i<n;i++) scanf("%d",&y[i]);

	//p=1
	for(i=0;i<n;i++) Man+=abs(x[i]-y[i]);
	printf("%.6f\n",Man);

	//p=2
	for(i=0;i<n;i++) Euc+=(x[i]-y[i])*(x[i]-y[i]);
	printf("%f\n",sqrt(Euc));

	//p=3
	for(i=0;i<n;i++) p3+=pow((double)abs(x[i]-y[i]),3.);
	printf("%f\n",pow(p3,1./3.));
				 
	//p=???
	double max=0.;
	for(i=0;i<n;i++)
		if(abs(x[i]-y[i])>max) max=abs(x[i]-y[i]);
  printf("%f\n",max);

	return 0;
}


	
		int abs(int a){
	  if(a>0) return a;
		else return -a;
	}

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

int main(){
  int H,W;
  cin >> H >> W;
  vector<string> line(H);
  for(int i=0;i<H;i++){
    string tmp;
    cin >> tmp;
    line.at(i)=tmp;
  }
  for(int i=0;i<W+2;i++){
    cout << '#';
  }
  cout << endl;
  for(int i=0;i<H;i++){
    cout << '#' << line.at(i) << '#' << endl;
  }
  for(int i=0;i<W+2;i++){
    cout << '#';
  }
  cout << endl;
}

Measured memory_bytes: 3612
#include<iostream>
#include<cmath>
#include<string.h>
#include<stdio.h>
#include<algorithm>
using namespace std;

int n,c,k;
int a[100011];

int ans;

int main()
{
    int i,j;
    scanf("%d %d %d",&n,&c,&k);
    
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a+1,a+n+1);
    
    int la,num;
    la=a[1];
    num=1;
    ans=0;
    for(i=2;i<=n;i++)
    {
        if(num==c)
        {
            ans++;
            la=a[i];
            num=1;
            continue;
        }
        
        if(la+k<a[i])
        {
            ans++;
            la=a[i];
            num=1;
            continue;
        }
        
        num++;
    }
    
    if(num>0)
    {
        ans++;
    }
    
    cout<<ans<<endl;
    
    return 0;
} 


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

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

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 100005;

int n, a[MAXN], d[MAXN];
vector <int> adj[MAXN];
LL f[MAXN];

inline void GG()
{
	puts("NO");
	exit(0);
}

inline void Dfs(int x, int p)
{
	if (d[x] == 1)
		f[x] = a[x];
	else
	{
		f[x] = a[x] << 1;
		for (auto y : adj[x])
			if (y ^ p)
			{
				Dfs(y, x), f[x] -= f[y];
				if (f[y] > a[x])
					GG();
			}
		if (f[x] < 0 || f[x] > a[x])
			GG();
	}
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read();
	for (int i = 1; i <= n; i ++)
		a[i] = Read();
	for (int i = 1, x, y; i < n; i ++)
		x = Read(), y = Read(), adj[x].pb(y), adj[y].pb(x), d[x] ++, d[y] ++;
	if (n == 2)
		return puts(a[1] == a[2] ? "YES" : "NO"), 0;
	for (int i = 1; i <= n; i ++)
		if (d[i] ^ 1)
		{
			Dfs(i, 0);
			return puts(f[i] ? "NO" : "YES"), 0;
		}
}


Measured memory_bytes: 9984
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
    class Program
    {
        public static void Main(string[] args)
        {
            var l = Console.ReadLine()
               .Split(' ')
               .Select(int.Parse)
               .ToArray();
            var n = l[0];
            var k = l[1];

            Console.WriteLine(n - k + 1);
        }
    }
}


Measured memory_bytes: 13396
n=int(input())
a=[]
for _ in range(n):
	a.append(int(input()))
a.append(0)

def ans():
	if a[0]>0:
		return -1
	else:
		ans=0
		for i in range(n):
			if a[i+1]-a[i]>1:
				return -1
			elif a[i+1]-a[i]<1:
				ans+=a[i]
		return ans

print(ans())


Measured memory_bytes: 11048
#include <stdio.h>

int main()
{
	int i, N, P, X[101];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(X[i]));
	
	long sum = 0;
	for (i = 1; i <= N; i++) sum += X[i];
	if (sum % N <= N/2) P = sum / N;
	else P = sum / N + 1;
	
	sum = 0;
	for (i = 1; i <= N; i++) sum += (X[i] - P) * (X[i] - P);
	printf("%ld\n", sum);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<set>
#include<algorithm>

using namespace std;

int main(){
  int R,C;
  cin>>R>>C;
  char a[32][32];
  int y,x;
  for(int i=0;i<R;i++){
    for(int j=0;j<C;j++){
      cin>>a[i][j];
      if(a[i][j]=='S'){
	y=i;
	x=j;
      }
    }
  }
  int u[32][32];
  fill(u[0],u[32],1e9);
  set<pair<int,int> > s[12345];
  s[0].insert({y,x});
  for(int i=0;;i++){
    for(auto e:s[i]){
      int y=e.first;
      int x=e.second;
      if(a[y][x]=='G'){
	cout<<i<<endl;
	return 0;
      }
      if(u[y][x]<=i)continue;
      u[y][x]=i;
      static int d[]={0,-1,0,+1,0};
      for(int j=0;j<4;j++){
	int ny=y+d[j];
	int nx=x+d[j+1];
	if(0<=ny&&ny<R&&0<=nx&&nx<C&&a[ny][nx]!='#'&&a[ny][nx]!='x'){
	  s[i+1+(a[ny][nx]!='o')].insert({ny,nx});
	}
	for(int k=1;k<=3;k++){
	  int ny=y+d[j]*k;
	  int nx=x+d[j+1]*k;
	  if(ny<0||R<=ny||nx<0||C<=nx||a[ny][nx]=='#')break;
	  s[i+2+k].insert({ny,nx});
	}
      }
    }
  }
}

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

using namespace std;

bool e[105][105],vis[105];
int link[105];

bool dfs(int x,int n) {
  for(int i=1;i<=n;i++)
    if (e[x][i]&&!vis[i]) {
    	vis[i]=1;
    	if (!link[i]||dfs(link[i],n)) {
    		link[i]=x;
    		return 1;
		}
	}
  return 0;
}

void match(int n) {
  memset(link,0,sizeof(link));
  for(int i=1;i<=n;i++) {
  	memset(vis,0,sizeof(vis));
  	dfs(i,n);
  }
}

int a[105][105],b[105][105],val[105][105];
bool use[105][105];

int main() {
  int n,m;
  scanf("%d%d",&n,&m);
  for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++) {
	  scanf("%d",&a[i][j]);
	  val[i][j]=(a[i][j]-1)/m+1;
    }
  for(int i=1;i<=m;i++) {
  	memset(e,0,sizeof(e));
  	for(int j=1;j<=n;j++)
  	  for(int k=1;k<=m;k++)
  	    if (!use[j][k]) e[j][val[j][k]]=1;
  	match(n);
  	for(int j=1;j<=n;j++) {
  		int x=link[j];
  		for(int k=1;k<=m;k++)
  		  if (!use[x][k]&&val[x][k]==j) {
  		  	  use[x][k]=1;
  		  	  b[x][i]=a[x][k];
  		  	  break;
			}
	  }
  }
  for(int i=1;i<=n;i++) {
  	for(int j=1;j<=m;j++) printf("%d ",b[i][j]);
  	printf("\n");
  }
  for(int i=1;i<=m;i++) {
  	for(int j=1;j<=n;j++)
  	  for(int k=1;k<j;k++)
  	    if (b[j][i]<b[k][i]) swap(b[j][i],b[k][i]);
  }
  for(int i=1;i<=n;i++) {
  	for(int j=1;j<=m;j++) printf("%d ",b[i][j]);
  	printf("\n");
  }
  return 0;
}

Measured memory_bytes: 512
N = int(input())
s = 0
ans = []
d = 0
for i in range(1, N + 1):
    s += i
    ans.append(i)
    if s == N:
        break
    elif s > N:
        d = s - N
        break


for a in ans:
    if a != d:
        print(a)


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

int main() {
  int n;
  cin >> n;
  
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  
  int count = 1, ans = 0;
  for(int i = 1; i < n; i++){
    if(a.at(i - 1) == a.at(i)) count++;
    else{
      ans += count / 2;
      count = 1;
    }
  }
  ans += count / 2;
  
  cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  int A[N];
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A, A + N);

  cout << abs(A[0] - A[N - 1]) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mod = 998244353;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){ //for debug
    ll n = vec.size();
    cout << "------------------------------------\n" ;
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
    cout << "------------------------------------\n" ;
}

void pr2d(vector<vector<ll>> vec){ // for debug
    ll h = vec.size();
    ll w = vec.at(0).size();
    cout << "------------------------------------\n" ;
    rep(i,h){
        rep(j,w){
            cout << vec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
    cout << "------------------------------------\n" ;
}

int main(){
    ll n ; cin >> n;
    vector<pair<ll,ll>> left(0),right(0); //first->minimum second->diff
    rep(i,n){
        string s; cin >> s;
        ll ss = s.size();
        ll val = 0;
        ll mnm = INF;
        rep(j,ss){
            if(s.at(j)=='('){
                val++;
            }else{
                val--;
                mnm = min(mnm,val);
            }
        }
        if(val>=0){
            left.push_back(make_pair(mnm,val));
        }else{
            right.push_back(make_pair(mnm,val));
        }
    }
    /*
    for(auto i:right){
        cout << i.first << " " << i.second << endl;
    }
    cout << endl;
    */

    ll rs = right.size();

    for(int i=0;i<rs;i++){
        right[i].first = right[i].first - right[i].second;
        right[i].second = right[i].second * (-1);
    }

    /*
    for(auto i:left){
        cout << i.first << " " << i.second << endl;
    }
    cout << endl;
    for(auto i:right){
        cout << i.first << " " << i.second << endl;
    }
    */

    bool ng = false;
    ll summit_left = 0,summit_right = 0;

    sort(left.rbegin(),left.rend());
    for(auto i:left){
        if(summit_left+i.first<0) ng = true;
        summit_left += i.second;
    }

    sort(right.rbegin(),right.rend());
    for(auto i:right){
        if(summit_right+i.first<0) ng = true;
        summit_right += i.second;
    }

    if(summit_left != summit_right) ng = true;

    if(ng){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 19132
def selection(A,n):
  count = 0
  for i in range(0,n-1):
    min = i
    for j in range(i,n):
      if(A[j] < A[min]):
        min = j
    if(min!=i):
      A[i], A[min] = A[min], A[i]
      count+=1
  printList(A)
  print(count)

def printList(A):
  print(" ".join(str(x) for x in A))

n = int(input())
A = [int(x) for x in input().split()]
selection(A,n)

Measured memory_bytes: 7760
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
   int A,B;
   cin >> A>>B;
   int wa,sa,seki;
   wa = A+B;
   sa = A-B;
   seki = A*B;
   int wasa = max(wa,sa);
   cout << max(wasa,seki) << endl;
   return 0;
}


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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
typedef long long ll;

int main() {
    int A, B; cin >> A >> B;
    cout << A*B << " " << (A*2) + (B*2) << endl;
}


Measured memory_bytes: 3092
import bisect
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
A.sort()
INF = 10 ** 9
A.append(INF)

left, right = 0, 2 * max(A)
while left + 1 < right:
    mid = (left + right) >> 1
    cnt = sum(N - bisect.bisect_left(A, mid-A[i]) for i in range(N))
    if cnt >= M:
        left = mid
    else:
        right = mid
acc = [0]
for i in range(N):
    acc.append(acc[-1] + A[i])
ans = 0
cnt = 0
for i in range(N):
    idx = bisect.bisect_left(A, left-A[i])
    cnt += N - idx
    ans += (N - idx) * A[i] + acc[N] - acc[idx]
ans -= (cnt - M) * left
print(ans)


Measured memory_bytes: 63768
n,a,b = (int(i) for i in input().split())
x = [int(i) for i in input().split()]
answer = 0
for i in range(n-1):
	if (x[i+1]-x[i])*a < b: answer += (x[i+1]-x[i])*a
	else: answer += b
print(answer)

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

typedef long long ll;
typedef vector<long long> vll;
typedef vector<vector<long long>> mll;
typedef vector<pair<long long, long long>> vpl;
typedef pair<long long, long long> pll;
#define minimize(var, val) (var = min((val), var))

class ModfieldInt {
   public:
    long long value;
    const static long long mod = 1e9 + 7;
    ModfieldInt(long long value = 0) {
        this->value = value;
    }
    friend ModfieldInt operator^(ModfieldInt val, long long power) {
        long long res = 1, cum = (val.value % val.mod);
        for (; power > 0; power >>= 1) {
            if (power & 1)
                res = (res * cum) % val.mod;
            cum = (cum * cum) % val.mod;
        }
        return ModfieldInt(res);
    }
    friend ModfieldInt operator+(ModfieldInt a, ModfieldInt b) {
        return ModfieldInt((a.value + b.value) % b.mod);
    }
    friend ModfieldInt operator-(ModfieldInt a, ModfieldInt b) {
        return ModfieldInt((a.value - b.value + b.mod) % b.mod);
    }
    friend ModfieldInt operator*(ModfieldInt a, ModfieldInt b) {
        return ModfieldInt((a.value * b.value) % a.mod);
    }
    friend ModfieldInt operator/(ModfieldInt a, ModfieldInt b) {
        return a * (b ^ (b.mod - 2));
    }
};

vector<ModfieldInt> factorial(200001, 1);

ModfieldInt comb(ll n, ll r) {
    return factorial[n] / (factorial[r] * factorial[n - r]);
}

int main() {
    // Precompute nCr to find out number of ways from cell to cell
    factorial[0] = 1;
    for (int i = 1; i <= 200000; i++)
        factorial[i] = factorial[i - 1] * ModfieldInt(i);
    // Take all the inputs and sort them in the lattice structure
    ll h, w, n;
    cin >> h >> w >> n;
    vpl a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i].first >> a[i].second;
    sort(a.begin(), a.end(), [](pll x, pll y) {
        return (x.first != y.first) ? x.first < y.first : x.second < y.second;
    });
    // Compute for each number of ways it can be the first forbidden hit
    vector<ModfieldInt> dp(n, 0);
    for (int i = 0; i < n; i++) {
        dp[i] = comb(a[i].first + a[i].second - 2, a[i].first - 1);
        for (int j = 0; j < i; j++) {
            if (a[i].second >= a[j].second && a[i].first >= a[j].first)
                dp[i] = dp[i] - comb(a[i].first + a[i].second - a[j].first -
                                         a[j].second,
                                     a[i].first - a[j].first) *
                                    dp[j];
        }
    }
    // Same computation for the last square
    ModfieldInt ans = comb(h + w - 2, h - 1);
    for (int j = 0; j < n; j++) {
        ans = ans -
              comb(h + w - a[j].first - a[j].second, h - a[j].first) * dp[j];
    }
    // Output the answer
    cout << ans.value << endl;
}


Measured memory_bytes: 1920
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Scanner;

class Main {

	class SegTree {
		int n;
		int[] v;

		public SegTree(int n_) {
			n = 1;
			while (n < n_)
				n *= 2;
			v = new int[2 * n - 1];
		}

		void addVal(int k, int val) {
			k += n - 1;
			v[k] += val;
			while (k > 0) {
				k = (k - 1) / 2;
				v[k] = v[2 * k + 1] + v[2 * k + 2];
			}
		}

		int query(int a, int b) {
			return query(a, b, 0, n, 0);
		}

		int query(int a, int b, int l, int r, int k) {
			if (b <= l || r <= a) {
				return 0;
			} else if (a <= l && r <= b) {
				return v[k];
			} else {
				return query(a, b, l, (l + r) / 2, 2 * k + 1) + query(a, b, (l + r) / 2, r, 2 * k + 2);
			}
		}
	}

	boolean[] isPrime = new boolean[200000];
	{
		Arrays.fill(isPrime, true);
		isPrime[0] = isPrime[1] = false;
		for (int i = 2; i < isPrime.length; ++i) {
			if (!isPrime[i])
				continue;
			for (int j = 2 * i; j < isPrime.length; j += i) {
				isPrime[j] = false;
			}
		}
	}

	boolean[] a = new boolean[200000];

	public void run() {
		Scanner sc = new Scanner(System.in);
		SegTree sum = new SegTree(200000);
		for (int i = 2; i < a.length; ++i) {
			if (isPrime[i] && isPrime[(i + 1) / 2]) {
				a[i] = true;
				sum.addVal(i, 1);
			}
		}
		int Q = sc.nextInt();
		for (int i = 0; i < Q; ++i) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			System.out.println(sum.query(l, r + 1));
		}

	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

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


Measured memory_bytes: 76308
from collections import defaultdict

def dfs(i, V, E, x):
    S = [i]
    while(len(S) > 0):
        vi = S.pop()
        p = x[vi]
        for j in E[vi]:
            if V[j] == 0:
                V[j] = 1
                x[j] += p
                S.append(j)
    return V, x

n, q = map(int, input().split())
V = [0 for _ in range(n + 1)]
E = [[] for _ in range(n + 1)]
for i in range(n - 1):
    a, b = map(int, input().split())
    E[a].append(b)
    E[b].append(a)

x = [0 for _ in range(n + 1)]
for i in range(q):
    pi, xi = map(int, input().split())
    x[pi] += xi

V[1] = 1
dfs(1, V, E, x)
print(*x[1:])


Measured memory_bytes: 56140
#include <iostream>

using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b){
        if (a == c){
            cout << "No" << endl;
        }else {
            cout << "Yes" << endl;
        }
    }else{
        if (a == c || b == c){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 256