akhauriyash/Code-Regression huggingface dataset:
const MOD = 10**9+7
// factors[f].e+n-1、において max(n)=10**5, max(factors[f].e)=log(M)=log(10**9)=21
const N = 10**5+29

let fac = [...new Array(N)].fill(0)
let ifac = [...new Array(N)].fill(0)
const mul = (a,b) => ((a>>16)*b%MOD*65536+(a&65535)*b)%MOD;

const factorization = (n) => {
    let primes= []
    for(let i=2; i*i<=n; i++) {
        let exponent = 0
        while(n%i===0) {
            n /= i
            exponent++
        }
        if(exponent) {
            primes.push({p:i, e:exponent})
        }
    }
    
    if(n!==1) {
        primes.push({p:n, e:1})
    }
    return primes
}

const mpow = (x, n) => {
    ans = 1;
    let _x = x
    while(n != 0){
        if(n & 1) ans = mul(ans,_x);
        _x = mul(_x,_x);
        n = n >> 1;
    }
    return ans;
}

const comb = (n, r) => {
    if(n == 0 && r == 0) return 1;
    if(n < r || n < 0) return 0;
    const tmp = mul(ifac[n-r],ifac[r])
    return mul(tmp,fac[n])
}

const init = () => {
    fac[0] = 1;
    ifac[0] = 1;
    for(let i=0; i<N; i++){
        fac[i+1] = mul(fac[i],(i+1));
        ifac[i+1] = mpow(fac[i+1], MOD - 2)
    }
}

const main = (arg) => {
    let [n, m] = arg.split(" ").map(Number)
    let factors = factorization(m)
    let ans = 1
    init()
    Object.keys(factors).forEach(f=>{
        let a = factors[f].e+n-1
        let b = factors[f].e
        ans = mul(ans,comb(a, b))
    })
    console.log(ans)
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 37444
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H, W, K;
    int rem[30][30];

    while(cin >> H >> W >> K) {
        vector<string> S(H);
        rep(y, H)cin >> S[y];

       

        ll ans = 0;

        rep(remY, H)rep(remX, W) {
            vector<list<int>> ls(W);
            rep(x, W) {
                rep(y, H) {
                    if(y != remY || x != remX)ls[x].push_back(S[H-1-y][x] - '0');
                }
            }

            vector<list<int>::iterator> its(W);
            vector<list<int>::reverse_iterator> rits(W);

            int upd = 1;
            ll mul = 1, value = 0;
            while(upd) {
                ll sm = 0;
                upd = 0;
                vi col(W);
                MEM(rem, 0);

                rep(x, W)its[x] = ls[x].begin();

                int row = 0;
                for(; row < H && count(all(col), -1) != W; ++row) {
                    int cur = -1, start = -1, suc = 0;
                    rep(x, W) {
                        if(its[x] == ls[x].end())col[x] = -1;
                        else {
                            col[x] = *its[x];
                            ++its[x];
                        }
                        if(cur != col[x]) {
                            if(cur != -1 && suc >= K) {
                                FOR(i, start, x)rem[row][i] = 1;
                                upd = 1;
                            }
                            suc = 1;
                            cur = col[x];
                            start = x;
                        } else {
                            suc++;
                        }
                    }

                    if(cur!=-1 && suc >= K) {
                        FOR(i, start, W)rem[row][i] = 1;
                        upd = 1;
                    }
                }

                rep(x, W)its[x] = ls[x].begin();

                rep(r, row) {
                    rep(x, W) {
                        if(rem[r][x]) {
                            sm += *its[x];
                            its[x] = ls[x].erase(its[x]);
                        } else if(its[x] != ls[x].end()) {
                            its[x]++;
                        }
                    }
                }

                value += sm*mul;

                mul *= 2;
            }

            
            smax(ans, value);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

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

int f(string s, int div) {
    int n = s.size();
    ll x = 0;
    rep(i,n) {
        if (s[i] == '1') {
            x += modpow(2,n-1-i,div);
            x %= div;
        }
    }
    return x%div;
}

int f_(int x, int ct = 1) {
    if (x == 0) return ct;
    int tmp = x % __builtin_popcount(x);
    if (tmp == 0) return ct+1;
    return f_(tmp,ct+1);
}

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int div = 0;
    rep(i,n) if (s[i] == '1') div++;
    int x_plus = f(s,div+1);
    int x_minus;
    if (div-1 != 0) x_minus = f(s,div-1);
    rep(i,n) {
        if (s[i] == '0') {
            ll x = x_plus+modpow(2,n-1-i,div+1);
            x %= div+1;
            printf("%d\n",f_(x));
        }
        if (s[i] == '1') {
            if (div-1 == 0) cout << 0 << endl; 
            else {
                ll x = x_minus-modpow(2,n-1-i,div-1);
                if (x < 0) x += div-1;
                x %= div-1;
                printf("%d\n",f_(x));
            }
        }
    }
}

Measured memory_bytes: 3924
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.C_Challenge
{
    class ABC_095
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] input = ReadInts();
            int price = 0;
            int cheaperIndex = input[0] < input[1] ? 0 : 1;
            int higherIndex = cheaperIndex == 0 ? 1 : 0;
            int lessIndex = input[3] < input[4] ? 3 : 4;
            int moreIndex = lessIndex == 3 ? 4 : 3;

            if (input[0] + input[1] < input[2] * 2)
            {//それぞれ購入
                price += input[0] * input[3];
                price += input[1] * input[4];
            }
            else if (input[higherIndex] < input[2] * 2)
            {
                price += input[2] * input[lessIndex] * 2;
                price += input[moreIndex - 3]
                    * (input[moreIndex] - input[lessIndex]);
            }
            else if (input[cheaperIndex]<input[2] * 2)//安い方とABのみ購入
            {
                price += input[2] * input[higherIndex + 3] * 2;
                if (higherIndex + 3 == lessIndex)
                {
                    price += input[cheaperIndex]
                        * (input[moreIndex] - input[lessIndex]);
                }
            }
            else
            {
                price += input[2] * input[moreIndex] * 2;
            }
            Console.WriteLine(price);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    vector<int> v(3);
    cin >> v[0] >> v[1] >> v[2];
    sort(all(v));
    cout << (v[0] == 5 && v[1] == 5 && v[2] == 7 ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define M 10000
#define N -1

struct Node{
  int parent;
  int left;
  int right;
};

struct Node T[M];
int n,D[M],H[M];

void setDepth(int u,int d){
  if( u == N ) return;
  D[u]=d;
  setDepth( T[u].left,d+1 );
  setDepth( T[u].right,d+1 );
}


int setHeight(int u){
  int h1=0;
  int h2=0;

  if( T[u].left != N )  h1=setHeight(T[u].left)+1;

  if( T[u].right != N )  h2=setHeight(T[u].right)+1;

  return H[u] = (h1 > h2 ? h1 : h2);
}



int getSibling(int u){
  if( T[u].parent == N )  return N;

  if( T[T[u].parent].left != u && T[T[u].parent].left != N ) return T[T[u].parent].left;

  if( T[T[u].parent].right != u && T[T[u].parent].right != N ) return T[T[u].parent].right;

  return N;
}

void p(int u){
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));

  int deg=0;

  if( T[u].left != N )  deg++;

  if( T[u].right != N )  deg++;

  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if( T[u].parent == N ){
    printf("root\n");
  }
  else if( T[u].left == N && T[u].right == N ){
    printf("leaf\n");
  }
  else{
    printf("internal node\n");
  }
}

int main(){
  int v,l,r,root=0;

  scanf("%d",&n);

  for( int i=0; i<n; i++ )
    T[i].parent = N;

  for( int i=0; i<n; i++ ){
    scanf("%d %d %d",&v,&l,&r);

    T[v].left=l;
    T[v].right=r;

    if( l != N ) T[l].parent = v;

    if( r != N) T[r].parent = v;
  }

  for( int i=0; i<n; i++ )
    if( T[i].parent == N )  root=i;

  setDepth(root,0);
  setHeight(root);

  for( int i=0; i<n; i++ )
    p(i);

  return 0;
}



Measured memory_bytes: 2048
#include<iostream>
#include<queue>
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int>p;
int m,n,h,sx,sy;
int total=0;
char a[1001][1001];
int d[1001][1001];
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int bfs()
{
    int num=0;
    queue<p>q;
    for(int cc=0;cc<h;cc++)
    {
        for(int i=0;i<m;i++)
            for(int j=0;j<n;j++)
            d[i][j]=INF;
            d[sx][sy]=0;
            q.push(p(sx,sy));
    while(q.size())
    {
        int x=q.front().first;
        int y=q.front().second;
        q.pop();
        if((int)a[x][y]==49+cc)
        {
            num=d[x][y];
            sx=x;
            sy=y;
            break;
        }
        for(int k=0;k<4;k++)
        {
            int nx=x+dx[k];
            int ny=y+dy[k];
            if(nx>=0&&nx<m&&ny>=0&&ny<n&&a[nx][ny]!='X'&&d[nx][ny]==INF)
            {
                q.push(p(nx,ny));
                d[nx][ny]=d[x][y]+1;
            }
        }
    }
    total+=num;
    while(!q.empty())
        q.pop();
    }
    return total;
}
int main()
{
    cin>>m>>n>>h;
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
        cin>>a[i][j];
        if(a[i][j]=='S')
        {
            sx=i;
            sy=j;
        }
        }
    }
    int cwt=bfs();
    cout<<cwt<<endl;
    return 0;
}



Measured memory_bytes: 7916
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
ll modpow(ll a, ll b, ll m) {
    if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll h = modpow(a, b / 2, m);
        return h * h % m;
    } else {
        return a * modpow(a, b - 1, m) % m;
    }
}
ll comb(ll a, ll b, ll m) {
    if (b > a - b) {
        return comb(a, a - b, m);
    }
    ll c = 1, d = 1;
    REP(i, b) {
        c *= (a - i);
        d *= (b - i);
        c %= m;
        d %= m;
    }
    return c * modpow(d, m - 2, m) % m;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) {
        cin >> A[i];
    }
    int res = 1;
    multimap<int, int> m;
    m.insert(make_pair(-A[0], res));
    FOR(i, 1, N, 1) {
        auto itr = m.upper_bound(-A[i]);
        if (itr == m.end()) {
            res++;
            m.insert(pair<int, int>(-A[i], res));
        } else {
            m.insert(make_pair(-A[i], itr->second));
            m.erase(itr);
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
int n, m, p = 998244353;
char a[100020];
char b[100020];
char c[100020];
char d[100020];
long long v[500020];
long long u[500020];
long long ans;
int a1, b1, c1, d1;
int f[100020];
int g[100020];
long long C(int n, int m) {
	if (n == -1 && m == -1) {
		return 1;
	}
	if (m < 0) {
		return 0;
	}
	return u[n] * v[m] % p * v[n - m] % p;
}
int main() {
	scanf("%d%d", &n, &m);
	scanf("%s%s%s%s", a, b, c, d);
	v[1] = 1;
	for (int i = 2; i <= 500010; i++) {
		v[i] = v[p % i] * (p - p / i) % p;
	}
	v[0] = u[0] = u[1] = 1;
	for (int i = 2; i <= 500010; i++) {
		v[i] = v[i] * v[i - 1] % p;
		u[i] = u[i - 1] * i % p;
	}
	a1 = b1 = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] == '1') {
			a1++;
		}
		if (b[i] == '1') {
			b1++;
		}
	}
	c1 = d1 = 0;
	for (int i = 0; i < m; i++) {
		if (c[i] == '1') {
			c1++;
		}
		if (d[i] == '1') {
			d1++;
		}
	}
	if (a1 == 0 && b1 == 0 && c1 == 0 && d1 == 0) {
		printf("1\n");
		return 0;
	}



	c1 = d1 = 0;
	for (int i = 0; i < m; i++) {
		if (i == 0) {
			f[i] = 0;
		} else {
			f[i] = f[i - 1];
		}
		if (c[i] == '1' || d[i] == '1') {
//			cerr << "?" << C(c1 + d1 + a1 - 1, a1 - 1) << ' ' << a1 << ' ' << b1 << ' ' << c1 << ' ' << d1 << endl;
			f[i] = (f[i] + C(c1 + d1 + a1 - 1, a1 - 1)) % p;
			if (c[i] == '1' && d[i] == '1') {
				f[i] = f[i] * 2 % p;
			}
		}
		if (c[i] == '1') {
			c1++;
		}
		if (d[i] == '1') {
			d1++;
		}
	}
	c1 = d1 = 0;
	for (int i = m - 1; i >= 0; i--) {
		if (c[i] == '1' || d[i] == '1') {
			ans = (ans + f[i] * C(c1 + d1 + b1 - 1, b1 - 1)) % p;
		}
		if (c[i] == '1') {
			c1++;
		}
		if (d[i] == '1') {
			d1++;
		}
	}




	c1 = d1 = 0;
	for (int i = 0; i < m; i++) {
		if (c[i] == '1') {
			c1++;
		}
		if (d[i] == '1') {
			d1++;
		}
	}
	a1 = b1 = 0;
	for (int i = 0; i < n; i++) {
		if (i == 0) {
			f[i] = 0;
		} else {
			f[i] = f[i - 1];
		}
		if (a[i] == '1' || b[i] == '1') {
//			cerr << "?" << C(a1 + b1 + c1 - 1, c1 - 1) << ' ' << a1 << ' ' << b1 << ' ' << c1 << ' ' << d1 << endl;
			f[i] = (f[i] + C(a1 + b1 + c1 - 1, c1 - 1)) % p;
			if (a[i] == '1' && b[i] == '1') {
				f[i] = f[i] * 2 % p;
			}
		}
		if (a[i] == '1') {
			a1++;
		}
		if (b[i] == '1') {
			b1++;
		}
	}
	a1 = b1 = 0;
	for (int i = n - 1; i >= 0; i--) {
		if (a[i] == '1' || b[i] == '1') {
			ans = (ans + f[i] * C(a1 + b1 + d1 - 1, d1 - 1)) % p;
		}
		if (a[i] == '1') {
			a1++;
		}
		if (b[i] == '1') {
			b1++;
		}
	}


	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 8832
n = int(input())
x = [0]
y = [0]
t = [0]

flag = 1
for i in range(n):
    t_tmp,x_tmp,y_tmp = map(int,input().split())
    t.append(t_tmp)
    x.append(x_tmp)
    y.append(y_tmp)
    time = abs(t[i+1] - t[i])
    d = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])#移動した距離の合計を求める
    if d > time or (d % 2) != (time%2): #timeは距離の最大値なのでdより小さいとアウト、パリティ条件があるのでmod 2があってないとアウト
        flag = 0
if flag == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 11764
using System;
using System.Linq;

namespace Study
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string[] strings = input.Split(' ');

            string result = strings[0].Last() == strings[1][0] 
                         && strings[1].Last() == strings[2][0] ? "YES" : "NO";

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
	int N, K, A, S = 0, i, ans = 0;
	scanf("%lld%lld", &N, &K);
	map<int, int> mp;
	queue<int> q;
	mp[S]++;
	q.push(S);
	for(i = 0; i < N; i++){
		if(q.size() >= K){
			mp[q.front()]--;
			q.pop();
		}
		scanf("%lld", &A);
		S = (S + A - 1) % K;
//		printf("S = %lld\n", S);
		ans += mp[S];
//		printf("ans = %lld\n", ans);
		mp[S]++;
		q.push(S);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 14336
def floor_sum(n, m, a, b)
  ans = 0

  if a >= m
    ans += (n - 1) * n * (a / m) / 2
    a %= m
  end

  if b >= m
    ans += n * (b / m)
    b %= m
  end

  y_max = (a * n + b) / m
  x_max = (y_max * m - b)

  return ans if y_max == 0

  ans += (n - (x_max + a - 1) / a) * y_max
  ans += floor_sum(y_max, a, m, (a - x_max % a) % a)

  ans
end

T = gets.to_i

T.times do
  n, m, a, b = gets.split.map(&:to_i)

  puts floor_sum(n, m, a, b)
end


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

using namespace std;

int main()
{
	string i1;
	string i2;

	cin >> i1;
	cin >> i2;
	
	if ((i1[0] != i2[2]) || (i1[1] != i2[1]) || (i1[2] != i2[0])) {
		cout << "NO" << endl;
	} else {
		cout << "YES" << endl;
	}

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  bool app = true;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (!(a % 2 == 1 || a % 3 == 0 || a % 5 == 0)) app = false;
  }
  cout << (app ? "APPROVED" : "DENIED") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
const int NR = 55;
int a[NR];
bool cmp(int a, int b)
{
	return a > b;
}
int main()
{
	int n, k, ans = 0;
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	sort(a + 1, a + 1 + n, cmp);
	for (int i = 1; i <= k; i++)
		ans += a[i];
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
#ifdef LOCAL_TEST
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    vector<string> ans(h);
    rep(i, h) rep(j, w) {
        if(s[i][j] == '#') ans[i] += '#';
        else {
            int cnt = 0;
            REP(k, -1, 2) REP(l, -1, 2) {
                int x = j + l;
                int y = i + k;
                auto isOutOfRange = [](int h, int w, int H, int W) {
                    return h < 0 || h >= H || w < 0 || w >= W;
                };
                if(isOutOfRange(y, x, h, w)) continue;
                if(s[y][x] == '#') cnt++;
            }
            ans[i] += (char)('0' + cnt);
        }
    }
    rep(i, h) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int a,b,c;

int main(void){
	scanf("%d%d%d",&a,&b,&c);
	if(a==b)printf("%d\n",c);
	if(a==c)printf("%d\n",b);
	if(b==c)printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
double A,B;
  cin>>A>>B;
    if(A>B){
	
    cout<<"GREATER\n";
}
    else if(B>A){
	
     cout<<"LESS\n";
 }
   else if(A==B){
    cout<<"EQUAL \n";
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* * * *   * * *   	* * * */
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define ms(a,v) memset(a,v,sizeof a)
/* * * *   * * *   	* * * */
/* *
 *
 * Author: Hamkor a.k.a. OakenSh1eld
 *
 * */
int n, m, x, y;
vector<vector<int>> graph(100010);
vector<int> dis(100010, 0), vis(100010, 0);
vector<int> topsort;
void dfs(int u){
	vis[u] = 1;
	for(auto v : graph[u]) if(!vis[v]) dfs(v);
	topsort.push_back(u);
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>n>>m;
	for(int i=0; i<m; ++i){
		cin>>x>>y;
		graph[x].push_back(y);
	}
	int ans = -1;
	for(int i=1; i<=n; ++i) dfs(i);
	reverse(topsort.begin(), topsort.end());
	for(auto i: topsort){
		for(int k : graph[i]){
			dis[k] = max(dis[k], dis[i] + 1);
			ans = max(ans, dis[k]);
		}
	}
	cout<<ans;
	return 0;
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int cnt[10];

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a[4];
    for(int i=0;i<4;i++){
        cin >> a[i];
        cnt[a[i]]++;
    }
    if(cnt[1] == 1 && cnt[7] == 1 && cnt[9] == 1 && cnt[4] == 1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007

using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int K; cin >> K;
	string s; cin >> s;
	int len = s.size();
	if (len <= K)cout << s << endl;
	else {
		for (int i = 0; i < K; i++) {
			cout << s[i];
		}
		cout << "..." << endl;
	}
}


Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
typedef long long ll;
using namespace std;
const int N=1e5+10;
double a[N];
int main(){
    int n;
    double m,y,tot=0.0;
    
    cin>>n>>m;
    y=0.25/m;

    for(int i=0;i<n;i++){
       cin>>a[i];
       tot+=a[i];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        double x;
        x=1.0*a[i]/tot;
        if(x>=y) ans++;

    }

    if(ans>=m) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    
    long long ret = 0;
    for (int i = 0; i < n; ++i)
    {
        ret += a[i] - 1;
    }
    
    cout << ret << endl;
    
    return 0;
}

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

namespace cswork
{
    class Program
    {
        class Scanner
        {
            string[] s;
            int i;

            char[] cs = new char[] { ' ' };

            public Scanner()
            {
                s = new string[0];
                i = 0;
            }

            public string next()
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();

                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next();
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

            public long nextLong()
            {
                return long.Parse(next());
            }

            public double nextDouble()
            {
                return double.Parse(next());
            }
        }

        public Program() { }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        public static List<long> GeneratePrime(long max)
        {
            long prime;
            double sqrtMax = Math.Sqrt(max);
            var primeList = new List<long>();

            List<long> searchList = new List<long>();
            for (long i = 2; i <= max - 1; i++)
            {
                searchList.Add(i);
            }

            do
            {
                prime = searchList.First();
                primeList.Add(prime);
                searchList.RemoveAll(n => n % prime == 0);
            } while (prime < sqrtMax);

            primeList.AddRange(searchList);

            return primeList;
        }

        void Omame()
        {
            cin = new Scanner();
            int A = cin.nextInt();
            int B = cin.nextInt();
            int C = cin.nextInt();

            if (A == B && A == C)
            {
                Console.WriteLine("No");
            }
            else if (A == B)
            {
                Console.WriteLine("Yes");
            }
            else if (B == C)
            {
                Console.WriteLine("Yes");
            }
            else if (A == C)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }

    }
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<long long int> p(n);
	long long int ans = 0;
	for(int i=0;i<n;i++){
		cin >> p.at(i);
	}
	for(int i=0;i<n;i++){
		if(p.at(i) == i+1){
			if(i != n-1){
				swap(p.at(i),p.at(i+1));
			}
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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


int main()
{
    int n;cin>>n;
    int sum = 0;
    vector<int> p(n);
    for(int i = 0; i<n;i++)cin>>p[i];
    for(int i = 1; i < n - 1; i++){
        int a,b;
        a = max(p[i-1],p[i]);
        a = max(p[i+1], a);
        b = min(p[i-1],p[i]);
        b = min(p[i+1], b);
        if(a != p[i] && b != p[i]) sum++;
    }
    cout << sum << endl;
    return 0;
}

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

int main(){
	int N,Y;
	cin >> N >> Y;
	bool flag = false;
	
	for(int a = 0;a <= N;a++){
		for(int b = 0;b <= N;b++){
			if((N-a-b) >= 0 && 10000*a + 5000*b + 1000*(N-a-b) == Y){
				cout << a << " " <<  b << " " << N-a-b << endl;
				flag = true;
				break;
			}
		}
		if(flag) break;
	}
	if(!flag) cout << -1 << " " << -1 << " " << -1 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int num;
	scanf( "%d", &num );
	
	int ans = 1;
	int count;
	for ( count = 0; count < 8; count++ )
	{
		num >>= 1;
		if ( num <= 0 )
		{
			break;
		}
		ans <<= 1;
	}
	
	printf( "%d\n", ans );
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 510000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
lli gcd(lli num1, lli num2){
    return num2 != 0 ? gcd(num2, num1 % num2) : num1;
}
lli lcm(lli num1, lli num2){
    return num1 / gcd(num1, num2) * num2;
}
lli repow(lli n,lli k,lli m){
  if(k==0)return 1;
  else if(k%2==1)return repow(n,k-1,m)*n%m;
  else{
    lli temp=repow(n,k/2,m);
    return temp*temp%m;
  }
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  Vec(P,lli,N,0);
  rep(i,0,N)cin >> P[i];
  Sort(P);
  Out(P[N/2]-P[N/2-1]);
}

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

using namespace std;

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

  int m = *max_element(a, a+n);
  int s = accumulate(a, a+n, 0);

  bitset<2000*2000+1> ba[2];

  ba[0][0] = true;
  for (int i = 0; i < n; i++) {
      ba[~i & 1] = ba[i & 1];
      ba[~i & 1] <<= a[i];
      ba[~i & 1] |= ba[i & 1];
  }

  for (int i = 0; i <= 2000 * m; i++) {
    if (i * 2 < s) continue;
    if (ba[n & 1][i]) {
        cout << i;
        return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	int n;
	cin >> n;
	int N = n;
	vector<int> div(1000,1);
	for(int i=2;i<=n;i++)
	{
		int I =  i;
		for(int j = 2;j<=i;j++)
		{
			//cout<<i<<':'<<j<<endl;
			while(I%j==0)
			{
				I/=j;
				div[j]++;
			}
		}
	}
	ll ans = 1;
	rep(i,1000)
	{
		//if(i-2<=n)cout<<div[i]<<endl;
		ans*=div[i];
		ans%=1000000007;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

S = input().strip()
Q = int(input())

reverse = False

before = ""
after = ""

for _ in range(Q):
    s = input().strip()
    if s[0] == "1":
        reverse = not reverse
    else:
        _, f, c = s.split()
        if f == "1":
            if reverse:
                after = after + c
            else:
                before = c + before
        else:
            if reverse:
                before = c + before
            else:
                after = after + c

if reverse:
    print(after[::-1] + S[::-1] + before[::-1])
else:
    print(before + S + after)


Measured memory_bytes: 4452
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    String N =sc.next();
    String n[] =N.split("",0);
    for(int i=0;i<N.length();i++){
      if(n[i].equals("7")){System.out.println("Yes");System.exit(0);}
    }
    System.out.println("No");
  }
}

Measured memory_bytes: 35684
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main(){

    long a, b, ans = 1;

    cin >> a >> b;

    if( a * b < 0 || a == 0 || b == 0){
        cout << "Zero" << endl;
        return 0;
    }

    if( a > 0 && b > 0){
        cout << "Positive" << endl;
        return 0;
    }

    if( a < 0 && b < 0){
        if((b - a) % 2 == 0){
            cout << "Negative" << endl;
        }
        else{
            cout << "Positive" << endl;
        }
        return 0;
    }
    return 0;
}


Measured memory_bytes: 256
public class Main {

  private static void solve() {
    int n = ni();

    int[] c = new int[n];
    long[] d = new long[n + 1];
    for (int v : na(n)) {
      v--;
      c[v]++;
      d[c[v]]++;
    }
    long[] sum = new long[n + 1];
    for (int i = 1; i <= n; i++) {
      sum[i] = sum[i - 1] + d[i];
    }

    for (int k = 1; k <= n; k++) {
      int left = 0;
      int right = n + 1;
      while (right - left > 1) {
        int x = (left + right) / 2;
        if (sum[x] >= (long) k * x) {
          left = x;
        } else {
          right = x;
        }
      }
      System.out.println(left);
    }


  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 83212
#include<bits/stdc++.h>
using namespace std;
int main(){
int i,j,k,l,m,n,x=0,y=0;
cin>>n;
int a[n];
for(i=0;i<n;i++){
	cin>>a[i];
}
int dp[n];
if(n>2){
dp[n-1]=0;
dp[n-2]=abs(a[n-1]-a[n-2]);
for(i=n-3;i>=0;i--){
	l=abs(a[i+1]-a[i]);
	m=abs(a[i+2]-a[i]);
dp[i]=min((l+dp[i+1]),(m+dp[i+2]));
}
cout<<dp[0]<<"\n";
}
else{

	k=abs(a[1]-a[0]);
	cout<<k<<"\n";
}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;
int n;

signed main()
{
    cin >> n;
    vector<ll> a(n);
    rep(i, n) { cin >> a[i]; }
    sort(a.begin(), a.end());
    ll ai = a[n - 1], aj = a[0];
    rep(i, n - 1)
    {
        if (abs(a[i] - ai / 2) <= abs(aj - ai / 2)) {
            aj = a[i];
        }
    }
    cout << ai << " " << aj << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define _ << " _ " <<
#define TRACE(x) cerr << #x << " = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
//#define debug
//#define TRACE(x)

using namespace std;

typedef long long llint;

const int MAXN = 200010;

int a[MAXN], bio[MAXN];

int main(void) {
  int n, x;
  scanf("%d %d",&n,&x);
  --x;
  if (x == 0 || x == 2*n-2)
    printf("No\n");
  else {
    memset(a, -1, sizeof(a));
    a[n-2] = x - 1; bio[x - 1] = 1;
    a[n-1] = x; bio[x] = 1;
    a[n] = x + 1; bio[x + 1] = 1;

    if (n >= 3 && (x == 1 || x == 2*n-3)) {
      if (x == 1) {
	a[n-3] = 2*n-3; bio[2*n-3] = 1;
      } else {
	a[n+1] = 1; bio[1] = 1;
      }
    }
    
    int j = 0;
    REP(i, 2*n-1) {
      if (a[i] != -1) continue;
      for (; bio[j]; ++j);
      a[i] = j;
      bio[j] = 1;
    }
    printf("Yes\n");
    REP(i, 2*n-1) printf("%d\n",a[i]+1);
  }
  return 0;
}


Measured memory_bytes: 3200
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner as = new Scanner(System.in);
		int n = Integer.parseInt(as.next());
		int[] t;
		t = new int[n];
		for(int i=0;i<n;i++){
			t[i]  = Integer.parseInt(as.next());
		}
		int m = Integer.parseInt(as.next());
		int[] p,x,l;
		p = new int[m];
		x = new int[m];
		l = new int[m];
		for(int i=0;i<m;i++){
			p[i]  = Integer.parseInt(as.next());
			x[i] = Integer.parseInt(as.next());
			l[i] = 0;
		}
		int a = 0;
		for(int i=0;i<n;i++){
			a += t[i];
		}
		for(int i=0;i<m;i++){
			l[i]  = a-t[p[i]-1]+x[i];
		}
		for(int i=0;i<m;i++){
			System.out.println(l[i]);
		}
	}
}

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

int main(){
  int h,w;

  while(1){
    cin >> h >> w;
    if(!h && !w)break;
    
    vector<string> grid;
    for(int i=0;i<h;i++){
      string tmp;
      cin >> tmp;
      grid.push_back(tmp);
    }

    int ans = 0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(grid[i][j] == '.'){
	  int dx = 1,dy = 1;
	  while(i+dy<h && grid[i+dy][j] == '.')dy++;
	  while(j+dx<w && grid[i][j+dx] == '.')dx++;
	  int tmp = 0;
	  int x = dx;
	  for(int k=0;k<dy;k++){
	    int l;
	    for(l=0;l<x;l++){
	      if(grid[i+k][j+l]=='*'){
		x = min(x,l);
		break;
	      }
	    }
	    tmp = max(tmp,x*(k+1));
	  }
	  //if(ans<tmp)cout << "[" << i << " " << j << "]:" << tmp << endl;
	  ans = max(ans,tmp);
	}
      }
    }
    cout << ans << endl;
  }
}

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

int main(){
	int n, k, x, sum = 0;
	cin >> n >> k;
	for(int i=0; i < n; i++) {
		cin >> x;
		int t = x;
		int s = (k>x) ? k-x : x-k;
		if(t > s)
			t = s;
		sum += t;
	}
	cout << sum*2 << endl;
}


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

int main() {
  int n,m,i,j,p;
  vector<string> s(101),t(101);
  cin >> n;
  for(i=0;i<n;i++){
    cin >> s.at(i);
  }
  cin >> m;
  for(i=0;i<m;i++){
    cin >> t.at(i);
  }
  
  p=0;
  vector<int> a(n,0);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(s.at(i)==s.at(j)){
        a.at(i)++;
      }
    }
    for(j=0;j<m;j++){
      if(s.at(i)==t.at(j)){
        a.at(i)--;
      }
    }
    if(a.at(i)>p){
      p=a.at(i);
    }
  }
  
  cout << p << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
  #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl "\n"
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int ans,n;
void dfs(int x,int a,int b,int c){
  if(x>n)return;
  if(a and b and c)ans++;
	   dfs(10*x+3,1,b,c);
	   dfs(10*x+5,a,1,c);
	   dfs(10*x+7,a,b,1);  	
}
void solve(){
   cin>>n;
   dfs(0,0,0,0);
   cout<<ans<<endl;
}
int32_t main(){
   IOS;
   solve();
   //debug();
  #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
  #endif	
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

const int MAX_N = 100000;

int A[MAX_N];

int partition(int p, int r) {
    int x = A[r];
    int i = p - 1;
    for (int j = p; j < r; ++j) {
        if (A[j] <= x) {
            i++;
            swap(A[i], A[j]);
        }
    }
    swap(A[i + 1], A[r]);
    return i + 1;
}

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

    int q = partition(0, n - 1);

    for (int i = 0; i < n; ++i) {
        if (i)
            printf(" ");
        if (i == q)
            printf("[");
        printf("%d", A[i]);
        if (i == q)
            printf("]");
    }
    printf("\n");

    return 0;
}

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

int main() {
    int x, y;
    
    for (int i = 0; i < 3000; i++) {
        cin >> x >> y;
        if (!(x) && !(y)) {
            break;
        }
        if (x <= y) {
            cout << x << ' ' << y << endl;
        } else {
            cout << y << ' ' << x << endl;
        }
    }
}


Measured memory_bytes: 3092
n = int(input())
p = list(map(lambda x: int(x),input().split()))

min_list = [p[0]]
count = 1
for i in range(1,n) :
    if p[i] < min_list[i - 1] :
        min_list.append(p[i])
    else :
        min_list.append(min_list[i - 1])

for j in range(1,n) :
    if p[j] <= min_list[j - 1] :
        count += 1

print(count)


Measured memory_bytes: 25716
import java.util.Scanner;

public class Main {

	public static int N;
	public static int M;
	public static int[] S;
	public static int[] C;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		M = sc.nextInt();
		S = new int[M];
		C = new int[M];
		for (int i = 0; i < M; i++) {
			S[i] = sc.nextInt() - 1;
			C[i] = sc.nextInt();
		}
		System.out.println(solve());
	}

	public static boolean ok(String x) {
		if (x.length() != N) {
			return false;
		}
		for (int i = 0; i < M; i++) {
			int s = Integer.valueOf(x.substring(S[i], S[i] + 1));
			if (s != C[i]) {
				return false;
			}
		}
		return true;
	}

	public static String solve() {
		for (int i = 0; i < 1000; i++) {
			String x = String.valueOf(i);
			if (ok(x)) {
				return x;
			}
		}
		return "-1";
	}

}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n, m; cin >> n >> m;
  cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
}

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

#define N 1005
#define MP make_pair
typedef long long LL;
const int mod = 1e9 + 7;


int main()
{
	//freopen("in.txt", "r", stdin);
	
	int n, k;
	cin >> n >> k;
	
	puts((n+1)/2 >= k? "YES": "NO"); 
	
	return 0;	
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
ll dp[100001];
int q(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int main(void) {
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  PRN(a+b+c);
  return 0;
}


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

int main(){
    int N, L;
    cin >> N >> L;
    int R = L+N-1;
    int sum = (L+R)*N/2;
    if(L>0){
        sum -= L;
    }else if(R<0){
        sum -= R;
    }
    printf("%d\n", sum);
    return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int x, y;
  cin >> x >> y;
  cout << x + y / 2 << endl;
}


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

string s;
string old = "AKIHABARA";

int main() {
	cin >> s;
	for (int mark = 0; mark < 16; mark++) {
		int i = mark;
		string cur = "";
		if (i & 1) {
			cur.push_back('A');
		}
		i >>= 1;
		cur.append("KIH");
		if (i & 1) {
			cur.push_back('A');
		}
		i >>= 1;
		cur.append("B");
		if (i & 1) {
			cur.push_back('A');
		}
		i >>= 1;
		cur.append("R");
		if (i & 1) {
			cur.push_back('A');
		}
		if (cur == s) {
			printf("YES");
			return 0;
		}
	}
	printf("NO");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	char card[52],card2[4]={'S','H','C','D'};
	int kazu[52],maisu,i,t,r=0,y,nai=0;
	scanf("%d",&maisu);
	for(i=0;i<maisu;i++){
		scanf("%s %d",&card[i],&kazu[i]);
	}
	for(i=0;i<4;i++){
			for(t=1;t<=13;t++){
				for(y=0;y<maisu;y++){
					if(card2[i]==card[y]&&t==kazu[y]){
					r++;
					
					}
				
				}
					if(r!=1){
						printf("%c %d\n",card2[i],t);
						
					}
				r=0;
			}
		
		}
	
	return 0;
}

Measured memory_bytes: 2732