akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  int ca = 1, cb = 0, cc = 0;
  char now = a[0];
  while (true) {
    if (now == 'a') {
      if (ca == a.size()) {
        cout << "A" << endl; return 0;
      }
      now = a[ca++];
    } else if (now == 'b') {
      if (cb == b.size()) {
        cout << "B" << endl; return 0;
      }
      now = b[cb++];
    } else {
      if (cc == c.size()) {
        cout << "C" << endl; return 0;
      }
      now = c[cc++];
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m,x,i,j,cur,r,ra[303][303],rb[303][303],f[303][303];
char a[303],b[303],s[303][303];
int main() {
  scanf("%d%d",&n,&m);
  for (i=0; i<n; i++) scanf("%s",s[i]);
  for (x=1; x<m; x++) {
    for (i=0; i<n; i++) {
      a[i]=s[i][x-1];
      b[i]=s[i][x];
    }
    for (i=0; i<n; i++) {
      ra[i][0]=0;
      rb[i][0]=0;
      for (j=i; j<n; j++) {
        ra[i][j-i+1]=ra[i][j-i]+int(a[j-i]==b[j]);
        rb[i][j-i+1]=rb[i][j-i]+int(a[j]==b[j-i]);
      }
    }
    for (i=1; i<=n; i++) for (j=1; j<=n; j++) {
      if (i>j) cur=ra[i-j][j]; else cur=rb[j-i][i];
      f[i][j]=min(f[i-1][j],f[i][j-1])+cur;
    }
    r+=f[n][n];
  }
  printf("%d\n",r);
  return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

// calculates nCr (1 <= r <= n <= 1e7)
const int MAX = 1e7;
long long f[MAX], finv[MAX], inv[MAX];
// initializes nCr
void initnCr() {
	f[0] = f[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		f[i] = f[i-1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}
}

ll nCr(int n, int r) {
	if (n < r) return 0;
	if (n < 0 || r < 0) return 0;
	return f[n] * (finv[r] * finv[n-r] % MOD) % MOD;
}

int main() {
	initnCr();
	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	rep(i,n) cin >> v[i];
	sort(ALL(v));
	ll sumMx = 0;
	for (int i = k-1; i < n; i++) {
		sumMx += nCr(i, k-1) * v[i];
		sumMx %= MOD;
	}
	ll sumMn = 0;
	for (int i = n-1 - (k-1); i >= 0; i--) {
		sumMn += nCr(n-(i+1), k-1) * v[i];
		sumMn %= MOD;
	}
	cout << (sumMx - sumMn) % MOD << endl;
}

Measured memory_bytes: 238068
#include <bits/stdc++.h>
using namespace std;
string s;
int k;
vector<string> ans;

int main() {
    cin >> s >> k;
    int slen = s.length();
    for(int i = 0; i < slen; ++i) {
        for(int j = 1; j <= min(k, slen-i); ++j) {
            string now = s.substr(i, j);
            ans.push_back(now);
        }
    }
    sort(ans.begin(), ans.end());
    ans.erase(unique(ans.begin(), ans.end()), ans.end());

    cout << ans.at(k-1) << endl;
}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long; 
int main() {
    int abcd;
    cin >> abcd;

    for(int i=0;i<(1<<3);i++){
        int result=0;
        int x=abcd;
        string ans="";
        for(int j=1;j<(1<<3);j*=2){
            ans =  to_string(x % 10)+ ans;
            if(i&j){
                result += x % 10;
                ans =  '+' + ans;
            }else{
                result -= x % 10;
                ans =  '-' + ans;
            }
            x /= 10;
        }
        result += x;
        ans =  to_string(x)+ ans + "=7";
        if(result == 7){
            cout << ans;
            break;
        }

    }


} 

Measured memory_bytes: 3672
#include <iostream>
#include <stdio.h>
using namespace std;

int F[45];
int fibonacci(int n)
{
    if(n==0||n==1)
        return F[n] = 1;
    else if(F[n]!=-1)
    {
        return F[n];
    }
    return F[n] = fibonacci(n-1)+fibonacci(n-2);
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 0; i < 45; i++)
    {
        F[i] = -1;
    }
    printf("%d\n",fibonacci(n));
}



Measured memory_bytes: 3216
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimensi0n, default_val) assert(type(default_val) ~= 'table') local n=dimensi0n local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
--
local S = read.l()
if S == 'SSS' then
    print(0)
elseif S == 'RSS' or S == 'SRS' or S == 'SSR' or S == 'RSR' then
    print(1)
elseif S == 'RRR' then
    print(3)
else
    print(2)
end

Measured memory_bytes: 2736
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin>>N;
  cout<<N*N*N<<endl;

}


Measured memory_bytes: 256
// BEGINNING WITH NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
// Atcoder Beginner contest
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#define ll long long
#define mo 1000000007
using namespace std;
//long long m = 1000000007;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.flush();
    ll a,b,n;
    cin >> a >> b >> n;
    if(n>=a)
    {
        n-=a;
        a =0;
//        n-=a;
//        cout<<n<<endl;
        if(n>=b)
        {
            b=0;
//            n-=b;
        }
        else{
//            cout<<"YES";
            b=(b-n);
        }
    }
    else{
        a=(a-n);
    }
    cout<<a<<" "<<b;
//    delete[] size;
//    delete[] parent;
//    mp.clear();
    return 0;
    // Bye Bye 2019
}




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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl



int main(){
    int n,k;
    cin >> n >> k;
    double ans = 0;
    FOR(i,1,min(k,n+1)){
        int t = i;
        double kaku = 1.0/n;
        double kaku1 = kaku;
        while(t<k){
            t *= 2;
            kaku /= 2.0;
        }
        if(n<k) ans+= kaku; 
        else ans += kaku1-kaku;
    }
    if(n<k)cout << setprecision(20) << ans << endl;
    else cout << setprecision(20) << 1-ans << endl;
    return 0;
}    


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    return

#B
def B():
    s = S()
    t = S()
    s.sort()
    t.sort(reverse = True)
    if s < t:
        print("Yes")
    else:
        print("No")
    return

#C
def C():
    n = I()
    d = [None for i in range(n+1)]
    d[0] = 2
    d[1] = 1
    for i in range(2,n+1):
        d[i] = d[i-1]+d[i-2]
    print(d[n])
    return

#D
def D():
    x,y,z = LI()
    for i in range(1000000)[::-1]:
        if i*y+(i+1)*z <= x:
            print(i)
            quit()
    return

#E
def E():
    d = [(1,0),(-1,0),(0,1),(0,-1)]
    h,w = LI()
    s = SR(h)
    for i in range(h):
        for j in range(w):
            if s[i][j] == "#":
                su = 0
                for dy,dx in d:
                    y = i+dy
                    x = j+dx
                    if 0 <= y < h and 0 <= x < w:
                        if s[y][x] == "#":
                            su += 1
                if su == 0:
                    print("No")
                    quit()
    print("Yes")
    return

#F
def F():
    a,b,c,X,Y = LI()
    ans = float("inf")
    for z in range(300001):
        if z%2 == 0:
            m = c*z
            x = z//2
            y = z//2
            m += a*max(0,X-x)
            m += b*max(0,Y-y)
            if m < ans:
                ans = m
    print(ans)
    return

#G
def G():
    n = I()
    x = LI()
    f = [(i,x[i]) for i in range(n)]
    f.sort(key = lambda x:x[1])
    g = [(f[i][0],i) for i in range(n)]
    g.sort(key = lambda x:x[0])
    for i in range(n):
        if g[i][1] < n//2:
            print(f[n//2][1])
        else:
            print(f[n//2-1][1])
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    B()


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

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


int solve(int bit, int H, int W, int K, vector<string> &S){
    int cnt = __builtin_popcount(bit);
    vector<vector<int>> tot(cnt+1, vector<int>(W));
    int pos = 0;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(S[i][j] == '1')
                tot[pos][j]++;
        }
        if(bit&(1<<i)) pos++;
    }

    int ans = cnt;
    vector<int> cumsum(cnt+1);
    for(int i=0; i<W; i++){
        for(int pos=0; pos<cnt+1; pos++){
            if(tot[pos][i] > K) return 1<<30;
            cumsum[pos] += tot[pos][i];
        }
        bool over = false;
        for(int pos=0; pos<cnt+1; pos++){
            if(cumsum[pos] > K){
                over=true;
            }
        }
        if(over){
            ans++;
            for(int pos=0; pos<cnt+1; pos++){
                cumsum[pos] = tot[pos][i];
            }
        }
    }
    return ans;
}

int main(){
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> S(H);
    REP(i, H) cin >> S[i];

    int ans = 1<<30;
    for(int i=0; i<(1<<(H-1)); i++){
        ans = min(ans, solve(i, H, W, K, S));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def sum_among_boundaries(i, a, b):
    digits_sum = sum(map(int, str(i)))
    return digits_sum >= a and digits_sum <= b

if __name__ == '__main__':
    n, a, b = map(int, input().split())
    print(sum([i for i in range(1, n + 1) if sum_among_boundaries(i, a, b)]))

Measured memory_bytes: 3296
N = int(input())
S = input()

wc = [0]
ec = [0]

for i in range(N):
    if S[i] == "W":
        wc.append(wc[i]+1)
        ec.append(ec[i])
    else:
        wc.append(wc[i])
        ec.append(ec[i]+1)

#print("wc : {}, ec : {}".format(wc, ec))

ans = ec[N]
for i in range(1, N):
    #W -> cnt, E -> sum - cnt
    tmp = wc[i] + ec[N] - ec[i+1]
    ans = min(tmp, ans)

print(ans)

Measured memory_bytes: 17644
#include<stdio.h>

int main(){
	int n,a,b,i,j;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&a,&b);
		if(a<6){
			if(a-b>0){
				for(j=a;j>b;j--){
					printf("%d ",j);
				}
				printf("%d\n",b);
			}else{
				for(j=a;j<b;j++){
					printf("%d ",j);
				}
				printf("%d\n",b);
			}
		}else{
			if(b>a){
				for(j=a;j<b;j++){
					printf("%d ",j);
				}
				printf("%d\n",b);
			}else if(b<6){
				for(j=a;j<10;j++){
					printf("%d ",j);
				}
				for(j=5;j>b;j--){
					printf("%d ",j);
				}
				printf("%d\n",b);
			}else{
				for(j=a;j<10;j++){
					printf("%d ",j);
				}
				for(j=5;j>0;j--){
					printf("%d ",j);
				}
				for(j=0;j<b;j++){
					printf("%d ",j);
				}
				printf("%d\n",b);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;


#define MAX 500000
#define SENTINEL 2000000000
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2


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

  int A[n+1][4];

  int gon = - (1<<21);
  int killua = - (1<<21);

  for (int i=0; i<n; i++){
    cin >> A[i][0] >> A[i][1] >> A[i][2] ;
    gon = max (gon, A[i][2]);
  }

  int x, y, q;

  for (int i=0; i<=100; i++){

    for (int j=0; j<=100; j++){

      for (int k=0; k<n; k++){
        killua = max(killua, gon+max(A[k][0], i)+max(A[k][1], j));
      }

      for (int h=gon; h<=killua; h++){
        for (int k=0; k<n; k++){
          if (max( h - abs(A[k][0]-i) - abs(A[k][1]-j), 0) != A[k][2]){
            break;
          } else {
            if (k==n-1){
              x = i, y = j, q = h;
            }
          }
        }
      }
      /*
      for (int k=0; k<n; k++){
        for ( int h=A[k][2]; h<= max(i, A[k][0])+ max(j, A[k][0]) + A[k][2]; h++ ){
          if (max( h - abs(A[k][0]-i) - abs(A[k][1]-j), 0) == A[k][2])
        }
      }

      while(it == false){
      */

          

          /*

          if (max( h - abs(A[k][0]-i) - abs(A[k][1]-j), 0) == A[k][2]) {
            if (k== n-1){
              it = true;
              x = i, y = j, q = h;
            }
          } else {
            if (k== n-1){
              it = true;
            }
            h++;
            break;
          }


        }
      }
                */
    }
  }

  cout << x << " " << y << " " << q << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll read(){
	ll x=0,sign=1;char s=getchar();
	while(!isdigit(s)){if(s=='-')sign=-1;s=getchar();}
	while(isdigit(s))x=(x<<1)+(x<<3)+s-'0',s=getchar();
	return x*sign;
}
int n,q,pd[200005],t[200005];
vector <int> j[200005];
void dfs(int x,int d)
{
	t[x]+=d;
	pd[x]=1;
	for(int i=0;i<j[x].size();i++){
		int to=j[x][i];
		if(!pd[to])
			dfs(to,t[x]);
	}
}
int main()
{
	cin>>n>>q;
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		j[u].push_back(v);
		j[v].push_back(u);
	}
	for(int i=0;i<q;i++){
		int p,x;
		cin>>p>>x;
		t[p]+=x;
	}
	dfs(1,0);
	for(int i=1;i<=n;i++)
		cout<<t[i]<<" ";
	return 0;
}


Measured memory_bytes: 24320
import sys
a,b,c = map(int,input().split())
k=int(input())

i=0

while a >= b:
    b *= 2
    if i == k:
        print('No')
        sys.exit()
    else:
        i += 1

while b >= c:
    c *= 2
    if i == k:
        print('No')
        sys.exit()
    else:
        i += 1

print('Yes')

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define pbds tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define mod 998244353
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)

int pwmd(int n, int m)
{
    int res = 1;
    while (m > 0)
    {
        if (m & 1)
            res = (res % mod * n % mod) % mod;
        m /= 2;
        n = (n % mod * n % mod) % mod;
    }
    return res;
}

int dp[200002];

int c(int n, int r)
{
    return (dp[n] % mod * (pwmd(dp[n - r], mod - 2) % mod * pwmd(dp[r], mod - 2) % mod) % mod) % mod;
}

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

    int res = 0;
    int n, m, k;
    cin >> n >> m >> k;
    dp[0] = 1;

    for (int i = 1; i <= 200000; i++)
        dp[i] = (dp[i - 1] * i) % mod;
    for (int i = 0; i <= k; i++)
    {
        int ans = 1;
        ans = (ans * c(n - 1, i)) % mod;
        ans = (ans * m) % mod;
        ans = (ans * pwmd(m - 1, n - 1 - i)) % mod;
        res = (res + ans) % mod;
    }
    cout << res;

    return 0;
}

Measured memory_bytes: 5232
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(500000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    N = int(input())
    S = input()
    if N % 2 == 0:
        h = N // 2
        if S[:h] == S[h:]:
            print("Yes")
            return
    print("No")


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9972
c,t,d[4010]={1};main(j){for(;t+=(j=getchar())&8?j=0:2;d[c<t?-1:c-t]=0,t--)for(j=c+=j%3;j;d[j--]%=998244353)d[j]+=d[j-1];printf("%d",d[c]);}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin >> n;
  vector<ll> a(n);
  vector<ll> s(n);
  map<ll,ll> m;
  rep(i,n){
    cin >> a[i];
    m[i-a[i]]++;
  }
  ll ans = 0;
  rep(i,n){
    ll tmp = a[i] + i;
    m[i-a[i]]--;
    ans += m[tmp];
  }
  cout << ans << endl;

}

Measured memory_bytes: 29056
#include <stdio.h>

#define int64 long long

int main()
{
  int64 nn, mm;
  scanf("%lld %lld", &nn, &mm);
  int64 hh[nn], data[nn][2];
  for(int64 ii = 0;ii < nn;ii++)
  {
    data[ii][0] = 0;//道の数
    data[ii][1] = 0;//ここより低い山の数
    scanf("%lld", &hh[ii]);
  }
  int64 aa, bb;
  for(int64 ii = 0;ii < mm;ii++)
  {
    scanf("%lld %lld", &aa, &bb);
    data[aa - 1][0]++;
    data[bb - 1][0]++;
    if(hh[aa - 1] != hh[bb - 1])
    {
      if(hh[aa - 1] > hh[bb - 1])
      {
        data[aa - 1][1]++;
      }
      else
      {
        data[bb - 1][1]++;
      }
    }
  }
  int64 ans = 0, flag;
  for(int64 ii = 0;ii < nn;ii++)
  {
    if(data[ii][0] == data[ii][1])
    {
      ans++;
    }
  }
  printf("%lld\n", ans);
  return 0;
}

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

using namespace std;

int main()
{
	long int n,a;
	cin>>n>>a;
	if(a>=n)
	  {
	  	  cout<<"Yes";
	  }
	else if(n%500<=a)
	   cout<<"Yes";
	else
	  cout<<"No"<<"\n";
}

Measured memory_bytes: 256
n,t=map(int,input().split())
tl=list(map(int,input().split()))
f=[]
for i in range(n-1):
    c=tl[i+1]-tl[i]
    if c<t:
        f.append(c)
    else:
        f.append(t)
f.append(t)
print(sum(f))

Measured memory_bytes: 26708
A,B,C,D = map(int, input().split())

HP_t = [A]
HP_a = [C]

while HP_t[-1] > 0:
  HP_t.append(HP_t[-1] - D)
  HP_a.append(HP_a[-1] - B)

if HP_a[-1] > 0:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 61984
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> data(h);
    for (int i = 0; i < h; i++) {
        cin >> data[i];
    }
    set<int> ex_h, ex_w;
    for (int i = 0; i < h; i++) {
        bool ok = false;
        for (int j = 0; j < w; j++) {
            if (data[i][j] == '#')
                ok = true;
        }
        if (!ok) {
            ex_h.insert(i);
        }
    }

    for (int j = 0; j < w; j++) {
        bool ok = false;
        for (int i = 0; i < h; i++) {
            if (data[i][j] == '#')
                ok = true;
        }
        if (!ok)
            ex_w.insert(j);
    }

    for (int i = 0; i < h; i++) {
        if (ex_h.count(i))
            continue;
        for (int j = 0; j < w; j++) {
            if (ex_w.count(j))
                continue;
            cout << data[i][j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int ans=0,n,m,c,b[22],a[22][22];
	cin>>n>>m>>c;
	for(int i=0;i<m;i++)cin>>b[i];
	for(int i=0;i<n;i++)for(int j=0;j<m;j++)cin>>a[i][j];
	for(int i=0;i<n;i++)
	{
		int t=c;
		for(int j=0;j<m;j++)
		{
			t+=a[i][j]*b[j];
		}
		if(t>0)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
Scanf.scanf "%d" (fun n ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    let b = Array.mapi (fun i v -> v - i - 1) a in
    Array.sort compare b;
    let q = b.(n / 2) in
    let rec loop i acc =
        if i = n then acc else loop (i + 1) (acc + abs (a.(i) - (q + i + 1)))
    in
    loop 0 0 |> Printf.printf "%d\n"
)

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = (int)1e9+7;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s,t;
	cin>>s>>t;
	int a,b;
	cin>>a>>b;
	string u;
	cin>>u;
	if(u==s){
		cout<<a-1<<" "<<b;
	}
	else{
		cout<<a<<" "<<b-1;
	}
	
	
	return 0;
}
	
	
	
	
	
	
	
	
	
	
	

























Measured memory_bytes: 256
//////////////////////////
/*      _        ____   */
/*  U  /"\  u U /"___|  */
/*   \/ _ \/  \| | u    */
/*   / ___ \   | |/__   */
/*  /_/   \_\   \____|  */
/*   \\    >>  _// \\   */
/*  (__)  (__)(__)(__)  */
/*  Compro by NULL_CT©  */
//////////////////////////
/*STL Libs*/
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

/*Boost to boost compile time*/
#include <boost/multiprecision/cpp_int.hpp>

#define REP(I, LIM) for (long I = 0; I < LIM; I++)
#define ALL(LIST) (LIST.begin()), (LIST.end())

using namespace std;
using bint = boost::multiprecision::cpp_int;

static constexpr int MOD = 10000007;
static constexpr long INF = LONG_MAX;

vector<long> divisor(long n) {
  vector<long> head, tail;
  for (long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      head.push_back(i);
      if (i * i != n)
        tail.push_back(n / i);
    }
  }
  head.insert(head.end(), tail.rbegin(), tail.rend());
  return (head);
}

//--------------------------------

void execute() {
  long n;
  cin>>n;
  auto ll=divisor(n);

  long mini=INF;
  REP(i,ll.size()){ 
    cerr<<ll[i]<<" ";
    mini=min(mini,ll[i]+n/ll[i]);
  }
  cout<<endl;

  cout<<mini-2<<endl;
}

//--------------------------------

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  // cout<<fixed<<setprecision(20);

  execute();

  return (0);
}


Measured memory_bytes: 3168
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

struct UnionFind {
    vector<ll> par;
    vector<ll> siz;

    UnionFind(ll N) : par(N),siz(N,1LL) {
        for(int i = 0; i < N; i++) par[i] = i;
    }
    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if(siz[rx]<siz[ry])swap(rx,ry);
        siz[rx]+=siz[ry];
        par[ry] = rx;
    }
    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    ll size(ll x){
        return siz[root(x)];
    }
};

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> K(N);
    vector<vector<int> > LSpeakers(M);
    rep(i,N){
        cin >> K[i];
        rep(j,K[i]){
            int k;cin >> k;
            k--;
            LSpeakers[k].push_back(i);
        }
    }
    UnionFind uf(N);
    rep(i,M){
        if(LSpeakers[i].size()>=2){
            for(int j=0;j<LSpeakers[i].size();j++){
                uf.unite(LSpeakers[i][0],LSpeakers[i][j]);
            }
        }
    }
    int ok=1;
    for(int i=0;i<N;i++)if(!uf.same(0,i))ok=false;
    if(ok)cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 5120
# Union Find 木
from sys import setrecursionlimit


def find(parent, i):
    t = parent[i]
    if t < 0:
        return i
    t = find(parent, t)
    parent[i] = t
    return t


def unite(parent, i, j):
    i = find(parent, i)
    j = find(parent, j)
    if i == j:
        return
    parent[j] += parent[i]
    parent[i] = j


setrecursionlimit(10 ** 6)


N, M, K = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
CD = [list(map(int, input().split())) for _ in range(K)]

parent = [-1] * N
friends = [[] for _ in range(N)]
for A, B in AB:
    unite(parent, A - 1, B - 1)
    friends[A-1].append(B-1)
    friends[B-1].append(A-1)
blocks = [[] for _ in range(N)]
for C, D in CD:
    blocks[C-1].append(D-1)
    blocks[D-1].append(C-1)

result = []
for i in range(N):
    p = find(parent, i)
    t = -parent[p] - 1
    t -= len(friends[i])
    for b in blocks[i]:
        if p == find(parent, b):
            t -= 1
    result.append(t)
print(*result)


Measured memory_bytes: 98436
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int zi[4]={0};
	for(int i=0;i<6;i++){
		int x;cin>>x;zi[x-1]++;
	}
		for(int i=0;i<4;i++){if(zi[i]==3){cout<<"NO"<<endl;return 0;}}
	cout<<"YES"<<endl;
	return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

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

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}


int main()
{
	int n, m;
	cin >> n >> m;
	vector<string> a(n), b(m);
	rep(i,n){
		cin >> a[i];
	}
	rep(i,m){
		cin >> b[i];
	}
	rep(i,n-m+1){
		rep(j,n-m+1){
			int f = 1;
			rep(k, m)
			{
				rep(l,m){
					if (a[i+k][j+l] != b[k][l])
						f = 0;
				}
			}
			if(f == 1){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}




Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <deque>
#include <math.h>
#include <set>
#include <iomanip>
#include <time.h>
#include <list>
#include <stdio.h>
#include <queue>
#include <map>
#include <algorithm>
#include <assert.h>
#include <memory.h>

#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )
#define int unsigned long long

using namespace std;

const int N = 1005;

int n;

pair <int, int> ar[N];

main ()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
        scanf("%d%d", &ar[i].fr, &ar[i].sc);

    for (int i = 2; i <= n; i++)
    {
        int l = 0, r = 2e18 / max( ar[i].fr, ar[i].sc );

        while (r - l > 1)
        {
            int md = (l + r) >> 1;
            if ( ar[i].fr * md >= ar[i - 1].fr && ar[i].sc * md >= ar[i - 1].sc )
                r = md;
            else
                l = md;
        }
        ar[i].fr *= r;
        ar[i].sc *= r;
    }
    cout << ar[n].fr + ar[n].sc << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

typedef long long lint;
int main(){
    int A, B, M;
    scanf("%d %d %d",&A, &B, &M);
    int min = 1000000;
    vector<int>a(A);
    vector<int>b(B);
    vector<int>x(M);
    vector<int>y(M);
    vector<int>c(M);
    REP(i,A){
        cin >> a[i];
    }
    REP(i,B){
        cin >> b[i];
    }
    REP(i,M){
        cin >> x[i];
        cin >> y[i];
        cin >> c[i];
    }
    min = *(min_element(ALL(a))) + *(min_element(ALL(b)));
    REP(i,M){
        if(min > a[x[i] - 1] + b[y[i] - 1] - c[i])
            min = a[x[i] - 1] + b[y[i] - 1] - c[i];
    }
    cout << min << endl;
}

Measured memory_bytes: 2176
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#define _USE_MATH_DEFINES

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <list>
#include <math.h>
#include <bitset>
#include <iterator>
#include <map>
#include <iomanip>
#include <functional>
#include <string>
#include <algorithm>
#include <queue>
#include <random>
#include <numeric>
#include <set>
#include <cassert>
#include <cmath>
#include <cinttypes>

using namespace std;

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? "" : " "); return os;
}
template<class T> istream& operator>>(istream& is, vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) is >> *i; return is;
}
template<class T> T read_val() { throw 1; }
template<> int read_val() { int tmp; scanf("%" PRId32, &tmp); return tmp; }
template<> long long read_val() { long long tmp; scanf("%" PRId64, &tmp); return tmp; }
auto read_int = read_val<int>; auto read_long = read_val<long long>;
template<class T> void scanf_vec(vector<T>& vec) { for (int i = 0; i < vec.size(); i++) vec[i] = read_val<T>(); }

#define MOD 1000000007
#define inf 2000000000
#define FWT_SIZE 2000000
#define pii pair<int,int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define sort_all(x) sort(all(x))
#define make_unique(x) (x).erase(unique(all(x)), (x).end())


int main() {

#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n = read_int();
	vector<int> arr(n);
	scanf_vec(arr);

	vector<int> cnts(n);
	for (int x : arr)
		cnts[x - 1]++;
	sort(all(cnts));
	
	vector<long long> partial(cnts.size());
	partial[0] = cnts[0];
	for (int i = 1; i < cnts.size(); i++)
		partial[i] = partial[i - 1] + cnts[i];

	vector<int> maxlen(n + 1, 0);
	maxlen[0] = n;
	for (int cnt = 1; cnt <= n; cnt++)
	{
		auto it = lower_bound(all(cnts), cnt);
		if (it == cnts.end())
		{
			maxlen[cnt] = partial.back() / cnt;
		}
		else
		{
			int pos = it - cnts.begin();
			int x = n - pos;
			maxlen[cnt] = x + (pos > 0 ? partial[pos - 1] : 0) / cnt;
		}
	}

	reverse(all(maxlen));
	for (int x = 1; x <= n; x++)
	{
		if (x > cnts.size())
			cout << 0 << "\n";
		else
		{
			auto it = lower_bound(all(maxlen), x);
			cout << (n - (it - maxlen.begin())) << "\n";
		}
	}

	
	return 0;
}

Measured memory_bytes: 6784
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N; cin>>N;
    // 1 2 3 4 5 6 ...
    // 6 5 6 5 6 5
    ll rem=(N-(N/11)*11);
    cout<<(N/11)*2+((N-(N/11)*11)==0?0:((N-(N/11)*11)<=6?1:2))<<endl;
}



Measured memory_bytes: 3592
def main():
    X,K,D=map(int,input().split())

    zero_flag=0
    if abs(X)>=K*D:
        zero_flag=1

    if zero_flag==0:
        d=abs(X)%D
        d_=abs(X)//D
        if (K-d_)%2==1:
            print(abs(D-d))
        else:
            print(abs(X)-abs(D*d_))
    else:
        print(abs(X)-K*D)

if __name__=="__main__":
    main()

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

using namespace std;

int main() {
  string S, T;
  cin >> S >> T;

  bool ok = false;
  for (int i = 0; i < S.size(); i++) {
    if (S == T) {
      ok = true;
      break;
    }
    S = S[S.size()-1] + S.substr(0, S.size() -1);;
  }

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

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

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)
#define Set(i, v) memset(i, v, sizeof i)
#define pb push_back

using namespace std;

const int N = 100010;

int n;
int dis[N];
bool vis[N];

struct Node{
	int o, d;

	bool operator < (const Node& A) const{
		return d > A.d;
	}
};

priority_queue<Node> q;

int main(){
	scanf("%d", &n);

	memset(dis, 0x3f, sizeof dis);
	dis[1] = 1;
	q.push((Node){1, 1});
	while(!q.empty()){
		Node s = q.top(); q.pop();
		if(vis[s.o]) continue;
		vis[s.o] = true;

		int u = (s.o + 1) % n;
		if(dis[u] > s.d + 1) dis[u] = s.d + 1, q.push((Node){u, dis[u]});

		u = (s.o * 10) % n;
		if(dis[u] > s.d) dis[u] = s.d, q.push((Node){u, dis[u]});
	}

	printf("%d\n", dis[0]);
	return 0;
}

Measured memory_bytes: 1404
#include<stdio.h>

int main(){
    int i,j,input,flag = 0;
    int data[5];

    while(scanf("%d",&input) != EOF){
        if(flag++)puts("");
        for(i = 0;i < 5;i++){
            data[4 - i] = input % 10;
            input /= 10;
        }
        for(i = 0;i < 8;i++){
            for(j = 0;j < 5;j++){
                switch(i){
                    case 0:
                        if(data[j] > 4){
                            printf(" ");
                        }else{
                            printf("*");
                        }
                        break;
                    case 1:
                        if(data[j] < 5){
                            printf(" ");
                        }else{
                            printf("*");
                        }
                        break;
                    case 2:
                        printf("=");
                        break;
                    default:
                        if(data[j] % 5 == i - 3){
                            printf(" ");
                        }else{
                            printf("*");
                        }
                        break;
                }
            }
            puts("");
        }
    }
    return 0;
}

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

int main(void) {

  long n;
  scanf("%ld", &n);
  long a,b;
  for (a = sqrt(n); a >= 1; a--) {
    if (n%a == 0) {
      b = n/a;
      break;
    }
  }
  int digit = 0;
  while (b > 0) {
    digit++;
    b /= 10;
  }
  printf("%d\n", digit);

  return 0;
}

Measured memory_bytes: 128
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        x: i64,
        a: i64,
    }
    let ans = if x < a { 0 } else { 10 };
    println!("{}", ans);
}


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

int main() {
    int N, a, b;
    cin >> N;
    vector<int>triangle(3);
    for(int i = 0; i < N; i++){
      for(int j = 0; j < 3; j++){
        cin >> triangle.at(j);
      }
      sort(triangle.begin(), triangle.end());

      int A, B, C;

      A = triangle.at(0);
      B = triangle.at(1);
      C = triangle.at(2);

      if(A * A + B * B == C * C){
        cout << "YES" << endl;
      }
      else{
        cout << "NO" << endl;
      }
    }
}



Measured memory_bytes: 3140
C = [list(map(int, input().split())) for _ in range(3)]
a = C[1][0]-C[0][0] == C[1][1]-C[0][1] == C[1][2]-C[0][2]
b = C[2][0]-C[0][0] == C[2][1]-C[0][1] == C[2][2]-C[0][2]
if a and b:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int n,k;
char s[51];
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>s[i];
	for(int i=1;i<=n;i++){
		if(i!=k)
			cout<<s[i];
		else cout<<char(s[i]+32);
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		int count = Integer.parseInt(br.readLine());
        String[] strArray = new String[count];
        strArray = br.readLine().split(" ");

        int max=-1000000, min=1000000;
        long sum = 0;
        int a = 0;

        for(String str : strArray) {
        	a = Integer.parseInt(str);
        	max = Math.max(max, a);
        	min = Math.min(min, a);
        	sum += a;
        }

        System.out.println(min + " " + max + " " + sum);
	}
}

Measured memory_bytes: 28764
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

using Edges = vector<int>;
using Graph = vector<Edges>;

int cnt = 0;

void dfs(int cur, int par, Graph const &graph, vector<bool> visited) {
    visited[cur] = true;
    if (all_of(visited.begin(), visited.end(), [](auto x) { return x; })) {
        cnt++;
        return;
    }

    for (auto next: graph[cur]) {
        if (!visited[next] && next != par) {
            dfs(next, cur, graph, visited);
        }
    }
}

int main() {
    int n, m; cin >> n >> m;
    Graph graph(n);

    rep(i, m) {
        int a, b; cin >> a >> b, --a, --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    cnt = 0;
    vector<bool> visited(n, false);
    dfs(0, -1, graph, visited);
    cout << cnt << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
A = []
for i in range(N):
	tmp = []
	n = INT()
	shougen = []
	for j in range(n):
		shougen = MAP()
		tmp.append(shougen)
	A.append(tmp)

cand = []
for i in range(2**N):
	shojiki = [0]*N
	for j in range(N):
		if (i>>j & 1):
			shojiki[N-j-1]=1
	cand.append(shojiki)
# print(cand)

ans = []
for c in cand:
	list = [-1]*(N+1)
	success = True
	ones = [a for idx,a in enumerate(A) if c[idx]==1]
	for idx,a in enumerate(ones):
		for aa in a:
			if list[aa[0]] == -1:
				list[aa[0]] = aa[1]
			else:
				if list[aa[0]]!=aa[1]:
					success=False
	for k in range(len(c)):
		if c[k]==1 and list[k+1]==0:
			success = False
		if c[k]==0 and list[k+1]==1:
			success = False
	if success:
		#print(c, list)
		ans.append(sum(c))
	
#print(ans)
if ans:
	print(max(ans))
else:
	print(0)

Measured memory_bytes: 52956
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
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 (b<a) { a=b; return 1; } return 0; }
// template end

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

    ll n;
    in >> n;
    out << n*(n+1)/2 << endl;
}


Measured memory_bytes: 256
abc = list(map(int, input().split()))

if abc[0] == abc[1]:
    if abc[0] == abc[2]:
        print('No')
    else:
        print('Yes')
else:
    if abc[0] == abc[2] or abc[1] == abc[2]:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main(){
	int n,k,m;
	while(cin>>n>>k>>m){
		if(n==0&&k==0&&m==0) break;
		int a[n];
		for(int i=0;i<n;i++){
			a[i]=i+1;
		}
		int g=n,now=m-1;
		a[now]=0;
		g--;
		for(int i=now;i<g;i++){
			a[i]=a[i+1];
		}
		for(int i=0;i<n-2;i++){
			now=(now+k-1)%g;
			a[now]=0;
			g--;
			for(int j=now;j<g;j++){
				a[j]=a[j+1];
			}
		}
		cout<<a[0]<<endl;
	}
    return 0;
}

Measured memory_bytes: 1196