akhauriyash/Code-Regression huggingface dataset:
n = gets.to_i
ab_count = 0
la_count = 0
fb_count = 0
lafb_count = 0
n.times do
  s = gets.chomp
  (0..s.size-2).each do |i|
    if s[i..i+1] == 'AB'
      ab_count += 1
    end
  end
  if s[-1] == 'A' && s[0] == 'B'
    lafb_count += 1
  else
    la_count += 1 if s[-1] == 'A'
    fb_count += 1 if s[0] == 'B'
  end
end
la_count += lafb_count
fb_count += lafb_count
ans = ab_count + [la_count, fb_count].min
if lafb_count > 0 && la_count == lafb_count && fb_count == lafb_count
  ans -= 1
end
puts ans

Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define ll long long

using namespace std;

const int maxn=1e5+5,md=1e9+7;

ll a[maxn],f[maxn];
ll i,j,k,l,m,n,x,y,ans,now,p;

ll quickmi(ll x,ll y){
	ll t1=1;
	while (y){
		if ((y & 1)) t1=(t1*x)%md;
		x=(x*x)%md;
		y/=2; 
	}
	return t1;
}
int main(){
	while (cin>>n>>k){
	p=n; now=0;
	for(i=1;i*i<=p;i++){
		if (p%i==0){
			a[++now]=i;
			if ((p/i)!=i) a[++now]=p/i;
		}
	}
	sort(a+1,a+now+1);
	memset(f,0,sizeof(f)); ans=0;
	fo(i,1,now){
		f[i]=quickmi(k,(a[i]+1)/2);
		fo(j,1,i-1) if (a[i]%a[j]==0) f[i]=(f[i]-f[j]+md)%md;
		if (a[i]%2==0) ans=(ans+f[i]*(a[i]/2))%md;
		else ans=(ans+f[i]*a[i])%md;
	}
	printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1024
s = input()
l = list(set(s))

if len(set(s)) == 1:
    print(0)
    exit()

min_c = 10**8
for i in l:
    old_s = s
    new_s = ''
    idx = 1
    c = 0
    
    while True:
        for j in range(len(s)-idx):
            if old_s[j] == i or old_s[j+1] == i:
                new_s += i
            
            else:
                new_s += old_s[j]
        
        idx += 1
        c += 1
        
        if len(set(new_s)) == 1:
            break
        
        else:
           old_s = new_s
           new_s = ''
    
    min_c = min(min_c,c)

print(min_c)

Measured memory_bytes: 41580
N = int(input())
Hs = list(map(int, input().split()))

count = 0

hs_len = len(Hs)
for i, H in enumerate(Hs):
    flag = True
    for j in range(i, -1, -1):
        if Hs[j] > H:
            flag = False
            break

    if flag:
        count += 1

print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int mod = 1000000007;

int main(){
    int n, k;
    cin >> k >> n;
    vi a(n);
    rep(i, n) cin >> a[i];

    vi dist(n);
    rep(i, n-1) dist[i] = a[i+1] - a[i];
    dist[n-1] = k - a[n-1] + a[0];

    sort(dist.begin(), dist.end(), greater<int>());

    cout << k-dist[0] << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i <(n); i++)
using namespace std;
using ll = long long;
const int n_max = 40;
const int a_max = 10;
const int b_max = 10;
const int c_max = 100;
const int inf = 10000;
int dp[n_max + 1][a_max * n_max + 1][b_max * n_max + 1];


int main()
{
    int n, ma, mb;
    cin >> n >> ma >>mb;

    vector<int> a(n), b(n), c(n);
    rep(i, n)
        cin >> a[i] >> b[i] >> c[i];

    rep(i, n + 1)
    rep(j, a_max * n + 1)
    rep(k, b_max * n + 1)
        dp[i][j][k] = inf;

    dp[0][0][0] = 0;

    rep(i, n)
    rep(j, a_max * n + 1)
    rep(k, b_max * n + 1)
    {
        if (dp[i][j][k] == inf) continue;
        dp[i + 1][j + a[i]][k + b[i]] =
            min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
        dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
    }

    int invalid = inf;
    int ans = invalid;

    rep(j, a_max * n + 1)
    rep(k, b_max * n + 1)
        if (j + k != 0 and j * mb == k * ma)
            ans = min(ans, dp[n][j][k]);

    if (ans == inf)
        ans = -1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 25984
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define REP2(i,m,n) for (int i=m;i<(n);i++)
typedef long long ll;

int dr4[] = {-1, 0, 0, 1};
int dc4[] = {0, -1, 1, 0};
int dr[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dc[] = {-1, 0, 1, -1, 1, -1, 0, 1};

int H, W;
ll X, Y;
string A[1010];
bool ng[1010][1010];
ll dist[1010][1010];

void solve() {
    cin >> H >> W >> X >> Y;
    REP(i, H) cin >> A[i];

    int sr, sc, gr, gc;

    REP(i, H) REP(j, W) {
        if (A[i][j] == 's') {
            sr = i;
            sc = j;
        } else if (A[i][j] == 'g') {
            gr = i;
            gc = j;
        } else if (A[i][j] == '*') {
            ng[i][j] = true;
            REP(k, 8) {
                int ni = i + dr[k];
                int nj = j + dc[k];
                if (ni >= 0 && ni < H && nj >= 0 && nj < W) ng[ni][nj] = true;
            }
        }
    }

    REP(i, H) REP(j, W) dist[i][j] = 1LL << 59;

    priority_queue<tuple<ll, int, int>> pq;
    pq.push(make_tuple(0LL, sr, sc));

    while (!pq.empty()) {
        auto tp = pq.top();
        auto d = -get<0>(tp);
        auto r = get<1>(tp);
        auto c = get<2>(tp);
        pq.pop();
        if (dist[r][c] <= d) continue;
        dist[r][c] = d;
        REP(i, 4) {
            auto nr = r + dr4[i];
            auto nc = c + dc4[i];
            auto nd = d + X;
            if (nr < 0 || nr >= H || nc < 0 || nc >= W || A[nr][nc] == '#') continue;
            if (dist[nr][nc] <= nd) continue;
            pq.push(make_tuple(-nd, nr, nc));
        }
        if (!ng[r][c]) {
            REP(i, 8) {
                auto nr = r + dr[i];
                auto nc = c + dc[i];
                auto nd = d + (abs(dr[i]) + abs(dc[i])) * X + Y;
                if (nr < 0 || nr >= H || nc < 0 || nc >= W) continue;
                if (A[nr][nc] != '#') continue;
                if (dist[nr][nc] <= nd) continue;
                pq.push(make_tuple(-nd, nr, nc));
            }
        }
    }

    if (dist[gr][gc] == 1LL << 59) {
        cout << "INF" << endl;
    } else {
        cout << dist[gr][gc] << endl;
    }

}

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

    solve();
}



Measured memory_bytes: 12804
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 ln             PIC X(43).
01 A              PIC 9(10).
01 B              PIC 9(10).
01 C              PIC 9(10).
01 K              PIC 9(10).
01 ans            PIC S9(10).
01 zs             PIC -(10)9.

PROCEDURE DIVISION.
  ACCEPT ln.
  UNSTRING ln DELIMITED BY SPACE INTO A B C K.
  IF K <= A
      COMPUTE ans = K
  ELSE
      IF K <= A + B
          COMPUTE ans = A
      ELSE
          COMPUTE ans = A - (K - A - B)
      END-IF
  END-IF.
  MOVE ans TO zs.
  DISPLAY FUNCTION TRIM(zs)
  STOP RUN.


Measured memory_bytes: 3936
N = int(input())

start = int(input())
flag = 0
if start != 0:
 flag = 1
t = 0

for i in range(N-1):
 k = int(input())
 if k == start:
  t += start
 elif k == start + 1:
  t += 1
  start = k
 elif k == 0:
  start = 0
 elif k > start + 1:
  t = -1
  break
 else:
  t += k
  start = k

if flag ==1:
 t = -1
print(t)

Measured memory_bytes: 3064
N = int(input())
P = list(map(int, input().split(' ')))
sort_P = sorted(P)
#print(P)
#print(sort_P)

diff_count = 0
for i in range(N):
    if P[i] != sort_P[i]:
        diff_count += 1

if diff_count <= 2:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
program name
    implicit none
    type edge
        integer(8):: to
        integer(8):: w
    end type
    type node
        integer(8):: num
        integer(8):: l
        type(edge),allocatable:: e(:)
    end type
    type(node),allocatable:: tree(:)
    integer(8):: n
    integer(8):: u,v,w
    integer(8):: i,dst
    integer(4),allocatable:: color(:)
    logical,allocatable:: is_passed(:)

    read*, n
    allocate(tree(n),color(n),is_passed(n))
    call init_tree(tree)

    do i=1,n-1
        read*, u,v,w
        call append(tree(u),v,w)
        call append(tree(v),u,w)
    end do

    ! do i=1,n
    !     print*, '---'
    !     print*, i
    !     print*, tree(i)%e(:)%to
    !     print*, tree(i)%e(:)%w
    ! end do
    dst=0
    is_passed(:) = .false.
    call dtm_color(tree(1),dst)

    do i=1,n
        print*, color(i)
    end do
contains
    recursive subroutine dtm_color(n,d)
        type(node):: n
        integer(8):: d,i
        ! print*, n%num,d
        is_passed(n%num) = .true.
        color(n%num) = mod(d,2_8)
        
        do i=1,n%l
            if (.not.is_passed(n%e(i)%to)) call dtm_color(tree(n%e(i)%to), d+n%e(i)%w)
        end do
    end subroutine


    subroutine init_tree(t)
        type(node):: t(:)
        integer(8):: i

        do i=1,size(t)
            allocate(t(i)%e(0))
            t(i)%num = i
            t(i)%l = 0
        end do
    end subroutine


    subroutine append(n,to,w)
        type(node),intent(inout):: n
        integer(8),intent(in):: to,w
        type(edge),allocatable:: tmp(:)

        if (n%l+1 > size(n%e)) then
            allocate(tmp(n%l))
            tmp(:) = n%e(:)
            deallocate(n%e)
            allocate(n%e(max(n%l*2,1_8)))
            n%e(:n%l) = tmp(:)
            deallocate(tmp)
            n%e(n%l+1:)%to = 0_8
            n%e(n%l+1:)%w = 0_8
        end if

        n%l=n%l+1
        n%e(n%l)%to = to
        n%e(n%l)%w = w
    end subroutine
end program name

Measured memory_bytes: 16256
#include <stdio.h>
#include <stdlib.h>
#define max(a, b) (a > b? a : b);

long long row[300000], col[300000], point[300000];

int binary_search(long long target, long long array[], long long n)
{
    long long fn = 0, bn = n - 1, tmp;
    while (fn <= bn)
    {
        tmp = (fn + bn) / 2;
        if (array[tmp] < target) {fn = tmp + 1;} else if (array[tmp] > target) {bn = tmp - 1;} else {return tmp;}
    }
    return fn;
}

int compare(const void *a, const void *b) {return *(long long*)a > *(long long*)b ? 1 : (*(long long*)a == *(long long*)b ? 0 : -1);}

int main(void)
{
    long long H, W, M;
    scanf("%lld %lld %lld", &H, &W, &M);
    long long maxRow = 0, maxCol = 0;

    for (long long i = 0; i < M; i++)
    {
        long long a, b;
        scanf("%lld %lld", &a, &b);
        row[a - 1]++;
        col[b - 1]++;

        if (row[a - 1] > maxRow)
            maxRow = row[a - 1];
        if (col[b - 1] > maxCol)
            maxCol = col[b - 1];

        point[i] = a * W + b;
    }

    long long r = maxRow + maxCol - 1;

    long long numRow = 0, numCol = 0;
    long long indexRow[M], indexCol[M];
    for (long long i = 0; i < H; i++)
    {
        if (row[i] == maxRow)
        {
            indexRow[numRow++] = i;
        }
    }

    for (long long i = 0; i < W; i++)
    {
        if (col[i] == maxCol)
        {
            indexCol[numCol++] = i;
        }
    }

    if (numRow*numCol>M) {printf("%lld", r+1); return 0;}
    qsort(point, M, sizeof(long long), compare);

    for (long long i = 0; i < numRow; i++)
    {
        for (long long j = 0; j < numCol; j++)
        {
            long long key = (indexRow[i]+1)*W+indexCol[j]+1;
            if (point[binary_search(key, point, M)] != key)
            {
                printf("%lld", r + 1);
                return 0;
            }
        }
    }

    printf("%lld", r);
    return 0;
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    string s,t; cin >> s >> t;
    t.pop_back();
    if(s==t)out("Yes");
    else out("No");
}


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

int main() {
  int A, B;
  char op;
  cin >> A >> op >> B;
  if(op == '+')
    cout << A + B << endl;
  else if(op == '-')
    cout << A - B << endl;
  else
    cout << "error" << endl;
}

Measured memory_bytes: 256
right, top, n = map(int, input().split())
list = [list(map(int, input().split())) for i in range(n)]
bottom, left = 0, 0

for i in range(n):
    if list[i][2] == 1:
        left = max(list[i][0], left)
    elif list[i][2] == 2:
        right = min(list[i][0], right)
    elif list[i][2] == 3:
        bottom = max(list[i][1], bottom)
    else:
        top = min(list[i][1], top)

area = (top - bottom) * (right - left)

print(area if top - bottom > 0 and right - left > 0 else 0)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
using namespace std;
int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if((10*b+c)%4==0)
		cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

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

    vector<int> A(M);

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

    sort(A.begin(),A.end());

    long long nowday = 0;
    for(int i = 0;i < M; i++)
    {
        nowday += (long long)A[i];
        if(nowday > N)
        {
            cout << -1 <<endl;
            return 0;
        }
    }

    cout << N - nowday <<endl;
    return 0;
}

Measured memory_bytes: 3680
def gcd(x, y):
    if x < y:
        x, y = y, x
    return x if y == 0 else gcd(y, x % y)


def run():
    while True:
        try:
            x, y = map(int, input().split())
            g = gcd(x, y)
            l = x * y // g
            print(g, l)
        except:
            break

if __name__ == '__main__':
    run()


Measured memory_bytes: 5592
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    int a, b;
    cin >> a >> b;
    if (a + b >= 10) {
        cout << "error" << endl;
        return 0;
    } else {
        cout << a + b << endl;
        return 0;
    }
}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  1 <= N <= 20;
  1 <= A <= 100;
  1 <= B <= 2000;
  if( N * A >= B ){
    cout << B << endl;
  }
  else{
    cout << A * N << endl;
  }
}

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

using namespace std;

int main () {
	int s;
	cin >> s;
	int a[4];
	a[0] = (s/1000)%10;
	a[1] = (s/100)%10;
	a[2] = (s/10)%10;
	a[3] = (s/1)%10;
	for (int i=0; i<3; i++){
		if (a[i] == a[i+1]) {
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

template <class T>
struct SegmentTree{
  using F = function<T(T,T)>;
  F f;
  T inf;
  int n;
  vector<T> node;

  SegmentTree(vector<T> v,T inf,F f):inf(inf),f(f){
    n = 1; while(n < v.size()) n *= 2;
    node.resize(2*n-1,inf);
    for(int i = 0; i < v.size(); i++) node[i+n-1] = v[i];
    for(int i = n-2; i >= 0; i--) node[i] = f(node[2*i+1],node[2*i+2]);
  }

  void update(int k,T val){
    k += n-1;
    node[k] = val;
    while(k > 0){
      k = (k-1) / 2;
      node[k] = f(node[2*k+1],node[2*k+2]);
    }
  }

  void add(int k,T val){
    k += n-1;
    node[k] += val;
    while(k > 0){
      k = (k-1) / 2;
      node[k] = f(node[2*k+1],node[2*k+2]);
    }
  }

  T getval(int a,int b){ return getval(a,b,0,0,n); }
  T getval(int a,int b,int k,int l,int r){
    //区間[a, b)の値を返す
    if(r <= a || b <= l) return inf;
    if(a <= l && r <= b) return node[k];
    T vl = getval(a, b, 2*k+1, l, (l+r)/2);
    T vr = getval(a, b, 2*k+2, (l+r)/2, r);
    return f(vl, vr);
  }
};

signed main(){

  int n; cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  SegmentTree<int> seg(a,0,[&](int x,int y){
    return __gcd(x,y);
  });
  int ans = 1;
  for(int i = 0; i < n; i++){
    int res = __gcd(seg.getval(0,i),seg.getval(i+1,n));
    ans = max(ans,res);
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;
const int N = 105;

int n, res;
char a[N], b[N];
string suf, pref;

void init(){
	scanf("%d%s%s",&n,a,b);
	res = n << 1;
	for(int i = 0; i < n; i++){
		suf = a[n - i - 1] + suf;
		pref += b[i];
		if(suf == pref) res = 2*n - i - 1;
	}
	printf("%d\n",res);
}

int main(){
	
	init();
	return 0;
}

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

int main(void){
    int i, j, minj, cnt, high[10];
    for(i=0; i<10; i++) cin >> high[i];
    for (i=0; i<10; i++){
        minj = i;
        for(j=i+1; j<10; j++){
            if(high[j] < high[minj]){
                minj = j; 
            }
        }
        if(minj!=i){
            cnt++;
            swap(high[i], high[minj]);
        }
    }
    cout << high[9] << endl;
    cout << high[8] << endl;
    cout << high[7] << endl;
    return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll vs[110][2];
ll dp[110][100100];

ll rec(int n, ll w) {
    if (0 < dp[n][w]) return dp[n][w];
    if (n == 0) return 0;
    if (w < vs[n][0]) dp[n][w] = rec(n - 1, w);
    else dp[n][w] = max(rec(n - 1, w), rec(n - 1, w - vs[n][0]) + vs[n][1]);
    return dp[n][w];
}

void solve() {
    int N, W;
    cin >> N >> W;
    for (ll i = 1; i <= N; ++i) cin >> vs[i][0] >> vs[i][1];
    for (ll i = 0; i <= N; ++i) for (int j = 0; j <= W; ++j) dp[i][j] = 0;
    cout << rec(N, W) << endl;
}

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


Measured memory_bytes: 80128
#include  <stdio.h>

int main(void)
{
	int V[20], C[20];
	int N;
	int i;
	int d = 0;

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

	for (i = 0; i < N; i++) {
		if (V[i] > C[i]) {
			d += (V[i] - C[i]);
		}
	}

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

	return 0;
}

Measured memory_bytes: 128
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int N = sc.nextInt();
        int M = sc.nextInt();
        boolean[] flg = new boolean[N + 1];
        for (int i = 0; i < M; ++i) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            flg[a] = !flg[a];
            flg[b] = !flg[b];
        }

        for (int i = 0; i <= N; ++i) {
            if (flg[i]) {
                _out.println("NO");
                return;
            }
        }
        _out.println("YES");
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  string a, b;
  cin >> a >> b;
  int ans = 0;
  for (int i = 0; i < min(a.length(), b.length()); i++) {
    if (a[i] == b[i]) ans++;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,K;
  cin >> A >> B >> K;
  K;
  for(int i = A ; i <= B  ; i++){
    if(i < A + K || B-K < i )
    cout << i << endl;
  }
  
  return 0; 
}

Measured memory_bytes: 256
#20131114

key=[]
gets.to_i.times{
	key.push gets.chomp
}
lock = true
gets.to_i.times{
	id = gets.chomp
	if key.count(id) > 0
		if lock
			puts "Opened by #{id}" 
			lock = false
		else
			puts "Closed by #{id}"
			lock = true
		end
	else
		puts "Unknown #{id}"
	end
}

Measured memory_bytes: 6104
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		
		String s;
		char[] ch;
		
		char[][] C = new char[2][n];
		char[][] C2 = new char[2][n];
		
		for(int i = 0; i < n; i++){
			s = scan.next();
			ch = s.toCharArray();
			C[0][i] = ch[0];
			C[1][i] = ch[1];
			C2[0][i] = C[0][i];
			C2[1][i] = C[1][i];
		}
		
		//??????????????????
		char swap;
		for(int i = 0; i <= n - 1; i++){
			for(int j = n-1; j >= i + 1; j--){
				if(C[1][j] < C[1][j-1]){
					swap = C[1][j];
					C[1][j] = C[1][j-1];
					C[1][j-1] = swap;
					swap = C[0][j];
					C[0][j] = C[0][j-1];
					C[0][j-1] = swap;
				}
			}
		}
		
		//???????????????
		int minj;
		for(int i = 0; i <= n - 1; i++){
			minj = i;
			for(int j = i; j <= n - 1; j++){
				if(C2[1][j] < C2[1][minj]){
					minj = j;
				}
			}
			swap = C2[1][i];
			C2[1][i] = C2[1][minj];
			C2[1][minj] = swap;
			swap = C2[0][i];
			C2[0][i] = C2[0][minj];
			C2[0][minj] = swap;
		}
		
		for(int i = 0; i < n; i++){
			System.out.print(C[0][i]);
			System.out.print(C[1][i]);
			if(i < n - 1)System.out.print(" ");
			else System.out.println();
		}
		System.out.println("Stable");
		
		boolean flag = true;
		
		for(int i = 0; i < n; i++){
			System.out.print(C2[0][i]);
			System.out.print(C2[1][i]);
			if(C[0][i] != C2[0][i] || C[1][i] != C2[1][i])flag = false;
			if(i < n - 1)System.out.print(" ");
			else System.out.println();
		}
		if(flag == true) System.out.println("Stable");
		else System.out.println("Not stable");
	}
}

Measured memory_bytes: 26164
#include <iostream>
//#include <algorithm>
//#include <numeric>
#include <cmath>
//#include <vector>
//#include <string>
typedef long long LL;
using namespace std;

LL gcd(LL a, LL b){
    LL tmp; 
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    tmp = a%b;
    while(tmp!=0){
        a = b;
        b = tmp;
        tmp = a%b;
    }

    return b;
}

int main(){
    LL a, b;
    LL num_gcd;
    int ans = 1;
    cin >> a >> b;
    num_gcd = gcd(a, b);
    for(int i=2;i<=(LL)sqrtl(num_gcd)+2;i++){
        if(num_gcd%i==0){
            while(num_gcd%i==0)num_gcd/=i;
            ans++;
        }
    }
    if(num_gcd>1)ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import math
import itertools
import statistics
#import numpy as np
import collections

#n = int(input())
n, m = list(map(int, input().split()))
a = []
b = []

for i in range(m):
    x,y = [int(j) for j in input().split()]
    a.append(x)
    b.append(y)



road = [[0]*n for i in range(n)]
for i in range(m):
    road[a[i]-1][b[i]-1] += 1
    road[b[i]-1][a[i]-1] += 1

for i in range(n):
    print(sum(road[i]))


#print(road)


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

int main(){

char h[3][3];
		
		for(int i = 0;i < 3;i++)
	cin >> h[0][i] >> h[1][i] >> h[2][i];

cout << h[0][0] << h[1][1] << h[2][2] <<endl;

	return 0;
}

Measured memory_bytes: 256
num = int(input())
l = []
for i in range(num):
    lst = list(map(float, input().split()))
    x1, y1 = lst[0], lst[1]
    x2, y2 = lst[2], lst[3]
    x3, y3 = lst[4], lst[5]
    x4, y4 = lst[6], lst[7]

    d = (x2 - x1) * (y4 - y3) - (x4 - x3) * (y2 - y1)
    k = abs(d)

    if k <= 1e-11:
        l.append('YES')
    else:
        l.append('NO')

for i in l:
    print(i)


Measured memory_bytes: 5616
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
    vector<long long int> A(3);
    for (int i = 0; i < 3; i++) {
        cin >> A[i];
    }
    int K;
    cin >> K;
    sort(A.begin(), A.end());
    cout << (A[0] + A[1] + (A[2] << K)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Fi first
#define Se second
pair<pair<int,int> ,int>p[1005];
int n;
int main()
{
    cin>>n;
    for(int i=0; i<n+n; i++)cin>>p[i].Fi.Fi>>p[i].Fi.Se,p[i].Se=i>=n;
    sort(p,p+n+n);
    set<int> s;
    int ans=0;
    for(int i=0; i<n+n; i++)
        if(p[i].Se&&!(s.empty()||*s.begin()>p[i].Fi.Se))s.erase(--s.lower_bound(p[i].Fi.Se)),ans++;
        else if(!p[i].Se)s.insert(p[i].Fi.Se);
    cout<<ans;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Collections;
import java.util.Arrays;
import java.lang.Math;

public class Main {
	public static void main(String[] args) {
		FS reader = new FS();
		// write reader
		int D = reader.nextInt();
		int G = reader.nextInt()/100;
		int[] P = new int[D];
		int[] C = new int[D];
		for(int i=0; i<D; i++) {
		    P[i] = reader.nextInt();
		    C[i] = reader.nextInt()/100;
		}
		
		solver(D, G, P, C);
	}
	
	public static void solver(int D, int G, int[] P, int[] C) {
		// write logic
		int ans = Integer.MAX_VALUE;
		for(int i=0; i<(int)Math.pow(2,D); i++) {
		    int tmpsum = 0;
		    int cntsum = 0;
		    for(int j=0; j<D; j++) {
		        if((i & (int)Math.pow(2,j)) > 0) {
		            tmpsum += (j+1)*P[j]+C[j];
		            cntsum += P[j];
		        }
		    }
		    if(G <= tmpsum) {
		        ans = Math.min(ans, cntsum);
		        continue;
		    }
		    int plusid = -1;
		    for(int j=D-1; j>=0; j--) {
		        if((i & (int)Math.pow(2,j)) == 0) {
		            plusid = j;
		            break;
		        }
		    }
		    int need = (int)Math.ceil((double)(G-tmpsum)/(double)(plusid+1));
		    if(need<P[plusid]) ans = Math.min(ans, cntsum+need);
		}
		System.out.println(ans);
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


Measured memory_bytes: 23124
import Control.Applicative
import Control.Monad

solver :: [Int] -> Int
solver xs = truncate $ fromIntegral (sum xs) / fromIntegral (length xs)

main :: IO()
main = do
  n <- (read :: String -> Int) <$> getLine
  inputs <- map (read :: String -> Int) <$> replicateM n getLine
  print $ solver inputs

Measured memory_bytes: 10352
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define PB push_back
#define F first
#define S second
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
const ll MOD = 1e9+7;
const ll INF = 1e9+10;

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
 
	int n; cin >> n;
	vector<ll> v(n+1); FOR(i, n+1) cin >> v[i];

	vector<ll> tam(n+7, 1);
	FOR(i, n+1){
		if(v[i] > tam[i]){
			cout << "-1\n";
			return 0;
		}
		tam[i+1] = min((tam[i]-v[i])*2LL, 1000000000000000LL);
	}

	ll ans = 0;
	ll now = 0;
	for(int i = n; i >= 0; i--){
		now = min(now+v[i], tam[i]);
		ans += now;
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 4768
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr




N = int(input())
sosuu = factorization(N)
#print(sosuu)
ans = 0

for partial in sosuu:
    #print(partial)
    partial_count = 0
    if partial[0] == 1:
        #print(0)
        ans = 0
        break
    for x in range(1,partial[1]+1):
        partial_count += x
        if partial_count > partial[1]:
            break
        ans += 1

print(ans)

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

int main(int argc, char** argv) {
	const double EPS = 1.0e-10;
	double a, b, c, d, e, f; // -1000 <= a, b, c, d, e, f <= 1000
	while (cin >> a >> b >> c >> d >> e >> f) {
		double x = (c*e - b*f) / (a*e - b*d);
		double y = (a*f - c*d) / (a*e - b*d);
		if (-0.0005 < x && x < 0.0 + EPS) x = 0.0;
		if (-0.0005 < y && y < 0.0 + EPS) y = 0.0;
		printf("%.3f %.3f\n", x, y);
	}
	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
bool D[20];
int hantei(int N){
  while(N){
    if(D[N%10]){
      return 0;
    }
    N=N/10;
  }
  return 1;
}
int main() {
  int N,K;
  cin>>N>>K;
  rep(i,20) D[i]=false;
  rep(i,K){
    int x;
    cin>>x;
    D[x]=true;
  }
  while(1){
    if(hantei(N)){
      cout<<N;
      return 0;
    }
    N++;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

int n;

void dfs(string s, int mx){
    if(s.length() == n) cout<<s<<endl;
    else{
        for(int i=0;i<=mx;i++){
            char c = 'a' + i;
            dfs(s+c,( (i==mx) ? mx+1:mx ));
        }
    }
    return;
}

int main(){
    cin>>n;

    dfs("a",1);
}

Measured memory_bytes: 1536
#include <stdio.h>
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
    int n,m;
    scanf("%d%d",&n,&m);
    if(n>m){
      printf("safe");
      return 0;
    }else{printf("unsafe");}
    
    
    return 0;
}

Measured memory_bytes: 1720
<?php
   fscanf(STDIN,"%d %d",$A,$B);
$ke = 0;
   if($A > $B){
     $ke += $A;
     $A--;
   }else{
     $ke+=$B;
     $B--;
   }

 if($A > $B){
     $ke += $A;
     $A--;
 }else{
     $ke+=$B;
     $B--;
   }
  print($ke);
?>



Measured memory_bytes: 3828
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInt2() (int, int) {
	return nextInt(), nextInt()
}

func nextInt3() (int, int, int) {
	return nextInt(), nextInt(), nextInt()
}

func nextInt4() (int, int, int, int) {
	return nextInt(), nextInt(), nextInt(), nextInt()
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

type Point struct {
	x, y int
}

func dist(p, q Point) int {
	return abs(p.x-q.x) + abs(p.y-q.y)
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func min(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()
	pp := make([]Point, n)
	for i := range pp {
		x, y := nextInt(), nextInt()
		pp[i] = Point{x, y}
	}

	add, sub := make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		add[i] = pp[i].x + pp[i].y
		sub[i] = pp[i].x - pp[i].y
	}

	ans := max(
		max(add...)-min(add...),
		-min(sub...)+max(sub...),
		max(sub...)-max(sub...),
		-min(add...)+max(add...),
	)

	puts(ans)
}


Measured memory_bytes: 12136
#!/usr/bin/env python3

MOD = 1000000007  # type: int


def comb(n, r):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    g1 = [1] * (n + 1)
    g2 = [1] * (n + 1)
    ig = [0] * (n + 1)
    ig[1] = 1
    for i in range(2, n + 1):
        g1[i] = (g1[i-1] * i) % MOD
        ig[i] = (-ig[MOD % i] * (MOD//i)) % MOD
        g2[i] = (g2[i-1] * ig[i]) % MOD
    return g1[n] * g2[r] * g2[n-r] % MOD


def solve(X: int, Y: int):
    if (X + Y) % 3:
        return 0
    t = (X + Y) // 3
    return comb(t, X - t) % MOD


def main():
    X, Y = sorted(map(int, input().split()))
    print(solve(X, Y))


if __name__ == '__main__':
    main()


Measured memory_bytes: 82076
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 998244353;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

ll multiply(ll x, ll y) {
    return (x % mod) * (y % mod) % mod;
}

ll gcd(ll a, ll b) {
    return b != 0 ? gcd(b, a % b) : a;
}

int main() {
    ll N;
    cin >> N;
    ll a[N];
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    sort(a, a + N);
    ll ans = 1;
    for (int i = 0; i < N; i++) {
        ans = multiply(ans, gcd(a[i], i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
/****************************************************************************************************
                                        SUBMITTED BY-

                                               aish_07

****************************************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define ll long long
#define sl set<ll>
#define vs vector<string>
#define pb push_back
#define vl vector<ll>
#define vi vector<int>
#define PI  3.14159265
#define mod 998244353
int main()
{
    int n;
    cin>>n;

    int l[n];
    for(int i=0;i<n;i++)
        cin>>l[i];
    sort(l,l+n);

    int sum=0;
    for(int i=0;i<n-1;i++)
        sum+=l[i];
    if(l[n-1]<sum)
        cout<<"Yes\n";
    else
      cout<<"No\n";
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,a) for(int i = 0; i < (a); i++)
using namespace std;

int main(){
	int n;
	cin >> n;
	string w[n];
	REP(i,n){
		cin >> w[i];
		REP(j,i){
			if(w[i] == w[j]){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	REP(i,n - 1){
		if(w[i][w[i].length() - 1] != w[i + 1][0]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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;
}

signed main() {
  init();
  string S, T;
  cin >> S >> T;

  if (S == T) {
    COUT("Yes");
    return 0;
  }

  rep(i, S.size()) {
    char b = S.back();
    S.erase(S.size() - 1, 1);
    S.insert(S.begin(), b);
    if (S == T) {
      COUT("Yes");
      return 0;
    }
  }
  COUT("No");

  return 0;
}

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

int main() {
  long n,k,l;
  cin >> n >> k >> l;
  vector<long> p(k),q(k),r(l),s(l);
  vector<vector<long>> douro(n,vector<long>(0));
  vector<vector<long>> tetsu(n,vector<long>(0));
  vector<vector<long>> kumi(n,vector<long>(2,-1));
  map<long,long> kumiwake;
  for(long i=0;i<k;i++) {
    cin >> p[i] >> q[i];
    douro[p[i]-1].push_back(q[i]-1);
    douro[q[i]-1].push_back(p[i]-1);
  }
  for(long i=0;i<l;i++) {
    cin >> r[i] >> s[i];
    tetsu[r[i]-1].push_back(s[i]-1);
    tetsu[s[i]-1].push_back(r[i]-1);
  }
  for(long i=0;i<n;i++) {
    if(kumi[i][0]!=-1)continue;
    queue<long> bfs;
    bfs.push(i);
    while(bfs.size()!=0) {
      kumi[bfs.front()][0]=i;
      for(long j=0;j<douro[bfs.front()].size();j++) {
        if(kumi[douro[bfs.front()][j]][0]==-1) {
          bfs.push(douro[bfs.front()][j]);
        }
      }
      bfs.pop();
    }
  }
  for(long i=0;i<n;i++) {
    if(kumi[i][1]!=-1)continue;
    queue<long> bfs;
    bfs.push(i);
    while(bfs.size()!=0) {
      kumi[bfs.front()][1]=i;
      for(long j=0;j<tetsu[bfs.front()].size();j++) {
        if(kumi[tetsu[bfs.front()][j]][1]==-1) {
          bfs.push(tetsu[bfs.front()][j]);
        }
      }
      bfs.pop();
    }
  }
  for(long i=0;i<n;i++) kumiwake[kumi[i][0]*100000000+kumi[i][1]]++;
  for(long i=0;i<n;i++) cout << kumiwake[kumi[i][0]*100000000+kumi[i][1]] << " ";
  cout << endl;
}

Measured memory_bytes: 133056
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;


ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}



/******************************************
** A main function is start from here  ****
*******************************************/
int main(){
  string S;
  int N, P;
  cin >> N >> P;
  cin >> S;
  if(P==2 or P==5){
    ll ans=0;
    rep(i, N){
      if(int(S[i] - '0') %P==0){
        ans += i+1;
      }
    }
    cout << ans;
  }else{
    vector<ll> count(P, 0);
    ll tmp=0;
    for(int i = N-1;i>=0;i--){
      //cout << int(S[i] - '0') << endl;
      tmp = mod(tmp + int(S[i]-'0')* modpow(10, N-1-i, P), P);
      count[tmp]+=1;
    }
    ll ans = 0;
    ans += count[0];
    rep(i,P){
      ans += (count[i]*(count[i]-1))/2;
    }
    cout << ans;
  }
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    vector<int> h(4);
    for(int i=0;i<s.size();i++){
        if(s.at(i)=='N')h.at(0)++;
        else if(s.at(i)=='W')h.at(1)++;
        else if(s.at(i)=='S')h.at(2)++;
        else if(s.at(i)=='E')h.at(3)++;
    }
    if(((h.at(0)>0&&h.at(2)>0)||(h.at(0)==0&&h.at(2)==0))&&((h.at(1)>0&&h.at(3)>0)||(h.at(1)==0&&h.at(3)==0)))cout << "Yes" <<endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
typedef long long LL;
const int N=1<<20;
const int MOD=998244353;
const int Inv=499122177;
int add (int x,int y)   {x=x+y;return x>=MOD?x-MOD:x;}
int mul (int x,int y)   {return (LL)x*y%MOD;}
int dec (int x,int y)   {x=x-y;return x<0?x+MOD:x;}
int Pow (int x,int y)
{
	if (y==0) return 1;
	if (y==1) return x;
	int lalal=Pow(x,y>>1);
	lalal=mul(lalal,lalal);
	if (y&1) lalal=mul(lalal,x);
	return lalal;
}
int n,sum;
int a[N];
int p[N],q[N];
int tmp[N];
void FWT (int *a,int nn,int o)
{
    for (int u=1;u<=nn;u<<=1)
    {
        for (int i=0;i<=nn;i++) tmp[i]=0;
        for (int i=0;i<=nn;i++)
        {
            if (i&u) tmp[i]=dec(tmp[i],a[i]),tmp[i^u]=add(tmp[i^u],a[i]);
            else tmp[i]=add(tmp[i],a[i]),tmp[i^u]=add(tmp[i^u],a[i]);
        }
        for (int i=0;i<=nn;i++)  {a[i]=tmp[i];if (o==-1) a[i]=mul(a[i],Inv);}
    }
}
int main()
{
	scanf("%d",&n);n=(1<<n);
	for (int u=0;u<n;u++) 	{scanf("%d",&a[u]);sum=add(sum,a[u]);}
	sum=Pow(sum,MOD-2);
	for (int u=0;u<n;u++)
	{
		p[u]=mul(a[u],sum);
		q[u]=MOD-1;
	}
	q[0]=n-1;p[0]=dec(p[0],1);
	FWT(p,n-1,1);FWT(q,n-1,1);
	for (int u=1;u<n;u++) 	p[u]=mul(q[u],Pow(p[u],MOD-2));
	FWT(p,n-1,-1);
	for (int u=0;u<n;u++) printf("%d\n",dec(p[u],p[0]));
	return 0;
}

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

int main(){
	string n; cin>>n;
	if(n[0]=='9'||n[1]=='9') cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 3656