akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <set>
using namespace std;

const int MAX_SIZE = 20;
typedef pair<int, int> P;

int calc(char f[][MAX_SIZE + 1], queue<P> q, int W, int H) {
  set<P> s;
  while (q.size()) {
    P p = q.front();
    q.pop();
    s.insert(p);
    int di[] = {-1, 1, 0, 0};
    int dj[] = {0, 0, -1, 1};
    for (int k = 0; k < 4; ++k) {
      int i = p.first  + di[k];
      int j = p.second + dj[k];
      if (i >= 0 && j >= 0 && i < H && j < W && f[i][j] == '.') {
        pair<set<P>::iterator, bool> r = s.insert(P(i, j));
        if (r.second) q.push(*r.first);
      }
    }
  }
  return s.size();
}
int main() {
  int W, H;
  char f[MAX_SIZE + 1][MAX_SIZE + 1];
  while (true) {
    queue<P> q;
    cin >> W >> H;
    if (W == 0 && H == 0) break;
    for (int i = 0; i < H; ++i) {
      cin >> f[i];
      for (int j = 0; j < W; ++j) {
        if (f[i][j] == '@') {
          q.push(P(i, j));
        }
      }
    }
    cout << calc(f, q, W, H) << endl;
  }
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
#define fastio     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define debug(x)   cerr<<#x<<": "<<x<<endl;
#define all(x)     (x).begin() , (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl       '\n'
#define MAX        1000000
typedef long long int ll;
using namespace std;


const ll mod = 1e9+7;
const double eps = 1e-9;


ll modpow(ll n , ll x) {
    ll res=1;
    while(x) {
        if(x&1)
            res=(res*n);
        x/=2;
        n=(n*n);
    }
    return res;
}


void solve(){
    ll n;
    cin>>n;
    ll tt=n;
    int lev=0;
    while(tt) {
        lev++;
        tt/=2;
    }
    ll ans = modpow(2LL,lev)-1;
    cout<<ans;
}





int main(){
    fastio
    int test=1;
    while(test--)
        solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>

ll INF = 10000000007;


//-----------------//
  #define amin main
//----------------//
    ll dp[2002]={0};

int amin()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t,i,j;
	ll n;
	cin>>n;
	ll mini= INF;
	ll maxi = -INF;
	ll mini1=INF;
	ll maxi1 = -INF;
	vector<pll>inp;
for(i=0;i<n;i++)
{
	ll x1,y1;
	cin>>x1>>y1;
	inp.pb({x1,y1});
	mini = min(mini,x1+y1);
	mini1 = min(mini1,x1-y1);
	maxi1 = max(maxi1,x1-y1);

	maxi = max(maxi,x1+y1);
}
ll x1,y1;
ll x2,y2;
ll x11,y11;
ll x22,y22;
for(i=0;i<n;i++)
{
	ll a = inp[i].first;
	ll b = inp[i].second;
	if(a+b==mini)
	{
		x1 =a;
		y1 = b;
	}
	if(a-b==mini1)
	{
		x11=a;
		y11 = b;
	}
	if(a-b==maxi1)
	{
		x22 = a;
		y22 = b;
	}
	if(a+b==maxi)
	{
		x2 = a;
		y2 = b;
	}
}
ll a=-INF,b=-INF,c=-INF,d=-INF;

	a = (x2+y2)-(y1+x1);

b = x2-y2-x1+y1;
c = (x22+y22)-(y11+x11);
d= x22-y22-x11+y11; 
cout<<max(a,max(b,max(c,d)))<<endl;

//	
	
	


	
	return 0;
}

Measured memory_bytes: 7416
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int div,a,b,count;
    while(cin>>div>>a>>b)
    {
        count=0;
        for(int i=a;i<=b;i++)
        {
            if(i%div==0)
            {
                count++;
                 break;
            }
        }
        if(count!=0)
        {
            cout<<"OK"<<endl;
        }
        else
        {
            cout<<"NG"<<endl;
        }
    }
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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 (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<char> t(q), d(q);
    rep(i, q) cin >> t[i] >> d[i];

    int lok = n, lng = -1, lmid;
    while (lok - lng > 1) {
        lmid = (lok + lng) / 2;
        int pos = lmid;
        bool f = true;
        rep(i, q) {
            if (s[pos] == t[i]) {
                if (d[i] == 'L') pos--;
                if (d[i] == 'R') pos++;
            }
            if (pos < 0) {
                f = false;
                break;
            }
            if (pos >= n) {
                break;
            }
        }
        (f ? lok : lng) = lmid;
    }

    int rok = -1, rng = n, rmid;
    while (rng - rok > 1) {
        rmid = (rok + rng) / 2;
        int pos = rmid;
        bool f = true;
        rep(i, q) {
            if (s[pos] == t[i]) {
                if (d[i] == 'L') pos--;
                if (d[i] == 'R') pos++;
            }
            if (pos >= n) {
                f = false;
                break;
            }
            if (pos < 0) {
                break;
            }
        }
        (f ? rok : rng) = rmid;
    }
    // cout << lok << " " << rok << endl;
    cout << max(0, rok - lok + 1) << endl;
}


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

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

    int odd, even;
    int ans = 0;
    even = k / 2;
    if(k%2 == 0){
        odd = k / 2;
    }else{
        odd = k / 2 + 1;
    }

    ans = odd * even;

    cout << ans << endl;

    return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define N	 100
int a, b,c;
void solve(){
	string s;
	cin>>s;
	rep(i,0,sz(s)){
	if(s[i]=='a')a++;
	if(s[i]=='b')b++;
	if(s[i]=='c')c++;
	}
	if(a&&b&&c) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}



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

const int MOD = 1000000007;
const int MAX = 5100000;
ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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 COM(int n, int 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 = 100000;
struct Edge {
    int to;
    int id;
};

const int D = 80 * 160 + 10;
const int D2 = D*2;
typedef bitset<D2> bs;
int a[100][100];
bs dp[90][90];



const int N = 20;
int h;
int w;
vector<vector<char>> maze(N, vector<char>(N,'#'));

const int MAX_WH = 21;
int d[MAX_WH][MAX_WH];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
const int INF = 100000;
int bfs(int x, int y) {
    queue<P> que;
    rep(i,MAX_WH) {
        rep(j,MAX_WH) {
            d[j][i] = INF;
        }
    }
    que.push(P(x,y));
    d[x][y] = 0;

    while (que.size()) {
        P p = que.front(); que.pop();
        for (int i=0; i< 4; i++) {
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            if (0 <= nx && nx < w && 0 <= ny && ny < h && maze[nx][ny] != '#' && d[nx][ny] == INF) {
                que.push(P(nx,ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
    int mx = 0;
    rep(i,h) rep(j,w) {
            if (d[j][i] == INF) continue;
            mx = max(mx, d[j][i]);
        }
    return mx;
}

bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.first < secondElof.first;
}
void dfs(){

}
const int MX = 100000;
vector<int> G[MX];

int main(){
    int h,a; cin >> h >> a;
    int ans = 0;
    while (h > 0) {
        h -= a;
        ans++;
    } 
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4352
import numpy as np
N, M = map(int, input().split())
p_dict = {}
p = [0 for i in range(M)]
y = [0 for i in range(M)]
i_in_p = [0 for i in range(M)]

for i in range(M):
    p[i], y[i] = map(int, input().split())
    if p[i] not in p_dict:
        i_in_p[i] = 0
        p_dict[p[i]] = [y[i]]
        continue
    i_in_p[i] = len(p_dict[p[i]])
    p_dict[p[i]].append(y[i])
for key in p_dict.keys():
    p_dict[key] = np.array(p_dict[key]).argsort().argsort() + 1
for i in range(M):
    print('{:06d}{:06d}'.format(p[i], p_dict[p[i]][i_in_p[i]]))


Measured memory_bytes: 50064
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = INT64_MAX;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;
using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<=former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
typedef vector<vector<ll> > matrix;
void princ(auto x){cout<<x<<" ";}; void print(auto x){cout<<x<<"\n";};
///////////////////////////////////////////////////////////////////////////////////

ll n;
Vi a;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll inp;
    cin>>n;
    rep(i,n){
        cin>>inp;
        a.pb(inp);
    }
    ll r=0,ans = 0,tmp = 0;
    rep(l,a.size()){
        while (r<a.size() && (tmp ^ a[r]) == (tmp + a[r])){
            tmp += a[r]; r++;
        }
        ans += r-l;
        if(r==l)r++;
        else tmp -= a[l];
    }
    print(ans);
    return 0;
}

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

int main(void){
    int N;
    cin>>N;
    
    int v[N];
    
    vector<int> cA(100001,0);
    vector<int> cB(100001,0);
    
    for(int i=0;i<N;i++){
        cin>>v[i];
    } 
    
    for(int i=0;i<N;i++){
        if(i%2==0){
            cA[v[i]]++;
        }else{
            cB[v[i]]++;
        }
    }
    
    int A=0,B=0;
    int A2=0,B2=0;
    int maxA=0,maxB=0;
    int maxA2=0,maxB2=0;
    
    for(int i=0;i<N;i++){
        if(i%2==0){
            if(maxA<cA[v[i]]){
                maxA=cA[v[i]];
                A=v[i];
            }
            if(cA[v[i]]!=0&&v[i]!=A&&cA[v[i]]>maxA2){
                maxA2=cA[v[i]];
                A2=v[i];
            }
        }else{
            if(maxB<cB[v[i]]){
                maxB=cB[v[i]];
                B=v[i];                
            }
            if(cB[v[i]]!=0&&v[i]!=B&&cB[v[i]]>maxB2){
                maxB2=cB[v[i]];
                B2=v[i];
            }
        }
    }
    
    if(A==B&&maxA2==0&&maxB2==0){
        if(N%2==0)cout<<N/2<<endl;
        else if(N%2!=0)cout<<(N-1)/2<<endl;
        return 0;
    }else if(A==B&&maxA2==0&&maxB2!=0){
        B=B2;
    }else if(A==B&&maxB2==0&&maxA2!=0){    
        A=A2;
    }else if(A==B&&maxA2>maxB2){
        A=A2;
    }else if(A==B&&maxA2<maxB2){
        B=B2;
    }
    
    int count=0;
    for(int i=0;i<N;i++){
        if(i%2==0&&v[i]!=A) count++;
        else if(i%2!=0&&v[i]!=B) count++;
    }

    cout<<count<<endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long unsigned int ll;

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

int main() {

  int R;

  cin >> R;

  if (R < 1200){
    cout << "ABC" <<endl;
  }else if(R < 2800){
    cout << "ARC" << endl;
  }else{
    cout << "AGC" << endl;
  }




  return 0;
}


Measured memory_bytes: 256
// Problem : C - Repsept
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sort(a) sort(all(a))
#define ff first
#define ss second
#define vi vector<int>
#define pii pair<int, int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define mod (ll)1e9+7
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define repf(i,a,b) for(i=a;i<b;i++)
#define repb(i,a,b) for(i=a;i>=b;i--)
#define N 100005
int main()
{
	FAST
    int t=1;
    // cin>>t;
    while(t--)
    {
		ll x;
		cin>>x;
		if(x%2==0 || x%5==0) cout<<-1;
		else
		{
			if(x==7) cout<<1;
			else if(x==1) cout<<1;
			else
			{
				if(x%7==0) x/=7;
				ll sum=1,rem=1;
				ll cnt=1;
				while(sum)
				{
					cnt++;
					rem=rem*10;
					rem%=x;
					sum=(sum+rem)%x;
				}
				cout<<cnt;
			}
		}
    }
    return 0;
} 


Measured memory_bytes: 3644
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

struct UFTree {
    static const int MAX_N = 1e6;
    int p[MAX_N], r[MAX_N];

    UFTree(int n) : p(), r() {
        for(int i = 0; i < n; ++i) {
            p[i] = i;
            r[i] = 0;
        }
    }

    int root(int x) {
        return p[x] == x ? x : (p[x] = root(p[x]));
    }

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

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y) return;

        if(r[x] < r[y]) {
            p[x] = y;
        } else {
            p[y] = x;
            if(r[x] == r[y]) r[x]++;
        }
    }
};

int n, m;
string s;

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

    V<V<P<ll, int>>> edges(n);
    REP(i, m) {
        int a,b,c;
        cin >> a >> b >> c;
        a--; b--;
        edges[a].push_back({-c, b});
    }

    unordered_set<int> toUpdate;
    Vl d(n, 1e18);
    d[0] = 0LL;
    toUpdate.insert(0);
    V<bool> loop(n, false);

    REP(i, n) {
        unordered_set<int> toUpdateBuf(toUpdate);
        toUpdate.clear();
        FOR(j, toUpdateBuf) {
            int node = *j;
            FOR(k, edges[node]) {
                int dist = k->second;
                ll cost = k->first;
                if (d[dist] > d[node] + cost) {
                    d[dist] = d[node] + cost;
                    toUpdate.insert(dist);
                    if (i == n - 1) {
                        loop[dist] = true;
                        loop[node] = true;
                    }
                }
            }
        }
        if (toUpdate.empty()) break;
    }

    unordered_set<int> loopset;
    REP(i, n) {
        if (loop[i]) loopset.insert(i);
    }
    REP(i, n) {
        unordered_set<int> loopsetBuf(loopset);
        loopset.clear();
        FOR(j, loopsetBuf) {
            int node = *j;
            FOR(k, edges[node]) {
                int dist = k->second;
                if (!loop[dist]) {
                    loop[dist] = true;
                    loopset.insert(dist);
                }
            }
        }
        if (loopset.empty()) break;
    }

    if (loop[n-1]) {
        std::cout << "inf" << '\n';
    } else {
        std::cout << -d[n-1] << '\n';
    }

    return 0;
}


Measured memory_bytes: 384
/**
 *    author:  tourist
 *    created: 14.05.2019 17:29:26       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, t;
  cin >> n >> m >> t;
  vector<int> u(m), v(m);
  for (int i = 0; i < m; i++) {
    cin >> u[i] >> v[i];
    --u[i]; --v[i];
  }
  if (t == 1) {
    const int N = 50010;
    vector<bitset<N>> reach(n);
    for (int i = 0; i < n; i++) {
      reach[i][i] = 1;
    }
    for (int i = m - 1; i >= 0; i--) {
      reach[u[i]] |= reach[v[i]];
      reach[v[i]] = reach[u[i]];
    }
    bitset<N> all = reach[0];
    for (int i = 1; i < n; i++) {
      all &= reach[i];
    }
    cerr << "n = " << n << ", m = " << m << ", count = " << all.count() << '\n';
    for (int i = 0; i < n; i++) {
      if (all[i]) {
        cerr << "i = " << i << '\n';
        vector<bool> got(n, false);
        got[i] = true;
        string res(m, '^');
        for (int j = m - 1; j >= 0; j--) {
          if (got[u[j]] && !got[v[j]]) {
            res[j] = '^';
            got[v[j]] = true;
          }
          if (!got[u[j]] && got[v[j]]) {
            res[j] = 'v';
            got[u[j]] = true;
          }
        }
        cout << res << '\n';
        return 0;
      }
    }
    cout << -1 << '\n';
  } else {
    if (n == 2) {
      cout << -1 << '\n';
      return 0;
    }
    vector<int> ids;
    for (int i = 0; i < m; i++) {
      if (v[i] < 3) {
        ids.push_back(i);
      }
    }
    string res(m, '^');
    for (int it = (int) ids.size() - 2; it >= 0; it--) {
      int me = ids[it];
      int nxt = ids[it + 1];
      if (u[me] == u[nxt] && v[me] == v[nxt]) {
        res[me] = res[nxt];
      } else {
        if (u[me] == u[nxt] || u[me] == v[nxt]) {
          res[me] = 'v';
        }
      }
    }
    cout << res << '\n';
  }
  return 0;
}


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

template <typename _tp> inline void read(_tp&x){
	char ch=getchar(),ob=0;x=0;
	while(ch!='-'&&!isdigit(ch))ch=getchar();if(ch=='-')ob=1,ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();if(ob)x=-x;
}

const int N = 201000;
int p[N], n;

struct Tree {
	#define lson l,mid,x<<1
	#define rson mid+1,r,x<<1|1
	int mi[N<<2], arr[N];
	Tree() {arr[0] = 1e9;}
	void build(int l, int r, int x) {
		if(l == r) return mi[x] = l, void();
		int mid = l + r >> 1;
		build(lson), build(rson);
		mi[x] = mi[x << 1 | (arr[mi[x<<1]] > arr[mi[x<<1|1]])];
	}
	int qry(int l, int r, int x, int L, int R) {
		if(L <= l and r <= R) return mi[x];
		int mid = l + r >> 1, t1 = 0, t2 = 0;
		if(L <= mid) t1 = qry(lson, L, R);
		if(mid < R) t2 = qry(rson, L, R);
		return arr[t1] < arr[t2] ? t1 : t2;
	}
	#undef lson
	#undef rson
};

namespace odd {
	Tree T;
	int ed;
	void init(int nn) {
		ed = 0;
		for(int i=1;i<=nn;i+=2)
			T.arr[++ed] = p[i];
		T.build(1, ed, 1);
	}
	inline int f(int x) {return x + 1 >> 1;}
	inline int ff(int x) {return (x << 1) - 1;}
	int qry(int l, int r) {return ff(T.qry(1,ed,1,f(l),f(r)));}
}

namespace even {
	Tree T;
	int ed;
	void init(int nn) {
		ed = 0;
		for(int i=2;i<=nn;i+=2)
			T.arr[++ed] = p[i];
		T.build(1, ed, 1);
	}
	inline int f(int x) {return x >> 1;}
	inline int ff(int x) {return x << 1;}
	int qry(int l, int r) {return ff(T.qry(1,ed,1,f(l),f(r)));}
}

struct node {
	int v0, v1, l, r;
	friend inline bool operator < (const node&A, const node&B) {
		return p[A.v0] > p[B.v0];
	}
}h[N];

int tp;

void add(int l, int r) {
	if(l > r) return ;
	node nw;
	if(l&1) {
		nw.v0 = odd::qry(l, r);
		nw.v1 = even::qry(nw.v0+1, r);
	} else {
		nw.v0 = even::qry(l, r);
		nw.v1 = odd::qry(nw.v0+1, r);
	}
	nw.l = l, nw.r = r;
	h[++tp] = nw, push_heap(h+1, h+tp+1);
}

inline void pop() {pop_heap(h+1, h+tp+1), --tp;}

int main() {
	read(n);
	for(int i=1;i<=n;++i) read(p[i]);
	odd::init(n);
	even::init(n);
	add(1, n);
	for(int t=n>>1;t;--t) {
		node nw = h[1]; pop();
		printf("%d %d ", p[nw.v0], p[nw.v1]);
		add(nw.l, nw.v0-1);
		add(nw.v0+1, nw.v1-1);
		add(nw.v1+1, nw.r);
	}
	return 0;
}

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

template <class T>
class LazySegmentTree{
private:
    int n;
    vector<T> dat, lazy;
    T def, lazy_def;
    function<T(T, T)> operation;
    function<T(T, T)> update;
    function<T(T, T)> lazy_update;
    function<T(T, T)> propagate;

    void _eval(int k, int l, int r){
        if(lazy[k]!=lazy_def){
            dat[k] = update(dat[k], lazy[k]);
            if(1<r-l){
                lint u = propagate(lazy[2*k+1], lazy[k]);
                lazy[2*k+1] = propagate(lazy[2*k+1], lazy[k]);
                lazy[2*k+2] = propagate(lazy[2*k+2], lazy[k]);
            }
            lazy[k] = lazy_def;
        }
    }

    T _query(int a, int b, int k, int l, int r){
        // [a, b), [l, r)
        if(r<=a or b<=l) return def;
        _eval(k, l, r);
        if(a<=l and r<=b){
            return dat[k];
        }
        else{
            T c1 = _query(a, b, 2*k+1, l, (l+r)/2);
            T c2 = _query(a, b, 2*k+2, (l+r)/2, r);
            return operation(c1, c2);
        }
    }

    void _change(int a, int b, T x, int k, int l, int r){
        _eval(k, l, r);
        if(b<=l or r<=a) return;
        else if(a<=l and r<=b){
            lazy[k] = lazy[k] + lazy_update(lazy[k], x) * (r-l);
            _eval(k, l, r);
        } else {
            _change(a, b, x, 2*k+1, l, (l+r)/2);
            _change(a, b, x, 2*k+2, (l+r)/2, r);
            dat[k] = operation(dat[2*k+1], dat[2*k+2]);
        }
    }

public:
    // [a, b)
    T query(int a, int b){
        return _query(a, b, 0, 0, n);
    }

    void change(int a, int b, T x){
        _change(a, b, x, 0, 0, n);
    }

    T operator[](int i){
        return dat[i+n-1];
    }

    LazySegmentTree(size_t _n, T _def, T _lazy_def, function<T(T, T)> _operation,
                    function<T(T, T)> _update, function<T(T, T)> _lazy_update,
                    function<T(T, T)> _propagate)
            : def(_def), lazy_def(_lazy_def), operation(_operation), update(_update),
            lazy_update(_lazy_update), propagate(_propagate){
        n = 1;
        while(n < _n){
            n *= 2;
        }
        dat = vector<T>(2*n-1, def);
        lazy = vector<T>(2*n-1, lazy_def);
    }
};

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int N, Q, c, s, t, x;
    cin>>N>>Q;
    LazySegmentTree<lint> ldat(N, 0, 0, [](lint a, lint b){return a+b;},
                               [](lint a, lint b){return a+b;}, [](lint a, lint b){return b;},
                               [](lint a, lint b){return a+b/2;});
    for(int i=0;i<Q;i++){
        cin>>c;
        if(c==0){
            cin>>s>>t>>x, s--, t--;
            ldat.change(s, t+1, x);
        } else {
            cin>>s>>t, s--, t--;
            printf("%lld\n", ldat.query(s, t+1));
        }
    }
    return 0;
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

typedef pair<int,int> pi;

struct MaxSegTree{
    int n; vector<pi> dat;
    //?????????
    MaxSegTree(int _n){
        n=1;
        while(n<_n) n*=2;
        dat=vector<pi>(2*n-1);
    }
    //k??????(0-indexed)???????????´??°
    void init(int k){
        int id=k;
        k+=n-1;
        dat[k]=pi(0,-id);
        //??´??°
        while(k>0){
            k=(k-1)/2;
            dat[k]=max(dat[2*k+1],dat[2*k+2]);
        }
    }
    //k??????(0-indexed)?????????+a
    void add(int k, int a){
        k+=n-1;
        dat[k].fi+=a;
        //??´??°
        while(k>0){
            k=(k-1)/2;
            dat[k]=max(dat[2*k+1],dat[2*k+2]);
        }
    }
    //?????¨??????????????????????????¨???
    pi _query(int a, int b, int k, int l, int r){
        if(r<=a || b<=l) return pi(-1200000000,0);

        if(a<=l && r<=b) return dat[k];
        else{
            pi vl=_query(a,b,2*k+1,l,(l+r)/2);
            pi vr=_query(a,b,2*k+2,(l+r)/2,r);
            return max(vl,vr);
        }
    }
    //[a,b)????????§???????±???????
    pi query(int a, int b){
        return _query(a,b,0,0,n);
    }
};

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

    MaxSegTree st(n);
    rep(i,n) st.init(i);

    vector<int> a(n,0);
    int T=0;
    while(R--)
    {
        int d,t,x;
        scanf(" %d %d %d", &d, &t, &x);
        --d;

        pi m=st.query(0,n);
        int id=-m.se;
        a[id]+=t-T;
        T=t;

        st.add(d,x);
    }
    pi m = st.query(0,n);
    int id = -m.se;
    a[id]+=L-T;

    int ans=-1;
    int maxT=0;
    rep(i,n)
    {
        if(maxT<a[i])
        {
            maxT=a[i];
            ans=i+1;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 5204
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
#include<map>
using namespace std;
typedef long long ll;
#define N 100005
int n;
string s;
bool check(int x)
{
    map<string, int> v;
    for(int i = 1; i <= n + 1 - x; i++)
    {
        string a = s.substr(i - 1, x);
        if(v[a])
        {
            if(i - v[a] >= x)
                return true;
        }
        else v[a] = i;
    }
    return false;
}
int main()
{
    int m,i,j,k;
    int T,unit;
    int x,z,y,x1,y1;
    ll ans1=0,ans2=0;
    int n1,n2;
    cin >> n >> s;
    int l = 0, r = n / 2;
    while(l <= r)
    {
        int m = (l + r) >> 1;
        if(check(m))
            l = m + 1;
        else r = m - 1;
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 6668
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

typedef pair<int, int>P;
const int INF = 1<<29;
int N,M;
int dp[256][128][16];
vector<P> s[151];

int main(){
  while(scanf("%d%d", &N,&M) && N||M){
    for(int i=0;i<151;i++) s[i].clear();
    for(int i=0;i<151;i++) for(int j=0;j<76;j++) for(int k=0;k<11;k++) dp[i][j][k] = INF;
    for(int i=0;i<N;i++){
      int k;
      scanf("%d", &k);
      for(int j=0;j<k;j++){
	int x,d; scanf("%d%d", &x,&d);
	s[i].push_back(P(x,d));
      }
    }
    
    for(int i=0;i<s[0].size();i++) dp[0][M][i] = min(dp[0][M][i], 0);
    if(M) for(int i=0;i<s[1].size();i++) dp[1][M-1][i] = min(dp[1][M-1][i], 0);
    /*    for(int m=0;m<=M;m++){
      for(int i=0;i<N;i++){
	for(int j=0;j<s[i].size();j++) printf("%d ", dp[i][m][j]);
	puts("");
      }puts("");
      } */   

    for(int i=0;i<N-1;i++){
      for(int j=0;j<s[i].size();j++){
	for(int m=0;m<=M;m++){
	  if(dp[i][m][j] == INF) continue;
	  for(int k=0;k<s[i+1].size();k++){
	    dp[i+1][m][k] = min(dp[i+1][m][k],
				dp[i][m][j]+(s[i+1][k].second+s[i][j].second)*abs(s[i+1][k].first-s[i][j].first));
	  }
	  if(i+2 < N && m) for(int k=0;k<s[i+2].size();k++){
	      dp[i+2][m-1][k] = min(dp[i+2][m-1][k],
				    dp[i][m][j]+(s[i+2][k].second+s[i][j].second)*abs(s[i+2][k].first-s[i][j].first));
	    }
	}
      }
      //      printf("%d\n" ,i);
      /*      for(int m=0;m<=M;m++){
	for(int i=0;i<N;i++){
	  for(int j=0;j<s[i].size();j++) printf("%d ", dp[i][m][j]);
	  puts("");
	}puts("");
      }*/
    }
    /*    for(int m=0;m<=M;m++){
      for(int i=0;i<N;i++){
	for(int j=0;j<s[i].size();j++) printf("%d ", dp[i][m][j]);
	puts("");
      }puts("");
      }*/
    
    int res = INF;
    for(int i=0;i<s[N-1].size();i++) for(int m=0;m<=M;m++) res = min(res, dp[N-1][m][i]);
    for(int i=0;i<s[N-2].size();i++) for(int m=1;m<=M;m++) res = min(res, dp[N-2][m][i]);
    printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 2264
s = input(); k = int(input())
a = 0
def count(t):
    i = 1; x = 0
    while i < len(t):
        if t[i-1] == t[i]:
            x += 1
            i += 1
        i += 1
    return x
for i in range(len(s)-1):
    if s[i] != s[i+1]: break
else: a = 1
if a == 1: print(len(s)*k//2)
else:
    if k == 1: print(count(s))
    else:
        ss = s+s; sss = ss+s
        print(count(ss)+(count(sss)-count(ss))*(k-2))

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

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

    int cnt = 0;

    while(b<=a) {
        b *=2;
        cnt++;
    }

    while(c<=b) {
        c *= 2;
        cnt++;
    }

    if(cnt <= k) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3632
from collections import deque

def bfs(g_list, visited):
    q = deque([1])
    visited[1] = 0
    while q:
        curr_room = q.popleft()
        for next_room in g_list[curr_room]:
            if visited[next_room] >= 0:
                continue
            visited[next_room] = curr_room
            q.append(next_room)


def main():
    n, m = map(int, input().split()) 
    g_list = [ [] for _ in range(n+1)]
    visited = [-1] * (n+1)
    visited[0] = 0
    # print(g_list)
    for i in range(m):
        a, b = map(int, input().split()) 
        g_list[a].append(b)
        g_list[b].append(a)
    bfs(g_list,visited)
    # print(visited)
    ans = visited[2:]
    if -1 in ans:
        print('No')
    else:
        print('Yes')
        for a in ans:
            print(a)

if __name__ == "__main__":
    main()

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

using i64 = std::int64_t;

namespace io {
  using i64 = std::int64_t;
  constexpr int is = 1 << 17;
  char ib[is], *ip = ib + is, it;
  inline char getc() {
    if (ip == ib + is) { read(STDIN_FILENO, ib, is); ip = ib; }
    return *ip++;
  }
  inline i64 scan() {
    i64 r = 0;
    if (ip + 16 > ib + is) while ((it = getc()) & 16) r = r * 10 + it - '0';
    else while ((it = *ip++) & 16) r = r * 10 + it - '0';
    return r;
  }
  constexpr int os = 1 << 17;
  char ob[os], *op = ob, ot;
  inline void putc(const char c) {
    *op++ = c;
    if (op == ob + os) { write(STDOUT_FILENO, ob, os); op = ob; }
  }
  /* x shoud be greater than or equal to zero */
  inline void print(i64 x) {
    char d[20];
    int i = 0;
    while (true) {
      d[i] = x % 10 + 48;
      x /= 10;
      ++i;
      if (x <= 0) break;
    }
    while (i--) {
      putc(d[i]);
    }
  }
  inline void flush() {
    write(STDOUT_FILENO, ob, op - ob);
  }
}

signed main() {
  using namespace io;
  i64 h = scan();
  i64 n = scan();
  i64 s = 0;
  for (int i = 0; i < n; i++) {
    s += scan();
  }
  if (s >= h) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}

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

typedef pair<int, int> Position;

int main(){
    int H, W;
    cin >> H >> W;

    vector<vector<char> > s(H, vector<char>(W));
    vector<vector<int> > reach(H, vector<int>(W));
    int black = 0;

    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            char a;
            cin >> a;
            if(a == '#')black++;
            s[i][j] = a;
            reach[i][j] = -1;
        }
    }
    int d = 0;
    queue<Position> q;
    q.push(make_pair(0,0));
    reach[0][0] = 0;
    while(!q.empty()){
        Position p = q.front();
        q.pop();
        int x = p.first; int y = p.second;
        if(x == H - 1 && y == W - 1){
            cout << H*W - black - reach[x][y] - 1 << endl;
            return 0;
        }
        if(x + 1 < H && s[x + 1][y] != '#' && reach[x + 1][y] == -1){
            reach[x + 1][y] = reach[x][y] + 1;
            q.push(make_pair(x + 1, y));           
        } 
        if(0 <= x - 1 && s[x - 1][y] != '#' && reach[x - 1][y] == -1){
            reach[x - 1][y] = reach[x][y] + 1;
            q.push(make_pair(x - 1, y));           
        }
        if(y + 1 < W && s[x][y + 1] != '#' && reach[x][y + 1] == -1){
            reach[x][y + 1] = reach[x][y] + 1;
            q.push(make_pair(x, y + 1));           
        }
        if(0 <= y - 1 < H && s[x][y - 1] != '#' && reach[x][y - 1] == -1){
            reach[x][y - 1] = reach[x][y] + 1;
            q.push(make_pair(x, y - 1));           
        }
    }
    cout << -1 << endl;
    return 0;

}

Measured memory_bytes: 3660
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cctype>
#include <stdio.h>
using namespace std;

int main(){
    string N;
    cin >> N;
    int x = N.length();
    for (int i = 0;i<x;i++){
        if (N[i]=='1'){
            cout << 9;
        } else {
            cout << 1;
        }
    }

    cout << endl;

}

Measured memory_bytes: 256
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define file_input
//#define multitest
//#define measure_time
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print_container(const ContainerType<ValueType, Args...> &c)
{
	cout << "{ ";
	for (const auto &v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

void solve()
{
	int n;
	cin >> n;
	v32 arr(n, 0);
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
		if (arr[i] % 2)
			continue;
		if (arr[i] % 2 == 0 && (arr[i] % 3 == 0 || arr[i] % 5 == 0))
			continue;
		cout << "DENIED" << ln;
		return;
	}
	cout << "APPROVED" << ln;
	return;
}

int main()
{
	FASTIO;
#ifdef file_input
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	clock_t start, stop;
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
#ifdef measure_time
	start = clock();
#endif
	for (int tc = 1; tc < t + 1; tc++)
		solve();
#ifdef measure_time
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int h,w;
  cin >> h >> w;
  vector<string> s(h);
  for(int i = 0; i < h; i++) cin >> s.at(i);
  for(int i = 0; i < w+2; i++) cout << "#";
  cout << endl;
  for(int i = 0; i < h; i++) {
    cout << "#"+s.at(i)+"#" << endl;
  }
  for(int i = 0; i < w+2; i++) cout << "#";
  cout << endl;
  return 0;
}

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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<< '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

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



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

int n;
cin >> n;

if(n<=999){
    cout << "ABC" << endl;
}else{
    cout << "ABD" << endl;
}


return 0;
}

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

A = [list(input()) for i in range(N)]
B = [list(input()) for i in range(M)]
C = []

for i in range(N-M+1):
    for j in range(N-M+1):
        tmp = []
        for k in range(i,i+M):
            tmp.append(A[k][j:j+M])
        C.append(tmp)

if B in C: print('Yes')
else: print('No')

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

#define all(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;

int main() {
    ll n, k; cin >> n >> k;
    V<double> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }

    // 期待値
    V<double> v2(n);
    for(int i = 0; i < n; i++){
        v2[i] = ((v[i] * (v[i] + 1)) / 2) / v[i];
    }

    // 累積和
    V<double> v3(n + 1);
    v3[0] = 0.0;
    for(int i = 0; i < n; i++){
        v3[i + 1] = v3[i] + v2[i];
    }

    // 和の計算
    double ans = 0.0;
    for(int i = 0; i < n - k + 1; i++){
        ans = max(ans, v3[i + k] - v3[i]);
    }
    cout << setprecision(20) << ans << endl;

}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
#define fasino ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
 
int dp[101][100001];
int we[101],val[101];
 
signed main()
{
    fasino
    int n,w;
    cin >> n >> w;
    for(int i=0;i<n;i++) cin>>we[i]>>val[i];
    memset(dp,0,sizeof dp);
    for(int i=1;i<n+1;i++){
        for(int j=1;j<w+1;j++){
            if(we[i-1]<=j){
                dp[i][j] = max(val[i-1]+dp[i-1][j-we[i-1]],dp[i-1][j]);
            }
            else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    cout<<dp[n][w];
    return 0;
}

Measured memory_bytes: 79232
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = ReadInts();

            var ka = ReadInts();
            var list = new List<int>(ka);
            list.RemoveAt(0);

            for (int i = 1; i < nm[0]; i++)
            {
                var ka1 = ReadInts();
                var tmplist = new List<int>(ka1);
                tmplist.RemoveAt(0);

                var tmp = new List<int>();
                foreach (var item in list)
                {
                    foreach (var item1 in tmplist)
                    {
                        if (item == item1)
                        {
                            tmp.Add(item);
                        }
                    }
                }
                list = tmp;
            }
            WriteLine(list.Count);
        }
       

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数
        
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

    }
}


Measured memory_bytes: 13268
import sys
from collections import defaultdict
from collections import deque
import numpy as np
import heapq
from heapq import heappush, heappop


#read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

a = input()
b = ord(a)
b += 1
print(chr(b))


Measured memory_bytes: 21648
#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 ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    string S; cin >> S;
    cout << "2018/01/" << S[8] << S[9] << endl;
    return 0;
}

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



// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    string alpha;
    cin >> alpha;
    if (alpha[0] <= 'Z') {
        cout << "A" << endl;
    } else {
        cout << "a" << endl;
    }
    return 0;
}


Measured memory_bytes: 3592
#include<stdio.h>

int main(){
    int n,i,min=0,ans=-1000000001;
    int a[200000];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(i==0)min=a[i];
        else if(a[i]!=min && ans<a[i]-min)ans=a[i]-min;
        else if(a[i]==min && ans<0)ans=a[i]-min;
        if(min>a[i] && i!=n-1)min=a[i];
    }
    printf("%d\n",ans);
    return 0;
}



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

typedef long long int   ll;
#define f(i,st,en)    for(int i=st;i<en;i++)
#define s(n)            scanf("%d",&n)
#define sc(n)           scanf("%c",&n)
#define sl(n)           scanf("%lld",&n)
#define sf(n)           scanf("%lf",&n)

using namespace std;


int main(){
    float r;
    cin>>r;
    cout<<(3.14159265358979323846*r*2);
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;
const ll mod = 1e9 + 7;

ll fac[maxn], ifac[maxn];

ll modpow(ll, ll);
ll inv(ll);
ll nck(ll, ll);
void build();
void testlib();


int n;
ll C[maxn];
ll pow4[maxn];
ll pow2[maxn];

ll get(int i) {
  ll sum = 0;
  for (int x=1; x<=i; x++) {
    sum += nck(i-1,x-1)*x;
    sum %= mod;
  }
  return sum;
}

ll getfast(int i) {
  if (i-2<0) return 1;
  return (pow2[i-2]*(i+1))%mod;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  build();
  pow4[0]=pow2[0]=1;
  for (int i=1; i<maxn; i++) {
    pow4[i]=4LL*pow4[i-1];
    pow2[i]=2LL*pow2[i-1];
    pow4[i]%=mod;
    pow2[i]%=mod;
  }
  cin>>n;
  for (int i=1; i<=n; i++) {
    cin>>C[i];
  }
  sort(C+1,C+1+n);
  reverse(C+1,C+1+n);
  ll ans = 0;

  for (int i=1; i<=n; i++) {
    ll cur = pow4[n-i]*C[i];
    cur %= mod;
    cur *= pow2[i];
    cur %= mod;

    ll sum = getfast(i);

    cur *= sum;
    cur %= mod;
    
    ans += cur;
    ans %= mod;
  }
  
  out(ans);  

  return 0;
}

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


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

ll inv(ll x) {
  assert(x != 0);
  return modpow(x, mod-2);
}

void build() {
  fac[0] = ifac[0] = 1;
  for (int i=1; i<maxn; i++) {
    fac[i] = fac[i-1] * i;
    fac[i] %= mod;
    ifac[i] = inv(fac[i]);
    ifac[i] %= mod;
  }
}

ll nck(ll n, ll k) {
  assert(n>=0 && k>=0);
  if (k > n) return 0;
  return (((fac[n] * ifac[k]) % mod) * ifac[n-k]) % mod;
}

void testlib() {
  assert(modpow(1,1) == 1);
  assert(modpow(4,2) == 16);
  assert(modpow(2,5) == 32);
  assert(fac[3] == 6);
  assert(nck(4,2) == 6);
  assert(nck(10,2) == 45);
}


Measured memory_bytes: 35200
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			long L = sc.nextLong();
			if (L == 0) break;
			long ans = 1;
			for (long i = 2; i * i <= L; ++i) {
				if (L % i != 0) continue;
				int c = 1;
				L /= i;
				while (L % i == 0) {
					L /= i;
					++c;
				}
				ans *= c * 2 + 1;
			}
			if (L != 1) {
				ans *= 3;
			}
			System.out.println((ans - 1) / 2 + 1);
		}
	}
}

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

		using namespace std;

		int main()
		{ios_base::sync_with_stdio(false);
		    cin.tie(NULL);
		 	  int n;
		 	  cin>>n;
		 	  int ans=0;
		 	  int tmp=n;
		 	  while(tmp)
		 	  {
		 	  	ans+=tmp%10;
		 	  	tmp=tmp/10;
		 	  }
		 	  if(n%ans==0)
		 	  {
		 	  	cout<<"Yes"<<endl;
		 	  }
		 	  else
		 	  {
		 	  	cout<<"No"<<endl;
		 	  }
			return 0;

		}

Measured memory_bytes: 3588
from sys import stdin
import sys
#import numpy as np
import collections
from functools import cmp_to_key
import heapq

##  input functions for me
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def rip(sep = ''):
    if sep == '' :
        return map(int, input().split()) 
    else: return map(int, input().split(sep))
def ria(sep = ''): 
    return list(rip(sep))
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##

class fenwick_tree:
    def __init__(self, n):
        self.N = n
        self.n = 1 # pow of 2
        while(self.n < self.N):
            self.n *= 2
        self.data = [0] * (self.n + 1)

    def add(self, idx, x):
        while idx <= self.n:
            self.data[idx] += x
            idx += (idx & -idx)

    def cumulate(self, idx):
        s = 0
        while idx > 0:
            s += self.data[idx]
            idx -= (idx & -idx)
        return s

def main():
    N = ri()
    S = rs()
    Q = ri()
    ans = []

    bit = [fenwick_tree(N) for i in range(26)]
    for i in range(N):
        d = ord(S[i]) - ord('a')
        bit[d].add(i + 1, 1)

    ca = [c for c in S]
    for _ in range(Q):
        ss = rsa()
        if ss[0] == '1':
            pos = int(ss[1]) - 1
            c = ss[2][0]
            bit[ord(ca[pos]) - ord('a')].add(pos + 1, -1)
            ca[pos] = c
            bit[ord(ca[pos]) - ord('a')].add(pos + 1, +1)
        else:
            l = int(ss[1]) - 1
            r = int(ss[2]) - 1
            cnt = 0
            for i in range(26):
                su = bit[i].cumulate(r + 1) - bit[i].cumulate(l)
                if su > 0: cnt += 1
            ans.append(cnt)
    
    print("\n".join([str(n) for n in ans]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 168308