akhauriyash/Code-Regression huggingface dataset:
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n";
#define int long long
#define mod 1000000007

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// template<class... Args>
// auto create(size_t n, Args&&... args) {
// 	if constexpr(sizeof...(args) == 1)
// 		return vector(n, args...);
// 	else
// 		return vector(n, create(args...));
// }

// template<typename... T>
// void read(T&... args) {
// 	((cin >> args), ...);
// }

// template<typename... T>
// void write(T&&... args) {
// 	((cout << args), ...);
// }

string solveUtil(int i) {
	return (i < 0 ? "" : solveUtil((i / 26) - 1) + (char)(65 + i % 26));
}

void solve() {
	int n;
	cin >> n;
	string ans = solveUtil(n - 1);
	for(auto ele : ans)
		cout << (char)tolower(ele);
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;
}


Measured memory_bytes: 3640
a=(int)(input())
b=(int)(input())
c=(int)(input())
n=(int)(input())

count = 0
for i in range(a + 1):
  for j in range(b + 1):
    if (n - (i * 500 + j * 100)) % 50 == 0 and 0 <= (n - (i * 500 + j * 100)) // 50 <= c:
      count += 1
      #print(i, j)
print(count)

Measured memory_bytes: 9080
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x,n;
    cin >> x >> n;
    int p[n];
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    for(int d=0;true;d++){
        for(int sn=-1;sn<=1;sn+=2){
            int f=1,y = x + d*sn;
            for(int i=0;i<n;i++){
                if(y==p[i]){
                    f=0;
                }
            }
            if(f){
                cout << y << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <vector>

using namespace std;

int n,k,mx = -1,gg,x;

int gcd(int a,int b){
    if(a < b) return gcd(b,a);
    if(!b) return a;
    return gcd(b,a%b);
}

int main(){
    scanf("%d %d %d",&n,&k,&gg);
    mx = gg;
    for(int i = 1;i<n;i++){
        scanf("%d",&x);
        gg = gcd(gg,x);
        if(x > mx)
            mx = x;
    }
    if(k <= mx && k % gg == 0){
        printf("POSSIBLE\n");
    }
    else{
        printf("IMPOSSIBLE\n");
    }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int i;cin>>i;int flag=0;
  for(int j=i;j>=0;j--){
    //cout<<j<<endl;
    for(int k=j;;){
      //cout<<k<<" ";
      if(k==1){flag=1;break;}
      if(k%2!=0)break;
      if(k==2){flag=1;break;}
      k=k/2;
    }
    //cout<<endl;
    if(flag){
      cout<<j<<endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
let n, m = Scanf.scanf " %d %d" @@ fun a b -> a, b
let xys = Array.init m @@ fun _ -> Scanf.scanf " %d %d" @@ fun a b -> a - 1, b - 1
let rs, bs = Array.(make n false, make n 1)
let _ = rs.(0) <- true; Array.(iteri (fun i (x, y) -> rs.(y) <- rs.(y) || rs.(x); bs.(x) <- bs.(x) - 1; if bs.(x) = 0 then rs.(x) <- false; bs.
(y) <- bs.(y) + 1) xys; Printf.printf "%d\n" @@ fold_left (fun c b -> c + if b then 1 else 0) 0 rs)

Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,0,n) cin>>a[i];
  bool p=true;
  rep(i,0,n){
    if(a[i]%2==0){
      if(a[i]%3!=0 && a[i]%5!=0){
        p=false;
      }
    }
  }
  if(p) cout<<"APPROVED"<<endl;
  else cout<<"DENIED"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll n,m;cin>>n>>m;
    vvi v(n,vi(m));
    rep(i,n)rep(j,m)cin>>v[i][j];
    ll ans=n;
    vi id(n);
    rep(i,n)rep(j,m)v[i][j]--;
    vb used(m,false);
    rep(i,m){
        vi cnt(m);
        rep(j,n)cnt[v[j][id[j]]]++;
        P ma=P(0,0);
        rep(j,m)chmax(ma,P(cnt[j],j));
        chmin(ans,ma.fi);
        if(i==m-1)break;
        used[ma.se]=true;
        rep(j,n)while(used[v[j][id[j]]])id[j]++;
    }
    out(ans);
}

Measured memory_bytes: 1024
n = gets.to_i
arr = Array.new(n)
n.times do |k|
  m = gets.to_i
  arr[k] = [] if arr[k].nil?
  m.times do
    i = gets.chomp.split(' ').map(&:to_i)
    arr[k] << [i[0] - 1, i[1]]
  end
end
max = 0
(0...(1 << n)).each do |i|
  ok = true
  map = Hash.new(false)
  bit = sprintf("%0#{n}d", i.to_s(2)).split('').reverse
  (0...bit.count).each do |j|
    map[j] = true if bit[j] == '1'
  end
  map.each do |k, _|
    arr[k].each do |l|
      if l[1] == 1
        ok = ok && map[l[0]]
      else
        ok = ok && !map[l[0]]
      end
    end
  end
  max = [max, i.to_s(2).count('1')].max if ok
end
puts max

Measured memory_bytes: 2044
#include <iostream>
#include <cstring>
#include <iomanip>
 
using namespace std;
const int N = 310;
double dp[N][N][N];
int a, b, c, n;
 
double get(int i, int j, int k) {
    if(dp[i][j][k] >= 0) return dp[i][j][k];
    double res = 0;
    double d = i + j + k;
    res += (double) n / d;
    if(i > 0) res += get(i-1, j, k) * (double) i / (double) d;
    if(j > 0) res += get(i+1, j-1, k) * (double) j / (double) d;
    if(k > 0) res += get(i, j+1, k-1) * (double) k / (double) d;
    dp[i][j][k] = res;
    return res;
}
 
int main() {
    cin >> n;
    for(int i = 1; i <= n; i ++) {
        int cnt;
        cin >> cnt;
        switch(cnt) {
            case 1:
                a ++;
                break;
            case 2:
                b ++;
                break;
            case 3:
                c ++;
                break;
        }
    }
    memset(dp, -1, sizeof dp);
    dp[0][0][0] = 0.0;
    cout <<setprecision(12) << fixed << get(a, b, c) << endl;
    return 0;
}

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

int main(){
   int a, b, k;
   cin >> a >> b >> k; 

   vector<int> x(k);

   for (int j=min(a,b);;j--){
           if(a%j==0 && b%j==0){
               x.at(0)=j;
               break;
           }
       }

   for (int i= 1; i < k; i++){
       for (int j=x.at(i-1)-1;;j--){
           if(a%j==0 && b%j==0){
               x.at(i)=j;
               break;
           }
       }
   }
   cout << x.at(k-1) << endl;
}

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

int main() {
	int N, A, B, C, D;
	scanf("%d%d%d%d%d", &N, &A, &B, &C, &D);
	N -= 1;
	B -= A;
	for(int i = 0; i <= N; ++i) {
		long long L = 1LL * i * C - 1LL * (N - i) * D,
				  R = 1LL * i * D - 1LL * (N - i) * C;
		if(L <= B && B <= R) {
			puts("YES"); 
			getchar(), getchar();
			return 0;
		}
	}
	puts("NO");
	getchar(), getchar();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */
lint a[2 * 100000 + 1];
void dfs(int cur, int par, vector<vector<int>> &g, vector<int> &ans, vector<vector<lint>> &lis, int curMax) {

  int n = g.size();
  lint val = a[cur];
  
  // 加える
  // val より小さい最大の id
  lint lb = 0;
  lint ub = n + 1;
  while (ub - lb > 1) {
    lint id = (ub + lb) / 2;
    if (lis[id].back() < val) {
      lb = id;
    } else {
      ub = id;
    }
  }
  
  int nxtMax = max((lint)curMax, lb + 1);
  ans[cur] = nxtMax;
  lis[lb + 1].push_back(val);

  for (auto nxt : g[cur]) {
    if (nxt == par) continue;
    dfs(nxt, cur, g, ans, lis, nxtMax);
  }

  // 帰るときに消す
  lis[lb + 1].pop_back();
}

int main() {

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

  vector<vector<int>> g(n);
  for (int i = 0; i < n - 1; i++) {
    int u, v; cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  vector<int> ans(n);
  vector<vector<lint>> lis(n + 1);
  lis[0].push_back(0);
  for (int i = 1; i <= n; i++) {
    lis[i].push_back(INF);
  }

  map<lint, lint> mp;
  dfs(0, -1, g, ans, lis, 0);

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


Measured memory_bytes: 46664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

int main() {
  ll a,b,k;
  cin >> a >> b >> k;
  if(k > a){
    b -= (k-a);
    chmax(b,0ll);
    a = 0;
  }else{
    a -= k;
  }
  cout << a << " " << b << endl;
}


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

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	int c = a*b;

	if (c % 2 == 0) {
		cout << "Even" << endl;
	}
	
	else {
		cout << "Odd" << endl;
	}

    return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

const int INF = 1001001001;
//const ll INF = 1e18;

ll cal_gcd(ll m, ll n) {
	while (m%n != 0) {
		ll c = m % n;
		m = n;
		n = c;
	}
	return n;
}



int main() {
	string s;
	cin >> s;
	int n = s.size() - 1;
	for (int i = 0; i < (1 << n); i++) {
		vector<int>op;
		for (int j = 0; j < n; j++) {
			if ((i >> j) & 1) {
				op.push_back(1);
			}
			else {
				op.push_back(0);
			}
		}
		int ans = s[0] - '0';
		for (int i = 0; i < n; i++) {
			if (op[i] == 1) {
				ans += s[i + 1] - '0';
			}
			else {
				ans -= s[i + 1] - '0';
			}
		}
		if (ans == 7) {
			cout << s[0];
			for (int i = 0; i < n; i++) {
				if (op[i] == 1) {
					cout << "+";
				}
				else {
					cout << "-";
				}
				cout << s[i + 1];
			}
			cout << "=7" << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll N;
const ll K = 1000000007;
string ss[2];
ll dp[100];
bool isVer(int j) {
  return ss[0][j] == ss[1][j];
}
int main () {
  cin >> N;
  cin >> ss[0] >> ss[1];
  int j = 0;
  if (N == 1) {
    cout << 3 << endl;
    return 0;
  }
  if (ss[0][j] == ss[1][j]) {
    dp[1] = 3;
    j = 1;
  } else {
    dp[2] = 6;
    j = 2;
  }
    
  
  while(j < N) {
    if (isVer(j)) {
      if (isVer(j - 1)) {
        dp[j + 1] = 2 * dp[j];
      } else {
        dp[j + 1] = dp[j];
      }

      dp[j + 1] %= K;
      j+=1;
    } else {
      if (isVer(j - 1)) {
        dp[j + 2] = 2 * dp[j];
      } else {
        dp[j + 2] = 3 * dp[j];
      }

      dp[j + 2] %= K;
      j += 2;
    }

  }

  cout << dp[N] % K << endl;
}

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

#define MAXN 1000

using namespace std;

int main() {
#ifdef orange
	freopen("input.txt", "r", stdin);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, k;
	cin >> n >> k;
	int info[n];
	for (int i = 0; i < n; i++) {
		cin >> info[i];
	}
	sort(info, info + n);
	int sum = 0;
	for (int i = 0; i < k; i++) {
		sum += info[i];
	}
	cout << sum << "\n";
}



Measured memory_bytes: 3636
n = int(input())
S = [str(input()) for _ in range(n)]

a = 0
b = 0
ab = 0
ans = 0
for s in S:
    ans += s.count('AB')
    if s[0] == 'B' and s[-1] == 'A':
        ab += 1
    elif s[0] == 'B':
        b += 1
    elif s[-1] == 'A':
        a += 1
    else:
        pass
if ab:
    ans += ab-1
if ab:
    if a:
        ans += 1
        a -= 1
    if b:
        ans += 1
        b -= 1
ans += min(a, b)
print(ans)


Measured memory_bytes: 3700
#include<stdio.h>
int main(void){
    int n[10000],i,j,max;
    int min;
    int k = 0;
    int l;
    scanf("%d",&n[k]);
    while(n[k] != EOF){
        k++;
        scanf("%d",&n[k]);
    }
    for(l = 0;l < k-1;l++){
        min = 0;
        for(i = 2;i < n[l]*2;i++){
            for(j = 2;j <= i;j++){
                if(i % j == 0 && j == i && i > n[l]){
                    min = i;
                    break;
                }
                if(i % j == 0 && j == i && i < n[l]){
                    max = i;
                }
                else if(i % j == 0){
                    break;
                }
                if(j > 2){
                    j++;
                }
            }
            if(i > 2){
                i++;
            }
            if(min != 0){
                break;
            }
        }
        if(min == 0){
            break;
        }
        printf("%d %d\n",max,min);
    }
    return 0;
}

Measured memory_bytes: 600
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=100005;
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int n,w[max_n];
int main()
{
    scanf("%d",&n);
    int sum=0;
    for(int i=1;i<=n;i++)scanf("%d",w+i),sum+=w[i];
    int ans=inf;
    int pre=0;
    for(int i=1;i<n;i++)
    {
        pre+=w[i];
        ans=min(ans,abs(sum-pre-pre));
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    string s; cin >> s;
    int cnt = 0;
    long long ans = 0;
    for (int i = s.size()-1; i >= 0; ) {
        if (i > 0 && s[i] == 'C' && s[i-1] == 'B') cnt++, i -= 2;
        else if (s[i] == 'A') ans += cnt, i--;
        else cnt = 0, i--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 644
//CODING ME ACCHHA KARNEKA HAI TERKO TO BAS PRACTICE KARTE REH
#include <bits/stdc++.h>
#define pragma
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define aisort sort(a,a+n)
#define adsort sort(a,a+n,greater<ll>())
#define PI 2 * acos(0)

typedef pair<ll, ll> pii;
typedef pair<ll, pii> piii;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef set<ll> Set;

const ll maxs = 1e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;

//MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

//POWER
    ll fastpow(ll x,ll y)
    {ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

//MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}
    
//PRIME
    bool isPrime(ll n) { if (n <= 1)  return false; if (n <= 3)  return true;if (n%2 == 0 || n%3 == 0) return false; for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false; return true; } 




int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,m,i;
    cin>>n>>m;
    ll a[m],sum=0;
    for(i=0;i<m;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    if(sum<=n)
    cout<<n-sum;
    else
    cout<<-1;
}




Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
 
int main(){
  string s;
  cin >> s;
  deque<char> d;
  d.push_back('S');
  int q;
  cin >> q;
  bool flag = true;
  rep(i,q){
    int ti;
    cin >> ti;
    //cout << "ti " << ti << endl;
    if (ti == 1){
      flag = flag? false : true;
    }
    else {
      int fi;
      char ci;
      cin >> fi >> ci;
      /*cout << "fi " << fi << endl;
      cout << "ci " << ci << endl;
      cout << "flag " << flag << endl;*/
      if (flag){
        if (fi == 1) d.push_front(ci);
        else d.push_back(ci);
      }
      else {
        if (fi == 1) d.push_back(ci);
        else d.push_front(ci);
      }
    }
    /*for(auto c : d) cout << c;
    cout << endl;
    cout << endl;*/
  }
  while(!d.empty()){
    if(flag){
      char c = d.front();
      if(c == 'S'){
        cout << s;
        d.pop_front();
        continue;
      }
      cout << c;
      d.pop_front();
    }
    else{
      char c = d.back();
      if (c == 'S'){
        reverse(s.begin(), s.end());
        cout << s;
        d.pop_back();
        continue;
      }
      cout << c;
      d.pop_back();
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3896
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

T = LS2()

for i in range(len(T)):
    if T[i] == '?':
        T[i] = 'D'

ans = ''
for i in range(len(T)):
    ans += T[i]

print(ans)

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

using namespace std;

using ll = long long;
#define long long long

int main(void) {
    constexpr ll MOD = 1e9+7;
    ll n, a, b;
    cin >> n >> a >> b;

    auto inv = [&](ll a) {
        ll r = 1, b = MOD-2;
        while(b) {
            if(b&1) (r *= a) %= MOD;
            (a *= a) %= MOD;
            b >>= 1;
        }
        return r;
    };
    auto comb = [&](ll a, ll b) {
        if(a < b) return 0ll;
        ll r = 1;
        for(ll i=0; i<b; i++)
            (r *= a-i) %= MOD, (r *= inv(i+1)) %= MOD;
        return r;
    };
    auto powm = [&](ll a, ll b) {
        ll r = 1;
        while(b) {
            if(b&1) (r *= a) %= MOD;
            (a *= a) %= MOD;
            b >>= 1;
        }
        return r;
    };


    ll r = powm(2, n);
    (r += MOD - 1) %= MOD;
    (r += MOD - comb(n, a)) %= MOD;
    (r += MOD - comb(n, b)) %= MOD;
    cout << r << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    scanf("%d",&n);
    int a=0,b=0;
    for(int i=0; i<n; i++) {
        int c;
        scanf("%d",&c);
        if(c%2)
            a++;
        if(c%4==0)
            b++;
    }
    if(a>b+1) {
        printf("No\n");
    } else
        {   if(a<b+1)
            printf("Yes\n");
            else{
                if(a+b!=n)printf("No\n");
                else printf("Yes\n");
            }
        }
    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,t;
    string s;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++) cin>>arr[i];
    ll count=0;
    for(i=1;i<n-1;i++) 
    {
        if((arr[i-1]<arr[i] && arr[i]<arr[i+1]) || (arr[i-1]>arr[i] && arr[i]>arr[i+1])) 
            count++;
    }
    cout<<count;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define sz(a) (int)a.size()
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}
 
ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 


int solve(){
	set<int>s;
	int n;cin>>n;
	for(int i=0;i<n;i++){
		int x;cin>>x;
		s.insert(x);
	}
	if(s.size()==n) cout<<"YES";
	else cout<<"NO";



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


Measured memory_bytes: 9600
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    ll N;
    cin >> N;
    int a[100001];
    ll sum = 0;
    for(int i = 1; i <= 100000; i++) a[i] = 0;
    for(int i = 0; i < N; i++){
        int b;
        cin >> b;
        sum += b;
        a[b]++;
    }
    int Q;
    cin >> Q;
    vector<pair<int,int>> query(Q);
    for(int i = 0; i < Q; i++) cin >> query[i].first >> query[i].second;
    for(int i = 0; i < Q; i++){
        int b,c;
        b = query[i].first;
        c = query[i].second;
        if(a[b] == 0) cout << sum << endl;
        else{
            sum += a[b] * (c - b);
            cout << sum  << endl;
        }
        int temp = a[b];
        a[b] = 0;
        a[c] += temp;
    }
    return 0;
}


Measured memory_bytes: 4580
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define ll long long

using namespace std;

const ll INF = LLONG_MAX / 2 - 1;


struct Edge {
	ll t;
	ll c;
	Edge(ll to, ll cost):t(to),c(cost){}
	Edge(){}
};

vector<ll> weigh;
ll R, C;
ll xmin, ymin;

bool DFS(ll node, vector<vector<Edge> >& edge) {
	if (node < R) xmin = min(xmin, weigh[node]);
	else ymin = min(ymin, weigh[node]);
	for (auto &to : edge[node]) {
		if (weigh[to.t] == INF) {
			weigh[to.t] = to.c - weigh[node];
			if (not DFS(to.t, edge)) return false;
		}
		else {
			if (weigh[to.t] + weigh[node] != to.c) return false;
		}
	}
	return true;
}
int main() {
	cin >> R >> C;
	ll N;
	cin >> N;
	weigh.resize(R + C, INF);
	vector<vector<Edge> > edge(R+C);
	for(int i = 0; i < N; i++){
		ll r, c, a; cin >> r >> c >> a;
		--r; --c;
		edge[r].push_back(Edge(R+c,a));
		edge[R+c].push_back(Edge(r, a));
	}

	bool res = true;
	for(int i = 0; i < R + C; i++){
		if(weigh[i] == INF and edge[i].size() > 0) {
			xmin = ymin = numeric_limits<int>::max();
			weigh[i] = 0;
			if (not DFS(i,edge) or xmin+ymin < 0) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}



Measured memory_bytes: 16512
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class C
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = long.Parse(Console.ReadLine());
            Func<long, long, long> F = (x, y) => Math.Max(x.ToString().Length, y.ToString().Length);
            var answer = F(N, 1);
            var prime = new Prime(N);
            if (!prime.IsPrime(N))
            {
                var factors = prime.Factors.SelectMany(x => Enumerable.Repeat(x.Key, x.Value)).ToArray();
                var length = factors.Length;
                for (var bit = 0; bit < (1 << length); bit++)
                {
                    var a = 1L;
                    var b = 1L;
                    for (var i = 0; i < length; i++)
                    {
                        if ((bit >> i & 1) == 1) a *= factors[i];
                        else b *= factors[i];
                    }
                    answer = Math.Min(answer, F(a, b));
                }

            }
            Console.WriteLine(answer);
        }

        public class Prime
        {
            public Dictionary<long, int> Factors => new Dictionary<long, int>(_factors);
            private Dictionary<long, int> _factors;
            private static HashSet<long> _primes;
            public Prime(long n)
            {
                if (_primes == null) _primes = new HashSet<long>();
                _factors = new Dictionary<long, int>();
                var tmp = n;
                var max = (long)Math.Sqrt(n);
                var p = 2;
                while (p <= max)
                {
                    if (tmp % p == 0)
                    {
                        _factors[p] = 0;
                        _primes.Add(p);
                        while (tmp % p == 0)
                        {
                            tmp /= p;
                            _factors[p]++;
                        }
                    }
                    p++;
                }
                if (tmp > 1)
                {
                    _factors[tmp] = 1;
                    _primes.Add(tmp);
                }
            }
            public bool IsPrime(long n)
            {
                if (_primes.Contains(n)) return true;
                var p = new Prime(n);
                return _primes.Contains(n);
            }
        }
    }
}


Measured memory_bytes: 46932
#include "stdio.h"

int main(){
int a,b,c,ans;
  scanf("%d %d %d",&a,&b,&c);
  if(a+b>=b+c&&c+b>=b+c)ans=b+c;
  if(b+c>=a+b&&c+a>=a+b)ans=a+b;
  if(a+b>=c+a&&b+c>=c+a)ans=c+a;
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
#N = int(input())
#a = [int(i) for i in input().split()]
#s = [[int(j) for j in input().split()] for i in range(N)]

s=input()
res=0
cnt=0
for i in range(len(s)):
    if s[i]=='W':
        res+=(i-cnt)
        cnt+=1
print(res)


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

int main(){

  string E,O;

  cin>>E>>O;

  for ( int i = 0; i < E.size(); i++){

    cout << E [i];
 


    if ( i < O.size()){
      

	 cout << O[i];
	 
	 }

  }

    return 0;

  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
bool flipx=0,flipy=0;
void out(vector<pii> ans){
    int mnox=1,mnoy=1;
    if(flipx)mnox=-1;
    if(flipy)mnoy=-1;
    cout<<sz(ans)<<'\n';
    for(pii p:ans)cout<<mnox*p.f<<' '<<mnoy*p.s<<'\n';
    exit(0);
}
int k,x,y;
void dostep(int&cx,int&cy){
    if(x>cx){
        int delta=min(k,x-cx);
        cx+=delta;
        cy+=k-delta;
    }else{
        cy+=k;
    }
}
int32_t main(){
    cin>>k>>x>>y;
    if(x<0){
        x=-x;
        flipx=1;
    }
    if(y<0){
        y=-y;
        flipy=1;
    }
    if(k%2==0&&(x+y)%2!=0){
        cout<<"-1\n";
        return 0;
    }
    vector<pii> ans;
    int cx=0,cy=0;
    while(x-cx+y-cy>k+k){
        dostep(cx,cy);
        ans.pb(cx,cy);
    }
    if(x-cx+y-cy==k){
        ans.pb(x,y);
        out(ans);
    }
    if(x-cx+y-cy==k+k){
        forn(it,2){
            dostep(cx,cy);
            ans.pb(cx,cy);
        }
        out(ans);
    }
    if((x+y)%2!=(cx+cy)%2){
        dostep(cx,cy);
        ans.pb(cx,cy);
    }
    assert((x+y)%2==(cx+cy)%2);
    int dx=x-cx,dy=y-cy;
    if(dy<0){
        assert(dx==0);
        dy=-dy;
        int a=k-dy/2;
        ans.pb(x+a,y+dy/2);
    }else if(dx>dy){
        int a=(dx+dy)/2;
        int b=k-a;
        cx+=a;
        cy-=b;
        ans.pb(cx,cy);
    }else{
        int a=k-(dx+dy)/2;
        int b=k-dx-a;
        cx=x+a;
        cy+=b;
        ans.pb(cx,cy);
    }
    ans.pb(x,y);
    out(ans);
    return 0;
}

Measured memory_bytes: 9912
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define vint vector<int>


int main(){
	int n;
	cin >> n;
	vint a(n);
	REP(i,n) cin >> a[i];
	
	int index=1;
	int ans=0;
	REP(i,n){
		if(a[i] != index){
			ans++;
		}else{
			index++;
		}
	}
	
	if(ans==n) cout << "-1\n";
	else cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 4028
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <math.h>
using namespace std;

int main() {

	int N, M, X;
	vector<int> C;
	vector<vector<int>> A;
	int res = -1, price = 0;

	cin >> N >> M >> X;

	A.resize(N);

	for(int i =0; i<N; i++){
		int tmp;
		cin >> tmp;
		C.push_back(tmp);
		for(int j =0; j<M; j++){
			cin >> tmp;
			A[i].push_back(tmp);
		}

		
	}

    
	
    for (int bit = 0; bit < (1 << N); bit++) {
		bool existence = true;
		for(int j = 0; j < M; j++){
			int sum = 0;
			price = 0;
	        for (int i = 0; i < N; i++) {
    	        if (bit & (1 << i)) {
					sum += A[i][j];
					price += C[i];
            	}
        	}
			if(sum < X){
				existence = false;
				break;
			}
		}
		if(existence){
			if(res == -1){
				res = price;
			}else{
				res = min(res, price);
			}
			price = 0;
		}
    }

	cout << res;
    
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    bool takahashi = true;
    while(a>0 && c>0){
        if(takahashi){
            c -= b;
            takahashi = false;
        }else{
            a -= d;
            takahashi = true;
        }
    }
    if(!takahashi)cout <<"Yes"<<endl;
    else cout <<"No"<<endl;
    
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl; 

int n,m;
int edge[10][10]={};
vector<int> A;




int main(){
    cin >> n >> m;
    int a,b;
    REP(i,m){
        cin >> a >> b;
        edge[a][b]=1;
        edge[b][a]=1;
    }
    FOR(i,2,n+1){
        A.push_back(i);
    }

    int tmp_v;
    bool flag;
    int ans=0;
    while(1){
        flag = true;
        tmp_v=1;
        itrfor(itr,A){
            if(edge[tmp_v][*itr] == 0){
                flag =false;
                break;
            }
            tmp_v= *itr;
        }
        if(flag) ans += 1;
        if(not next_permutation(A.begin(),A.end())) break;

    }
    print(ans);



}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
#define ll long long
int l,r,d,ans=0;
signed main(){
	cin>>l>>r>>d;
	int cnt=1;
	while(d*cnt<l)cnt++;
	while(d*cnt<=r){cnt++;ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	ll sum = 0;
	rep(i, m){
		int in;
		cin >> in;
		sum += in;
	}
	if(sum > n) cout << -1 << endl;
	else cout << n-sum << endl;
	return 0;
}

Measured memory_bytes: 3640
######################
#     _        ____  #
# U  /"\  u U /"___| #
#  \/ _ \/  \| | u   #
#  / ___ \   | |/__  #
# /_/   \_\   \____| #
#  \\    >>  _// \\  #
# (__)  (__)(__)(__) #
# Compro by NULL_CT© #
######################
from sys import stdin
import numpy as np
import math

input = stdin.readline

def divisor(_n):
    result = []
    for i in range(1, int(math.sqrt(_n)) + 1):
        if _n % i == 0:
            result.append(i)
            if _n % (_n / i) == 0:
                result.append(int(_n / i))
    return result

k,x = map(int,input().split())

if 500 * k >= x:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 27092
#include <string.h>
int main(void)
{
          char s[100] ;
          gets(s) ;
          int x ;
          x = strlen(s) ;
          if( x != 6)
          {
                    printf("No") ;
                    return 0 ;
          }
          else if( s[0] != s[1] && s[2]== s[3] && s[4]==s[5])
          {
                    printf("Yes") ;
                    return 0 ;
          }
          else printf("No") ;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FORE(i, a, b) for(int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORIT(i,v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++i)
#define X first
#define Y second
#define ll long long
#define mp make_pair
#define pb push_back
#define all(a) a.begin(),a.end()
#define sqr(x) (x)*(x)
#define endl '\n'

template <typename G> inline void read(G &x)
{
    x = 0; char c;
    while(!isdigit(c = getchar()));
    do{x = x*10 + c - '0';} while(isdigit(c = getchar()));
}

template <typename G> inline void write(G x)
{
    if (x > 9) write(x/10);
    putchar(x%10 + '0');
}

template <class T> inline T min(T a,T b,T c){ return min(a,min(b,c)); }
template <class T> inline T min(T a,T b,T c,T d) { return min(a,min(b,c,d)); }
template <class T> inline T max(T a,T b,T c){ return max(a,max(b,c)); }
template <class T> inline T max(T a,T b,T c,T d) { return max(a,max(b,c,d)); }



const int MAXN = 1e5 * 5;
const int base = 1e9 + 7;
const int N = 5000;
struct data
{
    int x,id;
    int k;
}a[MAXN];

int n,c,k;
int ans;
int d[MAXN],cc[MAXN];

int cmp(data a,data b)
{
    if (a.x != b.x) return a.x < b.x;
    return a.id < b.id;
}

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

    cin>>n>>c>>k;
    FORE(i,1,n)
    {
        int t;
        cin>>t;
        a[i].x = t; a[i].id = 1; a[i].k = i;
        a[i+n].x = t+k; a[i+n].id = 2; a[i+n].k = i;
    }
    int m = 2*n;
    sort(a+1,a+m+1,cmp);
    //FORE(i,1,m)
    //cout<< a[i].x <<' '<< a[i].id <<' '<< a[i].k <<endl;
    int cnt = 0;
    FORE(i,1,m)
    if (a[i].id == 1)
    {
        cc[++cnt] = a[i].k;
        if (cnt == c)
        {
            FORE(j,1,cnt)
            d[cc[j]] = 1;
            ++ans;
            cnt = 0;
        }
    }
    else
    if (!d[a[i].k])
    {
        //cout<< i <<' '<< a[i].k <<endl;
        FORE(j,1,cnt)
        d[cc[j]] = 1;
        ++ans;
        cnt = 0;
    }
    cout<< ans <<endl;
    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
using namespace std;

int main(void) {
	int a[13] = { 0,1,3,1,2,1,2,1,1,2,1,2,1 }, x, y;
	cin >> x >> y;
	cout << (a[x] == a[y] ? "Yes" : "No") << endl;
	return 0;
}

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
using Graph = vector<vector<int>>;
queue<int> quex,quey;

int main(){
    int a,b=0,c,d;    cin >> a ;
    vector<int>v(a);
    vector<int>w(a);
    vector<int>x(a);


    rep(i,a) {cin>>v.at(i); x.at(i)=i+1;}
    rep(i,a) {cin>>w.at(i);}
    
    do {
        b++;
        
        
        if(x==v)    c=b;
        if(x==w)    d=b;
    }while(next_permutation(x.begin(),x.end()));
    
    

    cout << abs(c-d) << endl;

    
}

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

void judge(string s)
{
    unsigned sum = 0;
    unsigned count = 0;
    for(int i = 0; i < s.size(); i++)
    {
        sum += s[i] - '0';
        if(sum >= 10)
        {
            sum -= 9;
            count++;
        }
    }
    if((count + s.size()) % 2)
        cout << "Audrey wins.\n";
    else
        cout << "Fabre wins.\n";
}

int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        judge(s);
    }
}

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

 
int main() {
    int n;
    cin>>n;
    map<int,int> A;
    rep(i,n){
        int a;
        cin>>a;
        A[a]++;
    }
    int ans=0;
    for(auto p:A){
        if(p.first<p.second)ans+=p.second-p.first;
        if(p.first>p.second)ans+=p.second;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,i,ans=0;cin>>N;ll A[N],X[N],Y[N];REP(i,N){cin>>A[i];X[i]=i-A[i];Y[i]=i+A[i];}
  sort(X,X+N);sort(Y,Y+N);
  REP(i,N)ans+=upper_bound(X,X+N,Y[i])-lower_bound(X,X+N,Y[i]);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 8276
s = input()
if s[0] == 'A':
    if s.count('C') == 1 and 2 <= s.find('C') <= len(s)-2:
        s_tmp = s[1:s.find('C')]+s[s.find('C')+1:]
        if s_tmp.islower() == True:
            print("AC")
            exit()

print("WA")

Measured memory_bytes: 3060
#!/usr/bin/env python3

# from numba import njit

# input = stdin.readline

# @njit
def solve(a,b,c,d,s):
  if '##' in s[a:c+1] or '##' in s[b:d+1]:
    return False
  if c < d:
    return True
  elif c > d:
    if "..." in s[b-1:d+2]:
      return True
    else:
      return False
  else:
    raise ValueError




def main():
  N,A,B,C,D = map(int,input().split())
  A -= 1
  B -= 1
  C -= 1
  D -= 1
  S = input()
  print("Yes" if solve(A,B,C,D,S) else "No")
  return

if __name__ == '__main__':
  main()


Measured memory_bytes: 9360
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int W;
int Search(int a, int w, vector<vector<int>> &d, const vector<int> &l, vector<int> &k, vector<vector<vector<vector<int>>>> &dp) {
	if (W < w)
		return 0;
	if (dp[k[0]][k[1]][k[2]][k[3]] > 0)
		return dp[k[0]][k[1]][k[2]][k[3]];
	int i, ans = 0;
	for (i = 0; i < 4; i++)
		ans += d[i][k[i]];
	for (i = 0; i < 4; i++) {
		if (l[i] > k[i]) {
			k[i]++;
			ans = max(ans, Search(a, w + a + i, d, l, k, dp));
			k[i]--;
		}
	}
	dp[k[0]][k[1]][k[2]][k[3]] = ans;
	return ans;
}

int main(void) {
	int num, w, i, j, v, a;
	cin >> num >> W >> a >> v;
	vector<vector<int>> d(4, vector<int>(num + 1));
	vector<int> l(4, 0), k(4, 0);
	d[0][l[0]++] = v;
	for (i = 0; i < num - 1; i++) {
		cin >> w >> v;
		d[w - a][l[w - a]++] = v;
	}
	for (i = 0; i < 4; i++) {
		sort(d[i].begin(), d[i].end(), greater<int>());
		for (j = 0; j < l[i] - 1; j++) {
			d[i][j + 1] += d[i][j];
		}
		for (j = l[i]; j > 0; j--)
			d[i][j] = d[i][j - 1];
		d[i][0] = 0;
	}
	vector<vector<vector<vector<int>>>> dp(l[0] + 1, vector<vector<vector<int>>>(l[1] + 1, vector<vector<int>>(l[2] + 1, vector<int>(l[3] + 1, 0))));
	a = Search(a, 0, d, l, k, dp);
	cout << a << "\n";
	return 0;
}

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

typedef long long ll;

#define PB push_back

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	set<string> s;
	for (int i = 0; i < n; ++i) {
		string si; cin >> si;
		s.insert(si);
	}
	cout << s.size() << "\n";
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* print new lines
*/


Measured memory_bytes: 19260
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);

bool cmp(LL x, LL y) {
	if (x < 0) x = -x;
	if (y < 0) y = -y;
	return x < y;
}

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	LL arr[n + 1];
	for (int i = 0; i < n; i++) {
		scanf("%lld", &arr[i]);
	}
	sort (arr, arr + n, cmp);
	stack<LL> pos, neg;
	if (arr[n - k] == 0) printf("0\n");
	else {
		for (int i = n - 1; i >= n - k; i--) {
			if (arr[i] >= 0) pos.push(arr[i]);
			else neg.push(arr[i]);
		}
		int l1 = neg.size();
		if (l1 % 2) {
			LL x = INT_MAX;
			LL y = INT_MAX;
			for (int i = 0; i < n - k; i++) {
				if (arr[i] >= 0) x = arr[i];
				else y = arr[i];
			}
			if (!pos.empty() && y != INT_MAX) {
				LL cnt1 = neg.top() * y;
				LL cnt2 = -1;
				if (x != INT_MAX) {
					cnt2 = x * pos.top();
				}
				if (cnt1 > cnt2) {
					pos.pop();
					LL ans = -y;
					while (!pos.empty()) {
						ans *= pos.top();
						ans %= MOD;
						pos.pop();
					}
					while (!neg.empty()) {
						ans *= -neg.top();
						ans %= MOD;
						neg.pop();
					}
					printf("%lld\n", ans);
				} else {
					neg.pop();
					LL ans = x;
					while (!pos.empty()) {
						ans *= pos.top();
						ans %= MOD;
						pos.pop();
					}
					while (!neg.empty()) {
						ans *= -neg.top();
						ans %= MOD;
						neg.pop();
					}
					printf("%lld\n", ans);
				}
			} else if (x != INT_MAX) {
				neg.pop();
				LL ans = x;
				while (!pos.empty()) {
					ans *= pos.top();
					ans %= MOD;
					pos.pop();
				}
				while (!neg.empty()) {
					ans *= -neg.top();
					ans %= MOD;
					neg.pop();
				}
				printf("%lld\n", ans);
			} else {
				LL ans = 1;
				for (int i = 0; i < k; i++) {
					if (arr[i] < 0) arr[i] += MOD;
					ans *= arr[i];
					ans %= MOD;
				}
				printf("%lld\n", ans);
			}
		} else {
			LL ans = 1;
			while (!pos.empty()) {
				ans *= pos.top();
				ans %= MOD;
				pos.pop();
			}
			while (!neg.empty()) {
				ans *= -neg.top();
				ans %= MOD;
				neg.pop();
			}
			printf("%lld\n", ans);
		}
	}
}


Measured memory_bytes: 7000