akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string s,t;
    cin>>s>>t;
    map<char, int>p;
    map<char, int>q;
    for(char x:s){
        p[x]++;
    }
    for(char x:t){
        q[x]++;
    }
    vector<int> a1(26);
    vector<int> b1(26);
    int i=0,j=0;
    for(auto xx:p){
        a1[i]=xx.second;
        i++;
    }
    for(auto xx:q){
        b1[j]=xx.second;
        j++;
    }
    sort(a1.begin(),a1.end());
    sort(b1.begin(),b1.end());
    if (a1==b1){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}


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

#define ll long long
#define NIL 0
#define INF 2e9
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define vl vector<ll>
#define vvl vector<vector<ll>> 
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define pb push_back
#define F first
#define S second
#define pp pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define rpk(i,k,n) for(int i=k;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++) 
#define RPK(i,k,n) for(int i=k;i<=n;i++) 
#define ritr(i,gr) for(auto i=gr.begin();i!=gr.end();i++)

const int M = 1e9+7;

int V, E, i, j, k, u, v, x, y, p, q, r, t, n,w;
vi *g;
vb sn;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string a,b;
    getline(cin, a);
    getline(cin, b);
    int n = a.length(), m = b.length();
    int dp[n+1][m+1];
    rep(i,m+1) dp[0][i] = 0;
    rep(i,n+1) dp[i][0] = 0;
    
    REP(i,n) {
        REP(j,m) {
            if(a[i-1]==b[j-1]) {dp[i][j] = dp[i-1][j-1]+1;}
            else { dp[i][j] = max(dp[i-1][j], dp[i][j-1]);}
        }
    }
    stack<char> st;
    for(int i=n, j=m;i>0;) {
        if((dp[i][j]==dp[i-1][j-1]+1) && a[i-1]==b[j-1]) {st.push(a[i-1]); i=i-1;j=j-1;}
        else if (dp[i][j] == dp[i-1][j]) i=i-1;
        else j=j-1;
    }
    while(!st.empty()) cout<<st.top(), st.pop();
    cout<<endl;
}
    

Measured memory_bytes: 38768
from itertools import product


X, Y, Z, K = map(int, input().split())
lst_A = list(map(int, input().split()))
lst_B = list(map(int, input().split()))
lst_C = list(map(int, input().split()))
lst_A.sort(reverse=True)
lst_B.sort(reverse=True)
lst_C.sort(reverse=True)
lst_C_K = lst_C[:K]


lst_AB = sorted([a+b for a, b in product(lst_A, lst_B)], reverse=True)
lst_AB_K = lst_AB[:K]

lst_ABC = sorted([ab+c for ab, c in product(lst_AB_K, lst_C_K)], reverse=True)
lst_ABC_K = lst_ABC[:K]

for i in range(K):
    print(lst_ABC_K[i])


Measured memory_bytes: 238176
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;

int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        int n,m;
        cin >> n >> m;
        int a[n+1][m+1];
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                char x;
                cin >> x;
                if(x=='.')
                a[i][j]=1;
                else 
                a[i][j]=0;
            }
        }
        int i,j,dp[n+1][m+1];
        for(i=0; i<n; i++){
            for(j=0; j<m; j++){
                if(i==0 && j==0)dp[i][j]=1;
                else if(i==0){
                    if(a[i][j])
                    dp[i][j]=dp[i][j-1]%mod;
                    else
                    dp[i][j]=0;
                }
                else if(j==0){
                    if(a[i][j])
                    dp[i][j]=dp[i-1][j]%mod;
                    else
                    dp[i][j]=0;
                }
                else{
                    if(a[i][j])
                    dp[i][j]=(dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;
                    else
                    dp[i][j]=0;
                }
            }
        }

        cout << dp[n-1][m-1]%mod;




   
    

}


Measured memory_bytes: 15872
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
cnt = Counter(s)
print("AC x {}".format(cnt["AC"]))
print("WA x {}".format(cnt["WA"]))
print("TLE x {}".format(cnt["TLE"]))
print("RE x {}".format(cnt["RE"]))

Measured memory_bytes: 16640
#include<cstdio>
#include<algorithm>
#define MAXN 106
using namespace std;
int n,ans,a[MAXN],b[MAXN],sum1,sum2;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&b[i]);
		sum2+=b[i];
	}
	sum1=a[1];
	ans=a[1]+sum2;
	for(int i=2;i<=n;i++)
	{
		sum2-=b[i-1];
		sum1+=a[i];
		ans=max(ans,sum2+sum1);
	}
	printf("%d",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t; cin >> s >> t;
  vector<string> dp(s.size(), "");

  for (int i = 0; i < t.size(); i++)
  {
    char c = t[i];
    string tmp = "";
    vector<string> nextdp(dp);
    for (int j = 0; j < s.size(); j++)
    {
      if (s[j] == c && dp[j].size() < tmp.size() + 1) {
        nextdp[j] = tmp;
        nextdp[j].push_back(c);
      }
      if (tmp.size() < dp[j].size()) tmp = dp[j];
    }
    dp = nextdp;
  }

  string ans = "";
  for (auto& s : dp)
  {
    if (ans.size() < s.size()) ans = s;
  }

  cout << ans << endl;
}


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

int main(){
	ll a,b,n;
	cin >> n >> a >> b;
	
	if((b-a)%2==0){
		cout << (b-a)/2 << endl;
	}else{
		cout << min((b-a+1)/2 + n-b, (b-a+1)/2 + a-1);
	}
    return 0;
}



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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T>
constexpr T INF = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()

template<typename T, typename U> istream& operator>>(istream& in, pair<T, U>& a) { cin >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& in, vector<T>& a) { for (T& x : a) cin >> x; }

void LOG(const int& x) { cerr << x << "\n"; }
void LOG(const vector<int>& a) { for (int x : a) cerr << x << " "; cerr << "\n"; }

int ceil(int a, int b) { return (a - 1) / b + 1; }
i64 gcd(i64 a, i64 b) { while (b != 0) { i64 t = b; b = a % b; a = t; } return a; }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
i64 gcd(const vector<i64>& v) { return accumulate(ALL(v), 1LL, static_cast<i64(*)(i64, i64)>(gcd)); }
i64 lcm(const vector<i64>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<i64(*)(i64, i64)>(lcm)); }
i64 pow(i64 x, i64 y, i64 z) { i64 a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
i64 inv(i64 x, i64 m) { return pow(x, m - 2, m); }

#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

class UnionFind { private: vector<int> par; vector<int> rnk; int find(int x) { return par[x] == x ? x : par[x] = find(par[x]); } public: UnionFind(int size) { par.resize(size); rnk.resize(size); REP(i, size) par[i] = i, rnk[i] = 0; } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; if (rnk[x] < rnk[y]) { par[x] = y; } else { par[y] = x; if (rnk[x] == rnk[y]) rnk[x]++; } } bool same(int x, int y) { return find(x) == find(y); } };

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;

int acc[200010];
signed main() {
  int n;
  cin >> n;
  vector<int> c(n);
  cin >> c;
  int m = 1000000007;
  int i = 0;
  int ans = 1;
  while (i < n) {
    while (i + 1 < n && c[i] == c[i + 1]) {
      i += 1;
    }
    int t = ans;
    ans = (ans + acc[c[i]]) % m;
    acc[c[i]] = (acc[c[i]] + t) % m;
    i += 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(ll a, ll b) {
return b ? gcd(b, a%b) : a;
}
ll lcm(ll a, ll b){
return a / gcd(a, b) * b;
}


int main(){
    int n;
    cin >> n;
    vector<ll> t(n);
    rep(i,n) cin >> t[i];
    ll ans = t[0];
    for(int i=1; i<n; i++){
        ans = lcm(ans,t[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

 public class Main{
	 public static void main(String[] args){
		 Scanner s = new Scanner(System.in);
		 int b,x,max,SH;
		 SH = 0;
		 while(s.hasNextInt()){
		 x = s.nextInt();
		 int[][] a = new int[x][3];
		 for(b = 0; b < x; b++){
			 a[b][0] = s.nextInt();
			 a[b][1] = s.nextInt();
			 a[b][2] = s.nextInt();
		 }
		 for(b = 0; b < x; b++){
			 max = a[b][0];
			 if(a[b][1] > max)max = a[b][1];
			 if(a[b][2] > max)max = a[b][2];
			 if(max == a[b][0]){
				 SH = a[b][1]*a[b][1]+a[b][2]*a[b][2];
			 }else if(max == a[b][1]){
				 SH = a[b][0]*a[b][0]+a[b][2]*a[b][2];
			 }else if(max == a[b][2]){
				 SH = a[b][0]*a[b][0]+a[b][1]*a[b][1];
			 }
			 max = max*max;
			 if(SH == max){
				 System.out.println("YES");
			 }else{
				 System.out.println("NO");
			 }
		 }
		 }
	 }
 }

Measured memory_bytes: 24040
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値

// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}

int main() {
int H, L;
cin>>H>>L;
string a[H]={};
int t[L]={};
int y[H]={};
int ca=0;
for(int i=0; i<H; i++){
cin>>a[i];}
for(int i=0; i<L; i++){
for(int q=0; q<H; q++){
if(a[q].at(i)=='#'){
t[i]++;
break;}}}
for(int i=0; i<H; i++){
for(int q=0; q<L; q++){
if(a[i].at(q)=='#'){
y[i]++;
break;}}}
for(int i=0; i<H; i++){
for(int q=0; q<L; q++){
if(t[q]==1&&y[i]==1){
cout<<a[i].at(q);
ca++;}}
if(ca>0){
cout<<endl;
ca=0;}}}


Measured memory_bytes: 3560
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	int d, l; cin >> d >> l;
	Cout(d / l + d % l);
}


Measured memory_bytes: 3104
#include <stdio.h>
int main(){
  int r,c,i,j,sum,s[101][101];
  scanf("%d %d", &r, &c);
  for (i = 0; i < r; i++){
    sum=0;
    for (j = 0; j < c; j++){
      scanf("%d",&s[i][j]);
      sum+=s[i][j];
    }
    s[i][c]=sum;
  }
  for (j = 0; j < c+1; j++){
    sum = 0;
    for (i = 0; i < r; i++)
      sum += s[i][j];
    s[r][j]=sum;
  }
  for (i = 0; i < r+1; i++){
    for (j= 0; j < c+1; j++){
      printf("%d",s[i][j]);
      if (j!=c) printf("%s"," ");
    }
    printf("%s","\n");
  }
  return 0;
}


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


vector<vector<int> > edges;
vector<int> col;

LL ncc = 0;
LL nbcc = 0;

int ok;
int cnt = 0;

void dfs(int v, int c){
	if(col[v] == c) return;
	if(col[v] != 0){
		ok = 0;
		return;
	}
	cnt++;
	col[v] = c;
	for(int a : edges[v]){
		dfs(a, -c);
	}
}
LL n1 = 0;

int main(){
	LL n, m;
	cin >> n >> m;
	edges.resize(n);
	col.resize(n, 0);
	for(int i = 0; i < m; i++){
		int u, v;
		cin >> u >> v;
		u--; v--;
		edges[u].push_back(v);
		edges[v].push_back(u);
	}
	for(int i = 0; i < n; i++){
		if(col[i] == 0){
			ok = 1;
			cnt = 0;
			dfs(i, 1);
			if(cnt == 1){
				n1++;
			} else {
				ncc++;
				if(ok) nbcc++;
			}
		}
	}
	cout << n * n - (n - n1) * (n - n1) + nbcc * nbcc + ncc * ncc << '\n';
}

Measured memory_bytes: 8960
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,w = li()
dp = [[0]*(w+1) for _ in range(n+1)]

for i in range(1,n+1):
    wi, vi = li()
    for j in range(1,w+1):
        if j-wi >= 0:
            dp[i][j] = max(dp[i-1][j],
                           dp[i-1][j-wi] + vi)
        else:
            dp[i][j] = dp[i-1][j]
            
print(dp[n][w])

Measured memory_bytes: 119916
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    int a, b, c; 
    cin >> a >> b >> c;
    int ans = c - a + b;
    if(ans >= 0) cout << ans << endl;
    else cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
import itertools
import math

def dfs(vum,v,depth,max_depth,candidate,dupcombi):
    if depth == max_depth:
        dupcombi.append(candidate.copy())
    else:
        for u in vum[v]:
            candidate[depth] = u
            candidate, dupcombi = dfs(vum,u,depth+1,max_depth,candidate,dupcombi)
    return candidate, dupcombi

def main():
    N,M,Q = [int(x) for x in input().split()]
    m = []
    for i in range(Q):
        a,b,c,d = [int(x) for x in input().split()]
        m.append((a,b,c,d))

    # 数列列挙
    vum = {}
    for i in range(1,M+1):
        ul = []
        for j in range(i,M+1):
            ul.append(j)
        vum.update({i:ul})
    dupcombi = []
    candidate = [0]*N
    _, candA = dfs(vum,1,0,N,candidate,dupcombi)
    # print(len(list(itertools.product(range(1,M+1),repeat=N)))) // 重複あり順列
    # print(len(list(itertools.combinations_with_replacement(range(1,M+1),N)))) // 重複あり組み合わせ
    # print(len(candA)) // 重複あり組み合わせ (自作)

    scoreA = {}
    for cand in candA:
        score = 0
        for a,b,c,d in m:
            # print(a,b,c,d)
            if cand[b-1] - cand[a-1] == c:
                # print(cand[b-1],cand[a-1])
                score += d
        # print(cand,score)
        scoreA.update({score:cand})
    print(sorted(scoreA.items(), reverse=True)[0][0])

if __name__ == '__main__':
    main()


Measured memory_bytes: 23104
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

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

int main() {
  int H,W; cin >> H >> W;
  string S[100];
  //  string ans[100];
  int cnt = 0;
  for ( int i = 0; i < H; i++ ) cin >> S[i];
  
  for ( int i = 0; i < H; i++ ) {
    for ( int j = 0; j < W; j++ ) {
      cnt = 0;
      if ( S[i][j] == '#' ) continue;
      if ( S[i][j] == '.' ) {
	for ( int d = 0; d < 8; d++ ) {
	  int ni = i + dy[d];
	  int nj = j + dx[d];
	    if ( 0 <= ni && ni < H && 0 <= nj &&
		 nj < W && S[ni][nj] == '#'  ) cnt++;
	}
	S[i][j] = (char)cnt + '0';
	//cout << cnt << " ";
      }
    }
  }
  /*
  for ( int i = 0; i < H; i++ ) {
    for ( int j = 0; j < W; j++ ) {
      if ( S[i][j] == '.' ) S[i][j] = ans[i][j];
	   
    }
  }
  */
  for ( int i = 0; i < H; i++ ) {
    cout << S[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cstdio>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
ll mod = 2e18;
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; }

void solve() {
	string s;
	cin >> s;
	rep(i, 0, sz(s)) {
		if (s[i] == '?')s[i] = 'D';
	
	}
	
	cout <<s << endl;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}







Measured memory_bytes: 3748
d={}
N,K=map(int,raw_input().split())

for i in xrange(N):
    a,b=map(int,raw_input().split())
#    print a,b
    if a in d:
        d[a] = d[a] + b
    else:
        d[a]=b
#    td={}
#    cnt=0
#    print d
#    for key in sorted(d):
#        print key
#        if cnt<=K:
#            td[key]=d[key]
#        else:
#            break
#    d=td

aa=None
cnt=0
#print d
for k in sorted(d):
    aa=k
    cnt+=d[k]
#    print cnt
    if cnt>=K:
        break
print aa

    


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

#define ll long long
#define pb push_back
#define F first
#define S second

int inf =1e9+10;
const int N=1e5+10;
int n , a[N];
int mem[N][3];

int dp(int i)
{
    if (i == n)
        return 0;
        if (i > n)
            return inf;
    int &p1 = mem[i][1];
    int &p2 = mem[i][2];
    if (p1 == -1)
    p1 = abs(a[i] - a[i+1] ) + dp(i+1);
    if (p2 == -1)
    p2 = abs(a[i] - a[i+2] ) + dp(i+2);
    return min(p1 , p2);
}

int main()
{
#ifdef Mohammad
 freopen("input.in","r",stdin);
#endif
     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
     cin >> n ;
     for (int i =1;i<=n;i++)
        cin >> a[i];
        memset(mem , -1 , sizeof mem);
        cout<<dp(1);
}


Measured memory_bytes: 6528
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <cmath>
#include <string>
#include <set>
#include <map>
#define SIZE 200005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

vector <int> vec[SIZE];
char str[SIZE];
int da[SIZE],db[SIZE];
bool use[SIZE];

int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	scanf("%s",&str);
	for(int i=0;i<m;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);a--,b--;
		vec[a].push_back(b);
		vec[b].push_back(a);
		if(str[a]=='A') da[b]++;
		else db[b]++;
		if(str[b]=='B') db[a]++;
		else da[a]++;
	}
	queue <int> que;
	for(int i=0;i<n;i++)
	{
		if(da[i]==0||db[i]==0)
		{
			que.push(i);
			use[i]=true;
		}
	}
	int cnt=0;
	while(!que.empty())
	{
		int v=que.front();que.pop();
		cnt++;
		for(int i=0;i<vec[v].size();i++)
		{
			int to=vec[v][i];
			if(!use[to])
			{
				if(str[v]=='A') da[to]--;
				else db[to]--;
				if(da[to]==0||db[to]==0)
				{
					use[to]=true;
					que.push(to);
				}
			}
		}
	}
	if(cnt<n) puts("Yes");
	else puts("No");
	return 0;
}


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

int main(){
  int N,M; cin >> N >> M;
  vector<vector<int>> path(N,vector<int>());
  for(int i=0; i<M; i++){
    int a,b; cin >> a >> b;
    a--; b--;
    path[a].push_back(b);
    path[b].push_back(a);
  }
  
  vector<int> mark(N,-1);
  mark[0]=0;
  
  queue<int> q;
  q.push(0);
  while(!q.empty()){
    int a=q.front();q.pop();
    for(int x:path[a]){
      if(mark[x]>=0) continue;
      mark[x]=a;
      q.push(x);
    }
  }
  cout << "Yes" << endl;
  for(int i=1; i<N; i++){
    cout << mark[i]+1 << endl;
  }
}

Measured memory_bytes: 10332
<?php
while ($line = fgets(STDIN)) {
    $line = rtrim($line);
    $data = explode(" ", $line);

    if ($data[2] < 0 || $data[3] < 0) {
        // ????????¢?????§?¨?(W, H)???????????£??¨???????????§
        // ????????§?¨?(x, y) ???????????´??????No??¨?????????
        echo "No" . PHP_EOL;
    } else {
        if ($data[2] + $data[4] <= $data[0] && $data[3] + $data[4] <= $data[1]) {
            // x + r <= W  ?????? y + r <= H
            echo "Yes" . PHP_EOL;
        } else {
            echo "No" . PHP_EOL;
        }
    }
}

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

using namespace std;
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;

#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;
#define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;
#define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}
#define debugaar(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[y][x]<<" ";}cout<<endl;}
#define ALL(v) (v).begin(),(v).end()
#define BIGINT 0x7FFFFFFF
#define E107 1000000007ll
void printbit(int u){if(u==0)cout<<0;else{int s=0,k=0;for(;0<u;u>>=1,k++)s=(s<<1)|(u&1);for(;0<k--;s>>=1)cout<<(s&1);}}

#define TIME chrono::system_clock::now()
#define MILLISEC(t) (chrono::duration_cast<chrono::milliseconds>(t).count())

template<typename T1,typename T2>
ostream& operator <<(ostream &o,const pair<T1,T2> p){o<<"("<<p.first<<":"<<p.second<<")";return o;}

int width,height;
int m,n;

int sx,sy,tx,ty;

int main(){
    int i,j,k;
    int x,y,a,b;
    
    cin >> sx>>sy>>tx>>ty;
    
    x=sx;y=sy;
    
    for (;x<tx;x++){
        printf("R");
    }
    for (;y<ty;y++){
        printf("U");
    }
    // もくてきち
    
    for (;sx<x;x--){
        printf("L");
    }
    for (;sy<y;y--){
        printf("D");
    }
    // 初期位置
    
    printf("D");y--;
    for (;x<tx+1;x++){
        printf("R");
    }
    for (;y<ty;y++){
        printf("U");
    }
    printf("LU");x--;y++;
    for (;sx-1<x;x--){
        printf("L");
    }
    for (;sy<y;y--){
        printf("D");
    }
    printf("R");
    
    cout << endl;
    
    return 0;
}

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

typedef long long ll;
const ll mod = 1e9+7;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "]\n" : ", "); } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    string k;
    int d;
    cin >> k >> d;
    int n = k.size();
    vector<vector<vector<ll>>> dp(2,vector<vector<ll>>(n+1,vector<ll>(d,0)));
    dp[1][0][0] = 1;
    for (int i = 0;i < n;++i) {
        int x = k[i]-'0';
        for (int j = 0;j < d;++j) dp[1][i+1][(j+x)%d] += dp[1][i][j];
        for (int j = 0;j < d;++j) for (int l = 0;l < x;++l) {
            dp[0][i+1][(j+l)%d] += dp[1][i][j];
            dp[0][i+1][(j+l)%d] %= mod;
        }
        for (int j = 0;j < d;++j) for (int l = 0;l < 10;++l) {
            dp[0][i+1][(j+l)%d] += dp[0][i][j];
            dp[0][i+1][(j+l)%d] %= mod;
        }
    }
    cout << (dp[0][n][0]+dp[1][n][0]-1+mod*2)%mod << endl;
    return 0;
}

Measured memory_bytes: 24832
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int a[3];
	while(scanf("%d %d %d",&a[0],&a[1],&a[2])!=EOF){
		sort(a,a+3);
		printf("%d\n",a[0]+a[1]);
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int 
#define w(x) int x; cin>>x; while(x--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
using namespace std;
int main(){
#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll a,b,z=0;
	cin>>a>>b;
	ll c[b];
	for(ll i=0; i<b; i++)
		cin>>c[i];
	sort(c,c+b);
	for(ll i=b-1; i>=0; i--){
		a-=c[i];
		if(a<=0){
			z=1;
			break;
		}
	}
	if(z==1)
		cout<<"Yes";
	else
		cout<<"No";

}

Measured memory_bytes: 4348
#pragma GCC optimize(2,3,"Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define in inline
namespace fast_io
{
    char buf[1<<12],*p1=buf,*p2=buf,sr[1<<23],z[23],nc;int C=-1,Z=0,Bi=0,ny;
    in char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
    in ll read()
    {
        ll x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;Bi=1;if(nc<0)return nc;
        x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48),Bi++;return x*ny;
    }
    in db gf() {int a=read(),y=ny,b=(nc!='.')?0:read();return (b?a+(db)b/pow(10,Bi)*y:a);}
    in int gs(char *s) {char c,*t=s;while(c=gc(),c<32);*s++=c;while(c=gc(),c>32)*s++=c;return s-t;}
    in void ot() {fwrite(sr,1,C+1,stdout);C=-1;}
    in void flush() {if(C>1<<22) ot();}
    template <typename T>
    in void write(T x,char t)
    {
        int y=0;if(x<0)y=1,x=-x;while(z[++Z]=x%10+48,x/=10);
        if(y)z[++Z]='-';while(sr[++C]=z[Z],--Z);sr[++C]=t;flush();
    }
    in void write(char *s) {int l=strlen(s);for(int i=0;i<l;i++)sr[++C]=*s++;sr[++C]='\n';flush();}
};
using namespace fast_io;
const int N=2e5+5;
ll n,x,d;ll ans;
struct pll{ll a,b;in bool operator<(pll x)const{return a^x.a?a<x.a:b<x.b;}};
vector<pll>q;map<int,vector<pll>>mp;
in int add(int a,int b) {return a+b>=d?a+b-d:a+b;}
in int sub(int a,int b) {return a-b<0?a-b+d:a-b;}
in int mul(int a,int b) {return (ll)a*b%d;}
in void inc(int &a,int b) {a=add(a,b);}
in void dec(int &a,int b) {a=sub(a,b);}
in ll sqr(ll x) {return x*(x+1)/2;}
int main()
{
	n=read();x=read();d=read();
	if(!d) return write(!x?1:n+1,'\n'),ot(),0;if(d<0) d=-d,x=-x;ll nx=add(x%d,d);
	for(int i=0;i<=n;i++) mp[mul(nx,i)].push_back({(x*i-mul(nx,i))/d+sqr(i-1),(x*i-mul(nx,i))/d+sqr(n-1)-sqr(n-i-1)});
	for(auto it:mp)
	{
		auto a=it.second;sort(a.begin(),a.end());ll l=a[0].a,r=a[0].b;
		for(int i=1;i<a.size();i++)
			if(a[i].a>r) ans+=r-l+1,l=a[i].a,r=a[i].b;
			else r=max(r,a[i].b);
		ans+=r-l+1;
	}
	write(ans,'\n');
	return ot(),0;
}
//Author: disangan233
//In my dream's scene,I can see the everything that in Cyaegha.

Measured memory_bytes: 22144
loop do
    n = gets.to_i
    break if n == 0
    n.times do
        s, t = gets.split.map(&:to_i)
        a = []
        if s < 6
            if t < 6
                a = (s < t ? (s..t).to_a : (t..s).to_a.reverse)
            else
                a = (s..t).to_a
            end
        else
            if t < 6
                a = (s..9).to_a + (t..5).to_a.reverse
            elsif t < s
                a = (s..9).to_a + (0..5).to_a.reverse + (1..5).to_a + (6..t).to_a
            else
                a = (s..t).to_a
            end
        end
        puts a.join " "
    end
end

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

using namespace std;
using ll = long long;

int main() {
	int N, K;
	cin >> N >> K;
	vector<ll> v(N + 1);
	for (int i = 1; i <= N; ++i) { cin >> v[i]; }

	ll res = 0;
	priority_queue<ll, vector<ll>, greater<ll>> que;
	for (int l = 0; l <= N; ++l) {
		for (int r = N + 1; r > 0; --r) {
			int n = l + N + 1 - r;
			if (n > K || l >= r) { continue; }
			for (int i = 1; i <= l; ++i) { que.push(v[i]); }
			for (int i = r; i <= N; ++i) { que.push(v[i]); }

			while (n < K && !que.empty()) {
				if (que.top() > 0) { break; }
				que.pop();
				++n;
			}

			ll tmp = 0;
			while (!que.empty()) {
				tmp += que.top();
				que.pop();
			}
			res = max(res, tmp);
		}
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

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

signed main() {
    //Here
    int n;
    cin>>n;

    vector<int> h(n);
    REP(i,n){
        cin>>h.at(i);
    }

    if(n <= 1){ cout<<"Yes"<<endl; return 0;}


    for(int i = n-1 ; i>=0; i--){
        if( i == 0 && h.at(0) <= h.at(1) ){
            cout<<"Yes"<<endl;
            return 0;
        } 
        if( i < n-1 ){
            if( h.at(i) > h.at(i+1)+1 ){
                break;
            } else if(h.at(i) == h.at(i+1) +1 ){
                h.at(i)--;
            }
        }

    }
    cout<<"No"<<endl;
/*
    REP(i,n){
        if( i == n-1 ){
            cout<<"Yes"<<endl;
                REP(j,n){
            cout<<h.at(j)<<" ";
    }
            return 0;
        } else if( h.at(i) > h.at(i+1) + 1){
            break;
        } else if( h.at(i) == h.at(i+1) + 1){
            h.at(i) -= 1;
        }
    }


    cout<<"No"<<endl;
    */

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

Measured memory_bytes: 640
//
// Created by swift on 2020/8/2.
//

#include<bits/stdc++.h>
using namespace std;
int n,num,ans;;
char s[300000];
int main(){
    scanf("%d",&n);
    scanf("%s",s);
    for(int i=0;i<n;i++){
       if(s[i]=='R')num++;
    }
    for(int i=0;i<n;i++){
        if(i>=num&&s[i]=='R')ans++;
    }
    printf("%d\n",ans);
    return 0;
}

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

typedef long long int ll;
typedef pair <ll, ll> pll;

const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const ll Inf = 1LL << 62;

ll ar[Max], br[Max];

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

	ll n, m, k, res = 0;
	cin >> n >> m >> k;
	for(int i = 1; i <= n; i++) {
		cin >> ar[i];
		ar[i] += ar[i - 1];
	}
	for(int i = 1; i <= m; i++) {
		cin >> br[i];
		br[i] += br[i - 1];
	}
	for(int i = 1; i <= n; i++) {
		ll x = ar[i];
		ll rem = k - x;
		if(rem < 0) continue;
		ll ans = 0;
		ll l = 1, r = m;
		while(l <= r) {
			ll mid = (l + r) >> 1;
			if(br[mid] <= rem) {
				ans = mid;
				l = mid + 1;
			} 
			else {
				r = mid - 1;
			}
		}
		res = max(res, i + ans);
	}
	for(int i = 1; i <= m; i++) {
		ll x = br[i];
		ll rem = k - x;
		if(rem < 0) continue;
		ll ans = 0;
		ll l = 1, r = n;
		while(l <= r) {
			ll mid = (l + r) >> 1;
			if(ar[mid] <= rem) {
				ans = mid;
				l = mid + 1;
			} 
			else {
				r = mid - 1;
			}
		}
		res = max(res, i + ans);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std ; 
#define int long long
const int MAXN = 1e6 + 100 ; 
bool a[MAXN] ; 
int32_t main(){
    ios_base::sync_with_stdio(0) ; 
    cin . tie(0) , cout . tie(0) ; 

    int n , k ; cin >> n >> k ; 
    for(int i = 0 ; i < n ; i ++){
    	char ch ; cin >> ch ; 
    	a[i] = (ch == 'A') ; 
    }

    int td = min(k , 2 * n) , i = 0 ; 
    k = k - td ; 
    bool rev = false ; 

    while(td --){
    	if(a[i] ^ rev){a[i] = !a[i] ; continue ; }
    	int now = n + i ; 
    	rev = !rev ; 
    	a[now] = !rev ; 
    	//cout << (a[i] ^ rev ? 'A' : 'B') ; 
    	i ++ ; 
    }
    if(n % 2)a[i] = a[i] ^ (k % 2) ; 
    for(int j = i ; j < i + n ; j ++)
    	cout << ((a[j] ^ rev) ? 'A' : 'B') ; 
}

Measured memory_bytes: 896
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int N, T;
vector<int> c, t;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> T;
  c.resize(N);
  t.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> c[i] >> t[i];
  }

  int ans = INT_MAX;
  for (int i = 0; i < N; i++) {
    if (t[i] <= T) {
      ans = min(ans, c[i]);
    }
  }

  if (ans != INT_MAX) {
    cout << ans << endl;
  } else {
    cout << "TLE" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
int a[3001][3001];
using ll = long long;
int main(){
	string s,t;
  	cin>>s>>t;
  	for(int i=0;i<s.length();i++){
    	for(int j=0;j<t.length();j++){
        	if(s[i]==t[j]){
            	a[i+1][j+1]=a[i][j]+1;
            }
          	else{
            	a[i+1][j+1]=max(a[i+1][j],a[i][j+1]);
            }
        }
    }
  	char c[3000];
  int  cctr=0;
  int j=t.length(),i=s.length();
  	while(i>0 && j>0){
    	if(a[i][j]==a[i-1][j-1]+1 && s[i-1]==t[j-1]){
        	c[cctr++]=t[j-1];
          	j--;
            i--;
        }
      else if(a[i][j]==a[i-1][j]) i--;
      else if(a[i][j] == a[i][j-1])j--;
    }
  /*
  for(int i=0;i<=s.length();i++){
    	for(int j=0;j<=t.length();j++){
        cout<<a[i][j]<<" ";
        }
  	cout<<endl;
  }*/
    for(int i=cctr-1;i>=0;i--) cout<<c[i];
}


Measured memory_bytes: 35456
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
int main(){
	int A,B,C;
	cin>>A>>B>>C;
	int num[11]={};
	num[A]++;
	num[B]++;
	num[C]++;
	if(num[5]==2 && num[7]==1)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    map<int, int> mp;
    rep(i, n) {
        int x;
        cin >> x;
        mp[x]++;
    }

    vvi mmd(m);
    for(P x:mp) {
        mmd[x.first%m].push_back(x.second);
    }

    int ans = 0;
    rep(i, m) {
        if(i == m-i or !i) {
            int sum = 0;
            rep(j, mmd[i].size()) {
                sum += mmd[i][j];
            }
            ans += sum/2*2;
        } else {
            int i_ = m-i;
            int sum = 0, sum_ = 0;
            int od = 0, od_ = 0;
            rep(j, mmd[i].size()) {
                sum += mmd[i][j];
                od += mmd[i][j]%2;
            }
            rep(j, mmd[i_].size()) {
                sum_ += mmd[i_][j];
                od_ += mmd[i_][j]%2;
            }
            if(sum > sum_) {
                ans += sum_;
                int num = sum-sum_;
                if(od > sum_) {
                    ans += (sum-od)/2;
                } else {
                    ans += num/2;
                }
            } else {
                ans += sum;
                int num = sum_-sum;
                if(od_ > sum) {
                    ans += (sum_-od_)/2;
                } else {
                    ans += num/2;
                }
            }
        }
    }

    cout << ans/2 << endl;
}

Measured memory_bytes: 13436
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

int d[5*100000+1];
int main(){
    string s;cin>>s;
    ll res = s.size();
    REP(i,1,s.size()-1){
        if(s[i-1]==s[i]){
            i+=2;
            res--;
        }
    }
    cout<<res;
}



Measured memory_bytes: 640
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a,MOD=1e9+7,ans=1;
stack<ll> sta;
int main(void){
    cin>>n;
    for(ll i=1;i<=n;i++){
        cin>>a;
        if(2*(sta.size()+1)-1>a){
            ans*=sta.size()+1;
            ans%=MOD;
        }
        else sta.push(a);
    }
    for(ll i=1;i<=sta.size();i++){
        ans*=i;
        ans%=MOD;
    }
    cout<<ans<<endl;
}


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

int main() {
  string s;
  cin >> s;
  
  if(s[0] == s[1]){
    cout << "Bad" << endl;
  }
  else if(s[1] == s[2]){
    cout << "Bad" << endl;
  }
  else if(s[2] == s[3]){
    cout << "Bad" << endl;
  }else{
    cout << "Good" << endl;
  }
}


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

namespace ABC057C
{
    class Program
    {
        static void Main(string[] args)
        {
            new Solver().Solve();
#if DEBUG
            Console.ReadLine();
#endif
        }
    }

    class Solver
    {
        long N;

        public void Solve()
        {

            int ans = 0;

            for (long a = (int)Math.Sqrt(N); a > 0; a--)
            {
                long r;
                long b = Math.DivRem(N, a, out r);
                if (r == 0)
                {
                    ans = F(a, b);
                    break;
                }
            }

            Console.WriteLine(ans);
        }

        public Solver()
        {
            N = ReadLong();
        }

        /// <summary>
        /// 正整数の桁数を返す.
        /// </summary>
        /// <param name="x"></param>
        /// <returns>桁数</returns>
        int GetDigit(long x)
        {
            int dgt = 0;
            while (x > 0)
            {
                x /= 10;
                dgt++;
            }
            return dgt;
        }

        int F(long a, long b)
        {
            return GetDigit(Math.Max(a, b));
        }

        static String ReadString() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static String[] ReadStringArray() { return Console.ReadLine().Split(' '); }
        static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToArray(); }
        static long[] ReadLongArray() { return Console.ReadLine().Split(' ').Select(e => long.Parse(e)).ToArray(); }
        static double[] ReadDoubleArray() { return Console.ReadLine().Split(' ').Select(e => double.Parse(e)).ToArray(); }
    }

}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7, N = 2e6 + 5;

template <int MOD=1000000007>
struct Modular {
  int value;
  static const int MOD_value = MOD;

  Modular(long long v = 0) { value = v % MOD; if (value < 0) value += MOD;}
  Modular(long long a, long long b) : value(0){ *this += a; *this /= b;}

  Modular& operator+=(Modular const& b) {value += b.value; if (value >= MOD) value -= MOD; return *this;}
  Modular& operator-=(Modular const& b) {value -= b.value; if (value < 0) value += MOD;return *this;}
  Modular& operator*=(Modular const& b) {value = (long long)value * b.value % MOD;return *this;}

  friend Modular mexp(Modular a, long long e) {
    Modular res = 1; while (e) { if (e&1) res *= a; a *= a; e >>= 1; }
    return res;
  }
  friend Modular inverse(Modular a) { return mexp(a, MOD - 2); }

  Modular& operator/=(Modular const& b) { return *this *= inverse(b); }
  friend Modular operator+(Modular a, Modular const b) { return a += b; }
  friend Modular operator-(Modular a, Modular const b) { return a -= b; }
  friend Modular operator-(Modular const a) { return 0 - a; }
  friend Modular operator*(Modular a, Modular const b) { return a *= b; }
  friend Modular operator/(Modular a, Modular const b) { return a /= b; }
  friend std::ostream& operator<<(std::ostream& os, Modular const& a) {return os << a.value;}
  friend bool operator==(Modular const& a, Modular const& b) {return a.value == b.value;}
  friend bool operator!=(Modular const& a, Modular const& b) {return a.value != b.value;}
};


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

  int k;
  string s;
  cin >> k >> s;

  int n = s.size();
  Modular<> fac[N], inv[N];
  fac[0] = inv[0] = 1;

  for (int i = 1; i < N; ++i) {
    fac[i] = i * fac[i-1];
    inv[i] = 1 / fac[i];
  }
  
  auto ncr = [&](int nn, int rr) {
    return fac[nn] * inv[rr] * inv[nn-rr];
  };
  
  Modular<> ans = 0;
  for (int i = n - 1; i < n + k; ++i) {
    ans += ncr(i, n - 1) * mexp(Modular<> (25), i-n+1) * mexp(Modular<> (26), n+k-i-1);
  }

  cout << ans << '\n';
}




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

int main(){
    string s; cin >> s;
    int alp[26] = {0};
    for(int i=0; i<s.size(); ++i){
        ++alp[s[i]-'a'];
    }
    for(int i=0; i<26; ++i){
        if(alp[i] == 0){ cout << (unsigned char)('a'+i) << endl; return 0;}
    }
    cout << "None" << endl; return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		long[] MARCH = new long[5];
		
		for(int i = 0; i < N; i++) {
			 String S = sc.next();
			if(S.charAt(0) == 'M') {
				MARCH[0]++;
			} else if(S.charAt(0) == 'A') {
				MARCH[1]++;
			} else if(S.charAt(0) == 'R') {
				MARCH[2]++;
			} else if(S.charAt(0) == 'C') {
				MARCH[3]++;
			} else if(S.charAt(0) == 'H') {
				MARCH[4]++;
			}
		}
		
		long total = 0;
		
		for(int i = 0; i < 3; i++) {
			for(int j = i + 1; j < 4; j++) {
				for(int k = j + 1; k < 5; k++) {
					total += MARCH[i] * MARCH[j] * MARCH[k];
				}
			}
		}
		
		System.out.println(total);
		
	}
}


Measured memory_bytes: 45944
n=int(input())
cnt=0

def check(v,n):
  if len(n) > len(v):
    return 10**(len(v)-2)
  if len(n) < len(v):
    return 0
  if n[0] > v[-1]:
    return 10**(len(v)-2)
  if n[0] == v[-1]:
    x=1 if v[0] > n[-1] else 0
    return max(0, int(n[1:-1])-x+1)
  if n[0] < v[-1]:
    return 0

for i in range(1,n+1):
  st=str(i)
  nst=str(n)
  if st[-1]=='0':
    continue
  if len(st) == 1:
    cnt+=1
    continue
  if len(st)==2:
    if int(st[-1]+st[0]) <= n:
      cnt += 1
  else:
    cnt+= check(st,nst)
    for i in range(len(st)-2):
      xst=st[-1]+'9'*i+st[0]
      cnt += check(xst,nst)*2
  if st[0]==st[-1]:
    cnt += 2

print(cnt)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, M;
  cin >> N >> M;
  ll a, b;
  map<ll, ll> m;
  for (int i = 0; i < M; i++) {
    cin >> a >> b;
    m[a]++;
    m[b]++;
  }
  bool succ = true;
  for (auto p : m) {
    if (p.second % 2 == 1) succ = false;
  }
  if (succ) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 9008
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////

//verify by https://atcoder.jp/contests/nikkei2019-final/tasks/nikkei2019_final_d
//RSQ and RUQ
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    int A,B,K;
    cin >> A >> B >> K;
    int num = 0;
    FORqr(i,1,1000){
        if ((A % i == 0) and (B % i == 0)){
            num++;
        }
        if (num == K){
            PRINTD(i);
            return 0;
        }
    }

}


Measured memory_bytes: 256