akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

typedef struct{
    int num;
    int code;
}POS;
int max(int a, int b){
    if( a > b ){
        return a;
    }else{
        return b;
    }
}
bool check(POS a, POS b){
    if( a.num > b.num){
        return true;
    }else{
        return false;
    }
}
int process();
int main(){
    cout << process() << endl;
}

int process(){
    int H,W,M;
    POS *row;
    POS *col;
    int max_row,max_col;
    LL *pos;
    int h,w,i,j;
    int e_max;
    int max;
    int temp;
    cin >> H >> W >> M;
    row = new POS[H];
    col = new POS[W];
    pos = new LL[M];
    
    for(i=0;i<H;i++){
        row[i].code = i;
    }
    for(j=0;j<W;j++){
        col[j].code = j;
    }
    for(i=0;i<M;i++){
        cin >> h >> w;
        row[h-1].num++;
        col[w-1].num++;
        pos[i] =  row[h-1].code * H + col[w-1].code;
    }
    sort(row,row + H,check);
    sort(col,col + W,check);
    sort(pos,pos + M);
    max_row = row[0].num;
    max_col = col[0].num;
    e_max = max_row + max_col;
    max = 0;
    for(i=0;i<H && row[i].num == max_row; i++){
        for(j=0;j<W && col[j].num == max_col;j++){
            temp = row[i].num + col[j].num - binary_search( pos, pos+M,row[i].code * H + col[j].code);
            if(max < temp){
                max = temp;
            }
            if(max == e_max){
                return max;
            }
        }
    }
   return max;
}

Measured memory_bytes: 10648
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

newUF :: PrimMonad m => Int -> m (VM.MVector (PrimState m) Int)
newUF n = do
  d <- VM.new n
  VM.set d (-1)
  return d

findUF :: PrimMonad m => VM.MVector (PrimState m) Int -> Int -> m Int
findUF d x = do
  dx <- VM.read d x
  if dx < 0
    then return x
    else do dx' <- findUF d dx
            VM.write d x dx'
            return dx'

uniteUF :: PrimMonad m => VM.MVector (PrimState m) Int -> Int -> Int -> m ()
uniteUF d x y = do
  x' <- findUF d x
  y' <- findUF d y
  when (x' /= y') $ do
    let (x'', y'') = if (x' <= y') then (x', y') else (y', x')
    dx <- VM.read d x''
    dy <- VM.read d y''
    VM.write d x'' (dx + dy)
    VM.write d y'' x''
  return ()

sameUF :: PrimMonad m => VM.MVector (PrimState m) Int -> Int -> Int -> m Bool
sameUF d x y = do
  fx <- findUF d x
  fy <- findUF d y
  return $ fx == fy

sizeUF :: PrimMonad m => VM.MVector (PrimState m) Int -> Int -> m Int
sizeUF d x = do
  fx <- findUF d x
  dfx <- VM.read d fx
  return (-dfx)

main = do
  [n, k] <- getIntList
  tas <- getIntList

  uf <- newUF (n+1)

  let as = V.fromList (0:tas)

      getDests :: Int -> [Int] -> IO (Int, V.Vector Int)
      getDests i res = do
        let d = as V.! i
            res' = (d:res)
        same <- sameUF uf 1 d
        if same
          then return (d, V.fromList (reverse res))
          else do uniteUF uf 1 d
                  getDests d res'

  (x, dests) <- getDests 1 [1]

  let Just idx = V.findIndex (== x) dests
      dests' = V.drop idx dests
      m = V.length dests'
      k' = k - idx
      j = k' `mod` m

      ans = if k <= idx
            then dests V.! k
            else dests' V.! j

  print ans


Measured memory_bytes: 28176
//

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
#define cout15(a) printf("%.15f\n",a)
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<ll,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    int a,b,c;cin>>a>>b>>c;
    if(a==b&&a!=c){cout<<"Yes"<<nnn;return 0;}
    if(a==c&&a!=b){cout<<"Yes"<<nnn;return 0;}
    if(c==b&&a!=c){cout<<"Yes"<<nnn;return 0;}
    cout<<"No"<<nnn;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    string S;
  	cin >> S;
    string ans = "Yes";
    REP(i,S.size()){
        if((i+1) % 2 == 1){
            if(S[i] == 'R' || S[i] == 'U' || S[i] == 'D') ans = "Yes";
            else{
                ans = "No";
                break;
            }
        }
        else{
            if(S[i] == 'L' || S[i] == 'U' || S[i] == 'D') ans = "Yes";
            else{
                ans = "No";
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import math
N,P = map(int,input().split())
A = list(map(int,input().split()))
A = [i%2 for i in A]
odd = A.count(1)
even = A.count(0)
sumo = 0
for i in range(odd+1):
    if i%2 == P:
        sumo += int(math.factorial(odd)//(math.factorial(odd-i)*math.factorial(i)))
print(sumo*(2**even))

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <vector>
#include <string.h>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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

int dx[] = { 1, -1, 0, 0 };
int dy[] = { 0, 0, 1, -1 };

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

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

bool prime(int n) {
  for (int i = 2; i <= sqrt(n); ++i) {
    if (n % i == 0) { return false; }
  }
  return n != 1;
}

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

class UnionFind {
public:
  UnionFind(int n) : par(n, -1), rnk(n, 0), _size(n) {}

  bool same(int x, int y) {
    return root(x) == root(y);
  }
  void unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return;

    --_size;

    if (rnk[x] < rnk[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if (rnk[x] == rnk[y]) { ++rnk[x]; }
    }
  }
  int root(int x) {
    if (par[x] < 0) {
      return x;
    } else {
      return par[x] = root(par[x]);
    }
  }
  int size() {
    return _size;
  }

private:
  vector<int> par;
  vector<int> rnk;
  int _size; // The number of connected components. Decreases by unite.
};


int main(int argc, char** argv) {
  ll N, M, Q;
  cin >> N >> M >> Q;

  UnionFind tree(N);
  vector<P> edges; // different edges.
  rep(i, Q) {
    ll A, B, C;
    cin >> A >> B >> C;
    if (C == 0) {
      tree.unite(A, B);
    } else {
      edges.emplace_back(A, B);
    }
  }

  if (M == N - 1) { // G must be a tree.
    if (edges.size() == 0) {
      cout << "Yes" << endl;
      return 0;
    } else {
      cout << "No" << endl;
      return 0;
    }
  }

  // Check different edges
  for (auto e : edges) {
    if (tree.same(e.first, e.second)) {
      cout << "No" << endl;
      return 0;
    }
  }

  ll K = tree.size(); // the number of connected components.

  // H must be lower than or equals to (N-K) + K*(K-1)/2 = N + K(K-3)/2
  if (M <= N + K * (K - 3) / 2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3188
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 5 2019
 * 
 */

#include <bits/stdc++.h>

//#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 

    int n , m , c;

    cin>>n>>m>>c;

    vi b(m);
    iv(b);
    int ans = 0;
    rep(n){
        vi a(m);
        bint counter = 0;
        iv(a);
        for(int j=0; j<m; ++j){
            counter += (a[j]*b[j]);
        }
        counter+=c;
        if(counter>0){
            ans++;
        }
    }

    cout<<ans<<endl;


    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("bin","r",stdin);
    freopen("bout","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

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

char T[102][102];

void DFS(int y, int x, char f) {

	if (T[y][x] != f)
		return;

	T[y][x] = '?';

	DFS(y - 1, x, f);
	DFS(y, x + 1, f);
	DFS(y + 1, x, f);
	DFS(y, x - 1, f);

}

int main() {

	int h, w;

	while (1) {
		cin >> h >> w;
		if (h == 0 && w == 0) {
			break;
		}


		for (int i = 1; i <= h; i++) {
			for (int j = 1; j <= w; j++) {
				cin >> T[i][j];
			}
		}

		int count = 0;

		for (int i = 1; i <= h; i++) {
			for (int j = 1; j <= w; j++) {
				if (T[i][j] == '@') {
					count++;
					DFS(i, j, '@');
				}
				else if (T[i][j] == '#') {
					count++;
					DFS(i, j, '#');
				}
				else if (T[i][j] == '*') {
					count++;
					DFS(i, j, '*');
				}
			}
		}


		cout << count << endl;

	}
	return 0;
}

Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b; cin >> a >> b;
  cout << a * b << "\n";
  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>

using namespace std;

typedef long long ll;

constexpr ll INF = 1e18;

ll f(ll b, ll n) {
    if (n < b) {
        return n;
    } else {
        return f(b, n / b) + n % b;
    }
}

int main(void) {
    ll n, s;
    cin >> n;
    cin >> s;

    if (n == s) {
        cout << n + 1 << endl;
        return 0;
    }

    for (ll b = 2; b * b <= n; b++) {
        ll ans = f(b, n);
        if (f(b, n) == s) {
            cout << b << endl;
            return 0;
        }
    }

    ll ans = INF;
    for (ll c = 1; c * c <= n - s; c++) {
        if ((n - s) % c != 0) {
            continue;
        }
        ll b = (n - s) / c + 1;
        if (f(b, n) == s) {
            ans = min(ans, b);
        }
    }

    cout << (ans == INF ? -1 : ans) << endl;
    return 0;
}



Measured memory_bytes: 256
inputs = open(0).readlines()
x, y, a, b, c = map(int, inputs[0].split())
*P, = map(int, inputs[1].split())
*Q, = map(int, inputs[2].split())
*R, = map(int, inputs[3].split())
P.sort(reverse=1)
Q.sort(reverse=1)
R.sort(reverse=1)
P, Q, R = P[:x][::-1], Q[:y][::-1], R[:x+y]

pi = qi = 0
ri = 0
while ri < len(R):
    if pi < x and qi < y: 
        if P[pi] < Q[qi]:
            if P[pi] < R[ri]:
                P[pi] = R[ri]
                pi += 1
                ri += 1
            else:
                break
        else:
            if Q[qi] < R[ri]:
                Q[qi] = R[ri]
                Q
                qi += 1
                ri += 1
            else:
                break
    elif pi < x and qi == y:
        if P[pi] < R[ri]:
            P[pi] = R[ri]
            pi += 1
            ri += 1
        else:
            break
    elif pi == x and qi < y:
        if Q[qi] < R[ri]:
            Q[qi] = R[ri]
            qi += 1
            ri += 1
        else:
            break
    else:
        raise ValueError('Error')
print(sum(P)+sum(Q))

Measured memory_bytes: 25568
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Vec2(T, n, m, xs, x0) vector<vector<T>> xs(n, vector<T>(m, x0))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n, k);
    Cin(string, s);
    
    vector<int> a {0};
    char t = '1';
    For(i, n){
        if(s[i] != t){
            t = s[i];
            a.push_back(1);
        }
        else{
            a.back() ++;
        }
    }
    //Couts(a);
    if(a.size() % 2 == 0) a.push_back(0);
    Cusum(int, a, sa);
    //Couts(sa);
    if(a.size()/2 <= k){
        Cout(n);
        return 0;
    }
    
    int ans = 0;
    for(int i = 0; i+2*k < (int)a.size(); i += 2){
        //Cout(i+2*k+1, " ", i, " ", sa[i+2*k+1] - sa[i]);
        ans = max(ans, sa[i+2*k+1] - sa[i]);
    }
    Cout(ans);
}


Measured memory_bytes: 1272
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  ll n;
  ll x, m;
  cin >> n >> x >> m;
  ll ans = 0;
  ll num = x;
  bool loop_on = false;
  int last = -1;
  int start = -1;
  vector<ll> tmp(m + 1);
  vector<ll> loop(m + 1);
  map<ll, ll> mp;
  rep(i, min(m, n)){
    tmp[i] = num;
    mp[num]++;
    if(mp[num]> 1){
      last = i;
      loop_on = true;
      break;
    }
    ans += num;
    num *= num;
    num %= m;
  }
  if(loop_on){
    rep(i, m){
      if(tmp[i] == num){
        start = i;
        break;
      }
    }
  }else{
    cout << ans << endl;
    return 0;
  }
  for (int i = start; i < last; i++){
    loop[i + 1 - start] = tmp[i];
  }
  rep(i, last-start){
    loop[i+1] += loop[i];
  }
  if(loop_on){
    n -= last;
    ll count = (ll)n / (ll)(last - start);
    ans += loop[last - start] * count;
    ans += loop[n % (last - start)];
  }
  cout << ans << endl;
}

Measured memory_bytes: 7964
# D - 756
from collections import defaultdict

N = int(input())

def prime_factorization(n):
    prime_factors = []
    if n < 2:
        return 0
    for i in range(2, int(pow(n, 0.5)+1)):
        if n%i==0:
            ex = 0
            while n%i==0:
                ex += 1
                n //= i
            prime_factors.append((i, ex))
    # 割り切れなかった残りのnが1でない(素数)場合、リストに加える
    if n!=1:
        prime_factors.append((n,1))
    return prime_factors

primes = defaultdict(int)
for i in range(2, N+1):
    p = prime_factorization(i)
    for (j, k) in p:
        primes[j] += k

primes = list(primes.values())
l = len(primes)

ans = 0
arr = []
def dfs(n, x, s):
    global ans
    if x == l:
        if s == 75:
            ans += 1
        return
    for i in range(min(primes[x]+1, 75//s)):
        if i in (0, 2, 4, 14, 24, 74):
            n.append(i)
            dfs(n, x+1, s*(i+1))
            n.pop()
    return

dfs(arr, 0, 1)
print(ans)

Measured memory_bytes: 3444
//In The Name of Allah
//Fri 12/2/97
#include <bits/stdc++.h>

#define Init ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define forar(i,n) for(long long int i = 0; i < n;i++)
#define fori(i,a,b) for(long long int i = a; i < b;i++)
#define WFile freopen("test.in","r",stdin),freopen("test.out","w",stdout)
#define Log(x) cout << "Log: " << x << endl;
#define F first
#define S second
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll mod = 1e9+7,M = 2e5+100;

void Solution();

bool grid[52][52];

int32_t main()
{
	Init;
	Solution();
	return 0;
}

inline void Solution(){
	int h,w;
	cin >> h >> w;
	fori(i,1,h+1){
		fori(j,1,w+1){
			char c;
			cin >> c;
			grid[i][j] = c=='#';
		}
	}
	bool ans = true;
	fori(i,1,h+1){
		fori(j,1,w+1){
			ans &= !grid[i][j] || grid[i-1][j] || grid[i+1][j] || grid[i][j+1] || grid[i][j-1];
		}
	}
	cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	Scanner sc = new Scanner(System.in);
	final int NUM_CONTEST = 26;
	int D;
	int [] c  = new int[NUM_CONTEST];
	int [][] s ;
	int [] t ;
	int [] last_day;
	void A() {
		D = sc.nextInt();
		s = new int[D][NUM_CONTEST];
		for(int i = 0; i < NUM_CONTEST; i++) {
			c[i] = sc.nextInt();
		}
		for(int i = 0; i < D; i++) {
			for(int j = 0; j < NUM_CONTEST; j++) {
				s[i][j] = sc.nextInt();
			}
			//System.out.println(Arrays.toString(s[i]));
		}

//		t = new int[D];
		last_day = new int[NUM_CONTEST];
		Arrays.fill(last_day, -1);
//		for(int i = 0; i < D; i++) {
//			t[i] = sc.nextInt() - 1;
//		}
		long ans = 0;
		for(int d = 0; d < D; d++) {
			int max_contest = 0, max_value = Integer.MIN_VALUE;
			for(int cand = 0; cand < NUM_CONTEST; cand++) {
				int inc = s[d][cand];
				int last_day_old = last_day[cand];
				last_day[cand] = d;
				int dec = 0;
				for(int i = 0; i < NUM_CONTEST; i++) {
					dec += c[i] * (d - last_day[i]);
				}
				if(inc - dec > max_value) {
					max_value = inc - dec;
					max_contest = cand;
				}
				last_day[cand] = last_day_old;
			}
			last_day[max_contest] = d;
			System.out.println(max_contest + 1);
		}
	}
	void B() {
		D = sc.nextInt();
		s = new int[D][NUM_CONTEST];
		for(int i = 0; i < NUM_CONTEST; i++) {
			c[i] = sc.nextInt();
		}
		for(int i = 0; i < D; i++) {
			for(int j = 0; j < NUM_CONTEST; j++) {
				s[i][j] = sc.nextInt();
			}
			//System.out.println(Arrays.toString(s[i]));
		}

		t = new int[D];
		last_day = new int[NUM_CONTEST];
		Arrays.fill(last_day, -1);
		for(int i = 0; i < D; i++) {
			t[i] = sc.nextInt() - 1;
		}
		long ans = 0;
		for(int d = 0; d < D; d++) {
			int inc = s[d][t[d]];
			last_day[t[d]] = d;
			int dec = 0;
			for(int i = 0; i < NUM_CONTEST; i++) {
				dec += c[i] * (d - last_day[i]);
			}
			//System.out.println(inc + " " + dec + " " + (inc - dec));
			ans += (inc - dec);
			System.out.println(ans);

		}
	}
	void doIt() {
		A();
	}
	public static void main(String[] args) {
		new  Main().doIt();
	}

}


Measured memory_bytes: 46452
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
int n;

vector<vector<int> >v;
vector<int >deg;

int dp[maxn];
int ans;

void dfs(int x,int prev)
{
	for(int i=0;i<v[x].size();i++)
	{
		int son=v[x][i];
		if(son!=prev)
		{
			dfs(son,x);
		}
	}
	vector<int>tmp;
	int sum=0;
	for(int i=0;i<v[x].size();i++)
	{
		int son=v[x][i];
		if(son!=prev)
		{
			tmp.push_back(dp[son]);
			sum+=dp[son];
		}
	}
	//dp[x]有可能为0 
	int add=0;
	for(int i=0;i<tmp.size();i++)
	{
		if(!tmp[i])add++;
	}
	dp[x]=sum+max(add-1,0); //add-1可能<0 
}

int main()
{
	ios::sync_with_stdio(0);
	
	cin>>n;v.resize(n+1);deg.resize(n+1);
	for(int i=1;i<n;i++)
	{
		int a,b;cin>>a>>b;
		v[a].push_back(b);v[b].push_back(a);
		deg[a]++;deg[b]++;
	}
	
	int ma=0,root=-1;
	for(int i=0;i<n;i++)
	{
		if(deg[i]>ma)
		{
			ma=deg[i];
			root=i;
		}
	}
	if(ma<=2)
	{
		cout<<"1\n";return 0;
	}
	
	dfs(root,-1);
	cout<<dp[root];
	return 0;
}

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


int n, k;

int main(){
  cin >> n >> k;
  int cnt = 0;
  for(int i = n; i > 0; i /= k){
    cnt++;
  }
  cout << cnt << endl;
    
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long T,x,y;
	cin>>T;
	while(T--){
		cin>>x>>y;
		long long a=(long long)(sqrt(x*y));
		int ans=2*(int)(a)-1;
		if(a*a==x*y&&x!=y)--ans;
		if(a*(a+1)>=x*y)--ans;
		cout<<ans<<endl;
	}return 0;
}

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

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String strArr[] = br.readLine().split(" ");
            int a = Integer.parseInt(strArr[0]);
            int b = Integer.parseInt(strArr[1]);
            int sum = a + b;
            if (sum >= 10) {
                System.out.println("error");
            } else {
                System.out.println(sum);
            }
       } catch (IOException e) {
            e.printStackTrace();
       }
    }
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define ll long long
#define pii pair<int,int> 
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
const int INF = 1001001001;
//int 2×10の9乗
//vector<vector<int>> a(n, vector<int>(m));
  //rep(i,n) rep(j,m) cin >> a[i][j]; 
//cout << fixed << setprecision(10);
//int gcd(int x, int y){
  //if(y==0) return x;
  //return gcd(y, x%y);
//}
//sort小さい順(昇順)
//g++ code.cpp   ./a.out 
int main(){
  int n;
  cin >> n;
  map<string,int> m;
  rep(i,n){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    m[s]++;
  }
  ll ans=0;
  for(pair<string,int> p : m){
    ll v = p.second;
    ans += v*(v-1)/2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 11136
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: print('Yes' if b else 'No')
YESNO=lambda b: print('YES' if b else 'NO')

def main():
    N=input()
    YesNo('7' in N)

if __name__ == '__main__':
    main()


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

using namespace std;

int main(){
    long long int N,ans=1;
    bool vartical;
    cin >> N;
    vector<string> S(2);

    for(int i=0;i<2;i++){
        cin >> S[i];
    }

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

        if(i==0){

            if(S[0][i]==S[1][i]){
                ans *= 3;
                vartical = true;
            }else{
                ans *= 6;
                vartical = false;
                i++;
            }

        }else{

            if(S[0][i]==S[1][i]){

                if(vartical){
                    ans *= 2;
                }else{
                    ans *=1;
                }
                vartical = true;

            }else{

                i++;
                if(vartical){
                    ans *= 2;
                }else{
                    ans *= 3;
                }
                vartical = false;

            }

        }

        ans %= 1000000007;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>
 
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

int count_str(string S){
  int check[26]={};
  int l = S.length();
  rep(i, l){
    if(check[S[i]-97]==0){
      check[S[i]-97]=1;
    }
  }
  int sum=0;
  rep(i, 26){
    sum += check[i];
  }
  return sum;
}

int main() {
  ll N;
  cin >> N;
  //vector<string> v[10];
  vector<string> v;
  vector<string> before;
  string tmp;
  
  //v[0].push_back("a");
  before.push_back("a");
  
  rep(i, N-1){
    for(auto x:before){
      //cout << x << endl;
      int alnum = count_str(x);
      //cout << alnum << endl;
      rep(j, alnum+1){
        tmp = char(j+97);
        v.push_back(x+tmp);
      }
    }
    before = v;
    v.clear();
  }
    
  //cout << count_str("aac") << endl;  
    
  for(auto x:before){
    cout << x << endl;
  }
  
  /*if(N>0){
    cout << v[1][0] << " " << v[1][1] << endl;
  }else{
    cout << "No" << endl;
  }*/
}

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

vector<int> get_primes(int n){
  //
  int lim = sqrt(n) + 1;
  vector<bool> is_primes(n, true);
  for(int i = 2; i <= lim; i++){
    if(!is_primes[i]) continue;

    for (int j = i*2; j <= n; j+=i) {
      is_primes[j] = false;
    }
  }

  //
  vector<int> primes;
  for (int i = 2; i <= n; ++i) {
    if(is_primes[i])
      primes.push_back(i);
  }

  return primes;
}


long long gcm(long long a, long long b){
  if(b == 0) return a;
  return gcm(b, a % b);
}

long long lcm(long long a, long long b){
  long long g = gcm(a, b);
  return a / g * b;
}


int main() {
  //
  int N;
  cin >> N;
  vector<long long> T(N);
  for (int i = 0; i < N; ++i) {
    cin >> T[i];
  }


  //

  long long ans = 1;
  for (int i = 0; i < N; ++i) {
    ans = lcm(ans, T[i]);
//    cout << ans << endl;
  }

  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

public class Therefore
{
    public static void Main(string[] args)
    {
        //数字入力
        int N = int.Parse(Console.ReadLine());

        if (N % 10 == 3) { Console.WriteLine("bon"); }
        else if (N % 10 == 0 ||
                      N % 10 == 1 ||
                      N % 10 == 6 ||
                      N % 10 == 8) { Console.WriteLine("pon"); }
        else { Console.WriteLine("hon"); }

    }
}

Measured memory_bytes: 27528
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscan(r, &n)
	as := make([]int, n)
	mp := make(map[int]int)
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &as[i])
		mp[as[i]]++
	}

	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	count := make(map[int]int)
	sum := 0
	for k, v := range mp {
		count[k] += v * (v - 1) / 2
		sum += count[k]
	}

	for i := 0; i < n; i++ {
		c := mp[as[i]] - 1
		self := c * (c - 1) / 2

		ans := sum - count[as[i]] + self
		fmt.Fprintln(w, ans)
	}
}


Measured memory_bytes: 23040
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [int(i) for i in input().split()]
    C = [int(i) for i in input().split()]
    A.sort()
    B.sort()
    C.sort()
    Bdic = [0]*N
    from bisect import bisect
    from itertools import accumulate
    for i, b in enumerate(B):
        idx = bisect(C, b)
        Bdic[i] = N - idx
    Bacc = list(accumulate([b for b in Bdic + [0]][::-1]))[::-1]
    ans = 0
    for i, a in enumerate(A):
        idx = bisect(B, a)
        ans += (Bacc[idx])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 114660
n = int(input())
if n < 10:
    print(n)
elif n < 100:
    print(9)
elif n < 1000:
    print(n-90)
elif n < 10000:
    print(909)
elif n < 100000:
    print(n-9999+909)
else:
    print(90909)


Measured memory_bytes: 2940
#include <cstdio>

int A[105];
int main(){
    int N;
    scanf("%d", &N);

    int sum = 0;
    for(int i=0; i<N; ++i) {
        scanf("%d", &A[i]);
        sum += A[i];
    }

    int M;
    scanf("%d", &M);

    for(int i=0; i<M; ++i) {
        int p, x;
        scanf("%d%d", &p, &x);
        --p;

        printf("%d\n", sum - A[p] + x);
    }

    return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#define int long long
#define double long double
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用

using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位


signed main() {
	int a, b;
	cin >> a >> b;
	if (a + b == 15) {
		cout << "+" << "\n";
	}
	else if (a*b == 15) {
		cout << "*\n";
	}
	else {
		cout << "x\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define IOS cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
int N,A,B,C,l[10];

int dfs(int n,int la,int lb,int lc){
    if(n==N){ if(la>0 && lb>0 && lc>0) {return abs(A-la)+abs(B-lb)+abs(C-lc)-30;}
    else return 999999999;}
    int pos1 = dfs(n+1,la+l[n],lb,lc)+10;
    int pos2 = dfs(n+1,la,lb+l[n],lc)+10;
    int pos3 = dfs(n+1,la,lb,lc+l[n])+10;
    int pos4 = dfs(n+1,la,lb,lc);
    return min({pos1,pos2,pos3,pos4});
}

main() {
    cin >> N >> A >> B >> C;
    rep(i,N) cin >> l[i];
    cout << dfs(0,0,0,0) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
ll solve(){
	ll H,W;
	cin>>H>>W;
	if(H%3==0) return 0;
	if(W%3==0) return 0;
	ll ans = min(H,W);
	rep1(i,H-1){
		vector<ll> s;
		s.pb(i*W);
		s.pb((H-i)*(W/2));
		s.pb((H-i)*((W+1)/2));
		sort(all(s));
		chmin(ans,s[2]-s[0]);
	}
	swap(H,W);
	rep1(i,H-1){
		vector<ll> s;
		s.pb(i*W);
		s.pb((H-i)*(W/2));
		s.pb((H-i)*((W+1)/2));
		sort(all(s));
		chmin(ans,s[2]-s[0]);
	}
	return ans;
}
int main(){
	cout<<solve()<<endl;
}

Measured memory_bytes: 256
def printArray(arr):
  for i in range(0, len(arr)):
    print(arr[i])
    
def minimumCost(n, hights):  
  if (n < 2):
    print("0")
  else:
    memo = []
    memo.append(0)
    memo.append(abs(hights[0] - hights[1]))
    for i in range(2, n):
      memo.append(min(
        (abs(hights[i] - hights[i - 1]) + memo [i - 1]), 
        (abs(hights[i] - hights[i - 2]) + memo [i - 2])
      ))
    print(memo[n-1])
    
n = int(input())
hights = list(map(int,input().split()))
minimumCost(n, hights)

Measured memory_bytes: 13908
#coding: utf-8
s=input()
k=int(input())
l=list(s)
ans=[]
i=0
j=1
while(j<=k):
    while(i+j<=len(l)):
        ans.append(s[i:i+j])
        i+=1
    j+=1
    i=0
ans=sorted(ans)
n=0
while(n+1<=len(ans)-1):
    if(ans[n]==ans[n+1]):
        ans.pop(n)
    else:
        n+=1
print(ans[k-1])

Measured memory_bytes: 4700
a,b=map(int,input().split())
print("100 100")
for i in range(50):
  if i%2:
    print('#'*100)
  else:
    for j in range(50):
      if a>1:
        a-=1
        print('.#',end='')
      else:
        print('##',end='')
    print()

for i in range(50):
  if i%2==0:
    print('.'*100)
  else:
    for j in range(50):
      if b>1:
        b-=1
        print('.#',end='')
      else:
        print('..',end='')
    print()

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

using namespace std;
const int N = 510;
int _w;

int n, m;
char a[N][N], b[N][N];

void solvea() {
	for( int i = 1; i <= n; ++i )
		for( int j = 1; j <= m; ++j )
			a[i][j] = '.';
	for( int i = 1; i <= n; i += 2 )
		for( int j = 1; j < m; ++j )
			a[i][j] = '#';
	for( int i = 1; i <= n; ++i )
		a[i][1] = '#';
}

void solveb() {
	for( int i = 1; i <= n; ++i )
		for( int j = 1; j <= m; ++j )
			b[i][j] = '.';
	for( int i = 2; i <= n; i += 2 )
		for( int j = 2; j <= m; ++j )
			b[i][j] = '#';
	for( int i = 1; i <= n; ++i )
		b[i][m] = '#';
}

int main() {
	cin >> n >> m;
	solvea(), solveb();
	for( int i = 1; i <= n; ++i )
		for( int j = 1; j <= m; ++j ) {
			char c;
			_w = scanf( " %c", &c );
			if( c == '#' ) a[i][j] = b[i][j] = c;
		}
	for( int i = 1; i <= n; ++i, puts("") )
		for( int j = 1; j <= m; ++j )
			putchar( a[i][j] );
	puts("");
	for( int i = 1; i <= n; ++i, puts("") )
		for( int j = 1; j <= m; ++j )
			putchar( b[i][j] );
	return 0;
}


Measured memory_bytes: 1280
#include<stdio.h>

int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a==b&&b==c&&c==a)
    {
        printf("No");


    }
    else if(a==b||b==c||c==a)
    {
        printf("Yes");

    }
    else
    {
     printf("No");
    }
    return 0;
}


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


int main()
{  
  
   string s;
   cin>>s;
   int num=0;
    int min=32000;
   int i;
  for(i=0;i<s.length()-2;++i)
  {
     num=100*(s[i]-48) + 10*(s[i+1]-48) + (s[i+2]-48);
     if(min>abs(num-753))
         min=abs(num-753);
  }
  
  printf("%ld",min);
        
   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define M 1000000007
#define ll long long int
#define F first
#define S second
#define INF (int)1000000000
const int N = 1e5 + 5;
#define maax(a,b,c) max((int)a,max((int)b,(int)c))
#define miin(a,b,c) min((int)a,min((int)b,(int)c))
#define mp make_pair
#define int long long int
#define all(a) a.begin(),a.end()
#define I insert 
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define inf (long long) 1e18
#define vl vector<ll>
#define sz(a) (ll)a.size()
#define mem(a,b) memset(a,b,a.size())
#define fr(i,m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define fre(i,m, n) for (int i = (int)(n); i <= (int)(m); i--)
#define rall(x) (x).rbegin(), (x).rend()
#define TIME    cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
//void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
typedef long long LL;
typedef pair<int, int> PII;
map<char,int>m;
int fuck(int x,int y)
{
	int a,b;cin>>a>>b;
	if(x!=a)
	{
		if(((a<x) && (m['L']<(x-a))) || ((a>=x) && (m['R']<(a-x))))
		{
			cout<<"NO\n";return 0;
		}
	}
	if(y!=b)
	{
		if(((b<y) && (m['D']<(y-b))) || ((b>=y) && m['U']<(b-y)))
		{
			cout<<"NO\n";return 0;
		}
	}int h,g;
	if((a>0 && x>0) || (a<0 && x<0)) h=abs(abs(a)-abs(x));
	else h=abs(a)+abs(x);
	if((b>0 && y>0) || (b<0 && y<0)) g=abs(abs(b)-abs(y));
	else g=abs(b)+abs(y);
	cout<<"YES "<<h+g<<"\n";
	return 0;
}
int sollvve()
{
    int n;cin>>n;
    vector<int>a(n),b(n+1);
    fr(i,0,n) cin>>a[i];int ma=0;
    fr(i,1,n)
    {int h=(a[i-1]-a[i]);
    	ma+=max(1LL*0,h);
	}cout<<ma<<"\n";
	return 0;
}
int32_t main()
{
	ios::sync_with_stdio(0); cin.tie(0);
//	int t;cin>>t;
//    while(t--) sollvve();
    string s;cin>>s;map<char,int>m;m[s[0]]++,m[s[1]]++,m[s[2]]++;
    if(m['R']==2) ((s[0]=='R' && s[1]=='R')|| (s[1]=='R' && s[2]=='R'))?cout<<2:cout<<1;
    else cout<<m['R'];
	return 0;	
}
 
//std::fill to fill a vector fill(all(a),0); 
//1 2 3 4 5 10 11 3 6 16
//1 2 3 3 4 5 6 10 11 16
//319-207=112+50=172
//set-> all elements are unique and sorted *_* 

Measured memory_bytes: 3668
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
int a[100010];
int main(){ _;
  int n,k;cin>>n>>k;
  REP(i,n)cin>>a[i];
  if(k==n){
    cout<<1<<endl;
    return 0;
  }
  REP(i,2*n)
    if(n<=i*(k-1)+1){
      cout<<i<<endl;
      return 0;
    }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 1e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};


int main() {
    string s; cin >> s;
    int n = sz(s);
    if (s[n-1] == 's') {
        cout << s + "es" << endl;
    } else {
        cout << s + "s" << endl;
    }

}

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

// long long power(int a, int b){
// 	if(b == 0){
// 		return 1;
// 	}
// 	if(b == 1){
// 		return a;
// 	}
// 	if(b % 2 == 0){
// 		int x = power(a, b / 2);
// 		return x * x;
// 	} else {
// 		int x = power(a, b / 2);
// 		return x * x * a;
// 	}
// }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m, a, pen = 0, ac = 0;
	string s;
	cin >> n >> m;
	bool madeQuestion[n];
	int penQuestion[n];
	memset(madeQuestion, false, sizeof(madeQuestion));
	memset(penQuestion, 0, sizeof(penQuestion));
	for(int i = 0; i < m; i++){
		cin >> a >> s;
		if(madeQuestion[a - 1]){
			continue;
		}
		if(s == "WA"){
			penQuestion[a - 1]++;
		} else {
			ac++;
			madeQuestion[a - 1] = true;
			pen += penQuestion[a - 1];
		}
	}
	cout << ac << ' ' << pen;
	
}

Measured memory_bytes: 768
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,m;
    ll ans=1;
    cin>>n>>m;
    vll a(n),b(m);
    rep(i,n){
        cin>>a[i];
    }
    rep(i,m){
        cin>>b[i];
    }
    sort(all(a));
    sort(all(b));
    ERASE(a);
    ERASE(b);
    if(a.size()!=n||b.size()!=m){
        cout<<0<<endl;
        return 0;
    }
    if(a[n-1]!=n*m||b[m-1]!=n*m){
        cout<<0<<endl;
        return 0;
    }
    ll cnt=0;
    for(ll i=n*m;i>0;i--){
        ll s=n-LB(a,i);
        ll t=m-LB(b,i);
        if(s*t-cnt<0){
            cout<<0<<endl;
            return 0;
        }
        if(a[n-s]==i&&b[m-t]==i){}
        else if(a[n-s]==i){
            ans*=t;
        }
        else if(b[m-t]==i){
            ans*=s;
        }
        else {
            ans*=(s*t-cnt);
        }
        ans%=MOD;
        cnt++;
    }
    cout<<ans%MOD<<endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin python3
# -*- coding: utf-8 -*-
import sys
input=sys.stdin.readline
n = 10**5
#primes = set(range(3, n+1, 2))|set([2])
primes = set(range(3, n+1, 2)) #偶数は除く
for i in range(3, int(n**0.5+1)):
    primes.difference_update(range(i*3, n+1, i*2))
primes.add(2)

Likes = [0] * (n+1)
cnt = 0
for i in range(1,n+1,2):
    Likes[i-1]=Likes[i-2]
    x = (i+1)//2
    if i in primes and (x in primes or x==2):
        Likes[i]=Likes[i-1] + 1
    else:
        Likes[i]=Likes[i-1]

def main():
    Q = int(input())
    for q in range(Q):
        l,r = map(int,input().split())
        print(Likes[r]-Likes[l-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 8684
n = int(input())

a = [1,2,3,4,5,6,7,8,9]
b = [1,2,3,4,5,6,7,8,9]

flag = False
for a_ in a:
  for b_ in b:
    if a_ * b_ == n:
      flag = True
   
if flag == False:
  print("No")
else:
  print("Yes")
  

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    string s;
    int t;
    // pair<pait<string,int>,int> ;
    vector<pair<pair<string,int>,int>> mp(n+1);
    for(int i=1;i<=n;i++)
    {
        cin>>s>>t;
      mp[i].first.first = s;
        mp[i].first.second = -t;
        mp[i].second = i;
    }
sort(mp.begin(),mp.end());
for(int i=1;i<=n;i++)
{
    cout<<mp[i].second<<endl;
}
}


Measured memory_bytes: 256
from collections import deque

H, W = map(int, input().split())
Ch, Cw =  map(int, input().split())
Dh, Dw = map(int, input().split())

maze = ["#" * (W+4)]
maze.append("#" * (W+4))

for i in range(H):
    maze.append("##"+input()+"##")
maze.append("#" * (W+4))
maze.append("#" * (W+4))

ans = [[-1] * (W+4) for _ in range(H+4)]

for i in range(H+4):
    for j in range(W+4):
        if maze[i][j] == "#":
            ans[i][j] = -2

Ch += 1
Cw += 1
Dh += 1
Dw += 1
ans[Ch][Cw] = 0
move = [[-1, 0], [1, 0], [0, -1], [0, 1]]
warp = [[-2, -2], [-2, -1], [-2, 0], [-2, 1], [-2, 2], [-1, -2], [-1, -1], [-1, 1], [-1, 2],
        [0, -2], [0, 2], [1, -2], [1, -1], [1, 1], [1, 2], [2, -2], [2, -1], [2, 0], [2, 1], [2, 2]]

movelst = deque([[Ch, Cw]])
movelst2 = deque([])

while len(movelst) > 0:
    x, y = movelst.popleft()
    movelst2.append([x, y])
    for p, q in move:
        v1, v2 = x+p, y+q
        if ans[v1][v2] == -1:
            movelst.append([v1, v2])
            ans[v1][v2] = ans[x][y]
    
    if len(movelst) == 0:
        while len(movelst2) > 0:
            x2, y2 = movelst2.popleft()
            for v1, v2 in warp:
                i, j = x2+v1, y2+v2
                if ans[i][j] == -1:
                    ans[i][j] = ans[x2][y2] + 1
                    movelst.append([i, j])

print(ans[Dh][Dw])

Measured memory_bytes: 108840