akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;


// DEFINE TO MAKE WRITING SMALL
typedef signed long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<ll,ll>> vpll;

#define pb push_back
#define ppb pop_back
#define mp make_pair
#define F first
#define S second
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define REPR(i,a,b) for(int i=a;i>=b;i--)
#define lb(arr,x) lower_bound(arr.begin(),arr.end(),x)
#define ub(arr,x) upper_bound(arr.begin(),arr.end(),x)
#define er(arr,x) equal_range(arr.begin(),arr.end(),x)
// #define sort(arr) sort(arr.begin(),arr.end())
#define reverse(arr) reverse(arr.begin(),arr.end()

#define scan(x) cin>>x
#define print(x) cout<<x
#define newline cout<<"\n"
#define mod 1000000007
#define MAX 1000007

#define INF 1e9
#define test int t;cin>>t;while(t--)
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);

// GLOBAL VARIABLES
ll fact[MAX] = {0};
bool isPrime[MAX];

// POWER USING BINARY EXPONENTIATION
ll power(ll a,ll n){
    ll res = 1;
    ll x = a;
    while(n){
        if(n&1) res = (res*x);
        x = (x*x);
        n >>= 1;
    }
    return res;
}

// EUCLIDEAN THEOREM FOR GCD
ll gcd(ll a,ll b){
	return (!b) ? a : gcd(b,a%b);  
}

// Nth FIBONACCI NUMBER TO FIND IT
pair<ll,ll> fibonacci(ll n){
	if(n == 0){
		return {0,1}; 
	}
	pair<ll,ll> p = fibonacci(n >> 1);
	ll a = ((p.first%mod) * ((2*(p.second)%mod)%mod - (p.first)%mod))%mod;
	ll b = ((p.first%mod) * (p.first%mod))%mod + ((p.second%mod) * (p.second%mod))%mod;
	
	if(n & 1) return {b,(a+b)%mod};
	else return {a,b};
}

// FATORIAL OF A NUMBER MOD WITH mod VARIABLE
void factorial(){
    fact[0] = 1;
    fact[1] = 1;
    for(int i=2;i<MAX;i++){
        fact[i] = (i*fact[i-1])%mod;
    }
}

// CALCULATE THE INVERSE OF THE FUNCTION
ll inverse(ll n){
    ll res = 1;
    ll x = n;
    ll MOD = mod-2;
    while(MOD){
        if(MOD & 1) res = (res*x)%mod;
        MOD >>= 1;
        x = (x*x)%mod;
    }
    return res;
}

// FINDING THE COMBINATION WITH N,R
ll combination(ll n,ll r){
    return (((fact[n] * inverse(fact[r]))%mod) * 1ll * inverse(fact[n-r]))%mod;
}

// FINDING THE PRIME NUMBERS USING SEIVE METHOD
void seive(int n){
    for(int i=0;i<3001;i++) isPrime[i]=true;
    isPrime[0] = false;
    isPrime[1] = false;
    for(int i=2;i*i<=n;i++){
        if(isPrime[i]){
            for(int j=i*i;j<=n;j+=i){
                isPrime[j] = false;
            }
        }   
    }
}




int main(){
    fastIO;
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    ll y = x/d;
    ll moves = min(y,k);
    ll res = 0;
    if(y>=k){
        res = abs(x-k*1ll*d);
    } else {
        ll diff = k-y;
        if(diff%2==0){
            res = abs(x-y*1ll*d);
        } else {
            res = abs(x-(y+1)*1ll*d);
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
//    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main(){
cin.sync_with_stdio(0); cout.tie(0);
string s;
cin>>s;
int n=s.size();
for(int i=0;i<s.size();i++){
	if(i<=n-3 &&s[i] == s[i+1] && s[i+1] == s[i+2])
		{
			cout<<"Yes"<<endl;
			return 0;
		}
}
cout<<"No"<<endl;

} 

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

using namespace std;
#define int long long
#define double long double
#define rep(i, n) for(int i=0;i<(n);++i)
#define INF (1ll<<60)
#define FI first
#define SE second
typedef pair<int, int> pii;
#define l_b lower_bound
#define u_b upper_bound

int N;
int A[100100];
int d[100100];

signed main() {
    cin >> N;
    int s = 0;
    rep(i, N) {
        cin >> A[i];
        s += A[i];
    }
    if (s % (N * (N + 1) / 2) != 0) {
        cout << "NO" << endl;
        return 0;
    }
    int k = s / (N * (N + 1) / 2);
    rep(i, N - 1) {
        int d = A[i + 1] - A[i] - k;
        if (d > 0 || d % N != 0) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

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

int main(){
ll n; cin >>n;
vector<ll> a(n);
for(int i = 0; i< n; i++)cin >> a[i];
sort(a.begin(),a.end());
reverse(a.begin(),a.end());
ll ans = a[0];
if(n%2==0){
  for(int i = 1; i <= n/2-1; i++)ans += 2*a[i];
}else{
     for(int i = 1; i <= (n-1) /2 -1; i++)ans += 2*a[i];
     ans += a[(n-1) /2];
}        
cout << ans <<endl;
return 0;
 }    

Measured memory_bytes: 4812
#include<bits/stdc++.h>
using namespace std;
int dp[100005];
int a[100005];
int n;
int cost(int i)
{
	if(dp[i]!=-1)
	return dp[i];
	if(i==n-1)
	return 0;
	if(i==n-2)
	return dp[i]=abs(a[i]-a[i+1]);
	return dp[i]=min(abs(a[i]-a[i+1])+cost(i+1),abs(a[i]-a[i+2])+cost(i+2));
}
int main()
{
	for(int i=0;i<100005;i++)
	dp[i]=-1;
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>a[i];
	cout<<cost(0);
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int hh, ww;
    cin >> hh >> ww;
    int h, w;
    cin >> h >> w;
    cout << (hh - h) * (ww - w) << endl;
    return 0;
}


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

using namespace std;

/**
 *  Name: Chris M. Perez
 *  University: Interamerican University Metro Campus
 *
**/

#define endl '\n'
#define MOD 10E9
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define gcd(x , y) __gcd(x , y)
#define all(x) (x).begin() , (x).end()
#define forn(i , a , b) for(int i=(a);i<(b);i++)
#define forrange(j , a , b) for(int j=(a);j<=(b);j++)
#define nestedforn(i , a , b , j , c , d) for(int i=(a);i<=(b);i++) for(int j=(c);j<=(d);j++)
#define sort_all(x) sort(all(x))
#define zeros_at_beginning(x) __builtin_clz(x)
#define zeros_at_end(x) __builtin_ctz(x)
#define ones(x) __builtin_popcount(x)
#define parity_even_or_odd_ones __builtin_parity(x)


typedef vector<int> vi;
typedef pair<int , int> pii;
typedef tuple<int , int , int> tiii;
typedef vector<pii> vpii;
typedef vector<tiii> vtiii;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long long ll;
typedef long long int lli;

             
inline int input(){
  int n;
  scanf("%d" , &n);
  return n;
}
                                                                                  
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;  

#ifdef LOCAL_DEFINE
  freopen("input.txt" , "rt" , stdin);
#endif

  int a; cin >> a;
  int b; cin >> b;
  int t; cin >> t;
  cout << (int)(t / a * b) << endl; 
                                                   
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int a, b, c; cin >> a >> b >> c;
    if (a+b == c || a+c == b || b+c == a) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

int ans = 1<<30;
int n,a,b,c;
vector<int> l;
int cal(vector<int> g){
  int aa = 0, bb = 0, cc = 0;
  int p = 0;
  for(int i = 0; i < n; i++){
    if(g[i] == 0) aa += l[i];
    else if(g[i] == 1) bb += l[i];
    else if(g[i] == 2) cc += l[i];
    if(g[i] != 3) p += 10;
  }
  p += abs(aa - a);
  p += abs(bb - b);
  p += abs(cc - c);
  if(aa == 0 || bb == 0 || cc == 0)  p = 1<<30;
  else p -= 30;
  return p;
}

void dfs(vector<int> g){
  if(g.size() == n){
    int now = cal(g);
    ans = min(ans, now);
    return;
  }
  for(int i = 0; i <= 3; i++){
    g.push_back(i);
    dfs(g);
    g.pop_back();
  }
}

int main(){
  cin >> n >> a >> b >> c;

  l.resize(n);
  for(int i = 0; i < n; i++){
    cin >> l[i];
  }
  vector<int> g;
  dfs(g);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define sz(x)             (int)((x).size())
#define int               long long
#define M                 1000000007
#define MM                998244353
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount

template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}
template<typename T1,typename T2>std::istream& operator>>(std::istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>std::ostream& operator<<(std::ostream& out,pair<T1,T2> &a){out<<a.fr<<" "<<a.sc;return out;}

const int N=0;

void solve(){
	string s,t,u;
	int a,b;
	cin>>s>>t>>a>>b>>u;
	if(s==u)a--;
	else b--;
	cout<<a<<" "<<b;
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif
	#ifdef DSU
		cleardsu(MAXDSUSIZE);
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define gcd __gcd
#define lcm(a, b) (a*b)/gcd(a, b) 
#define pcount __builtin_popcount 
#define pcountll __builtin_popcountll
#define nxtperm next_permutation
//primitive roots: 998244353 - 3; 7340033 - 5
//#pragma 03
//#pragma GCC target ("sse4.2")
const ll mod = 1000000007;
const double PI = acos(-1.);
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef complex<double> cd;

int n, k ,s; 
int a[100005]; 

signed main()
{
//	freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
// 	fast_cin();
	cin >> n >> k >> s; 
	for(int i=0;i<k;i++) a[i] = s;  
	for(int i=k;i<n;i++) 
	{
		if(s == 1e9)a[i] = 1; 
		else a[i] = 1e9; 
	}
	for(int i=0;i<n;i++) cout << a[i] << ' '; 
}

/*
	Test input:
*/



Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n, q;
    cin >> n >> q;
    fenwick_tree<ll> bit(n);
    REP(i, n) {
        ll a;
        cin >> a;
        bit.add(i, a);
    }
    REP(i, q) {
        int t;
        ll u, v;
        cin >> t >> u >> v;
        if (t == 0) bit.add(u, v);
        else cout << bit.sum(u, v) << endl;
    }
}


Measured memory_bytes: 8228
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  vector<int> t(N);
  rep(i, N) {
    cin >> t[i];
  }

  long long sum = 0;
  rep(i, N-1) {
    sum += std::min(T, t[i+1] - t[i]);
  }
  sum += T;

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a, b, need;
    int result = 0;
    cin >> a >> b >> need;
    
    while( need > 1000 ){
        need -= 1000;
        if( ( b * 2 ) > a ){
            result += a;
        }else{
            result += b * 2;
        }
    }
    
    if( need > 500 ){
        if( ( b * 2 ) > a ){
            result += a;
        }else{
            result += b * 2;
        }
        cout << result << endl;    
    }else{
        if( b > a ){
            result += a;
        }else{
            result += b;
        }
        cout << result << endl;
    }
    
    
}


Measured memory_bytes: 3116
n,m = map(int, input().split())
a = list(map(int, input().split()))
# 累積和
s = []
s.append(0)
for idx in range(len(a)):
  s.append((s[idx] + a[idx]) % m)

c = {0:1}
ans = 0
for l in range(1, n+1):
  ans += c.get(s[l],0)
  c[s[l]] = c.get(s[l],0) + 1
print(ans)


Measured memory_bytes: 16296
from itertools import accumulate
max2 = lambda x,y: x if x > y else y
min2 = lambda x,y: x if x < y else y

N = int(input())
S = input()

res = 0
for i in range(1,N):
    m = 0
    r = 0
    for a,b in zip(S,S[i:]):
        if a == b:
            r += 1
        else:
            r = 0
        m = max2(m,r)
    m = min2(m,i)
    res = max2(res, m)

print(res)



Measured memory_bytes: 74396
#include <bits/stdc++.h>
#define ll long long int
#define N 1000
#define M 1000000007
#define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define fi first
#define se second
#define mp make_pair
#define bs binary_search
#define debug(x) cout << #x << " = " << x << endl
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define all(x) x.begin(), x.end()
#define PI 3.14159265
#define cot cout.tie(0)
using namespace std;
/**
  * @author :: Rishabh
  *
  */
int main()
{
	ibs;
	cti;
	int n,k;
	cin>>n>>k;
	int *a=new int[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	if(k>n)
	k=n;
	int dp[n];
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	int ans;
	for(int i=1;i<=k-1;i++)
	{
		ans=INT_MAX;
		for(int j=i+1;j>=1;j--)
		{
			ans=min((dp[j-1]+abs(a[i+1]-a[j-1])),ans);
		}
		dp[i+1]=ans;
	}
	for(int i=k+1;i<n;i++)
	{
		int p=i-1;
		ans=INT_MAX;
		for(int h=0;h<k;h++)
		{
			ans=min((ans,dp[p]+abs(a[i]-a[p])),ans);
			p--;
		}
		dp[i]=ans;
	}
	cout<<dp[n-1]<<"\n";
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main() {
    int i;
    int n;
    double ans;
    scanf("%d", &n);

    if(n % 2 == 0) {
        ans = n/2;
        ans /= n;
        printf("%f\n", ans);
    } else if (n % 2 != 0) {
        ans = (n - 1)/2 + 1;
        ans /= n;
        printf("%f\n", ans);
    }
    return 0;
}

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> p(h+2, vector<char>(w+2, '#'));
  for (int i = 1; i <= h; ++i) for (int j = 1; j <= w; ++j) cin >> p[i][j];
  rep(i, h+2) {
    rep(j, w+2) cout << p[i][j];
    cout << endl;
  }
  return 0;
}

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


int main() 
{


    string S;

    cin >>S;

  	bool flagB = false;
  	bool flagA = false;
    for(int i=0;i<3;i++){
      if(S.at(i)=='A')
        flagA=true;
      if(S.at(i)=='B')
        flagB=true;
    }
  
  	if(flagA&&flagB)
      cout<<"Yes"<<endl;
  	else
      cout<<"No"<<endl;

 

    return 0;
}

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

char s[10][10], t[10][10];

int main(){
    int n, m, k;
    scanf("%d %d %d", &n, &m, &k);
    for (int i = 1; i <= n; ++i){
        scanf("%s", &s[i][1]);
    }
    int nlmt = 1 << n, mlmt = 1 << m;
    int ans = 0;
    for (int i = 0; i < nlmt; ++i){
        for (int j = 0; j < mlmt; ++j){
            memcpy(t, s, sizeof(s));
            for (int _i = 1; _i <= n; ++_i){
                if (i >> _i-1 & 1){
                    for (int _j = 1; _j <= m; ++_j) t[_i][_j] = 'r';
                }
            }
            for (int _j = 1; _j <= m; ++_j){
                if (j >> _j-1 & 1){
                    for (int _i = 1; _i <= n; ++_i) t[_i][_j] = 'r';
                }
            }
            int cnt = 0;
            for (int _i = 1; _i <= n; ++_i){
                for (int _j = 1; _j <= m; ++_j){
                    if (t[_i][_j] == '#') ++cnt;
                }
            }
            if (cnt == k) ++ans;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 3824
/*---------------Go Code GO---------------*/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

template<typename T>
using Order_Set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define     PI              acos(-1.0)
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define     precision(a)    fixed<<setprecision(a)
#define     endl            '\n'
#define     Flush           cout<<flush
#define     LLMX            0x3fffffffffffffff


long long H,W;
char Maze[22][22];
int dis[22][22];

int X[] = {0,0,-1,1};
int Y[] = {1,-1,0,0};
int bfs(int x, int y, int d)
{
    int mx = 0;
    queue<pair<int,int> > qu;
    qu.push({x,y});
    dis[x][y]=d;
    while(qu.size())
    {
        x=qu.front().first;
        y=qu.front().second;
        qu.pop();
        for(int i=0; i<4; i++)
        {
            int dx = x + X[i];
            int dy = y + Y[i];
            if(Maze[dx][dy]=='.'&&dis[dx][dy]>dis[x][y]+1)
            {
                dis[dx][dy]=dis[x][y]+1;
                mx = max(mx,dis[dx][dy]);
                qu.push({dx,dy});
            }
        }
    }
    return mx;
}


int main()
{
    O_O;
    long long i,j,k,l,tst=0,ans=0, csno=0 ;
    cin>>H>>W;
    for(i=1; i<=H; i++)
    {
        for(j=1; j<=W; j++)
        {
            cin>>Maze[i][j];
            dis[i][j]=0x3fffffff;
        }
    }
    k=H*W;
    for(i=1; i<=H; i++)
    {
        for(j=1; j<=W; j++)
        {
            if(Maze[i][j]=='.')
            {
                ans=max(ans,bfs(i,j, H*W*k)-H*W*k);
                k--;
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#define rep(i, x) for(ll i = 0; i < x; i++)
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9+7;
const ll N = 5e5+5, inf = 1e9+5000;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

struct FenwickTree {
    vector<int> bit;  // binary indexed tree
    int n;

    FenwickTree(int n) {
        this->n = n;
        bit.assign(n, 0);
    }

    FenwickTree(vector<int> a) : FenwickTree(a.size()) {
        for (size_t i = 0; i < a.size(); i++)
            add(i, a[i]);
    }

    int sum(int r) {
        int ret = 0;
        for (; r >= 0; r = (r & (r + 1)) - 1)
            ret += bit[r];
        return ret;
    }

    int sum(int l, int r) {
        return sum(r) - sum(l - 1);
    }

    void add(int idx, int delta) {
        for (; idx < n; idx = idx | (idx + 1))
            bit[idx] += delta;
    }
};

vector<pair<int, int>> right_segs[500005]; // left, id

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n, q; cin >> n >> q;
  vector<int> a(n);
  rep (i, n) cin >> a[i];
  FenwickTree t(n);
  vector<int> last(500005, -1);
  vector<int> ans(q);

  rep (i, q) {
    int l, r; cin >> l >> r;
    l--, r--;
    right_segs[r].push_back({l, i});
  }

  for (int i = 0; i < n; i++) {
    if (last[a[i]] != -1) {
      t.add(last[a[i]], -1);
    }
    t.add(i, 1);
    last[a[i]] = i;

    for (auto p : right_segs[i]) {
      ans[p.second] = t.sum(p.first, i);
    }

  }

  for (int i = 0; i < q; i++) {
    cout << ans[i] << endl;
  }
  

  return 0;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  vector<string> A(N);
  vector<string> B(M);
  for (int i=0; i<N; i++) {
      cin >> A.at(i);
  }
  for (int i=0; i<M; i++) {
      cin >> B.at(i);
  }
  bool finished=false;
  bool finishedd=false;
  for (int i=0; i<=N-M; i++) {
      for (int j=0; j<=N-M; j++) {
          for (int k=0; k<M; k++) {
              for (int l=0; l<M; l++) {
                  if (A.at(i+k).at(j+l)!=B.at(k).at(l)) {
                      finished=true;break;
                  }
              }
              if(finished) {
                  finished=false;break;
              }
              if (k==M-1) {
                  finishedd=true;
              }
          }
      }
  }
  if (finishedd) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
from fractions import gcd

a, b = map(int, input().split())
g = gcd(a, b)
m = gcd(a, b)

c = 1
i = 2
while i * i <= g:
    if m % i == 0:
        c += 1
    while m % i == 0:
        m = m // i
    i += 1

if m > 1:
    c += 1
print(c)


Measured memory_bytes: 5560
#include <bits/stdc++.h>
using namespace std;
#define mxx 100001
typedef long long L;
L ar[mxx+5],gcd,sz,mx=-1,tgcd;
queue<L>q;
set<L>s;
void solve(L n){
	sort(ar,ar+n);
	gcd=ar[0];
	q.push(gcd);
	s.insert(gcd);sz=1;
	tgcd=ar[1];
	for(L i=1;i<n;i++){
		tgcd=__gcd(tgcd,ar[i]);
		L top,top1;
		while(true){
			top=q.front();top1=top;
			q.pop();
			if(top==gcd)break;
			top=__gcd(top,ar[i]);
			s.insert(top);
			if(sz!=s.size()){
				sz++;
				q.push(top);
			}
			else if(top==top1){
				q.push(top);
			}
		}
		q.push(top);
		if(top!=1){
			gcd=__gcd(gcd,ar[i]);
			s.insert(gcd);
			if(sz!=s.size()){
				q.push(gcd);sz++;
			}
		}
		gcd=q.back();
	}
}

int main()
{
	L n;
	scanf("%lld",&n);
	for(L i=0;i<n;i++)scanf("%lld",&ar[i]);
	solve(n);
	while(!q.empty()){
		mx=max(q.front(),mx);
		q.pop();
	}
	mx=max(tgcd,mx);
	printf("%lld\n",mx);
	return 0;
}

Measured memory_bytes: 1024
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import *
from bisect import *

def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

x = read()
ans = x // 11 * 2 + int(x % 11 > 0) + int(x % 11 > 6)
print(ans)



Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
/*    #ifndef ONLINE_JUDGE
      // for getting input from input.txt
      freopen("input.txt", "r", stdin);
      // for writing output to output.txt
      freopen("output.txt", "w", stdout);
  #endif*/
fast();
//ll  t;cin>>t;while(t--)
{
  ll a,r,g,b=0,c,x=0;
  cin>>r>>g;
  cout<<2*g-r<<endl;
  

}
return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  vector<int> task(3);
  cin >> task[0] >> task[1] >> task[2];
  sort(ALL(task));
  cout << task[2] - task[0] << "\n";
  return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
d = [0]*k
a = [0]*k
for i in range(k):
    d[i] = int(input())
    a[i] = list(map(int, input().split()))

total_list = []

for i in range(k):
    total_list += a[i]

uni = set(total_list)
ans = n - len(uni)

print(ans)

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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int N;
  int ans = INF;
  cin >> N;
  vector<int> X(N);
  rep(i, N)
    cin >> X[i];
  repto(i, 100) {
    int sum = 0;
    rep(j, N)
      sum += (X[j]-i)*(X[j]-i);
    ans = min(sum, ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N = int(input())
    T = list(map(int, input().split()))
    V = list(map(int, input().split()))
    end = 2 * sum(T)

    H = [INF] * (end + 10)
    now = 0
    for i, t in enumerate(T):
        for j in range(now, (now + t * 2) + 1):
            H[j] = min(H[j], V[i])
        now = now + t * 2

    H[0] = 0.0
    H[end] = 0.0
    for i in range(end):
        H[i + 1] = min(H[i + 1], H[i] + 1 / 2)
    for i in range(end, 0, -1):
        H[i - 1] = min(H[i - 1], H[i] + 1 / 2)

    ans = 0
    for i in range(end):
        ans += (H[i] + H[i + 1]) * 0.5 * (1/2)

    print(ans)


if __name__ == '__main__':
    main()


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

#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define reset(a, v) memset((a), v, sizeof(a))

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

const int N = 100005;

int n, k, s;
int ans[N];

int main() {
	scanf("%d %d %d", &n, &k, &s);
	for (int i = 0; i < n; i++) {
		if (s != (int)1e9) ans[i] = s+1;
		else ans[i] = s-1;
	}
	for (int i = 0; i < k; i++) ans[i] = s;
	for (int i = 0; i < n; i++) printf("%d%c", ans[i], i == n-1 ? '\n': ' ');
	return 0;
}

Measured memory_bytes: 1664
import sys
sys.setrecursionlimit(10**5)

def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LI_(): return [-1*int(x) for x in input().split()]
def II(): return int(input())
def IF(): return float(input())
def LM(func,n): return [[func(x) for x in input().split()]for i in range(n)]
mod = 1000000007
inf = float('INF')


def solve(L):
   L = L[1:-1]
   if L[0] != '[':
       return int(L)//2+1
   ret = []
   s=0
   c = 0

   for i in range(len(L)):
       if L[i] == '[':
           c += 1
       elif L[i] == ']':
           c -= 1
       if c == 0:
           ret.append(solve(L[s:i + 1]))
           s = i + 1
   ret.sort()
   return sum(ret[0:len(ret)//2+1])


N = II()
for i in range(N):
    L = input()
    print(solve(L))




Measured memory_bytes: 5688
s = input()
num1 = int((len(s)-1)/2)
num2 = int((len(s)+3)/2)
s2 = s[:num1]
s3 = s[num2-1:]
if s == s[::-1] and s2 == s2[::-1] and s3 == s3[::-1]:
    print('Yes')
else:
    print('No')

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

int main(){
	long long a;
	string b;

	cin >> a >> b;
	string c;
	c += b[0];
	c += b[2];
	c += b[3];

	cout << a * (long long)stoi(c) / 100 << endl;
}

Measured memory_bytes: 3616
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let mut a = get!(usize;n);

    a.sort();
    let len = a.len();
    let small = a.drain(0..len/2).collect::<Vec<_>>();
    let mut big = a;
    if n % 2 == 0 {
        println!("{}", 2*(big.iter().sum::<usize>()-small.iter().sum::<usize>())+small[small.len()-1]-big[0]);
    } else {
        let mid = big.remove(0);
        println!("{}", 2*(big.iter().sum::<usize>()-small.iter().sum::<usize>())+small[small.len()-1]-big[0]+max!(big[0]-mid, mid-small[small.len()-1]));
    }
        

}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
using namespace std;
int read(){
	int x=0;
	char ch=getchar();
	while (!isdigit(ch))
		ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x;
}
const int N=100005;
int n;
int a[N],b[N],A[N],B[N];
map <int,int> Map;
int fa[N],cnt[N];
int getf(int x){
	return fa[x]==x?x:fa[x]=getf(fa[x]);
}
void Merge(int x,int y){
	fa[getf(x)]=getf(y);
}
int main(){
	n=read();
	for (int i=1;i<=n;i++)
		a[i]=read(),a[n+1]^=a[i];
	for (int i=1;i<=n;i++)
		b[i]=read(),b[n+1]^=b[i];
	for (int i=1;i<=n+1;i++){
		A[i]=a[i];
		B[i]=b[i];
	}
	sort(A+1,A+n+2);
	sort(B+1,B+n+2);
	for (int i=1;i<=n+1;i++)
		if (A[i]!=B[i])
			return puts("-1"),0;
	int _n=0;
	for (int i=1;i<=n;i++)
		if (a[i]!=b[i])
			_n++,a[_n]=a[i],b[_n]=b[i];
	a[_n+1]=a[n+1],b[_n+1]=b[n+1];
	n=_n;
	int m=0;
	for (int i=1;i<=n+1;i++)
		a[i]=Map[a[i]]?Map[a[i]]:Map[a[i]]=++m;
	for (int i=1;i<=n+1;i++)
		b[i]=Map[b[i]];
	for (int i=1;i<=m;i++)
		fa[i]=i;
	for (int i=1;i<=n+1;i++)
		Merge(b[i],a[i]);
	for (int i=1;i<=m;i++)
		cnt[getf(i)]++;
	int ans=n-1;
	for (int i=1;i<=m;i++)
		if (cnt[i])
			ans++;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 7040
n,m,k=map(int,input().split(" "))
a=list(map(int,input().split(" ")))
b=list(map(int,input().split(" ")))

t=0
i=0
while i<n :
    if t+a[i]>k :
        break
    t+=a[i]
    i+=1

j=0
while j<m :
    if t+b[j]>k :
        break
    t+=b[j]
    j+=1

ans=i+j
while i>0 :
    i-=1
    t-=a[i]
    while j<m and t+b[j]<=k :
        t+=b[j]
        j+=1
    ans=max(ans,i+j)

print(ans)


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

int main() {
    int N;
    cin >> N;
    vector<pair<int,int>> pairvec(N);
    for(int i=0; i<N; i++){
        cin >> pairvec[i].first;
        pairvec[i].second = i+1; 
    }
    sort(pairvec.begin(),pairvec.end());
    for(int i=0; i<N; i++){
        cout << pairvec[i].second << " ";
    }
    return 0;
}

Measured memory_bytes: 1536
N,M  = map(int,input().split())

H = list(map(int,input().split()))

lis = [ [] for i in range(N)]

for i in range(M):

    A,B = map(int,input().split())

    A -= 1
    B -= 1

    lis[A].append(B)
    lis[B].append(A)

ans = 0

for i in range(N):

    flag = True

    for nex in lis[i]:

        if H[i] <= H[nex]:
            flag = False
            break

    if flag:
        ans += 1

print (ans)


Measured memory_bytes: 92896
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M;
    cin >> N >> M;
    if(M==0){
        cout << 0 << " " << 0 << endl;
        return 0;
    }
    VI p(M);
    VS S(M);
    rep(i,M){
        cin >> p[i];
        cin >> S[i];
    }
    map<ll, ll> count;
    int ans=0;
    VI judge(N+1);
    rep(i,M){
        if(judge[p[i]]==0){
            if(S[i]=="WA"){
                count[p[i]]++;
            }
            else{
                judge[p[i]]=1;
                ans++;
            }
        }
    }
    ll wa_sum=0;
    rep(i,N+1){
        if(judge[i+1]==1){
            wa_sum+=count[i+1];
        }
    }
    cout << ans << " " << wa_sum << endl;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define ALL(x) (x).begin(),(x).end()
#define PB push_back
#define MP make_pair
#define Mod 998244353
#define MOD 1000000007
using namespace std;
using lint = long long;
using vi = vector<lint>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<lint, lint>;

// cout << fixed << setprecision(12)

lint modpow(lint a, lint n, lint m = MOD){
  lint ans = 1;
  while(n>0){
    if(n%2==1) ans *= a; ans %= m;
    a *= a; a %= m;
    n /= 2;
  }
  return ans;
}

lint inv(lint a, lint m = MOD){
  return modpow(a, m-2, m);
}

///////////////////////////////////

int main(){
  lint N; cin>>N;
  lint cnt = 0;
  for(lint i=0; i<N; i++){
    lint tmp = i;
    tmp++;
    lint a;
    cin >> a;
    // cout << tmp*a << endl;
    cnt += (tmp*a % 2 == 1);
  }
  cout << cnt << endl;
}
    
 

Measured memory_bytes: 3572
str = input()
cnt = 0
max = 0

for i in range(len(str)):
  if str[i] == 'A' or str[i] == 'C' or str[i] == 'G' or str[i] == 'T':
    cnt += 1
  else:
    if max < cnt:
      max = cnt
      cnt = 0

if max < cnt:
   max = cnt
   cnt = 0

print(max)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



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

  ll W , a, b ; cin >> W >> a >> b ;
  if(b<a) swap(a,b);
  cout << max((ll)0,b - (W+a)) << endl;
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		
		boolean[] isOK = new boolean[100001];
		
		// initialize
		for (int i = 0; i < 100; ++i) isOK[i] = false;
		isOK[100] = true;
		isOK[101] = true;
		isOK[102] = true;
		isOK[103] = true;
		isOK[104] = true;
		isOK[105] = true;
		
		for (int i = 106; i <= N; ++i) {
			isOK[i] = isOK[i-100] || isOK[i-101] || isOK[i-102] || isOK[i-103] || isOK[i-104] || isOK[i-105];
		}

		
		System.out.println(isOK[N] ? "1" : "0");
		
	}
	
	
	
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


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


int main(){
    int n,ans=0;
    cin>>n;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin>>p.at(i);
    }
    for(int i=0;i<n;i++){	
        int S=sqrt(p.at(i));
        int f=0;
        for (int j = 2; j <= S; j++) {
            if(p.at(i)%j==0){f=1;}
        }
        if(f==0){
            ans+=1;
        }
    }
    cout<<ans<<endl;
}
      


Measured memory_bytes: 3128
#include <iostream>
using namespace std;
signed main(){
int a,b,c,d,e,f,g,h;
cin>>a>>e>>b>>f>>c>>g>>d>>h;
if(a==1){
cout<<e*6000<<endl;
}
else
if(a==2){
cout<<e*4000<<endl;
}
else
if(a==3){
cout<<e*3000<<endl;
}
else
if(a==4){
cout<<e*2000<<endl;
}
if(b==1){
cout<<f*6000<<endl;
}
else
if(b==2){
cout<<f*4000<<endl;
}
else
if(b==3){
cout<<f*3000<<endl;
}
else
if(b==4){
cout<<f*2000<<endl;
}
if(c==1){
cout<<g*6000<<endl;
}
else
if(c==2){
cout<<g*4000<<endl;
}
else
if(c==3){
cout<<g*3000<<endl;
}
else
if(c==4){
cout<<g*2000<<endl;
}
if(d==1){
cout<<h*6000<<endl;
}
else
if(d==2){
cout<<h*4000<<endl;
}
else
if(d==3){
cout<<h*3000<<endl;
}
else
if(d==4){
cout<<h*2000<<endl;
}
return(0);
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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 dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[4]={0,1,0,-1},mdy[4]={-1,0,1,0};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int h,w;
int n;
int a[10010];
int c[110][110];
int main(){
	cin>>h>>w;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	int l=1;
	for(int i=0;i<h;i++){
		for(int t=0;t<w;t++){
			int j=t;
			if(i%2==1)j=w-t-1;
			c[i][j]=l;
			a[l]--;
			if(a[l]==0)l++;
		}
	}
	REP(i,h){
		REP(j,w){
			cout<<c[i][j]<<" ";
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
N,M=map(int,input().split())    
X=list(map(int,input().split()))
X.sort()
Y=[]
for i in range(len(X)-1):
    Y.append(X[i+1]-X[i])
Y.sort()    
if N!=1:
    Y = Y[:-(N-1)]
    print(sum(Y))
else:
    print(sum(Y))

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s; cin >>s;
	int n = sz(s);
	VL dp(13); dp[0] =1;
	rep(i, n){
		VL np(13);
		int d = (s[i] =='?')?  99: s[i]-'0';
		rep(j, 13){
			if(d< 10) ( np[(j*10+d)%13] +=dp[j] ) %=MD;
			else  rep(k, 10) (np[(j*10+k)%13] += dp[j])%=MD;
		}
		swap(dp, np);
	}
	
	//for(auto x :dp) cerr<<x<<" "; dbg();
	cout << dp[5] <<"\n";
	
	return 0;
	
}


Measured memory_bytes: 3776