akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
    class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            
            
            String s = sc.nextLine();
            
            for(int i=0;i<s.length();i++){
                if(Character.isLowerCase(s.charAt(i))){
                   System.out.print(Character.toUpperCase(s.charAt(i)));
                }else{
                    System.out.print(Character.toLowerCase(s.charAt(i)));
                }
            }
            System.out.println();
        }
    }


Measured memory_bytes: 27008
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long X = sc.nextLong();
        sc.close();
        
        int year = 0;
        
        long kouza = 100L;
        
        while(kouza < X) {
            year++;
            long risi = kouza * 1 / 100;
            kouza += risi;
        }
        
        System.out.println(year);
    }

}


Measured memory_bytes: 35836
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
    int N;
    scanf("%d", &N);
    int L[N];
    for(int i = 0; i < N; ++i) scanf("%d", &L[i]);
    sort(L, L + N);
    int len = L[N-1] + 1;
    int num[len]; //num[i] --- i以下の数がどれだけあるか
    fill(num, num + len, 0);
    for(int i = 0; i < N; ++i) ++num[L[i]];
    for(int i = 1; i < len; ++i) num[i] += num[i-1];
    ll res = 0;
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < i; ++j) {
            int tmp = 0;
            // abs(L[i] - L[j]) < c < L[i] + L[j]でなければならない
            int up = L[i] + L[j];
            int lw = abs(L[i] - L[j]);
            if(up > L[N-1]) tmp += N;
            else        tmp += num[up-1];
            tmp -= num[lw];
            if(lw < L[i] && L[i] < up) tmp -= 1;
            if(lw < L[j] && L[j] < up) tmp -= 1;
            res += (ll)tmp;
        }
    }
    printf("%lld\n", res/3);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100
int main(void){
    int n,i,a[MAX];
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(i=0;i<n;i++){
        printf("%d",a[n-i-1]);
        if(i!=n-1)
            putchar(' ');
    }
    puts("");
    return 0;
}


Measured memory_bytes: 2724
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF MOD
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    int a;
    cin >> a;
    cout << pow(a, 3) + pow(a, 2) + a << endl;
}

Measured memory_bytes: 4192
#include <bits/stdc++.h>
using namespace std;
int main () {
    int n;
    cin >> n;
    set<int> s;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        s.insert(a);
    }
    if (n == s.size()) {
        puts("YES");
    }
    else {
        puts("NO");
    }
}

Measured memory_bytes: 9600
S = input()

n = len(S)

good = True

for i in range(n):
    if i % 2 == 0:
        if S[i] == 'L':
            good = False
            break
    else:
        if S[i] == 'R':
            good = False
            break

if good:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<map>

using namespace std;

int main()
{
    int N;
    cin >> N;
    map<int, int> V1;
    map<int, int> V2;
    int a;
    for(int i=0; i<N; i++){
        cin >> a;
        if(i%2==1){
            V1[a] += 1;
        }else{
            V2[a] += 1;
        }
    }
    int m = 0;
    int k = 0;
    for(pair<int, int> p: V1){
        if(p.second>m){
            m = p.second;
            k = p.first;
        }
    }
    int n = 0;
    for(pair<int, int> p: V2){
        if(p.second>n and p.first!=k){
            n = p.second;
        }
    }
    int ans1 = N-m-n;
    m = 0;
    k = 0;
    n = 0;
    for(pair<int, int> p: V2){
        if(p.second>m){
            m = p.second;
            k = p.first;
        }
    }
    for(pair<int, int> p: V1){
        if(p.second>n and p.first!=k){
            n = p.second;
        }
    }
    int ans2 = N-m-n;
    cout << min(ans1,ans2) << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    int n,k;
    cin >> n >> k;
    cout << (n-1+k-1-1)/(k-1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>

using namespace std;

int main(){
  string S;
  char check;
  bool flag = true;

  cin >> S;

  for(int i = 0; i < S.size()-1; i++){
    check = S[i];
    for(int j = i+1; j < S.size(); j++){
      if(check == S[j]){
        flag = false;
        break;
      }
    }
  }

  if(flag) cout << "yes" << endl;
  else cout << "no" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
#include <algorithm>
using namespace std;

int n;
bool isAlive = false;

struct WaterServer{
	int x,y;
};

bool rangeCheck(int col,int row){
	if(col >=0 && col <= 9 && row >=0 && row <= 9)return true;
	else{
		return false;
	}
}

bool isInZone(int col,int row,int count,WaterServer server[10]){
	int x = server[count].x,y = server[count].y;

	if(rangeCheck(x,y) == true && x == col && y == row)return true;
	if(rangeCheck(x-1,y-1) == true && x-1 == col && y-1 == row)return true;
	if(rangeCheck(x,y-1) == true && x == col && y-1 == row)return true;
	if(rangeCheck(x+1,y-1) == true && x+1 == col && y-1 == row)return true;
	if(rangeCheck(x-1,y) == true && x-1 == col && y == row)return true;
	if(rangeCheck(x+1,y) == true && x+1 == col && y == row)return true;
	if(rangeCheck(x-1,y+1) == true && x-1 == col && y+1 == row)return true;
	if(rangeCheck(x,y+1) == true && x == col && y+1 == row)return true;
	if(rangeCheck(x+1,y+1) == true && x+1 == col && y+1 == row)return true;

	return false;
}

void recursive(int col,int row,int count,WaterServer server[10]){
	if(count == n){
		isAlive = true;
		return;
	}
	if(rangeCheck(col-1,row-2) == true && isInZone(col-1,row-2,count,server) == true)recursive(col-1,row-2,count+1,server);
	if(rangeCheck(col,row-2) == true && isInZone(col,row-2,count,server) == true)recursive(col,row-2,count+1,server);
	if(rangeCheck(col+1,row-2) == true && isInZone(col+1,row-2,count,server) == true)recursive(col+1,row-2,count+1,server);
	if(rangeCheck(col-2,row-1) == true && isInZone(col-2,row-1,count,server) == true)recursive(col-2,row-1,count+1,server);
	if(rangeCheck(col+2,row-1) == true && isInZone(col+2,row-1,count,server) == true)recursive(col+2,row-1,count+1,server);
	if(rangeCheck(col-2,row) == true && isInZone(col-2,row,count,server) == true)recursive(col-2,row,count+1,server);
	if(rangeCheck(col+2,row) == true && isInZone(col+2,row,count,server) == true)recursive(col+2,row,count+1,server);
	if(rangeCheck(col-2,row+1) == true && isInZone(col-2,row+1,count,server) == true)recursive(col-2,row+1,count+1,server);
	if(rangeCheck(col+2,row+1) == true && isInZone(col+2,row+1,count,server) == true)recursive(col+2,row+1,count+1,server);
	if(rangeCheck(col-1,row+2) == true && isInZone(col-1,row+2,count,server) == true)recursive(col-1,row+2,count+1,server);
	if(rangeCheck(col,row+2) == true && isInZone(col,row+2,count,server) == true)recursive(col,row+2,count+1,server);
	if(rangeCheck(col+1,row+2) == true && isInZone(col+1,row+2,count,server) == true)recursive(col+1,row+2,count+1,server);
}

int main(){

	int col,row,table[10][10];
	WaterServer server[10];

	while(true){
		scanf("%d %d",&col,&row);
		if(col == 0 && row == 0)break;

		for(int i=0; i < 10; i++){
			for(int k=0; k < 10; k++)table[i][k] = 0;
		}

		scanf("%d",&n);

		for(int i=0; i < n; i++){
			scanf("%d %d",&server[i].x,&server[i].y);
		}

		recursive(col,row,0,server);

		if(isAlive)printf("OK\n");
		else{
			printf("NA\n");
		}

		isAlive = false;
	}

    return 0;
}

Measured memory_bytes: 2492
N, M = map(int, input().split())
A = list(map(int, input().split()))

all_A = sum(A)
border = all_A / (M*4)

select = 0

for a in A:
    if a >= border:
        select += 1

if select >= M:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9132
#include <iostream>

using namespace std;

int main(void) {
  int yama[51], tmp[51];

  int n, r;
  while (cin >> n >> r, (n || r)) {
    // initialization
    for (int i=0; i<n; i++) {
      yama[i] = i + 1;
    }

    // shuffle
    for (int i=0; i<r; i++) {
      int p, c;
      cin >> p >> c;

      for (int j=0; j<c; j++) {
        tmp[c-1-j] = yama[n-p-j];
      }
      for (int j=n-p+1; j<n; j++) {
        yama[j-c] = yama[j];
      }
      for (int j=0; j<c; j++) {
        yama[n-c+j] = tmp[j];
      }
    }

    cout << yama[n-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <set>
#include <map>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N;
  std::cin >> N;
  vvi data = vv(N, 3, 0, int);
  for(int i=0;i<N;i++) std::cin >> data[i][0] >> data[i][1] >> data[i][2];
  int h;
  sort(data.begin(), data.end(), [](std::vector<int> &a, std::vector<int> &b){
    return a[2] > b[2];
  });
  //for(int i=0;i<N;i++) std::cout << data[i][0] << '\n';
  for(int i=0;i<=100;i++){
    for(int j=0;j<=100;j++){
      h = -1;
      for(int k=0;k<N;k++){
        if(h==-1&&data[k][2]>0){
          h = data[k][2] + abs(data[k][0]-i) + abs(data[k][1]-j);
        }else if(max(0, h-abs(data[k][0]-i)-abs(data[k][1]-j)) != data[k][2]) break;
        else if(k==N-1){
          std::cout << i << " " << j << " " << h << '\n';
        }
      }
    }
  }
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define M_PI 3.14159265358979323846
#define ll long long
int main()
{

     double a,b,h,m,i,j,cnt=0;
    string s;

    cin>>a>>b>>h>>m;

     double min_d=m*6;
     double hor_d=(h*30)+(m/2);
     double angle=abs(min_d-hor_d);
    if(angle>180)
    {
        angle=360-angle;
    }
    double radian = angle * (M_PI/180);

     double ot=sqrt((a*a)+(b*b)-(2*a*b*cos(radian)));

    cout<<fixed<<setprecision(20)<<ot<<endl;

}


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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& a) { return is >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }

void LOG(const int& x) { cerr << x << "\n"; }
template<typename T> void LOG(const vector<T>& a) { for (const T& x : a) cerr << x << " "; cerr << "\n"; }
template<typename T, std::size_t S> void LOG(const T (&a)[S]) { REP(i, S) cerr << a[i] << " "; cerr << "\n"; }
template<typename T, std::size_t S, std::size_t R> void LOG(const T (&a)[S][R]) { REP(i, S) { REP(j, R) cerr << a[i][j] << " "; cerr << "\n"; } }

i64 ceil(i64 a, i64 b) { return (a - 1) / b + 1; }
i64 gcd(i64 a, i64 b) { while (b != 0) { i64 t = b; b = a % b; a = t; } return a; }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
i64 gcd(const vector<i64>& v) { return accumulate(ALL(v), 1LL, static_cast<i64(*)(i64, i64)>(gcd)); }
i64 lcm(const vector<i64>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<i64(*)(i64, i64)>(lcm)); }
i64 pow(i64 x, i64 y, i64 z) { i64 a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
i64 inv(i64 x, i64 m) { return pow(x, m - 2, m); }

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;

const i64 INF = inf<i64>;
using P = pair<i64, i64>;
i64 dp[12][12][12];
signed main() {
  i64 N;
  string S;
  cin >> N >> S;
  const i64 NONE = 10;
  dp[NONE][NONE][NONE] = 1;
  for (char c : S) {
    i64 d = c - '0';
    for (i64 a = 0; a <= 9; a++) {
      for (i64 b = 0; b <= 9; b++) {
        dp[a][b][d] |= dp[a][b][NONE];
      }
    }
    for (i64 a = 0; a <= 9; a++) {
      dp[a][d][NONE] |= dp[a][NONE][NONE];
    }
    dp[d][NONE][NONE] |= dp[NONE][NONE][NONE];
  }
  i64 cnt = 0;
  REP(a, 10) REP(b, 10) REP(c, 10) {
    cnt += dp[a][b][c];
  }
  cout << cnt << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const int N = 1e5;
int cnt[N];
set<int> e[N];

int main() {
    int n, m;
    cin >> n >> m;
    m += n - 1;

    VI tmp(n);

    REP(i,m){
        int u = in() - 1, v = in() - 1;
        e[u].insert(v);
        tmp[v] = 1;
        cnt[v]++;
    }

    int root;
    REP(i,n){
        if (!tmp[i]) root = i;
    }

    VI par(n, -1), dist(n, -1);
    queue<int> que;
    que.push(root);
    while (!que.empty()){
        int x = que.front();
        que.pop();
        for (int next : e[x]){
            cnt[next]--;
            if (cnt[next] == 0){
                par[next] = x;
                que.push(next);
            }
        }
    }

    REP(i,n) printf("%d\n", par[i] + 1);

    return 0;
}


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

int main(){
	string a, b;
	cin>>a>>b;
	int c=stoi(a+b);
	for(int i=1; i<=1000; i++){
		if(i*i==c){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
	int result = 0;
	int a, b, c;
	try (Scanner sc = new Scanner(System.in)) {
	    a = sc.nextInt();
	    b = sc.nextInt();
	    c = sc.nextInt();
	    for (int i = a; i <= b; i++) {
	 	if (canMod(i, c)) {
		    result++;
		}
  	    }
	} catch (Exception e) {
	    System.out.println(e.getMessage());
	}
	System.out.println(result);
    }

    private static boolean canMod(int a, int c) {
	return c % a == 0 ? true : false;
    }
}

Measured memory_bytes: 26276
#include<cmath>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
vector<long long>q[2];  
long long a[200005],b[200005],mi[100];  
inline long long read()
{
	char ch=getchar(),last='!';
	while (ch<'0' || ch>'9') last=ch,ch=getchar();
	long long ans=0;
	while (ch<='9' && ch>='0')
	{
		ans=ans*10+ch-48;
		ch=getchar();
	}
	if (last=='-') ans=-ans;
	return ans;
}
int main()
{
	int n=read();
	mi[0]=1;  
    for(int i=1; i<=61; i++) mi[i]=mi[i-1]*2;  
	for (int i=1; i<=n; i++) a[i]=read();
	for (int i=1; i<=n; i++) b[i]=read();
	long long ans=0;  
    for (int i=0; i<62; i++)  
    {  
        long long s=0;  
        q[0].clear(); q[1].clear();  
        for (int j=1; j<=n; j++) q[(a[j]>>i)&1].push_back(a[j]);  
        for (int j=0; j<q[0].size(); j++) a[++s]=q[0][j];  
        for(int j=0; j<q[1].size(); j++) a[++s]=q[1][j];  
        s=0;  
        q[0].clear(); q[1].clear();  
        for(int j=1; j<=n; j++) q[(b[j]>>i)&1].push_back(b[j]);  
        for(int j=0; j<q[0].size(); j++) b[++s]=q[0][j];  
        for(int j=0; j<q[1].size(); j++) b[++s]=q[1][j];  
        int l1=1,l2=1,l3=1;
        long long mx=(1ll<<(i+1))-1;
     	long long x=1ll<<i,y=1ll<<(i+1);  
        long long sum=0;  
        for (int j=n; j>=1; j--)  
        {  
            while ((((a[j]&mx)+(b[l1]&mx))<x) && (l1<=n)) l1++;
            while ((((a[j]&mx)+(b[l2]&mx))<y) && (l2<=n)) l2++;  
            while (((a[j]&mx)+(b[l3]&mx)<x+y) && (l3<=n)) l3++; 
            sum+=n-(l1-1-l2+1+l3-1);  
        }
        if(sum&1) ans+=mi[i];  
    }  
    printf("%lld\n",ans);
	return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

struct UnionFind {
    vi parent, rank, count;
    UnionFind(const int nodeSize)
        : parent(nodeSize), rank(nodeSize, 1), count(nodeSize) {
        rep(i, nodeSize) parent[i] = i, count[i] = 1;
    }
    int find(int x) {
        if (parent[x] == x) return x;
        return parent[x] = find(parent[x]);
    }
    void unite(int x, int y) {
        int rx = find(x);
        int ry = find(y);
        if (rx == ry) return;
        if (rank[rx] < rank[ry]) swap(rx, ry);
        parent[ry] = rx;
        count[rx] += count[ry];
        if (rank[rx] == rank[ry]) ++rank[rx];
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int num(int x) {
        return count[find(x)];
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int n, m; std::cin >> n >> m;
    UnionFind uf(n);
    rep(i, m) {
        int a, b; std::cin >> a >> b; --a, --b;
        uf.unite(a, b);
    }
    int ans = 0;
    rep(i, n) chmax(ans, uf.num(i));
    std::cout << ans << "\n";
}


Measured memory_bytes: 5580
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class D
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var X = Scanner.Scan<long>();
            var A5 = Enumerable.Range(0, 1001).Select(x => (long)Math.Pow(x, 5)).ToArray();
            for (var i = 0; i < A5.Length; i++)
            {
                var a5 = A5[i];
                var b5 = a5 - X;
                for (var j = 0; j < A5.Length; j++)
                {
                    if (Math.Abs(b5) == A5[j])
                    {
                        var a = i;
                        var b = b5 < 0 ? -j : j;
                        Console.WriteLine($"{a} {b}");
                        return;
                    }
                }
            }
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 28712
#include<iostream>

using namespace std;

int main(){
    int r,d,x; cin >> r >> d >> x;
    int ans = r*x-d;
    cout << ans << endl;
    for(int i = 0; i < 9; i++){
        ans = r*ans-d;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>

void    chmin(int *left, int right)
{
        if (*left > right)
        {
                *left = right;
        }
}

int             main(void)
{
        int             n;
        int             height[100000];
        int             answer[100000];
        int             i;

        scanf("%d", &n);
        for (i = 0; i < n; i++)
        {
                scanf("%d", &height[i]);
                answer[i] = INT_MAX;
        }
        answer[0] = 0;
        for (i = 0; i < n - 1; i++)
        {
                chmin(&answer[i + 1], answer[i] + abs(height[i + 1] - height[i]));
                chmin(&answer[i + 2], answer[i] + abs(height[i + 2] - height[i]));
        }
        printf("%d\n", answer[n - 1]);
        return (0);
}

Measured memory_bytes: 2504
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (~scanf("%d", &N)) {
    vector<int> color(N);
    for (auto& x : color) scanf("%d", &x), --x;
    vec<int, 2> G(N);
    for (int i = 0; i < N - 1; i++) {
      int a, b;
      scanf("%d %d", &a, &b);
      --a;
      --b;
      G[a].push_back(b);
      G[b].push_back(a);
    }
    vector<int> size(N);
    auto dfs1 = [&](auto& f, int v, int p = -1) -> void {
      size[v] = 1;
      for (int u : G[v]) {
        if (u != p) {
          f(f, u, v);
          size[v] += size[u];
        }
      }
    };
    dfs1(dfs1, 0);
    vector<ll> res(N);
    for (int c = 0; c < N; c++) res[c] = 1ll * (N + 1) * N / 2;
    vec<int, 2> stacks(N);
    for (int i = 0; i < N; i++) stacks[i].push_back(N);
    auto dfs2 = [&](auto& f, int v, int p = -1) -> void {
      int c = color[v];
      for (int u : G[v]) {
        if (u == p) continue;
        stacks[c].push_back(size[u]);
        f(f, u, v);
        int sz = stacks[c].back();
        res[c] -= 1ll * (sz + 1) * sz / 2;
        stacks[c].pop_back();
      }
      stacks[c].back() -= size[v];
    };
    dfs2(dfs2, 0);
    for (int c = 0; c < N; c++) {
      int sz = stacks[c].back();
      res[c] -= 1ll * (sz + 1) * sz / 2;
    }
    for (ll x : res) cout << x << endl;
  }
  return 0;
}


Measured memory_bytes: 47780
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

long long  gcd(long long   a,long long   b){
  if(a<b){
    long long swap;
    swap=b;
    b=a;
    a=swap;
  }
  long long  r=a%b;
  while(r>0){
    a=b;
    b=r;
    r=a%b;
  }
  return b;
}
int main(){
ll n,x; cin >>n>>x;

ll a[110000];

rep(i,n) cin>>a[i];

ll ans=abs(a[0]-x);
rep(i,n){
  ans=gcd(ans,abs(a[i]-x));
}
cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(){
	int a,b,sum=0,nsum=0,n;
	double t;
	for(n=0;;n++){
		if(scanf("%d,%d",&a,&b) == EOF){break;}
		sum+=a*b;
		nsum+=b;
	}
	t = (double)nsum/n;
	if(t-(int)t<0.5){n=(int)t;}
	else{n=(int)t+1;}
	printf("%d\n%d\n",sum,n);
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#define swap(x,y) x^=y^=x^=y

int main(void)
{
	int x,y,r;
	
	scanf("%d %d",&x,&y);
	if(x < y)swap(x,y);
	while(y > 0){
		r = x % y;
		x = y;
		y = r;
	}
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, age;
    while (cin >> n, n) {
        int num[7] = {};
        for (int i=0; i<n; ++i) {
            cin >> age;
            if (60 <= age) ++ num[6];
            else ++ num[age/10];
        }
        for (int i=0; i<7; ++i) {
            cout << num[i] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1196
#include"bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
typedef pair<int, int> P;
const long long mod = 1000000007;
int dp[52][52][5005];

bool valid(int a) {
	return 0 <= a && a <= 5000;
}

signed main() {
	int n, k; cin >> n >> k;
	dp[0][0][2500] = 1;

	rep(i, n) {
		rep(j, i + 1) {
			rep(k, 5001) {
				if (j&&valid(k + i + i)) {
					dp[i + 1][j - 1][k + i + i] += dp[i][j][k] * j*j;
					dp[i + 1][j - 1][k + i + i] %= mod;
				}
				dp[i + 1][j][k] += dp[i][j][k] * (2 * j+1); dp[i + 1][j][k] %= mod;
				if (valid(k - i - i)) {
					dp[i + 1][j + 1][k - i - i] += dp[i][j][k]; dp[i + 1][j + 1][k - i - i] %= mod;
				}
			}
		}
	}
	cout << dp[n][0][2500+k] << endl;
}

Measured memory_bytes: 102656
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        
        int n = stdIn.nextInt();
        double num[] = new double[n];
        double sum = 0;
        
        for(int i = 0; i < n; i++){
            num[i] = stdIn.nextDouble();
        }
        
        Arrays.sort(num);
        
        for(int i = 0; i < n - 1; i++){
            num[i + 1] = (num[i] + num[i + 1]) / 2;
        }
        
        
        System.out.println(num[n - 1]);
    }
}


Measured memory_bytes: 24276
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <sstream>
#include <stdio.h>
#include<math.h>
using namespace std;

int main(){

    int p,q,r;
    int now=100000;

    cin >> p >> q >> r;

    if(now>p+q){
        now = p + q;
    }
    if(now>p+r){
        now = p + r;
    }
    if(now>q+r){
        now = q + r;
    }

    cout << now;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int  main(){
    ll a,b;
    cin>>a>>b;
    //2 < 3 < 4 < 5 < 6 < 7 < 8 < 9 < 10 < 11 < 12 < 13 < 1
    if(a!=1&&b!=1)
    a==b? cout<<"Draw"<<endl: a>b?cout<<"Alice"<<endl:cout<<"Bob"<<endl;
    else{
        if(a==1&&b!=1){
            cout<<"Alice"<<endl;
        }
        else if(a!=1&&b==1){
            cout<<"Bob"<<endl;
        }
        else{
            cout<<"Draw"<<endl;
        }
    }
return 0;
}


Measured memory_bytes: 256
def main():
    l = []
    N, K = map(int, input().split())
    d_num = {i: 0 for i in range(100002)}
    for i in range(N):
        a, b = map(int, input().split())
        d_num[a] = d_num[a] + b

    for i in range(100002):
        K = K - d_num[i+1]

        if K <= 0:
            break

    print(i+1)

main()

Measured memory_bytes: 15084
#ifdef Rahul
#include "RAHUL.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define error(...) 42;
#endif
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
const int MOD = (int) 1e9 + 7;
const i64 INF = (i64) 1e18 + 42;

#include <atcoder/fenwicktree>

int main() {
  cin.tie(nullptr) -> sync_with_stdio(false);
  
  int n, q; cin >> n >> q;
  auto fenw = atcoder::fenwick_tree<i64>(n);
  for (int i = 0; i < n; ++i) {
    int x; cin >> x;
    fenw.add(i, x);
  }
  while (q--) {
    int t, u, v; cin >> t >> u >> v;
    if (t == 0) {
      fenw.add(u, v);
    } else {
      cout << fenw.sum(u, v) << '\n';
    }
  }
}


Measured memory_bytes: 8256
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false); //cin.tie(NULL); cout.tie(NULL)
#define mp make_pair
#define pb push_back
#define fs first
#define sc second

using namespace std;
typedef long long ll;
typedef long double ld;

void bug();

/* BIEN CUC BO BEGIN*/
	ll n, m;
	pair<int,int> P[100002];
	
	int a, b;
	ll PA[100002], ANS[100002];
/* BIEN CUC BO END*/
	
int Find(int x){
	return (PA[x] > 0 ? PA[x]=Find(PA[x]) : x);
}
	
void solve(){	
	cin >> n >> m;
	fill (PA+1,PA+n+1,-1);
	for (int i=1; i<=m; ++i){
		cin >> P[i].fs >> P[i].sc;
	}
	
	ll ans = n*(n-1)/2;
	
	for (int i=m; i>=1; --i){
		ANS[i] = ans;
		a = Find(P[i].fs);
		b = Find(P[i].sc);
		if (a != b){
			ans -= (-PA[a])*(-PA[b]);
			PA[a] += PA[b];
			PA[b] = a;
		}
	}
	
	for (int i=1; i<=m; ++i){
		cout << ANS[i] << '\n';
	}
}

int main(){ FIO;
	solve();
return 0;}	

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

#define MAX 200



    void intialize();
int isEmpty();
int isFull();
void push(int);
int pop();
int s[MAX], top;

int main()
{

    char n[1000000];
    int a,b;

    while (scanf("%s", n) != EOF)
    {
        if(n[0]=='-'){
            a=pop();
            b=pop();
            push(b-a);
        }
        else if(n[0]=='+'){
            a=pop();
            b=pop();
            push(b+a);
        }
        else if(n[0]=='/'){
            a=pop();
            b=pop();
            push(b/a);
        }
        else if(n[0]=='*'){
            a=pop();
            b=pop();
            push(b*a);
        }

        else {
            push(atoi(n));
        }
    }

    printf("%d\n",s[1]);

    return 0;
}

void intialize()
{
    top = 0;
}

int isEmpty()
{
    if (top == 0)
    {
        return 1;
    }

    else{
         return 0;
    }
       
}

int isFull()
{
    if (top >= MAX - 1)
    {
        return 1;
    }

    else{
     return 0;
    }
     
}

void push(int x)
{
    if (isFull())
    {
        printf("エラー\n");
    }
    top++;
    s[top] = x;
}

int pop()
{
    if (isEmpty())
    {
        printf("エラー\n");
    }
    top--;
    return s[top + 1];
}


Measured memory_bytes: 2076
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <map>
#include <queue>
#include <list>


#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define vint vector<int>
#define INF 1e9

using namespace std;
typedef long long  ll;

int main(){
    ll x;
    cin >> x;

    ll init = 100;
    ll ans = 0;
    while(init < x){
        init += init/100;
        ans++;
    }

    p(ans);
    return 0;
}


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

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

using ll = long long;
using P = pair<int,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;



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

    int n;
    cin >> n;

    int ans = 0, c1 = 0, c2 = 0, c3 = 0;
    rep(i, n){
        string s;
        cin >> s;

        int len = s.size();
        rep(j, len-1){
            if(s[j] == 'A' && s[j+1] == 'B'){
                ans++;
            }
        }

        if(s[0] == 'B'){
            if(s[len-1] == 'A'){
                c1++;
            }else{
                c2++;
            }
        }else{
            if(s[len-1] == 'A'){
                c3++;
            }
        }
    }

    ans += c1 + min(c2, c3);
    if(c2 == 0 && c3 == 0 && c1 != 0) ans--;

    cout << ans << "\n";


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, r;
    cin >> n >> r;
    if (n >= 10) cout << r << endl;
    else cout << r + 100 * (10 - n) << endl;
    return 0;
}


Measured memory_bytes: 256
N,H = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(N)]
maxa = max(ab[i][0] for i in range(N))
lastb = [ab[i][1] for i in range(N) if ab[i][1] >= maxa]
lastb.sort(reverse=True)
count = 0
while H > 0 and count < len(lastb):
    H -= lastb[count]
    count += 1
if H <= 0:
    print(count)
else:
    count += (H-1)//maxa+1
    print(count)

Measured memory_bytes: 28588
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair < llint, llint> pllint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

//aのb乗を1000000007で割った余りを求める
llint power(llint a, llint b) {
	if (b == 1)return a;
	if (b == 0)return 1;
	llint tmp = power(a, b / 2);
	tmp *= tmp;
	tmp %= 1000000007;
	if (b % 2 == 1) {
		tmp *= a;
		tmp %= 1000000007;
	}
	return tmp;
}

int main() {
	int n;
	cin >> n;
	vint a(n - 1);
	llint ans = 0;
	rep(i, n - 1) {
		cin >> a[i];
	}
	rep(i, n - 1) {
		if (i == 0)ans += (llint)a[i];
		else ans += (llint)min(a[i], a[i - 1]);
	}
	ans += (llint)a[n - 2];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
// B - Grid Compression
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int H,W; cin>>H>>W;
	vector<string> A(H);
	rp(i,0,H) cin>>A[i];

	vector<string> B;
	rp(h,0,H) rp(w,0,W)
		if(A[h][w] == '#'){ B.push_back(A[h]); break; }

	vector<string> C(B.size());
	rp(w,0,W){
		int h;
		for(h=0; h<B.size(); ++h) if(B[h][w] == '#') break;
		if(h < B.size())
			for(h=0; h<B.size(); ++h) C[h] += B[h][w];
	}

	for(auto x:C) cout<<x<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int H,W,Rs,Cs;
int U[505][505],L[505][505],R[505][505],D[505][505];
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
bool ng[505][505];
int f[2][505][505];
bool solve(){
	memset(ng,false,sizeof(ng));
	memset(f,0,sizeof(f));
	memset(U,0,sizeof(U));
	memset(L,0,sizeof(L));
	memset(R,0,sizeof(R));
	memset(D,0,sizeof(D));
	cin >> H >> W >> Rs >> Cs;
	if(H+W+Rs+Cs==0)return false;
	for(int k=0;k<2*H+1;k++){
		if((k&1)==0){
			int i = k/2+1; //[1,H+1]
			for(int j=1;j<=W;j++){
				cin >> U[i][j];
				D[i-1][j]=U[i][j];
			}
		}else{
			int i = (k-1)/2+1; //[1,H]
			for(int j=1;j<=W+1;j++){
				cin >> L[i][j];
				R[i][j-1]=L[i][j];
			}
		}
	}
	queue<P> q;
	for(int i=0;i<=H+1;i++){
		ng[i][0]=ng[i][W+1]=true;
		q.push(P(i,0));
		q.push(P(i,W+1));
	}
	for(int i=0;i<=W+1;i++){
		ng[0][i]=ng[H+1][i]=true;
		q.push(P(0,i));
		q.push(P(H+1,i));
	}
	while(!q.empty()){
		P pos = q.front();
		q.pop();
		int x = pos.fi,y = pos.sec;
		for(int i=0;i<4;i++){
			int nx = x+dx[i];
			int ny = y+dy[i];
			if(nx<=0||nx>H)continue;
			if(ny<=0||ny>W)continue;
			if(ng[nx][ny])continue;
			//cout << nx << ' ' << ny << endl;
			if(i==0){
				f[L[nx][ny]][nx][ny]=1;
			}else if(i==1){
				f[U[nx][ny]][nx][ny]=1;
			}else if(i==2){
				f[R[nx][ny]][nx][ny]=1;
			}else{
				f[D[nx][ny]][nx][ny]=1;
			}
			if((f[0][nx][ny]&f[1][nx][ny])==1){
				ng[nx][ny]=true;
				//cout << nx << ' ' << ny << endl;
				q.push(P(nx,ny));
			}
		}
	}
	bool ans = false;
	if(!U[Rs][Cs]){
		ans |= ng[Rs-1][Cs];
	}
	if(!L[Rs][Cs]){
		ans |= ng[Rs][Cs-1];
	}
	if(!R[Rs][Cs]){
		ans |= ng[Rs][Cs+1];
	}
	if(!D[Rs][Cs]){
		ans |= ng[Rs+1][Cs];
	}
	if(ans)printf("Yes\n");
	else printf("No\n");
	return true;
}
int main(){
	while(solve()){}
	return 0;
}


Measured memory_bytes: 9408
(defun split (delimiter target-string)
  (let ((delimiter-position (search delimiter target-string))
        (delimiter-size (length delimiter)))
    (if delimiter-position
        (cons (subseq target-string 0 delimiter-position)
              (split delimiter (subseq target-string (+ delimiter-position delimiter-size))))
        (list target-string))))

(let ((n (read))
      (l (split "ABC" (read-line))))
  (princ (- (length l) 1)))

Measured memory_bytes: 24032
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<class T> void re(T& x) { cin >> x; }
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
template<class H, class... T> void re(H& h, T&... t) { re(h); re(t...); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "/home/o_o/MyCodes/pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  

void solve(){
	string s , t ;
	cin >> s >> t ;
	int n = 3 , cnt = 0 ;
	rep(i,0,n){
		cnt+=(s[i]==t[i]);
	}
	cout << cnt << endl; 
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define MAX_L 8
#define MAX_N 100005
typedef long long ll;
ll mod=1e9+7;
ll B=5575777;

int N;
string S[MAX_N];
unordered_set<ll> t[MAX_L+1];
char tmp[MAX_L+5];

bool dfs(ll hash,int depth,int anslen){
  if(depth==anslen){
    if(t[anslen].count(hash)==1)return false;
    for(int i=0;i<depth;i++)cout<<tmp[i];
    cout<<endl;
    return true;
  }

  for(char ch='a';ch<='z';ch++){
    tmp[depth]=ch;
    ll nhash=(hash*B+ch)%mod;
    if( dfs(nhash,depth+1,anslen) )return true;
  }
  return false;
}

void solve(){
  for(int i=0;i<N;i++){
    int size=S[i].size();
    
    for(int j=1;j<=MAX_L;j++){
      
      ll key=0,nb=1;
      for(int k=0;k<size;k++){
        key=(key*B+S[i][k])%mod;
        if(k-j>=0){
          key+=(mod- (S[i][k-j]*nb)%mod );
          key%=mod;
        }else nb=(nb*B)%mod;
        if(k+1>=j)t[j].insert(key);
      }
      
    }
  }

  ll cnt=1;
  int anslen=1;
  for(int i=1;i<=MAX_L;i++){
    cnt*=26;
    if( (ll)t[i].size() < cnt ){
      anslen=i;
      break;
    }
  }

  dfs(0,0,anslen);
}

int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin>>N;
  for(int i=0;i<N;i++)
    cin>>S[i];
  solve();
  return 0;
}

Measured memory_bytes: 87684
//@source : 
//@create : 19:05:16 Sunday 05/07/2020
//@author : nghethuat102
//@status : 
#include <bits/stdc++.h>
using namespace std;

#define fastio() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
template<typename T> void write(const T&x) { cout << x; }
template<typename T, typename... Args> void write(const T&x, Args... args) { cout << x; write(args...); }
template<typename... Args> void writeln(Args... args) { write(args..., "\n"); }
template<typename T> void read(T&x) { cin >> x; }
template<typename T, typename... Args> void read(T&x, Args&... args) { cin >> x; read(args...); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << "\n"; err(++it, args...); }

void solve() {
    int n, m, k;
    read(n, m, k);
    vector<vector<char>> a(n + 1, vector<char>(m + 1));
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            read(a[i][j]);
        }
    }
    int cnt = 0;
    for (int bitrow = 0; bitrow < (1<<n); ++bitrow) {
        for (int bitcol = 0; bitcol < (1<<m); ++bitcol) {
            vector<vector<bool>> b(n + 1, vector<bool>(m + 1, false));
            for (int i = 1; i <= n; ++i) {
                for (int j = 1; j <= m; ++j) {
                    if ((1 & (bitrow>>(i - 1))) || (1 & (bitcol>>(j - 1)))) {
                        b[i][j] = true;
                    }
                }
            }
            int c = 0;
            for (int i = 1; i <= n; ++i) {
                for (int j = 1; j <= m; ++j) {
                    if (b[i][j] == false  && a[i][j] == '#') {
                        ++c;
                    }
                }
            }
            if (c == k) {
                ++cnt;
            }
        }
    }
    writeln(cnt);
}

int main() {
    fastio();
    int t = 1;
    for (int it = 1; it <= t; ++it) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3660
n = int(input())
a,b = map(int,input().split())
l = list(map(int,input().split()))
c = [0]*3
for i in l:
    if i <= a:
        c[0] += 1
    elif i > b:
        c[2] += 1
    else:
        c[1] += 1
print(min(c))

Measured memory_bytes: 9184
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest
import heapq

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    X,Y,a,b,c=map(int, readline().rstrip().split())

    R=list(map(lambda x: int(x)*(-1), readline().rstrip().split()))
    G=list(map(lambda x: int(x)*(-1), readline().rstrip().split()))
    C=list(map(lambda x: int(x)*(-1), readline().rstrip().split()))

    heapq.heapify(R)
    heapq.heapify(G)
    heapq.heapify(C)
    ans = []
    heapq.heapify(ans)

    for _ in range(X):
        a = heapq.heappop(R)
        heapq.heappush(ans,a)
    for _ in range(Y):
        a = heapq.heappop(G)
        heapq.heappush(ans,a)
    for _ in range(min(X+Y,c)):
        a = heapq.heappop(C)
        heapq.heappush(ans,a)
    a=0
    for _ in range(X+Y):
        a += heapq.heappop(ans) * -1

    print(a)
    #n=int(readline())
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 36788