akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <numeric>
#include <iomanip>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>

///////////////////////////////////////////////////////////////
// namespace
///////////////////////////////////////////////////////////////
using namespace std;
// namespace mp = boost::multiprecision;

///////////////////////////////////////////////////////////////
// types
///////////////////////////////////////////////////////////////
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
// using mpi = mp::cpp_int;
// using mpf = mp::number<mp::cpp_dec_float<1024>>;

/////////////////////////////////////////////////////////////////
// https://github.com/atcoder-live/library/blob/master/mint.cpp
/////////////////////////////////////////////////////////////////
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main() {
    ld a, b; cin >> a >> b;
    printf("%.0Lf\n", floor(a * b));
    return 0;
}


Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  vi B(N+1);
  int ans=0;
  map<int,int> M;
  M[0]++;
  rep(i,0,N){
    B[i+1]=B[i]+A[i];
    ans+=M[B[i+1]];
    M[B[i+1]]++;
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 15872
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

using namespace std;
int main() {
	int a, p;
	cin >> a >> p;
	cout << (3 * a + p) / 2 << endl;
	return 0;
}

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

void solve(){
	int n , x , y;
	cin >> n >> x >> y;
	cout << min (n*x , y ) << endl;
	return;
}

int main(){
	int q = 1;
	//cin >> q;
	for(int i = 1; i <= q ; ++i){
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

struct Point {
  double x,y;
};

typedef struct Point Point;

void print(Point a);
double koch1(Point a,Point b);
void koch(int n, Point a, Point b);

int main(void)
{  
  Point a,b;
  int n;
  
  scanf("%d",&n);
  
  a.x=0;
  a.y=0;
  b.x=100;
  b.y=0;
  
  printf("%.8f %.8f\n",a.x,a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n",b.x,b.y);
  
  return 0;
}


void print(Point a)
{
  printf("%.8f %8f\n",a.x,a.y);
}

double koch1(Point a,Point b)
{
  return (2.0*a.x+1.0*b.x)/3.0;
}

void koch(int n, Point a, Point b)
{
  if(n==0)
    {
    return;
    }

  Point s,t,u;
  double th=M_PI*60.0/180.0;

  s.x= koch1(a,b);
  s.y=(2.0*a.y+1.0*b.y)/3.0;
  t.x=(1.0*a.x+2.0*b.x)/3.0;
  t.y=(1.0*a.y+2.0*b.y)/3.0;
  u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
  u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

  koch(n-1,a,s);
  print(s);  
  koch(n-1,s,u);
  print(u);
  koch(n-1,u,t);
  print(t);
  koch(n-1,t,b);
}



Measured memory_bytes: 2048
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <utility>
const int maxn = 2005;
using ll = long long;
const ll ha = 1000000007LL;
ll pow_mod(ll a, ll b) {
  ll ans = 1, res = a;
  while(b) {
    if(1LL & b) ans = ans * res % ha;
    res = res * res % ha; b >>= 1;
  }
  return ans;
}
ll inv(ll x) {
  return pow_mod(x, ha - 2LL);
}

ll fac[maxn * maxn], ifac[maxn * maxn];
void process() {
  fac[0] = 1;
  const int n = 4000005;
  for(int i = 1; i <= n; i ++) {
    fac[i] = fac[i - 1] * (ll)i % ha;
  }
  ifac[n] = inv(fac[n]);
  for(int i = n - 1; i >= 0; i --) {
    ifac[i] = ifac[i + 1] * (ll(i + 1)) % ha;
  }
}
ll C(int n, int m) {
  if(n < m) return 0;
  ll ret = fac[n] * ifac[n - m] % ha;
  ret = ret * ifac[m] % ha;
  return ret;
}

int main() {
  process();
  int n, k; scanf("%d%d", &n, &k);
  if(k == 1) {
    puts("1"); return 0;
  }
  static ll f[maxn];
  f[0] = 1;
  for(int i = 1; i <= n; i ++) {
    for(int j = 1; j <= i; j ++) {
      ll delta = n - j + 1;
      delta = delta * C(n * k - i - (j - 1) * (k - 1) - 1, k - 2) % ha;
      delta = delta * f[j - 1] % ha;
      f[j] += delta;
      if(f[j] >= ha) f[j] -= ha;
    }
  }
  printf("%lld\n", f[n]);
  return 0;
}

Measured memory_bytes: 62848
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<functional>
#include<algorithm>
#include<bitset>
#include<utility>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	int a,b;
	cin>>a>>b;
	if((a+b)&1)
		cout<<"IMPOSSIBLE";
	else
		cout<<(a+b)/2;
	return 0;
}


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

int main(){
	int n;
  	cin >> n;
  	string s;
  	cin >> s;
  	if(n & 1){
		cout << "No" << endl;
    }
	else{
      int flag=1;
      for(int i=0;i<n/2;i++){
        if(s[i] != s[i+n/2]){
       		flag=0; 
        }
      }
      if(flag)
        cout << "Yes" << endl;
      else
        cout << "No" << endl;
    }
 	return 0;
}

Measured memory_bytes: 256
S=list(input())
T=list(input())

for i in reversed(range(len(S)-len(T)+1)):
  c=0
  for j in range(len(T)):
    if S[i+j]==T[j] or S[i+j]=="?":
      c+=1
    else:
      break
  if c==len(T):
    for j in range(len(T)):
      S[i+j]=T[j]
    for k in range(len(S)):
      if S[k]=="?":
        S[k]="a"
    print("".join(S))
    exit()

print("UNRESTORABLE")

Measured memory_bytes: 3064
#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;

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF -1e18
#define INF 1e18
#define int ll int
#define OOK order_of_key  //no of elements less than
#define FBO find_by_order //iterator pointing kth element;indexing starts from 0
#define CK3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define CK4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef pair<int,pair<int,int>> PIPI;
typedef map<int,int>MII;
typedef vector<int> VI;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/*int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}
*/
//int modInverse(int a, int m) {return power(a, m-2);} //gcd(a,m)=1 


signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{//cout<<"Case #"<<T1<<": ";
    int n;
    cin>>n;
    string s;
    cin>>s;
    set<int> r,g,b;int ans=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='R')r.insert(i);
        if(s[i]=='G')g.insert(i);
        if(s[i]=='B')b.insert(i);
    }
    for(auto it:r)
    {
        for(auto it1:g)
        {
            int x=it;
            int y=it1;
            if(x>y)swap(x,y);int sum=0;
            if(x-(y-x)>=0)
            {
                if(b.find(x-(y-x))!=b.end())sum++;
            }
            if(y+(y-x)<n)
            {
                if(b.find(y+(y-x))!=b.end())sum++;
            }
            if((y-x)%2==0)
            {
                if(b.find((y+x)/2)!=b.end())sum++;
            }
            ans+=(b.size()-sum);
        }
    }
    cout<<ans<<endl;
}


return 0;
}





Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

ll a[N], use[N];
int main () {
	ios::sync_with_stdio(0), cin.tie(0);
    	ll x, n;
    	cin >> x >> n;
    	for (int i = 1; i <= n; i ++) {
    		cin >> a[i];
    		use[a[i]] = 1;
	}
	ll ans = 0;
	for (int i = 1; i < N; i ++) {
		if (use[i]) continue;
		if (abs(i - x) < abs(ans - x)) ans = i;
	}
	cout << ans;
    	
}

Measured memory_bytes: 3652
#include <iostream>
using namespace std;
typedef long long ll;

const ll mod = 1e9+7;
ll v[200005], iv[200005];

ll pow_mod(ll x, ll a) {
  ll an = 1, xx = x;
  while(a) {
    if (a&1) an = an * xx % mod;
    xx = xx * xx % mod;
    a>>=1;
  }
  return an;
}

ll ncr(ll n, ll r) {
  return v[n] * iv[n-r] % mod * iv[r] % mod;
}

int main() {
  v[0] = v[1] = 1;
  for(int i=2; i<200005; i++) {
    v[i] = v[i-1] * i % mod;
  }
  iv[200004] = pow_mod(v[200004], mod-2);
  for(int i=200003; i>=0; i--) {
    iv[i] = iv[i+1] * (i+1) % mod;
  }
  
  int h, w, a, b; cin >> h >> w >> a >> b;
  ll an = 0;
  
  for(int i=0; i<h-a; i++) {
    an += ncr(b+i-1, i) * ncr(h-i+w-b-2, h-i-1) % mod;
    an %= mod;
    //cout << b+i << " " << i << " " << h-i+w-b <<" " << h-i << endl;
  }
  cout << an << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <iomanip>
#include <set>
using namespace std;

int main() {
	// your code goes here
	int n; cin >> n;
	int input;
	std::multiset<int> set_length;
	
	for (int i = 0; i < n; i++)
	{
		cin >> input;
		set_length.insert(input);
	}
	
	int sum_length = 0;
	for (const auto& e : set_length)
	{
		sum_length += e;
	}

	if (sum_length - *set_length.rbegin() * 2 > 0)
		cout << "Yes";
	else
		cout << "No"; 

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;

int A=0, P=0;

int main(){
  cin >> A >> P;
  cout << (3*A + P) / 2 << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

int main()
{
    long long int n;
    long long int a[200010];
    long long int max = -1, max2 = -1, sub, sub2;

    cin >> n;

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

    for (int i = 0; i < n; i++) {
        if (max2 < a[i] && i != sub) {
            max2 = a[i];
            sub2 = i;
        }
    }

    for (int i = 0; i < n; i++) {
        if (i == sub) {
            cout << max2 << endl;
        }
        else {
            cout << max << endl;
        }
    }
}


Measured memory_bytes: 3200
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//(*'ω'*)ACほちぃ...
int main(){
    int n;cin>>n;
    lint x,y,x1,x2,y1,y2;
    vector<pair<lint,lint>> vec(n,pair<lint,lint>(0,0));
    for(int i=0;i<n;i++)cin>>vec[i].first>>vec[i].second;
    map<pair<lint,lint>,int> dic;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j)continue;
            x1=vec[i].first;
            y1=vec[i].second;
            x2=vec[j].first;
            y2=vec[j].second;
            x=x2-x1;y=y2-y1;
            dic[make_pair(x,y)]++;
        }
    }
    int freq=0;
    for(auto p:dic){
        if(p.second>freq){
            x=p.first.first;
            y=p.first.second;
            freq=p.second;
        }
    }
    lint tx,ty;
    int ans=n;
    for(int i=0;i<n;i++){
        tx=vec[i].first+x;ty=vec[i].second+y;
        for(int j=0;j<n;j++){
            if(tx==vec[j].first && ty==vec[j].second)ans--;
        }
    }
    cout<<ans<<endl;
}


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

int main() {
  int A, N, x, ans;
  cin >> N;
  ans = 100;
  for(int i = 0; i < N; i++){
    cin >> A;
    x = 0;
    if(A % 2 != 0){
      ans = 0;
      break;
    }
    else{
      while(A % 2 == 0){
        A /= 2;
        x++;
      }
      if(ans > x){
        ans = x;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

const int mod = 1000000007;
struct mint {
    long long x;
    mint(long long x=0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
bool operator==(const mint& a, const mint& b) { return a.x == b.x;}

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<mint> dp(k+1);
    dp[0] = 1;
    rep(i, n) {
        rep(j, k) dp[j+1] += dp[j];
        rrep(j, k+1) if (j >= a[i]+1) dp[j] -= dp[j-a[i]-1]; 
    }
    cout << dp[k] << endl;
}


Measured memory_bytes: 3976
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <unordered_map>
 
using namespace std;
typedef long long ll;
 
int main()
{
    ll N;
    cin >> N;
    if(N == 1){
        cout << "Hello World";
    }
    else {
        ll A, B;
        cin >> A >> B;
        cout << A+B;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define x first
#define y second
#define mp make_pair
#define pb push_back
template <typename TYPE> inline void chkmax(TYPE &x,TYPE y){x<y?x=y:0;}
template <typename TYPE> inline void chkmin(TYPE &x,TYPE y){y<x?x=y:0;}
template <typename TYPE> void readint(TYPE &x)
{
    x=0;int f=1;char c;
    for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
    for(;isdigit(c);c=getchar())x=x*10+c-'0';
    x*=f;
}
const int MAXN=1000005,K[3]={2,3,5};

ll n,a[6],b;
map<ll,ll> f;
ll dp(ll n)
{
	if(!n)return 0;
	if(f.count(n))return f[n];
	ll ans=1ll<<60;
	if(ans/n>=b)ans=n*b;
	for(int t=0;t<3;++t)
	{
		int k=K[t];
		chkmin(ans,(n%k)*b+a[k]+dp(n/k));
		if(n%k && n!=n/k+1)chkmin(ans,(k-(n%k))*b+a[k]+dp(n/k+1));
	}
	return f[n]=ans;
}
void solve()
{
	cin>>n>>a[2]>>a[3]>>a[5]>>b;
	f.clear();
//for(int i=1;i<=n;++i)cerr<<dp(i)<<" ";cerr<<endl;
	cout<<dp(n)<<endl;
}

int main()
{
	#ifndef ONLINE_JUDGE
//	freopen("code.in","r",stdin);
//	freopen("code.out","w",stdout);
	#endif
	int T;
	readint(T);
	while(T--)solve();
	return 0;
}

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

int main(){

    int n,m;
    cin >> n >> m;

    vector<string> a(m);
    rep(i,m) cin >> a[i];

    vector<int> f={0,2,5,5,4,5,6,3,7,6};

    vector<int> dp(n+1,-1);
    dp[0]=0;

    for(int i=1;i<=n;i++){
        for(int j=0;j<m;j++){
            if(i-f[a[j][0]-'0']>=0&&dp[i-f[a[j][0]-'0']]!=-1){
                dp[i]=max(dp[i],dp[i-f[a[j][0]-'0']]+1);
            }
        }
    }

    sort(a.begin(),a.end(),greater<string>());
    int t=n;
    string ans="";
    while(t>0){
        for(int j=0;j<m;j++){
            if(t-f[a[j][0]-'0']>=0){
                if(dp[t]-1==dp[t-f[a[j][0]-'0']]){
                    ans+=a[j];
                    t-=f[a[j][0]-'0'];
                    break;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

int main(){
    ll N;
    cin >> N;
    ll a = 0, un = 0, ng = 0;
    for(ll i = 0; i < N; i++){
        string s;
        cin >> s;
        if(s == "A")a++;
        else un++;
        if(un > a)ng = 1;
    }
    if(a != un)ng = 1;
    Say(!ng, "YES", "NO");
    return 0;
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
string s[10];

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    for (int i = 0; i < h; i++) cin >> s[i];

    int ans = 0;
    for (int r = 0; r < (1<<h); r++) {
        for (int c = 0; c < (1<<w); c++) {
            int cnt = 0;
            for (int i = 0; i < h; i++) {
                if (r&(1<<i)) continue;
                for (int j = 0; j < w; j++) {
                    if (c&(1<<j)) continue;
                    cnt += s[i][j]=='#';
                }
            }
            ans += cnt == k;
        }
    }

    cout << ans << endl;


    return 0;
}



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

int main() {
	int N; cin >> N;
	int a[110];
	for(int i=0; i<N; ++i) cin >> a[i];
	int S=0;
	for(int i=1; i<N; ++i){
	    if(a[i-1]==a[i]){
	        a[i]=-1;
	        ++S;
	    }
	}
	cout << S << endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

H,W = map(int, input().split())
HW = []
for i in range(H):
    HW.append(list(map(int, input().split())))

ans = []
for i in range(H):
    for j in range(W):
        # 該当マスが奇数の時に処理
        if HW[i][j] % 2 == 1:
            # 最終行以外全部下に移動
            if i != H-1:
                HW[i+1][j] += 1
                HW[i][j] -= 1
                ans.append([i+1, j+1, i+1+1, j+1])
            else:
                # 最終行は最後のマス以外全部右に移動
                if j != W-1:
                    HW[i][j+1] += 1
                    HW[i][j] -= 1
                    ans.append([i+1, j+1, i+1, j+1+1])

# 操作回数から出力
print(len(ans))
for s in ans:
    print(' '.join(map(str, s)))

Measured memory_bytes: 29804
number = int(input())
words = {}
answer = []
maxnum = 0
for i in range(number):
    word = input()
    if word in words:
        words[word] += 1
    else:
        words[word] = 1
    if maxnum < words[word]:
        maxnum = words[word]
        answer.clear()
        answer.append(word)
    elif maxnum == words[word]:
        answer.append(word)
answer.sort()
for j in range(len(answer)):
    print(answer[j])

Measured memory_bytes: 141780
def bisect(x):
    l,r=-1,M+1
    while(r-l>1):
        mid=(l+r)//2
        if cumB[mid]>=x:
            r=mid
        else:
            l=mid
    return l

N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
cumB=[0]*(M+1)
for i in range(M):
    cumB[i+1]=cumB[i]+B[i]
c=0
ans=0
for i in range(N+1):
    if c>K:
        break
    r=K-c
    b=bisect(r+1)
    ans=max(ans,i+b)
    if i!=N:
        c+=A[i]
print(ans)

Measured memory_bytes: 111400
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    string S; cin >> S;
    reverse(S.begin(), S.end());
    int start = S.size();
    rep(i, S.size()) {
        if(S[i] == 'W') {
            start = i;
            break;
        }
    }
    ll ans = 0, count = 0;
    for(int i = start;i < S.size(); ++i) {
        if(S[i] == 'W') ++count;
        else ans += count;
    }
    cout << ans << endl;
}


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

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

    int t[n], x[n], y[n];

    for (int i=0; i<n; i++) {
        scanf("%d%d%d", &t[i], &x[i], &y[i]);

        if (x[i] + y[i] > t[i]) {
            printf("No\n");
            return 0;
        }
        if ((x[i] + y[i]) % 2 != t[i] % 2) {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
}

Measured memory_bytes: 1280
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};


bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  ll res=0;
  int N,K;
  cin >> N >> K;
  if(K == 0){
   for(int i=K+1;i<=N;i++){
    res += (N/i)*(i-K) +  N%i;
  } 
  }else{
  for(int i=K+1;i<=N;i++){
    res += (N/i)*(i-K) + (N%i >= K ? N%i-K+1 : 0);
  }
  }
  cout << res << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
const int MOD = 1000000007;
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 10000000000000000; //10^16
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    ll N,M;
    cin >> N >> M;
    vector<pair<ll,ll>> ab(N);
    for (ll i = 0; i < N; i++){
        cin >> ab.at(i).first >> ab.at(i).second;
    }
    
    sort(ab.begin(), ab.end());

    priority_queue<ll, vector<ll>, less<ll>> c;

    ll cnt = 0;
    ll ans = 0;
    for(ll i = 1; i <= M; i++){
        for(; cnt < N; cnt++){
            if(ab.at(cnt).first > i) break;
            c.push(ab.at(cnt).second);
        }
        if(c.empty()) continue;
        ans += c.top();
        c.pop();
    }
    printf("%lld\n", ans);
    


}


Measured memory_bytes: 2936
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int arr[200200];
int cnt[200200];
int main()
{
    int n,i,j,k,x,y,ans,curr,m;
    int tc;
    cin >> n;
    ll chaeng = 0;
    for(i=1;i<=n;i++) {
        cin >> arr[i];
        cnt[arr[i]]++;
        chaeng += arr[i];
    }
    int q;
    cin >> q;
    while(q--) {
        int a, b;
        cin >> a >> b;
        chaeng -= 1LL * cnt[a] * a;
        chaeng += 1LL * cnt[a] * b;
        cnt[b] += cnt[a];
        cnt[a] = 0;
        cout << chaeng << endl;
    }
    return 0;
}


Measured memory_bytes: 4412
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

int main()
{

  int step_num;
  int dp[31];

  fill(dp,dp + 31,0);

  0[dp] = 1;

  for(int i = 1; i <= 30; ++i)
    {
      for(int j = 1; j <= 3; ++j)
        {

          if( i - j >= 0)   dp[i] = dp[i] + dp[i - j];

        }
    }

  while(cin >> step_num && step_num != 0) { cout << dp[step_num]/10/365 + 1<< endl; }

  return 0;

}

Measured memory_bytes: 1160
/**
 *     created by: nayakashutosh9
 *	   "Winners Never Quit and Quitters Never Win".
**/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl '\n'
#define mod 1000000007
#define inf 1e18
const int N = 300005;

/*************************************/



void solve() {

	int n; cin >> n;
	int x = n / 1000;
	if (n % 1000 != 0) x++;
	cout << (x * 1000 - n) << endl;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t = 1, z = 1;
	// cin >> t; cin.ignore();
	while (t--) {
		// cout<<"Case #"<<(z++)<<": ";
		// clock_t clockst = clock();
		solve();
		// clock_t clocked = clock();
		// cout << clocked - clockst << endl;
	}

	return 0;
}

Measured memory_bytes: 3644
from collections import Counter

n = int(input())
l = list(map(int, input().split()))
d = Counter(l)
ite = sorted(d.items(), key=lambda x: (-x[0], -x[1]))
first = 0
taken = False
second = 0
for i in range(len(ite)):
    if ite[i][1] >= 4:
        if not taken:
            print(ite[i][0] * ite[i][0])
            exit()
        elif taken:
            second = ite[i][0]
            break
        exit()
    elif ite[i][1] >= 2 and not taken:
        first = ite[i][0]
        taken = True
    elif ite[i][1] >= 2 and taken:
        second = ite[i][0]
        break
print(first * second)

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

#define len(s) int(s.size())
#define res(x) cout<<((x)?"No\n":"Yes\n")
#define all(v) v.begin(),v.end()

typedef long long ll;
typedef long double ld;

ll mod = 1e9+7;

void solution() {
	vector<int> s(5);
	for(int& x:s){
		cin >> x;
	}
	for(int i = 0; i < len(s); ++i) {
		if(!s[i]) {
			cout << i+1;
		}
	}
	
}

int main(){
	
	int t = 1;
	//cin >> t;
	
	while(t--)
		solution();
	
	return 0;
}


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int sum = 0;
    for(int i = 1; i <= n; i++)
    {
        sum += i;
    }
    cout << sum << endl;
    return 0;
}


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

const int MAX_N = 501;

int main(){
  int N,M,Q;
  cin >> N >> M >> Q;
  int data[MAX_N][MAX_N];
  for(int i = 0 ; i < MAX_N ; i++){
    for(int j = 0 ; j < MAX_N ; j++){
      data[i][j] = 0;
    }
  }
  
  for(int i = 0 ; i < M ; i++){
    int l,r;
    cin >> l >> r;
    data[l][r]++;
  }

  for(int i = 0 ; i <= N ; i++){
    for(int j = 1 ; j <= N ; j++){
      data[i][j] += data[i][j-1];
    }
  }

  for(int i = 0 ; i < Q ; i++){
    int p,q;
    cin >> p >> q;
    long long int res = 0;
    for(int j = p ; j <= q ; j++){
      res += data[j][q] - data[j][p-1];
    }
    cout << res << endl;
  }
  
  return 0;
}


Measured memory_bytes: 1920
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        Set<Integer> answers = new HashSet<>();
        answers.add(1);
        answers.add(2);
        answers.add(3);

        answers.remove(a);
        answers.remove(b);

        System.out.println(answers.toArray()[0]);
    }
}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
long long M=1e9+7;
int solve(){
	int n,K,x,y,p,q;
	cin>>n>>K;
	vector<int>A(n);
	for(int i=0;i<n;i++) cin>>A[i];
	long long dp[n][K+1];
	memset(dp,0,sizeof(dp));
	for(int i=0;i<=min(A[0],K);i++) dp[0][i]=1;
	for(int i=1;i<n;i++){
		//check 7 dec 16 in diary for solution;
		x=min(A[i],K);
		dp[i][0]=1;
		// cout<<x<<"\n";
		for(int k=1;k<=x;k++){
			dp[i][k]=(dp[i][k-1]+dp[i-1][k])%M;
		}
		for(int k=x+1;k<=K;k++){
			dp[i][k]=(dp[i-1][k]+dp[i][k-1]-dp[i-1][k-1-x]+M)%M;	
		}
		
	}
	return dp[n-1][K];

}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<solve()<<"\n";

}

Measured memory_bytes: 81640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define MAX_NM 100000

using namespace std;
typedef pair<int, int> ipair;

int dif[MAX_NM + 2];
int arr[MAX_NM + 2];
int main(int argc, char **argv) {
    int N, M;
    cin >> N >> M;
    for(int i = 0; i < M; ++i) {
        int L, R;
        cin >> L >> R;
        dif[L]++;
        dif[R + 1]--;
    }
    
    int res = 0;
    for(int i = 1; i <= N; ++i) {
        arr[i] = arr[i - 1] + dif[i];
        if(arr[i] == M)
            ++res;
    }
    
    cout << res << endl;
}

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

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

    vector<int> era(n + 1, 0);
    era[0] = 0;

    for (int i = 1; i <= n; ++i)
    {
        for (int j = i; j <= n; j += i)
            ++era[j];
    }

    ll ans = 0;
    for (ll i = 1; i <= (ll)n; ++i)
        ans += era[i] * i;

    cout << ans << endl;
}

Measured memory_bytes: 42324
#include <cstdio>
#include <vector>
using namespace std;

int main() {
	int n;
	(void)scanf("%d", &n);
	vector<int> v(n);
	for (int i = 0; i < n; i++) {
		(void)scanf("%d", &v[i]);
	}
	printf("%d", v[n - 1]);
	for (int i = n-2; i >= 0; i--) {
		printf(" %d", v[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2744
dd = (0, 0, -1, 0)
dm = (1, -1, 0, 0)
da = (1, 0, 0, 0)
md = (-1, 1, 2, 0)
mm = (0, 0, 1, 0)
ma = (0, 1, 1, 0)
cd = (-1, 0, -1, 1)
cm = (0, -1, 0, 1)
ca = (0, 0, 0, 1)
ad = (-1, 0, -1, 0)
am = (0, -1, 0, 0)
aa = (0, 0, 0, 0)

convert :: (Char, Char) -> (Int, Int, Int, Int)
convert ('D', c) =
  case c of
    'D' -> dd
    'M' -> dm
    _   -> da
convert ('M', c) =
  case c of
    'D' -> md
    'M' -> mm
    _   -> ma
convert ('C', c) =
  case c of
    'D' -> cd
    'M' -> cm
    _   -> ca
convert (_, c) =
  case c of
    'D' -> ad
    'M' -> am
    _   -> aa

count :: (Int, Int, Int, Int) -> (Int, Int, Int, Int) -> (Int, Int, Int, Int)
count (d, m, dm, dmc) (v0, v1, v2, v3) = (u0, u1, u2, u3)
  where
    u0 = d + v0
    u1 = m + v1
    u2 = dm + du2
    u3 = dmc + v3 * dm
    du2 = case v2 of
            0 -> 0
            1 -> d
            2 -> d - u1
            _ -> - u1

solve :: String -> Int -> Int
solve s k = ans
  where
    (_, _, _, ans) = foldl count (0, 0, 0, 0) $ map convert $ zip s $ (replicate (k - 1) '_') ++ s

main :: IO ()
main = do
  n <- readLn :: IO Int
  s <- getLine
  q <- readLn :: IO Int
  ks <- (fmap (\s -> read s :: Int)) . words <$> getLine
  mapM_ (print . (solve s)) ks


Measured memory_bytes: 56700
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    double r;
    cin >> r;
    double pi = acos(-1);
    cout << fixed << setprecision(10) << 2.0 * pi * r << "\n";
    return 0;
}

Measured memory_bytes: 3820
#include<iostream>
#include<string>
#include<cstdio>
#include<stack>
#include<algorithm>
using namespace std;
string str1;
string str2;
stack<int> sta;

int main()
{
  int n;
  int i,j;
  int exc;//??°?????????
  int sum;

  cin>>n;
  for(i=0;i<n;i++){
    cin>>str1;
    cin>>str2;
    if(str1.size()>80 || str2.size()>80){
      cout<<"overflow"<<endl;
      continue;
    }
    exc=0;
    for(j=1;j<=min(str1.size(),str2.size());j++){
      sum=str1[str1.size()-j]-'0'+str2[str2.size()-j]-'0'+exc;
      exc=sum/10;
      sta.push(sum%10);
    }
    if( str1.size() < str2.size() ){
      while(j<=str2.size()){
	sum=str2[str2.size()-j]-'0'+exc;
	exc=sum/10;
	sta.push(sum%10);
	j++;
      }
    }else if( str1.size() > str2.size() ){
      while(j<=str1.size()){
	sum=str1[str1.size()-j]-'0'+exc;
	exc=sum/10;
	sta.push(sum%10);
	j++;
      }
    }
    if(max(str1.size(),str2.size())==80 && exc==1){
      cout<<"overflow"<<endl;
      continue;
    }
    if(exc)
      cout<<exc;
    for(j=0;j<max(str1.size(),str2.size());j++){  
      cout<<sta.top();
      sta.pop();
    }
    cout<<endl;
  }
}

Measured memory_bytes: 1208
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>
#include <bitset>

#define P pair
#define X first
#define Y second
#define VSORT(v) sort(v.begin(), v.end())
#define VREV(v) reverse(v.begin(), v.end())
#define VMAX_P(v) max_element(v.begin(), v.end())
#define VMIN_P(v) min_element(v.begin(), v.end())
#define VMAX_IDX(v) distance(v.begin(), VMAX_P(v))
#define VMIN_IDX(v) distance(v.begin(), VMIN_P(v))
#define VCOPY(src, dst) copy(src.begin(), src.end(), back_inserter(dst))
#define SUPPER(src, dst) transform(src.begin(), src.end(), dst.begin(), toupper);
#define SLOWER(src, dst) transform(src.begin(), src.end(), dst.begin(), tolower);

using namespace std;
using ll = long long;

void displayVec(vector<int> v)
{
    for (int i = 0; i < v.size(); i++)
    {
        cout << v[i] << endl;
    }
    cout << endl;
}

int binarySearch(vector<int> v, int target)
{
    int left = -1;
    int right = v.size();

    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (v[mid] >= target)
        {
            right = mid;
        }
        else
        {
            left = mid;
        }
    }

    if (right < v.size() && v[right] == target)
    {
        return right;
    }
    return -1;
}

int main(int argc, const char *argv[])
{
    int n;
    cin >> n;
    vector<int> v(n), w(n);
    for (int i = 0; i < n; i++)
    {
        cin >> w[i];
    }

    v[0] = w[0];
    for (int i = 1; i < n; i++)
    {
        v[i] = v[i - 1] + w[i];
    }

    int ans = INT_MAX;
    for (int i = 0; i < n - 1; i++)
    {	
        ans = min(ans, abs((v[n - 1] - v[i]) - v[i]));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];

bool cmp(pint a, pint b) { return a.second > b.second; }
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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll a,b;cin>>a>>b;
  if(a>=13){
    cout<<b<<endl;
  }else if(a>=6 && a<=12){
    cout<<b/2<<endl;
  }else{
    cout<<0<<endl;
  }
}

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

//#pragma gcc optimize("O3,unroll-loop")
//#pragma gcc target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,abm,mmx,popcnt,tune=native")
//#define int long long
//#define double long double

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

    int a, b, c;
    cin >> a >> b >> c;
    for (int i = b; i <= c; i++)
        if (i % a == 0)
            cout << "OK\n", exit(0);
    cout << "NG\n";

    return 0;
}

//      *   *  *****  *   *  *   *
//     *   *  *      **  *  *   *
//    *****  *****  * * *  *   *
//   *   *      *  *  **  *   *
//  *   *  *****  *   *   ***

//      ***** ***** *   * *     ***** *   * ***** *****
//        *  *   * *   * *       *   **  *   *   *   *
//       *  *   * ***** *       *   * * *   *   *****
//   *  *  *   *   *   *       *   *  **   *   *
//  ****  *****   *   ***** ***** *   *   *   *


Measured memory_bytes: 3644
s=list(input())
flag=3;
if 1<=int(s[0])*10+int(s[1])<=12:
	flag-=2
if 1<=int(s[2])*10+int(s[3])<=12:
	flag-=1
print(["AMBIGUOUS","MMYY","YYMM","NA"][flag])

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

using namespace std;

int solve(const vector<int>& a, int k) {
    const int n = a.size();
    int count = 1;
    set<int> seg;
    vector<int> s(n);
    s[0] = 1;
    for (int i = 1; i < n; ++i) {
        if (a[i] > a[i - 1])
            s[i] = s[i - 1] + 1;
        else
            s[i] = 1;
    }
    if (*max_element(s.begin(), s.end()) >= k && s[k - 1] < k)
        ++count;
    for (int i = 0; i < k; ++i)
        seg.insert(a[i]);
    for (int i = k; i < n; ++i) {
        if (a[i - k] == *seg.begin() && a[i] > *(seg.rbegin()))
            ;
        else if (s[i] < k) {
            ++count;
        }
        seg.erase(a[i - k]);
        seg.insert(a[i]);
    }
    return count;
}
int solve_naive(const vector<int>& a, int k) {
    const int n = a.size();
    set<vector<int>> s;
    for (int i = k; i <= n; ++i) {
        vector<int> b = a;
        sort(b.begin() + i - k, b.begin() + i);
        s.insert(b);
    }
    return s.size();
}
int main() {
//    int n = 7;
//    vector<int> a(n);
//    iota(a.begin(), a.end(), 0);
//    do {
//        for (int k = 2; k <= n; ++k) {
//            if (solve(a, k) != solve_naive(a, k)) {
//                cout << n << " " << k << "\n";
//                cout << solve(a, k) << " " << solve_naive(a, k) << "\n";
//                for (int v: a)
//                    cout << v << " ";
//                cout << "\n";
//            }
//        }
//    } while (next_permutation(a.begin(), a.end()));
//    cout << "done\n";
//    return 0;
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    cout << solve(a, k) << "\n";
    return 0;
}


Measured memory_bytes: 11264
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0162

"""
import sys
from sys import stdin
from bisect import bisect_right, bisect_left
from math import ceil, log
input = stdin.readline


def main(args):
    hammings = []

    temp = set()
    for i in range(ceil(log(1e6, 2)) + 1):
        for j in range(ceil(log(1e6, 3)) + 1):
            for k in range(ceil(log(1e6, 5)) + 1):
                ans = 2**i * 3**j * 5**k
                temp.add(ans)

    hammings = list(temp)
    hammings.sort()

    while True:
        try:
            m, n = map(int, input().split(' '))
        except ValueError:
            break

        s = bisect_left(hammings, m)
        t = bisect_right(hammings, n)

        print(t - s)


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7824
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
typedef vector<int> vi;
typedef vector<vector<int>> vi2;
int main(void)
{
    int H, W;
    cin >> H >> W;
    string *s;
    s = new string[H];
    for (int i = 0; i < H; i++)
    {
        cin >> s[i];
    }
    for (int i = 0; i < H; i++)
    {
        cout << s[i] << endl;
        cout << s[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void *wmem;
template<class T1, class T2> void sortA_L(int N, T1 a[], T2 b[], void *mem = wmem){
  int i;
  pair<T1, T2> *arr=(pair<T1, T2> *) mem;
  for(i=0;i<N;i++){
    arr[i].first = a[i];
    arr[i].second = b[i];
  }
  sort(arr, arr+N);
  for(i=0;i<N;i++){
    a[i] = arr[i].first;
    b[i] = arr[i].second;
  }
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class T> inline T popFirst(multiset<T> &a){
  T res=*(a.begin());
  a.erase(a.begin());
  return res;
}
template<class T> inline T popFirst(set<T> &a){
  T res=*(a.begin());
  a.erase(a.begin());
  return res;
}
template<class S, class T> inline S chmax(S &a, T b){
  if(a<b){
    a=b;
  }
  return a;
}
char memarr[96000000];
int N;
int K;
int T[100000];
int D[100000];
int main(){
  int i, j;
  long long res, tmp;
  multiset<int> deletable;
  set<int> used;
  wmem = memarr;
  rd(N);
  rd(K);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(T[Lj4PdHRW]);
      rd(D[Lj4PdHRW]);
    }
  }
  sortA_L(N, D, T);
  res = tmp = 0;
  for(i=N-1;i>=0;i--){
    if(used.count(T[i])){
      deletable.insert(D[i]);
    }
    else{
      used.insert(T[i]);
    }
    tmp += D[i];
    if(K==0){
      if(deletable.size()==0){
        break;
      }
      tmp -= popFirst(deletable);
    }
    else{
      K--;
    }
    chmax(res, tmp + (long long)used.size() * (long long)used.size());
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190715-1

// --- original code ---
// int N, K, T[1d5], D[1d5];
// {
//   int i, j;
//   ll res, tmp;
//   
//   set<int> used;
//   multiset<int> deletable;
// 
//   rd(N,K,(T,D)(N));
//   sortA(N, D, T);
// 
//   res = tmp = 0;
//   for(i=N-1;i>=0;i--){
//     if(used.count(T[i])){
//       deletable.insert(D[i]);
//     } else {
//       used.insert(T[i]);
//     }
//     tmp += D[i];
// 
//     if(K==0){
//       if(deletable.size()==0) break;
//       tmp -= popFirst(deletable);
//     } else {
//       K--;
//     }
// 
//     res >?= tmp + (ll)used.size() * (ll)used.size();
//   }
// 
//   wt(res);
// }


Measured memory_bytes: 6272
#![doc = " # Bundled libraries"]
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
fn main() {
    input! { n : usize , }
    let mut res = 0;
    for a in 1..n {
        res += (n - 1) / a;
    }
    println!("{}", res);
}


Measured memory_bytes: 2176
#include <iostream>
#include <cstdio>
#include <math.h>
using namespace std;

int main ()
{
    double dx = 0, dy = 0, x, y, t = 90.0;
    while (scanf("%lf,%lf", &x, &y), x || y) {
        dx += x * cos(t * M_PI / 180.0);
        dy += x * sin(t * M_PI / 180.0);

        t -= y;
    }

    cout << (int)dx << endl << (int)dy << endl;

    return 0;
}

Measured memory_bytes: 1236