akhauriyash/Code-Regression huggingface dataset:
import sys
h, w = [int(i) for i in sys.stdin.readline().split()]
s_ls = []
target = []
for i in range(h):
    s = sys.stdin.readline().strip()
    for j, _s in enumerate(s):
        if _s == ".":
            target.append(i * h + j)
    s_ls.append(s)

len_target = len(target)
already = set()
def wfs(x, y):
    res = 0
    for plus_x, plus_y in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
        next_x = max(0, min(w - 1, x + plus_x))
        next_y = max(0, min(h - 1, y + plus_y))
        if (next_y, next_x) not in already and s_ls[next_y][next_x] == ".":
            already.add((next_y, next_x))
            res = max(res, wfs(next_x, next_y) + 1)
    return res

best = 0
for start in range(h * w):
    start_x, start_y = start % w, start // w
    if s_ls[start_y][start_x] == "#":
        continue
    already = {(start_y, start_x)}
    ls = {start_y * w + start_x : 0}
    que = [(start_y, start_x, 0)]
    res = 0
    while len(que) > 0:
        y, x, dis = que.pop(0)
        for plus_x, plus_y in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
            next_x = max(0, min(w - 1, x + plus_x))
            next_y = max(0, min(h - 1, y + plus_y))
            if (next_y, next_x) not in already and s_ls[next_y][next_x] == ".":
                already.add((next_y, next_x))
                que.append((next_y, next_x, dis+1))
                ls[next_y * w + next_x] = dis + 1
                res = max(res, dis + 1)
        if len(already) == len_target:
            break
    best = max(best, res)
print(best)

Measured memory_bytes: 62300
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

vi bin(ll x){
    if(x == 0) return {0};
    vi ans;
    while(x != 0){
        ans.pb(x % 2);
        x /= 2;
    }
    return ans;
}

void printv(vi v){
    for(auto i : v) cout << i;
    cout << endl;
}

void Main(){
	ll a, b;
	cin >> a >> b;
	if(a > 0) a--;
	
	// printv(bin(a));
	// printv(bin(b));
	
	// 0 から a までの XOR を求める　
	// mod 4 で a = 0 のとき a
	// a = 1 のとき 1
	// a = 2 のとき a + 1
	// a = 3 のとき 0
	
	auto f = [&](ll x){
	    switch(x%4){
	        case 0: return x; break;
	        case 1: return (ll)1; break;
	        case 2: return x+1; break;
	        case 3: return (ll)0; break;
	    }
	};
	
    cout << (f(a) ^ f(b)) << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mo 1000000007
#define add(a,b) (a+b<mo)?(a+=b):(a+=b-mo)
using namespace std;
int f[4010][4010];
int main()
{
	int n,m,k;scanf("%d%d%d",&n,&m,&k);
	f[0][0]=1;
	for (int i=1;i<=4000;i++)
	{
		for (int j=0;j<=4000;j++)
		{
			if (i) f[i][j]=f[i][j-1];
			add(f[i][j],f[i-1][j]);
			if (j>=k) add(f[i][j],mo-f[i-1][j-k]);
			//cerr<<i<<' '<<j<<' '<<f[i][j]<<endl;
		}
	}
	int ans=0;
	for (int i=1;i<=m;i++) if ((m-i)%(k-1)==0)
	{
		//cerr<<(n+i-1)/(k-1)<<endl;
		add(ans,f[(n+i-1)/(k-1)][i]);
	}
	printf("%d\n",ans);
} 

Measured memory_bytes: 62848
#include <iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s=="abc"||s=="acb"||s=="bac"||s=="bca"||s=="cab"||s=="cba") cout << "Yes" << "\
\n";
  else cout << "No" << "\n";
  return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
using P = pair <int, int>;
 
 
int main() {
    int w,h,n;
    cin >> w>> h >> n;
    int Xh =0,Xl=w,Yh=0,Yl=h;
    rep(i,n){
        int x,y,a;
        cin >> x >> y >>a;
        if(a==1){
            Xh = max(x,Xh);
        }
        else if(a==2){
            Xl=min(x,Xl);
        }
        else if(a==3){
            Yh = max(y,Yh);
        }
        else Yl = min (y,Yl);
    }
    if(Yl-Yh<=0||Xl-Xh<=0) cout <<0 << endl;
    else cout << (Yl-Yh)*(Xl-Xh) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll ret = 0;
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N){
        cin >> A[i];
    }
    rep(i, N - 1){
        ret += A[i] / 2;
        A[i] %= 2;
        if(A[i] > 0 && A[i + 1] > 0){
            ret++;
            A[i]--, A[i + 1]--;
        }
        
    }
    ret += A[N - 1] / 2;
    
    output(ret, 0);
    
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int	num_of_diviser(int n)
{
	int	count = 0, i = 1;

	while (i * i < n)
	{
		if (n % i == 0)
			count += 2;
		i++;
	}
	if (i * i == n)
		count++;
	return (count);
}

int	main(void)
{
	int	N, i, res = 0, tmp;

	scanf("%d", &N);
	for (i = 1; i < N; i++)
	{
		res += num_of_diviser(i);
	}
	printf("%d\n", res);
	return (0);
}

Measured memory_bytes: 1732
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
typedef long double ld;

constexpr int INF = 1e9;
constexpr ll BIGINF = 1e18;
constexpr double EPS = 1e-16;

void preambule() {
  cin.tie(0);
  cout.precision(16);
  cout << fixed;
}

int n;

vector<int> a;

void input() {
  cin >> n;

  a.resize(n);
  for (auto&& i : a) {
    cin >> i;

    ++i;
  }
}

void solve() {
  int r = 1e5 + 2;

  vector<int> ans(r);

  for (auto&& i : a) {
    ans[i - 1]++;
    ans[i + 1]++;
    ans[i]++;
  }

  cout << *max_element(ans.cbegin(), ans.cend()) << '\n';
}

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  preambule();
  input();
  solve();
}


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

#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,n,a) for (int i=n-1;i>=a;i--)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define SZ(x) ((x).size())
#define i0(x) memset(x,0,sizeof(x))
#define i1(x) memset(x,-1,sizeof(x))
#define el cout<<endl
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define MOD 1000000007
#define N 100000
#define M 500000

#define trace1(x)                    cout <<#x<<": "<<x<< endl;
#define trace2(x, y)                 cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)              cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)           cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;

typedef long long ll;
typedef long double lld;

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

ll powmod(ll a,ll b) {ll res=1;a%=MOD; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    lld n;
    cin>>n;
    cout<<fixed<<n*(6.28318530717958623200);
    return 0;
}

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

int main() {
  char b;
  cin >> b;
  if (b == 'A') cout << 'T' << endl;
  else if (b == 'T') cout << 'A' << endl;
  else if (b == 'C') cout << 'G' << endl;
  else cout << 'C' << endl;
}


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

string solve(string s, string t) {
  if(s.size() + 1 != t.size()) {
    return "No";
  }
  for(int i=0;i<(int) s.size(); i++) {
    if(s[i] != t[i]) {
      return "No";
    }
  }
  return "Yes";
}

int main() {
  string s;
  string t;
  cin >> s >> t;
  cout << solve(s, t);
}

Measured memory_bytes: 3604
n=int(input())
s='abcdefghij'
def f(string):
  r=[]
  for i in range(len(string)):
    m=0
    for j in string[i]:
      if ord(j)-97 > m:
        m=ord(j)-97
    for j in range(m+2):
      r.append(string[i] + s[j])
  return r
string=['a']
for i in range(n-1):
  string=f(string)
for a in string:
  print(a)

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

using namespace std;

/* alias */
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using vpii = vector<pii>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

/* repetition */
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define repr(i, n) for(int i=(n-1);i>=0;--i)
#define repre(i, n) for(int i=(n);i>=0;--i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define FORR(i, a, b) for(int i=(b-1);i>=(a);--i)
#define FORRE(i, a, b) for(int i=(b);i>=(a);--i)

int main() {
    int A,B,ans=0;
    cin >> A >> B;
    if (B==1){
        cout << 0 <<endl;
    }
    else{
        rep(i, 1000)
        {
            if (B <= A) {
                ans++;
                break;
            }
            else{
                B -= A-1;
                ans++;
            }
        }
        cout << ans << endl;
    }
    
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = list(map(int, input().split()))

C = list(dict(Counter(A)).items())
C.sort(reverse=True)
use = []
ans = 0
for length, num in C:
    if num >= 4:
        ans = max(length**2, ans)
        use.append(length)
    elif num >= 2:
        use.append(length)

    if len(use) >= 2:
        ans = max(ans, use[-1]*use[-2])

print(ans)


Measured memory_bytes: 21668
#include <iostream>
#include <cstdio>
#include <set>

using namespace std;

int main() {
	int a;

	set<int> s;
	for (int i = 0; i < 3; i++) {
		cin >> a;
		s.insert(a);
	}

	cout << s.size() << endl;
	return 0;
}


Measured memory_bytes: 256
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int m, n;
int f[135][15];
map<vector<int>, int> mem;

int dfs(vector<int>& S) {
  if (S.size() <= 1) return 0;
  if (mem[S]) return mem[S];

  int res = m;
  rep(i, m) {
    vector<int> left, right;
    for (int v: S) {
      if (f[v][i]) left.push_back(v);
      else right.push_back(v);
    }
    if (left.empty() || right.empty()) continue;
    chmin(res, 1 + max(dfs(left), dfs(right)));
  }
  return mem[S] = res;
}


void solve() {
  mem.clear();

  vector<int> a;
  rep(i, n) a.push_back(i);
  cout << dfs(a) << '\n';
}

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

  while (cin >> m >> n, m && n) {
    rep(i, n) {
      string s;
      cin >> s;
      rep(j, m) f[i][j] = s[j] - '0';
    }

    solve();
  }

  




  
  return 0;
}


Measured memory_bytes: 5284
def main():
    import sys
    input=sys.stdin.readline
    import math
    a,b,c,d=map(int,input().split())
    x=math.ceil(c/b)
    y=math.ceil(a/d)
    if y<x:
        print("No")
    else:
        print("Yes")
if __name__ == '__main__':
    main()

Measured memory_bytes: 62172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H,W;
  cin >> H >> W;
  int h,w;
  cin >> h >> w;
  
  cout << H*W - (w * H + W*h - w*h) << endl;
  return 0;
 
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<vector<int> > edge(N);
  int a, b;
  for(int i=0;i<N-1;++i) {
    cin>>a>>b;
    a--;
    b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  vector<int> c(N);
  for(int i=0;i<N;++i) cin>>c[i];
  sort(c.begin(), c.end(), greater<int>());
  int ans = 0;
  for(int i=0;i<N-1;++i) ans += c[N-1-i];
  queue<int> que;
  int state;
  int index = 0;
  que.push(0);
  map<int, int> amap;
  while(!que.empty()) {
    state = que.front();que.pop();
    amap[state] = c[index];
    index++;
    for(int i=0;i<edge[state].size();++i) {
      if(amap[edge[state][i]]>0) continue;
      que.push(edge[state][i]);
    }
  }
  cout<<ans<<endl;
  for(int i=0;i<N;++i) cout<<amap[i]<<" ";
  cout<<endl;
}



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

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    long long M, N, a;
    a = 0;
    cin >> M;
    for(int j = 1;j < M; j++ ){
      N = M - j;
      const auto &pf = prime_factorize(N);
      long long res = 1;
      for (auto p : pf) res *= p.second + 1;
      a += res;
    }
    cout << a << endl;
} 

Measured memory_bytes: 3608
#create date: 2020-07-05 10:13

import sys
stdin = sys.stdin

mod = 10**9 + 7

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    a = na()
    ans = 0
    for i in range(61):
        cnt = 0
        for ai in a:
            if (ai >> i) & 1:
                cnt += 1
        ans += ((cnt * (n - cnt)) * 2**i) % mod
    ans %= mod
    print(ans)


if __name__ == "__main__":
    main()

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

using namespace std;

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

    cin >> N >> K;

    if (K == 1) {
        cout << 0 << '\n';
    } else {
        cout << N - K << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
// At Corder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <algorithm>
#include <iostream>
using namespace std;
#include <vector>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using p = pair<int, int>;//<key,value>

int main()
{
string s;
cin>>s;
if(s=="ABC")
	cout<<"ARC"<<endl;
else cout<<"ABC"<<endl;

	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント:
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


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

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
char A[6011], B[6011];
int sums[6011];
int prv[6011];
int nxt[6011];
const int INF = 1<<29;

int solve() {
    REP (i, N) B[i+N+N] = B[i+N] = B[i];
    REP (i, N*3) sums[i+1] = sums[i] + B[i] - '0';

    prv[0] = -INF;
    REP (i, N*3) {
	if (B[i] == '1') prv[i] = i;
	prv[i+1] = prv[i];
    }

    nxt[3*N-1] = INF;
    for (int i=3*N; i--;) {
	if (B[i] == '1') nxt[i] = i;
	if (i) nxt[i-1] = nxt[i];
    }

    int ret = INF;
    REP (s, N) {
	vector<pair<int, int> > v;
	int add = 0;
	REP (i, N) {
	    if (A[i] != B[i+s]) {
		add++;
		if (sums[i+s+1] - sums[i]) {
		} else {
		    int l = (N+i) - prv[N+i];
		    int r = nxt[i+s] - (i+s);
		    v.push_back(make_pair(l*2, r*2));
		}
	    }
	}

	sort(v.begin(), v.end());
	int m = v.size();
	for (int i=m-2; i>=0; i--) {
	    amax(v[i].second, v[i+1].second);
	}

	REP (i, m-1) {
	    amin(ret, s + add + v[i].first + v[i+1].second);
	}
	if (m) {
	    amin(ret, s + add + v[0].second);
	    amin(ret, s + add + v.back().first);
	} else {
	    amin(ret, s + add);
	}
    }
    return ret;
}

void MAIN() {
    scanf("%s%s", A, B);
    N = strlen(A);

    if (count(B, B+N, '1') == 0) {
	if (count(A, A+N, '1')) {
	    puts("-1");
	} else {
	    puts("0");
	}
	return;
    }

    int ans = solve();
    reverse(A, A+N);
    reverse(B, B+N);
    amin(ans, solve());
    printf("%d\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
int MOD;
int mod_pow(int x,int n,int mod){
  int res=1LL;
  while(n>0){
    if(n&1) (res*=x)%=mod;
    (x*=x)%=mod;
    n>>=1;
  }
  return res;
}
int mod_inverse(int x,int mod){
  return mod_pow(x,mod-2,mod);
}
int flag;
int expression(string s,int&p);
int term(string s,int&p);
int factor(string s,int&p);
int number(string s,int&p);

int expression(string s,int&p){
  int res=term(s,p);
  while(p<(int)s.size()){
    if(s[p]=='+'){
      p++;
      (res+=term(s,p))%=MOD;
      continue;
    }
    if(s[p]=='-'){
      p++;
      (res+=MOD-term(s,p))%=MOD;
      continue;
    }
    if(flag) return 0;
    break;
  }
  return res;
}

int term(string s,int&p){
  int res=factor(s,p);
  while(p<(int)s.size()){
    if(s[p]=='*'){
      p++;
      (res*=factor(s,p))%=MOD;
      continue;
    }
    if(s[p]=='/'){
      p++;
      int tmp=factor(s,p);
      if(tmp==0){
	flag=1;
	break;
      }
      (res*=mod_inverse(tmp,MOD))%=MOD;
      continue;
    }
    if(flag) return 0;
    break;
  }
  return res;
}

int factor(string s,int&p){
  int res;
  if(s[p]=='('){
    p++;
    res=expression(s,p);
    p++;
  }else{
    res=number(s,p);
  }
  return res;
}

int number(string s,int&p){
  int res=0;
  while(p<(int)s.size()&&isdigit(s[p]))
    res=res*10+s[p++]-'0';
  return res;
}

signed main(){
  string s;
  while(getline(cin,s),s[0]!='0'){
    int latte=s.find(':');
    string x=s.substr(0,latte);
    //cout<<latte<<": "<<x<<endl;
    MOD=stoll(x);
    s.erase(s.begin(),s.begin()+latte+1);
    string t;
    for(int i=0;i<(int)s.size();i++) if(s[i]!=' ') t+=s[i];
    int p=0;
    flag=0;
    int ans=expression(t,p);
    if(flag) cout<<"NG"<<endl;
    else cout<<t<<" = "<<ans<<" (mod "<<MOD<<")"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3436
#include<stdio.h>
int main(void){
    int a[101][101],b,r,c,i,j,d,e,f,g,h;
    d=0;
    e=0;
    f=0;
    scanf("%d%d",&r,&c);
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
                scanf("%d",&b);
            a[i][j]=b;
        }
    }
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            printf("%d ",a[i][j]);
            d=d+a[i][j];
        }
        printf("%d\n",d);
        e=e+d;
        d=0;
    }
     for(i=0;i<c;i++){
        for(j=r-1;j>-1;j--){
            f=f+a[j][i];
        }
        printf("%d ",f);
        f=0;
     }
    printf("%d\n",e);
 
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
typedef long long ll;
#define N 200020
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,a[N],b[N];
ll ans;
priority_queue<pair<int,int> > q;
#define las(x) (x==1?n:(x-1))
#define nxt(x) (x==n?1:(x+1))
#define NO !printf("-1\n")
int main(){
	n=read();
	for(int i=1;i<=n;++i){
		a[i]=read();
	}
	for(int i=1;i<=n;++i){
		b[i]=read();
	} 
	for(int i=1;i<=n;++i){
		if(a[i]^b[i])q.push(make_pair(b[i],i));
	}
	while(!q.empty()){
		int u=q.top().second;
		q.pop();
		int s=b[las(u)]+b[nxt(u)];
		if(s>=b[u])return NO; 
		if(s<=a[u]){
			if((b[u]-a[u])%s)return NO;
			ans+=(b[u]-a[u])/s;
		}
		else{
			ans+=b[u]/s;
			b[u]%=s;
			if(b[u]<a[u])return NO;
			else if(b[u]>a[u]){
				q.push(make_pair(b[u],u));
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

bool isprime(int x){
  for(int p=2;p*p<=x;p++){
    if(x%p==0)return false;
  }
  return true;
}

int main(){
  int n;
  cin>>n;
  vi ps[5];
  FOR(i,2,55556){
    if(!isprime(i))continue;
    ps[i%5].push_back(i);
  }
  REP(i,5)if(ps[i].size() >= n){
    REP(j,n)printf("%d%c",ps[i][j],j<n-1?' ':'\n');
    return 0;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define INF 0x3f3f3f3f
typedef long long ll;
using namespace std;

int main()
{
	IO;
	double l;
	cin>>l;
	printf("%.10lf\n",l*l*l/27.0);
 	return 0;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m;
string s;
int main(){
	cin >> s;
	if(s[0] == s[2]) puts("Yes");
	else puts("No");
}

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

int main(){
  string s;
  cin >> s;
  
  int ans = 0;
  if(s[0] == 'o') ans++;
  if(s[1] == 'o') ans++;
  if(s[2] == 'o') ans++;
  
  cout << 700 + 100 * ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  cin >> N;
  
  vector<int> p(N);
  
  for(int i = 0; i < N; i++){
    cin >> p.at(i);
  }
  
  int count = 0;
  
  for(int i = 1; i < N - 1; i++){
    
    bool a = p.at(i - 1) < p.at(i);
    bool b = p.at(i) < p.at(i + 1);
    bool c = p.at(i - 1) > p.at(i);
    bool d = p.at(i) > p.at(i + 1);
    bool x = a && b;
    bool y = c && d;
    
    if(x || y){
      count++;
    }
  }
  
  cout << count << endl;
}

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

int main()
{
  int n;cin>>n;
  vector<int> a(n);
  int i;
  for(i=0;i<n;i++)cin>>a.at(i);
  vector<int> count(n,0);
  count.at(0)=1;
  long long ans=3;
  for(i=1;i<n;i++)
  {
    if(a.at(i)==0)
    {
      if(count.at(0)>=3)ans=0;
      if(count.at(0)==1)ans=ans*2%MOD;
      count.at(0)++;
    }
    else
    {     
      if(count.at(a.at(i)-1)<count.at(a.at(i)))ans=0;
      if(count.at(a.at(i))>=3)ans=0;
      ans=ans*(count.at(a.at(i)-1)-count.at(a.at(i)))%MOD;
      count.at(a.at(i))++;
    }
  }
  if(a.at(0)!=0)ans=0;
  cout<<ans<<endl;
}


Measured memory_bytes: 1152
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())


ans = 0
commands = [''] * N
for i, t in enumerate(T):
    if t == 'r':
        command = 'p'
        point = P

    elif t == 's':
        command = 'r'
        point = R

    elif t == 'p':
        command = 's'
        point = S

    if (i - K >= 0) and (commands[i -  K] == command):
        command = ''
        point = 0

    ans += point
    commands[i] = command

print(ans)

Measured memory_bytes: 10440
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)
using namespace std;
using Weight = int;
using Array = vector<int>;
using Matrix = vector<Array>;
constexpr int INF = 1000000000;


pair<Weight, Array> hungarian(const Matrix &m) {
  int n = m.size();
  int p, q;
  Array fx(n, INF), fy(n, 0);
  vector<int> x(n, -1), y(n, -1);
  for (int i = 0; i < n; ) {
    vector<int> t(n, -1), s(n+1, i);
    for (p = q = 0; p <= q && x[i] < 0; ++p)
      for (int k = s[p], j = 0; j < n && x[i] < 0; ++j)
        if (fx[k] + fy[j] == m[k][j] && t[j] < 0) {
          s[++q] = y[j], t[j] = k;
          if (s[q] < 0)
            for (p = j; p >= 0; j = p)
              y[j] = k = t[j], p = x[k], x[k] = j;
        }
    if (x[i] < 0) {
      Weight d = INF;
      for (int k = 0; k <= q; ++k)
        for (int j = 0; j < n; ++j)
          if (t[j] < 0) d = min(d, fx[s[k]] + fy[j] - m[s[k]][j]);
      for (int j = 0; j < n; ++j) fy[j] += (t[j] < 0 ? 0 : d);
      for (int k = 0; k <= q; ++k) fx[s[k]] -= d;
    } else ++i;
  }
  Weight ret = 0;
  REP(i,n) ret += m[i][x[i]];
  return make_pair(ret, x);
}

int main() {
  int n;
  cin>>n;
  Matrix w(n, Array(n));
  REP(i,n)REP(j,n) cin >> w[i][j];
  Matrix e(n, Array(n));
  REP(i,n)REP(j,n) cin >> e[i][j];
  vector<string> m(n);
  Matrix mat(n, Array(n));
  int cost = 0;
  REP(i,n) {
    cin>>m[i];
    REP(j,n) {
      if (m[i][j] == 'o') {
        mat[i][j] = 1000 + e[i][j];
        cost += e[i][j];
      } else {
        mat[i][j] = 1000 - w[i][j];
      }
    }
  }
  auto res = hungarian(mat);
  cout << (n*1000 - res.first + cost) << endl;
  int cnt = 0;
  stringstream ss;
  REP(i,n)REP(j,n) {
    if (m[i][j] == 'o') {
      if (res.second[i] != j) {
        ss << (i+1) << ' ' << (j+1) << " erase" << endl;
        ++cnt;
      }
    } else {
      if (res.second[i] == j) {
        ss << (i+1) << ' ' << (j+1) << " write" << endl;
        ++cnt;
      }
    }
  }
  cout << cnt << endl;
  cout << ss.str() << flush;
  return 0;
}

Measured memory_bytes: 3308
import java.util.Scanner;

public class Main {
	private Scanner sc;

	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);

		while (sc.hasNextLine()) {
			double q = Double.parseDouble(sc.nextLine());
			if (q == -1.0) break;
			
			double x = q / 2;
			while (Math.abs(x * x * x - q) >= (q * 1E-5)) {
				x = x - (x * x * x - q) / (3 * x * x);
			}
			
			System.out.println(x);
		}
	}
}

Measured memory_bytes: 26132
#include <iostream>
#include<set>
#include <vector>
#include <algorithm>
using namespace std;
const long long INF = 100000000;

const int prime[25] = {
    2, 3, 5, 7, 11,
    13, 17, 19, 23, 29,
    31, 37, 41, 43, 47,
    53, 59, 61, 67, 71,
    73, 79, 83, 89, 97};

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

    vector<int> cnt(25, 0);

    // 75 -> (a1 + 1) * (a2 + 1) * (a3 + 1) + ...
    //75 -> 3*5^2 - -> 25*3, 15*5, 75, 3*5*5
    //a = (24,2) / (14, 4) / (74) / (2, 4, 4)

    for (int j = 1; j <= N; j++){
        int t = j;
        for (int i = 0; i < 25; i++){
            while(t % prime[i] == 0){
                t = t / prime[i];
                cnt[i]++;
            }
        }
    }

    int res = 0;

    // a = 75
    for (int i = 0; i < 25; i++){
        if(cnt[i] >= 74) res++;
    }

    // a =(24, 2), (4,14)
    for (int i = 0; i < 25; i++)
    {
        for (int j = 0; j < 25; j++)
        {
            if(i == j) continue;
            if(cnt[i] >= 2 && cnt[j] >= 24) res++;
            if(cnt[i] >= 4 && cnt[j] >= 14) res++;
        }
    }

    // a = (2,4,4)
    for (int i = 0; i < 25; i++)
    {
        for (int j = 0; j < 25; j++)
        {
            for (int k = j+1; k < 25; k++)
            {
                if(i == j || i == k) continue;
                if(cnt[i] >= 2 && cnt[j] >= 4 && cnt[k] >= 4) res++;
            }   
        }
    }

    cout << res << endl;
}

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


int main() {
  string s; cin >> s;
  int ans[1000] = {0};
  for(int i = 0; i < s.size(); i++){
    ans[s[i]]++;
  }
  bool j = true;
  for(int i = 0; i < 1000; i++){
    if(ans[i]%2!=0)j = false;
  }
  if(j) cout << "Yes" << endl;
  else cout <<"No" << endl;
}


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

using namespace std;
using ll=long long;

int t;
const ll INF=1e18L+5;

void test_case(){
    int n;
    cin>>n;
    vector<ll>a(n);
    for(int i=0; i<n; i++)cin>>a[i];
    vector<vector<ll>>dp(n+1,vector<ll>(n+1,INF));
    for(int l=n-1; l>=0; l--){
        for(int r=l; r<n; r++){
            ll sm=0;
            for(int i=l; i<=r; i++)sm+=a[i];
            if(l==r)dp[l][r]=0;
            for(int i=l; i<r; i++){
                dp[l][r]=min(dp[l][r], dp[l][i]+dp[i+1][r]+sm);
            }
        }
    }
    cout<<dp[0][n-1]<<endl;
}

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

    t=1;
    while(t--){
        test_case();
    }

    return 0;
}

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

#define INFTY 1000000000
#define n_max 500000

void merge(int *,int,int,int);
void mergeSort(int *,int,int);
int count=0;

int main(){
  int i,n,*p;
  int S[n_max];

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&S[i]);

  p=&S[0];
  mergeSort(p,0,n);
  
  for(i=0;i<n-1;i++){
    printf("%d ",S[i]);
  }
  printf("%d\n",S[i]);
  printf("%d\n",count);
  
  return 0;
}

void merge(int *A,int left,int mid,int right){
  int n1,n2,i,j,k,*L,*R;

  n1=mid-left;
  n2=right-mid;

  L=(int *)malloc(sizeof(int)*(n1+1));
  R=(int *)malloc(sizeof(int)*(n2+1));

  for(i=0;i<n1;i++) L[i]=A[left+i];
  for(i=0;i<n2;i++) R[i]=A[mid+i];
  
  L[n1]=INFTY;
  R[n2]=INFTY;

  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
      count++;
    }
    else{
      A[k]=R[j];
      j++;
      count++;
    }
  }
}

void mergeSort(int *A,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}



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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

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

int main(){
    ll x,k,d;
    cin>>x>>k>>d;

    if(x<0)x=abs(x);

    if(k<=x/d){
        cout<<x-d*k<<endl;
        return 0;
    }

    ll X=x%d;
    k-=x/d;

    if(k%2==0)cout<<X<<endl;
    else cout<<abs(X-d)<<endl;

}


Measured memory_bytes: 3592
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		String S = sc.next();
		String S2 = new String(S);
		int cnt = 0;
		while(S2.contains("()")) {
			S2 = S2.replace("()", "");
		}
		StringBuilder ans = new StringBuilder(S);
		for(int i = 0; i < S2.length(); i++) {
			if(S2.substring(i, i + 1).equals(")")) {
				ans.insert(0, "(");
			} else {
				ans.append(")");
			}
		}
		System.out.println(ans.toString());
	}
}


Measured memory_bytes: 23892
#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 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  int n, res = INF;
  cin >> n;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  sort(ALL(a));

  for(int i = a[0]; i <= a[n - 1]; i++) {
    int cost = 0;
    REP(j, n) cost += (a[j] - i) * (a[j] - i);
    res = min(res, cost);
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
if N == 1:
    ans = [0]
else:
    ans = [1]
mark = [0]

for _ in range(N-1):
    ans.append(0)
    mark.append(0)

for _ in range(M):
    s,c = map(int,input().split())
    if s == 1 and c == 0 and N != 1:
        print(-1)
        exit()
    elif mark[s-1] == 1 and ans[s-1] != c:
        print(-1)
        exit()
    else:
        ans[s-1] = c
        mark[s-1] = 1
if N == 1:
    a = ans[0]
if N == 2:
    a = ans[0] * 10 + ans[1]
if N == 3:
    a = ans[0] * 100 + ans[1] * 10 + ans[2]
print(a)

Measured memory_bytes: 3064
#include <iostream>
#include <string.h>
using namespace std;

int main()
{
    int height, width, l;
    int N, M;
    int i = 0;
    string line;
    cin >> N;
    int T[N];
    // スペース区切りで一個ずつ取るのをN回繰り返す
    for (int i = 0; i < N; i++)
    {
        cin >> T[i];
    }
    cin >> M;

    int P[M], X[M];
    for (int i = 0; i < M; i++)
    {
        cin >> P[i] >> X[i];
    }
    for (int i = 0; i < M; i++)
    {
        int sum = 0;
        for (int j = 0; j < N; j++)
        {
            if (j == P[i] - 1)
            {
                sum += X[i];
                // cout << "if" << X[i] << endl;
            }
            else
            {
                sum += T[j];
                // cout << "else" << T[j] << endl;
            }
        }
        cout << sum << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
import Data.List

main = readLn >>= print . pairs
pairs n = length . filter (odd . foldl1' subtract) . 
          combination 2 $ [1 .. n] where
combination 0 _         = [[]]
combination _ []        = []
combination n (x : xs)  = map (x :) (combination (n - 1) xs) ++
                          combination n xs 


Measured memory_bytes: 892
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define REPI(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) REPI(i,0,n)

typedef long long ll;

int SURP = 1000000007;

int ctoi(char c){
	int r = c - '0';
	return r;
}

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

	string sN = to_string(N);
	int sNLen = sN.length();
	int ret = 0;

	REP(i,sNLen-1){
		int temp = 0;
		if(sN[i] != '0'){
			REP(j,i){
				temp += ctoi(sN[j]);
			}
			temp += ctoi(sN[i]) - 1;

			REPI(j,i+1,sNLen){
				temp += 9;
			}
			if (ret < temp) ret = temp;
		}
	}

	int temp = 0;
	REP(j,sNLen){
		temp += ctoi(sN[j]);
	}
	if (ret < temp) ret = temp;



	cout << ret << endl;
	return 0;
}

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

using namespace std;

int main() {

	uint64_t N, M;
	cin >> N >> M;

	vector<uint64_t>H;
	vector<uint64_t>mount(N,1);

	for (uint64_t i = 0; i < N; i++) {
		uint64_t h;
		cin >> h;
		H.push_back(h);
	}

	for (uint64_t i = 0; i < M; i++) {
		uint64_t A, B;
		cin >> A >> B;
		A = A - 1, B = B - 1;

		if (H[A] > H[B]) {
			mount[B] = 0;
		}
		else if (H[A] < H[B]) {
			mount[A] = 0;
		}
		else {
			mount[A] = 0; 
			mount[B] = 0;
		}

	}
	uint64_t count = 0;
	for (uint64_t i = 0; i < N; i++) {
		count += mount[i];
	}
	
	cout << count;
}

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

int x,y;

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

int main(){
	cin >> x >> y;
	int g = gcd(x,y);
	int p = x / g;
	int blk = x / p;

	cout << 1 + x + y - blk << endl;

	return 0;
}



Measured memory_bytes: 3116
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

void solve(int n,int a,int b)
{
    if(abs(b-a)%2==1)
    {
        puts("Borys");
    }
    else
    {
        puts("Alice");
    }
}
int main()
{
    int n,a,b;
    while(scanf("%d %d %d",&n,&a,&b)!=EOF)
    {
        solve(n,a,b);
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>
int main()
{
   long int k,b,c,i;
   char a[100];
   gets(a);
   k=b=c=0;
   for(i=0;i<strlen(a);i++)
   {
       if(a[i]=='a')
       {
           k=1;
       }
       if(a[i]=='b')
       {
           b=1;
       }
       if(a[i]=='c')
       {
           c=1;
       }
   }
if(k==1 && b==1 && c==1)
{
    printf("Yes");
}else{
    printf("No");
}
  
     return 0;
}

Measured memory_bytes: 128
from collections import Counter
n = int(input())
d = list(map(int,input().split()))
c = Counter(d)
m = int(input())
t = list(map(int,input().split()))

for i in t:
	if c[i] == 0:
		print("NO")
		exit()
	else:
		c[i] -= 1

print("YES")

Measured memory_bytes: 46560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 10;
char s[N + 1];
int main()
{
	cin >> s + 1; 
	int len = strlen(s + 1);
	reverse(s + 1, s + len + 1);
	s[len + 1] = '0';
	s[len + 2] = '\0';
	ll cnt = 0, cur = 0;
	for (int i = 1; i <= len + 1; i++)
	{
		int val = s[i] -'0' + cur;
		cur = 0;
		if (i == len + 1)
		{
			cnt += val;
			break;
		}
		if (0 <= val && val <= 4)
		cnt += val;
		else if(6 <= val && val <= 9)
		{
			cur = 1;
			cnt += 10 - val;
		}
		else if (val == 10)
		cur = 1;
		else if (val == 5)
		{
			cnt += 5;
			if (s[i + 1] - '0' >= 5)
			cur = 1;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 1280
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
#include <stdio.h>
    
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using TP = tuple<ll, ll, ll>;
ll MOD = 1e9+7;
const int INF = 1e6;
const ll LINF = (ll)1e19;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin >> N;
    
    for(int i = 11; i <= 55555; i+=10){
        bool sosuu = true;
        for(int j = 2; j < i; j++){
            if(i % j == 0){
                sosuu = false;
                break;
            }
        }
        if(sosuu){
            cout << i;
            N--;
            if(N == 0){
                cout << endl;
                break;
            }else{
                cout << " ";
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
// {{{
#[allow(unused_macros)]
macro_rules! getl {
    ( $( $t:ty ),* ) => {
        {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).unwrap();
            let mut ws = s.split_whitespace();
            ($(ws.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}

#[allow(unused_macros)]
macro_rules! getl_vec {
    ( $t:ty ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect::<Vec<$t>>()
    }};
}

#[allow(unused_macros)]
macro_rules! multi_vec {
    ( $elem:expr; $num:expr ) => (vec![$elem; $num]);
    ( $elem:expr; $num:expr, $($rest:expr),* ) => (vec![multi_vec![$elem; $($rest),*]; $num]);
}

// }}}

const INF: i64 = std::i64::MAX >> 2;

fn main() {
    let (n, m, p) = getl!(usize, usize, i64);
    let mut edges = vec![];
    for _ in 0..m {
        let (a, b, c) = getl!(usize, usize, i64);
        edges.push((a, b, c));
    }

    let mut edges0 = vec![];
    for edge in edges {
        let (a, b, c) = edge;
        edges0.push((a - 1, b - 1, c - p));
    }
    let edges = edges0;

    // ゴールにたどり着けない頂点・辺を削除する
    let mut graph = vec![vec![]; n];
    for &(from, to, coin) in &edges {
        graph[from].push(to);
    }
    let mut ok = vec![false; n];
    for v in 0..n {
        let mut visited = vec![false; n];
        let mut visited2 = vec![false; n];
        ok[v] = dfs(v, n - 1, &graph, &mut visited) && dfs(0, v, &graph, &mut visited2);
    }
    // eprintln!("{:?}", &ok);

    let mut edges2 = vec![];
    for &e in &edges {
        let (from, to, coin) = e;
        if ok[from] && ok[to] {
            edges2.push(e);
        }
    }
    let edges = edges2;

    let mut dp = vec![-INF; n];
    dp[0] = 0;
    let mut has_max = true;
    for i in 0..n {
        for &(from, to, coin) in &edges {
            if dp[to] < dp[from] + coin {
                dp[to] = dp[from] + coin;

                if i == n - 1 {
                    has_max = false;
                }
            }
        }
    }
    if has_max {
        if dp[n - 1] >= 0 {
            println!("{}", dp[n - 1]);
        } else {
            println!("0");
        }
    } else {
        println!("-1");
    }
}

fn dfs(start: usize, goal: usize, graph: &Vec<Vec<usize>>, visited: &mut Vec<bool>) -> bool {
    if start == goal {
        return true;
    }
    visited[start] = true;
    for &v in &graph[start] {
        if !visited[v] {
            visited[v] = true;
            if dfs(v, goal, graph, visited) {
                return true;
            }
        }
    }
    false
}


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

public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		short size, sum;
		while (true) {
			sum = 0;
			String input = in.readLine();
			if (input.equals("0")) {
				break;
			}
			size = (short) input.length();
			char[] charNum = input.toCharArray();
			for (int i = 0; i < size; i += 1) {
				charNum[i] = input.charAt(i);
			}
			for (int j = 0; j < size; j += 1) {
				sum += Short.parseShort(Character.toString(charNum[j]));
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 17028
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  int a, b, c ;
  cin >> a >> b >> c ;
  
  cout << min(b/a,c)<<endl ;
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

Measured memory_bytes: 256
N = int(input())
val = 0
def mojicheck(a,b):
    if a==b:
        return 1
    else:
        return 0
flag = 0
for i in range(N):
    d1,d2 = map(int,input().split())
    flag = mojicheck(d1,d2)

    if flag == 0:
        val = 0
    elif flag == 1:
        val += 1
    if val ==3:
        break
if val >=3:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9176
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
using namespace std;
int main(){
  int j,sum=0,ans=(1<<29),n,i,a[110];
  scanf("%d\n",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<=101;i++){
    for(j=0;j<n;j++){
      sum=sum+(i-a[j])*(i-a[j]);
    }
    if(sum<ans){
      ans=sum;
    }
    sum=0;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 256
import sys
f=lambda:sys.stdin.readline()
while 1:
 n=int(f())
 if n==0:break
 d={}
 for _ in[0]*n:
  k,v=f().strip().split()
  d[k]=v
 a=''
 for _ in[0]*int(f()):
  e=f().strip()
  a+=d[e]if e in d else e
 print(a)


Measured memory_bytes: 6480
from collections import Counter
N = int(input())
BlueCard = list(input() for _ in range(N))
M = int(input())
RedCard = list(input() for _ in range(M))
BlueCard_Counter = Counter(BlueCard)
RedCard_Counter = Counter(RedCard)
ans = 0
for key , blue_cnt in BlueCard_Counter.items():
    if key in RedCard:
        red_cnt = RedCard_Counter[key]
    else:
        red_cnt = 0
    now = blue_cnt - red_cnt
    if ans < now:
        ans = now
print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/
signed main(){

	int d,t,s;
	cin>>d>>t>>s;
	if(d>s*t)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 3632
/*input
12 5 2
cabbabaacaba
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
string s;
int main()
{
	IOS;
	int n,a,b;
	cin>>n>>a>>b;
	cin>>s;

	int cnt=0;
	int co=0;
	REP(i,n){
		if(s[i]=='c'){
			cout<<"No\n";
		}
		else if(s[i]=='a'){
			if(cnt<a+b){
				cout<<"Yes\n";
				cnt++;
			}
			else cout<<"No\n";
		}
		else{
			co++;
			if(cnt<a+b&&co<=b){
				cout<<"Yes\n";
				cnt++;
			}
			else cout<<"No\n";
		}
	}
	return 0;
}


Measured memory_bytes: 848