akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
template<typename T> T gcd(T a,T b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int n;
vpii v;
set<pair<pii, int> > s[2];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    int l, r;
    cin >> l >> r;
    v.pb(pii(l, r));
  }
  ll aans = 0;
  FOR(ii, 0, 2){
    s[0].clear();
    s[1].clear();
    FOR(i, 0, n){
      s[0].insert(mp(pii(-v[i].fi, -v[i].se), i));
      s[1].insert(mp(pii(v[i].se, v[i].fi), i));
    }
    int iii = ii, x = 0, l, r;
    ll ans = 0;
    FOR(i, 0, n){
      pair<pii, int> tii = *s[iii].begin();
      pii p = tii.fi;
      if(iii){
        l = p.se;
        r = p.fi;
      }else{
        l = -p.fi;
        r = -p.se;
      }
      if(r < x){
        ans += x - r;
        x = r;
      }else if(x < l){
        ans += l - x;
        x = l;
      }
      s[iii].erase(s[iii].begin());
      s[1-iii].erase(s[1-iii].find(mp(pii(-p.se, -p.fi), tii.se)));
      iii ^= 1;
    }
    ans += abs(x);
    maxs(aans, ans);
  }
  cout << aans << endl;
  return 0;
}


Measured memory_bytes: 13556
N, K = map(int, input().split())

MOD = 10 ** 9 + 7

from operator import mul
from functools import reduce


def cmb(n, r):
	if n < r:
		return 0
	r = min(n - r, r)
	if r == 0:
		return 1
	numer = reduce(mul, range(n, n - r, -1))
	denom = reduce(mul, range(1, r + 1))
	return numer // denom % MOD

for i in range(1, K + 1):
	print(cmb(K - 1, i - 1) * cmb(N - K + 1, i) % MOD)

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

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

using namespace std ;

const int MAXN = 501 * 1001 , MOD = 1e9 + 7 ; 



int32_t main()
{
	ios::sync_with_stdio(0) ; cin.tie(0) ; 
	int n ; ;
	int a[3] ; 
	int b[3] ; 
	cin >> a[0] >> a[1] >> a[2] ; 
	int ans = 0 ; 
	while(1)
	{
		if(a[0]&1||a[1]&1||a[2]&1)
			break ; 
		b[0] = (a[1]+a[2]) / 2 ; 
		b[1] = (a[0]+a[2]) / 2 ; 
		b[2] = (a[0]+a[1]) / 2 ; 
		sort(b,b+3) ; 
		bool f = 0 ; 
		for(int i = 0 ; i < 3 ; i ++ ) if(a[i]!=b[i]) f = 1 ;
		if(!f) return cout << -1 << endl , 0 ; 
		a[0] = b[0] ; 
		a[1] = b[1] ; 
		a[2] = b[2] ; 
		ans ++ ; 
	}
	cout << ans << endl ; 

}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  unordered_set<int> us;
  int j;

  for (int i = 0; i < m; ++i) {
    cin >> j;
    us.emplace(j);
  }
  
  int ansN = 0, ans0 = 0;
  for (int i = x; i <= n; ++i)
    if (us.find(i) != us.end()) ansN++;
  for (int i = x; i >= 0; --i)
    if (us.find(i) != us.end()) ans0++;

  int ans = min(ansN, ans0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define LL long long int
using namespace std;
 
int main(){
  	ios::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
    LL x, y, z;    cin >> x >> y >> z;	LL n = x + y + z;
    vector<LL> a(n), b(n), c(n);    vector< pair<LL,LL> > a_b(n);
    for(LL i = 0; i < n; ++i){
        cin >> a[i] >> b[i] >> c[i];
        a_b[i] = pair<LL,LL>(a[i] - b[i], i);
    }
    sort(a_b.begin(), a_b.end());    vector<LL> xz(n), yz(n);
    priority_queue<LL> q_xz, q_yz;    LL total = 0;
    for(LL i = 0; i < n; ++i){
        total += b[a_b[i].second];
        q_yz.push(c[a_b[i].second] - b[a_b[i].second]);
        if(q_yz.size() > y){
            total += q_yz.top(); q_yz.pop();
        }
        yz[i] = total;
    }
    total = 0;
    for(LL i = n-1; i >= 0; --i){
        total += a[a_b[i].second];
        q_xz.push(c[a_b[i].second] - a[a_b[i].second]);
        if(q_xz.size() > x){
            total += q_xz.top(); q_xz.pop();
        }
        xz[i] = total;
    }

    LL best = 0;
    for(LL k = y; k <= y + z; ++k){
        best = max<LL>(best, yz[k-1] + xz[k]);
    }
    cout << best;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
using ll = long long;
using P = pair<ll,ll>;
#define pb push_back
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; }

/*
 string -> int : stoi(S);
 int -> string : to_string(N);
 Sのn文字以降をm文字取り出す : S.substr(n,m)
cout << fixed << setprecision(2) << 3.14 << endl; //3.1

 int: -2,147,483,648 ～ 2,147,483,647 (2×10^9)
 ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 (9×10^18)

*/

int main() {

  ll n, m, k, count=0;
  string s;
  
  cin >> n >> k;

  vector<bool> ans(n,true);

  rep(i,k){
    int d;
    cin >> d;
    rep(l,d){
      int a;
      cin >> a;
      a--;
      ans[a]=false;
    }
  }

  rep(i,n){
    if (ans[i]) count++;
  }

  cout << count << endl;
}

Measured memory_bytes: 3632
while true
    n, q = gets.chomp.split.map(&:to_i)
    break if [n, q] == [0, 0]
    arr = Array.new(100, 0)
    n.times{
        line = gets.chomp.split.map(&:to_i)
        line[1..-1].each{|day| arr[day] += 1}
    }
    date, x = 0, 0
    for i in 1..99
        if arr[i] > x && arr[i] >= q
            date = i
            x = arr[i]
        end
    end
    puts date
end


Measured memory_bytes: 7016
#include <bits/stdc++.h>
#define ll long long
ll mod=1000000007;
#define vl vector<ll>
#define pl pair<ll,ll>
#define rep(i,b) for(ll i=0;i<b;i++)
#define reverse(v) reverse(all(v))
#define all(v) (v).begin(),(v).end()
using namespace std;

string s,q;
ll n,l,r;
int main(){
    cin>>s>>n;
    rep(i,n){
        cin>>q;
        if(q=="replace"){
            cin>>l>>r>>q;
            for(ll j=l,k=0;j<r+1;j++,k++)s[j]=q[k];
        }else if(q=="reverse"){
            cin>>l>>r;
            q=s.substr(l,r-l+1);
            for (ll j= l,k=r-l; j<r+1 ; j++,k--)s[j]=q[k];
        }else{
            cin>>l>>r;
            cout<<s.substr(l,r-l+1)<<endl;
        }
    }
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e18;
#define rep(i, n) for (int i = 0; i < n; i++)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    string s;
    int k;
    cin >> k >> s;
    if (s.size() > k) cout << s.substr (0, k) << "...\n";
    else
        cout << s << "\n";
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

pair<pair<string, li>, li> shops[100100];

int main() {
    li n;
    cin >> n;
    rin{
        string s;
        li x;
        cin >> s >> x;
        shops[i] = {{s, -x}, i + 1};
    }
    sort(shops, shops + n);
    rin{
        cout << shops[i].S << endl;
    }


    return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>

int main(void)
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W, &H, &x, &y, &r);
	if(x -r < 0 || x + r > W || y -r < 0 || y + r > H){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 584
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <queue>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

struct Vertex {
  int id;
  vector<int> neighbor;

  Vertex(int id = -1) {
    this->id = id;
  }
};

struct Node {
  int v;
  int state;
  int dist;

  Node(int v, int dist = -1, int state = -1) {
    this->v = v;
    this->dist = dist;
    this->state = state;
  }
};

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

  Vertex vertexes[N + 1];

  for (int i = 1; i <= N; ++i) {
    vertexes[i] = Vertex(i);
  }

  for (int i = 0; i < M; ++i) {
    int u, v;
    cin >> u >> v;

    vertexes[u].neighbor.push_back(v);
  }

  int S, T;
  cin >> S >> T;
  bool visited[N + 1][3];
  memset(visited, false, sizeof(visited));

  queue<Node> que;
  que.push(Node(S, 0, 0));

  while (!que.empty()) {
    Node n = que.front();
    que.pop();

    if (n.v == T && n.state == 0) {
      cout << n.dist / 3 << endl;
      return 0;
    }

    if (visited[n.v][n.state]) continue;
    visited[n.v][n.state] = true;

    for (int j = 0; j < vertexes[n.v].neighbor.size(); ++j) {
      que.push(Node(vertexes[n.v].neighbor[j], n.dist + 1, (n.state + 1) % 3));
    }
  }


  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const ll MOD = (ll)1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

ll fac[1] = {1}, inv[1] = {1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}
ll cmb(ll r, ll c) {return fac[r] * inv[c] % MOD * inv[r - c] % MOD;}

struct node {
    ll co;
    int ty, pre, len;
    bool operator< (const node &v2) const {
        return co>v2.co;
    }
};

priority_queue<node> pq;

int n;
int nn[100];
char s[100][51];
ll c[100];
ll dist[2][100][51];

void ins(ll co, int ty, int pre, int len) {
    if (dist[ty][pre][len] > co) {
        dist[ty][pre][len] = co;
        pq.push({co, ty,pre,len});
    }
}

int isPal(char st[], int l, int r) {
    while (l < r) {
        if (st[l] != st[r]) return 0;
        l++; r--;
    }
    return 1;
}

int main() {
    memset(dist, 0x3f, sizeof(dist));
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf("%s %lld", s[i], &c[i]);
        nn[i] = strlen(s[i]);

        dist[0][i][nn[i]] = c[i];
        dist[1][i][nn[i]] = c[i];
        pq.push({c[i], 0, i, nn[i]});
        pq.push({c[i], 1, i, nn[i]});
    }

    int ty,pre,len;
    ll co;

    while (!pq.empty()) {
        node tv = pq.top();
        pq.pop();

        if (tv.co != dist[tv.ty][tv.pre][tv.len]) continue;
        ty=tv.ty, pre = tv.pre, len=tv.len, co = tv.co;

        if (tv.len == 0) return !printf("%lld", co);
        if (tv.ty == 0 && isPal(s[pre], nn[pre]-len, nn[pre] - 1)) return !printf("%lld", co);
        else if (tv.ty == 1 && isPal(s[pre], 0, len - 1)) return !printf("%lld", co);

        if (ty == 0) {
            for (int i = 0; i < n; i++) {
                int flag = 0;
                for (int j = 0; j < min(len, nn[i]); j++)
                    if (s[i][nn[i]-j-1] != s[pre][nn[pre]-len+j])
                        flag = 1;

                if (flag == 1) continue;
                if (len >= nn[i]) ins(co+c[i], 0, pre, len-nn[i]);
                else ins(co+c[i], 1, i, nn[i]-len);
            }
        }
        else {
            for (int i = 0; i < n; i++) {
                int flag = 0;
                for (int j = 0; j < min(len, nn[i]); j++)
                    if (s[i][j] != s[pre][len-j-1])
                        flag = 1;

                if (flag == 1) continue;
                if (len >= nn[i]) ins(co+c[i], 1, pre, len-nn[i]);
                else ins(co+c[i], 0, i, nn[i]-len);
            }
        }
    }

    printf("-1");
}

Measured memory_bytes: 3872
#include<bits/stdc++.h>
using namespace std;
int main()
{
  unsigned long long int a,b,c,n,ans;
  cin>>n>>a>>b;
  c=n/(a+b);
  ans=c*a;
  n=n%(a+b);
  ans=ans+min(a,n);
  cout<<ans<<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 rep(i,n) for(int i=0;i<(int)(n);i++)
const int mod = 1e9+7;
const long long INF = 1LL << 60;
typedef long long ll;
int main(){
    ll N;
    cin >> N;
    vector<pair<int, int> > task;
    rep(i,N){
        int a,b;
        cin >> a >> b;
        task.emplace_back(b,a);
    }
    sort(task.begin(), task.end());
    int sum = 0;
    bool flag = true;
    //ソート済みだから
    for(auto v : task){
        sum += v.second;
        if(sum > v.first){
            flag = false;
            break;
        }
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int INF = 1000000007;

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

  int64_t N;
  cin >> N;
  int64_t ans = 10000000000000;
  for(int64_t i=1;i*i<=N;i++){
    if(N % i == 0){
      ans = min(ans, i + (N/i));
    }
  }
  cout << ans - (int64_t)2 << endl; 
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<iostream>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <cstring>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <sstream>
#include <map>
#include <unordered_map>
#include <vector> 
#include <bitset>
#include <cctype>
#include <set>
#include <stack>
#include <queue>
#include <fstream>
#include <numeric>
#include <random>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int MAXN = 5005;
const int MAXM = 20500;
const ll MOD = 1e9+7;

#define MP make_pair
#define INF 0x3f3f3f3f
#define closeSync ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template <typename T> inline T min(T a, T b, T c,T d) { return min(min(a, b), min(c,d)); }
template <typename T, typename T1> inline T qpower(T x, T p, T1 mod) { T re = 1; x %= mod; while (p) { if (p & 1)re = (re * x) % mod; x = (x * x) % mod; p >>= 1; }return re; }
#define mst(X,Y) memset(X,Y,sizeof(X)) 
#define rep(i, a, n) for (int i=(a); i<=(n); i++)
#define per(i, a, n) for (int i=(a); i>=(n); i--)
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) { cerr << " " << to_string(H);    debug_out(T...);}


// int solve(int l,int r)
// {
		
// }

int main()
{//closeSync;
#ifdef DEBUG
	//freopen("C:/Users/86159/Desktop/input.txt", "r", stdin);
	//freopen("C:/Users/86159/Desktop/output.txt", "w", stdout);
#endif
	//clock_t c1 = clock();

	double d,t,s;
	cin>>d>>t>>s;
	if (d/s <= t)
	{
		cout<<"Yes\n";
	}
	else 
		cout<<"No\n";




	//cerr << "Time:" << clock() - c1 << "ms" <<endl;
    return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h> 
#define ll long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fr(i,a,b) for(long long int i=a; i<b; i++)
#define pb push_back
#define mp make_pair
using namespace std;
signed main() 
{
    fast
    ll t=1;
  // cin>>t;
    while(t--)
    {
           ll n;
           cin>>n;
           ll a[n][3];
           for(ll i=0;i<n;i++) cin>>a[i][0]>>a[i][1]>>a[i][2];
           ll dp[n+1][3];
           dp[0][0]=0; dp[0][1]=0; dp[0][2]=0;
           for(ll i=1;i<n+1;i++)
           {
                  dp[i][0]=a[i-1][0]+max(dp[i-1][1],dp[i-1][2]);
                  dp[i][1]=a[i-1][1]+max(dp[i-1][0],dp[i-1][2]);
                  dp[i][2]=a[i-1][2]+max(dp[i-1][0],dp[i-1][1]);
           }
           cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<"\n";
    }
}

Measured memory_bytes: 8264
#include <stdio.h>

int main()
{
    int a, b, i;
    
    for (i = 0; i < 4; i++)
    {
        scanf("%d %d", &a, &b);
        
        if (a == 1)
        {
            printf("%d\n", b * 6000);
        } else if (a == 2)
        {
            printf("%d\n", b * 4000);
        } else if (a == 3)
        {
            printf("%d\n", b * 3000);
        } else if (a == 4)
        {
            printf("%d\n", b * 2000);
        }
    }
    
    return 0;
}

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

using std::pair;
using std::vector;
using std::string;

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

#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int oo = 0x3f3f3f3f;

string procStatus() {
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}

template <typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x *= f;
}

const int N = 100000;

int n;
int a[N + 5], c[2*N + 5];

void clear() { memset(c, 0, sizeof c); }
void add(int x) {
    x += N + 1;
    while(x <= 2*N + 1) { 
        ++ c[x];
        x += (x & -x);
    }
}
int query(int x) {
    int res = 0;
    x += N + 1;
    while(x > 0) {
        res += c[x];
        x -= (x & -x);
    }
    return res;
}

bool chk(int x) {
    clear();
    add(0);

    int cur = 0;
    ll ans = 0;
    for(int i = 1; i <= n; ++i) {
        if(a[i] >= x) cur ++; else cur --;
        ans += query(cur)*2 - i;
        add(cur);
        //printf("%d %d\n", cur, ans);
    }
    return ans >= 0;
}

int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    read(n);
    for(int i = 1; i <= n; ++i) read(a[i]);

    int l = 0, r = (int) 1e9;

    while(l < r) {
        int m = (l + r + 1) >> 1;
        if(chk(m)) l = m; else r = m - 1;
    }
    printf("%d\n", l);

    return 0;
}


Measured memory_bytes: 1408
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
int digit(int x){
    int cnt = 0 ;
    while(x != 0){
        x /= 10 ;
        cnt++ ;
    }
    return cnt ;
}
signed main(){
    fastio
    int n ;
    cin >> n ;
    int ans = INF ; 
    for(int i = 1; i * i <= n; i++){
        if ( n % i == 0 ) {
            int a = i ; 
            int b = n / i ; 
            debug() << imie(a) imie(b) ;
            ans = min(ans, max(digit(a) , digit(b))) ;
        }
    }
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define sd(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define pl(n) printf("%lld",n)
#define endc printf("\n")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

const int maxn = 5e5 + 7; 
//const int md = 1e9 + 7;

int f[maxn][2];
int kmp[maxn];

void calc(string s, int n, int p) {
	fill(kmp+1,kmp+n+1,0); int q = 0; kmp[1] = q; f[1][p] = 1;
	for (int i = 2; i <= n; i++) {
		while (q > 0 && s[q+1] != s[i]) q = kmp[q];
		if (s[q+1] == s[i]) q++; kmp[i] = q;
		int d = i - kmp[i];
		if (i % d == 0) f[i][p] = i/d;
		else f[i][p] = 1;
	}
}

int main() {
	string s; cin>>s; string t = s; reverse(t.begin(), t.end());
	int n = s.size(); s = " " + s; t = " " + t; calc(s,n,0); calc(t,n,1);
	if (f[n][0] == n) {
		pd(n); endc; pd(1); endc; return 0;
	} else if (f[n][0] == 1) {
		pd(1); endc; pd(1); endc; return 0;
	}
	int ans = 0;
	for (int i = 1; i < n; i++) {
		if (f[i][0] == 1 && f[n-i][1] == 1) ans++;
	}
	pd(2); endc; pd(ans); endc; return 0;
}


Measured memory_bytes: 7604
n = int(input())
a = [int(i) for i in input().split()]

a.sort()

MAXN = a[-1]


divisors = [False for _ in range(MAXN + 1)]
answer = 0
apast = None
for i, ai in enumerate(a):
    if ai == apast:
        is_good = False
    elif i < n - 1 and ai == a[i + 1]:
        is_good = False
        m = 1
        while m * ai <= MAXN:
            divisors[m * ai] = True
            m += 1
    else:
        is_good = not divisors[ai]

        m = 1
        while m * ai <= MAXN:
            divisors[m * ai] = True
            m += 1

    if is_good:
        answer += 1

    apast = ai


print(answer)


Measured memory_bytes: 32360
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int a, b;
    cin >> a >> b;

    int temp = b;
    int A = 0;
    while (temp > 0)
    {
        A = A * 10 + a;
        --temp;
    }

    temp = a;
    int B = 0;
    while (temp > 0)
    {
        B = B * 10 + b;
        --temp;
    }

    cout << (a <= b ? A : B) << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    if ((a + b)%3 == 0)
    {
        printf("Possible");
    }
    else if (a%3 == 0)
    {
        printf("Possible");
    }
    else if (b%3 == 0)
    {
        printf("Possible");
    }
    else
    {
        printf("Impossible");
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n,k,x,ans;
int main()
{
    scanf("%d%d",&n,&k);
    for(register int i=1; i<=n; i++)
    {
        scanf("%d",&x);
        ans+=2*min(x,k-x);
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
const int mod=1e9+7;
using namespace std;

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



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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (c >= a && c <= b)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int a, b, c; cin >> a >> b >> c;

  if((a == b && b != c) ||
      (b == c && c != a) ||
      (c == a && a != b)) {
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }

}


Measured memory_bytes: 256
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;
typedef pair<LL,LL> LP;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	string s;
	while(cin >> s){
		char pre = s[0];
		int ans = 0;
		REP(i,SZ(s)){
			if(s[i] != pre){
				ans++;
				pre = s[i];
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int k = in.nextInt();
            int x = in.nextInt();
            for (int i = x - k + 1; i <= x + k - 1; i++)
                out.print(i + " ");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD = 1000000007;
ll cnt =0,ans=0;
const int MAX = 510000;

int main(){
   int n;   cin >> n;
   for(int i=1;i<n;i++){
       ans += n/i ;
       if(n % i == 0)ans--;
   }
   cout << ans << endl;
}

Measured memory_bytes: 3628
def solve(n,a,v)
  dp = Array.new(n+1){[]}
  dp[2][0] = a[0].gcd(a[1])
  dp[2][1] = v
  2.upto(n-1) do |i|
    dp[i+1][0] = dp[i][0].gcd(a[i])
    t = dp[i][1].gcd(a[i])
    dp[i+1][1] = dp[i][0] > t ? dp[i][0] : t
  end
  return dp[n][1]
end

n = gets.to_i
a = gets.split.map(&:to_i)

p [solve(n,a,a[0]),solve(n,a,a[1])].max


Measured memory_bytes: 18564
/***********************************************************
	When you are inspired by passion 
	and you want to live for the current moment

	When your every thought and action
	has the power to become the story of your future

	When difficulties stand to demolish your Glory
	Just remember that Life is a 'Golden adverse Story'

	Withstand it to acheive your passion and dreams
	more amazingly more easily.

	Why then? When writing the story of your Life
	You want to Let someone else hold your pen

					huzaifa242©

***********************************************************/
#include "bits/stdc++.h"
using namespace std;
#define int int32_t
#define MAX 100005
#define x first 
#define y second

int seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l = 0, int r = numeric_limits <int>::max())
{return uniform_int_distribution<int> (l, r)(rng);}

template <typename T, typename G>
ostream& operator << (ostream& out, const pair <T, G> &a) 
{return out << "( " << a.x << ", " << a.y << ")";}

template <typename T>
ostream& operator << (ostream& out, const vector <T> &a) 
{out << "[ "; for(const auto &i: a) out << i << ", "; return out << "]" << endl;}

template <typename T>
ostream& operator << (ostream& out, const set <T> &a) 
{out << "{ "; for(const auto &i: a) out << i << ", "; return out << "}" << endl;}

template <typename T, typename G>
ostream& operator << (ostream& out, const map <T, G> &a) 
{out << "< "; for(const auto &i: a) out << i << ", "; return out << ">" << endl;}

template <typename T, size_t N>
typename enable_if<!is_same <typename remove_cv <T>::type, char>::value,
ostream&>::type operator << (ostream& out, T (&a)[N])
{out << "[ "; for(const auto &i: a) out << i << ", "; return out << "]" << endl;}

void debug_out(){cerr << endl;} 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{cerr << (H) << ' '; debug_out(T...);}
 
#ifdef LOCAL
#define debug(...) cerr << '#' << #__VA_ARGS__ << ":\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 24
#endif

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	vector <pair <int,int> > a(n);
	for (int i = 0; i < n; ++i) 
		cin >> a[i].x >> a[i].y;
	for (int i = 0; i < n - 2; ++i) {
		bool ok = true;
		for (int j = 0; j < 3; ++j) {
			ok &= (a[i + j].x == a[i + j].y);
		}
		if (ok) {
			cout << "Yes\n";
			exit(0);
		} 
	}
	cout << "No\n";
	return 0;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;


int n;
vector<int> h;
int ans = 0;

int main() {
    cin >> n;
    h.resize(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    int ans = h[0];
    for(int i = 1; i < n; i++){
        int sub = h[i] - h[i - 1];
        if(sub > 0) ans += sub;
    }
    cout << ans << endl;
}


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

string S;
int dp[80000][11];

inline int rec(int idx, int mod)
{
  if(idx == S.size()) return(mod == 0);
  if(~dp[idx][mod]) return(dp[idx][mod]);
  return(dp[idx][mod] = rec(idx + 1, (mod * 10 + S[idx] - '0') % 11) + (mod == 0));
}

int main()
{
  while(cin >> S, S != "0") {
    memset(dp, -1, sizeof(dp));
    int ret = 0;
    for(int i = 0; i < S.size(); i++) {
      if(S[i] != '0') ret += rec(i + 1, S[i] - '0');
    }
    cout << ret << endl;
  }
}

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

int main() {
  int a,b;
  cin >> a >> b;
  if(a+b<10){
    cout << a+b << endl;
  }else{
    cout << "error" << endl;
  }
}

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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

ll dp[101][100500];
int a[100500], b[100500];
int n;

ll f(int i, int w){
	if(w == 0) return 0;
	if(w < 0) return -inf;
	if(i == n) return 0;
	if(dp[i][w] != -1) return dp[i][w];
	return dp[i][w] = max(f(i + 1, w), b[i] + f(i + 1, w - a[i]));
}

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

	int w;
	cin >> n >> w;
	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
	}
	memset(dp, -1, sizeof dp);
	cout << f(0, w);
}

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

int main(){
  int64_t N,ans,ansif;
  cin >> N;
  int A = sqrt(N);
  ans = N - 1;
  for (int i = 1; i <= A; i++){
    if (N % i == 0){
      ansif = i + (N / i) - 2;
      ans = min(ans,ansif);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mp    make_pair
#define pb    push_back
#define F     first
#define pi 	  3.14159265358979323846
#define S     second
#define ll    long long
#define ld    long double
#define sz(s) (ll)s.size() 
#define vl    vector < ll >
#define pll   pair < ll, ll >
#define ml    map < ll, ll >
#define mod   1000000007
#define q	998244353
#define MAXN  50005 
#define mx 10000005
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define inv(i,a,b)  for(ll i=a;i>=b;i--)
#define all(a)  (a).begin(),(a).end()
using namespace std;
int main(){
	IOS;
	ll t,n,l;
	ll i,j,m,mn,d,x,y,ans=0,sum=0,p,k,c;
	string s,s1;
	cin>>n;
	ll a[n];
	rep(i,0,n)cin>>a[i];
	sort(a,a+n);
	bool b=true;
	sum=a[n-1];
	j=n-2;
	rep(i,2,n){
		sum+=a[j];
		b^=1;
		if(b)j--;
	}
	cout<<sum;
}

Measured memory_bytes: 5220
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define FFOR(i, a, b) for(int (i)=a;(i)>(b);--(i))
#define rrep(i,n) FFOR(i,0,n)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define lb long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define ll long long
#define mod 1000000007LL
#define INF 123456789012345
typedef pair<int, int> P;
typedef pair<int, P> PP;

const int maxn =1e4 + 10;

string s[maxn];

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

	rep(i,n) cin >> s[i];

	string t;cin >> t;
	// tの前か後ろのどっちに入るか
	int mae = 0;
	int mid = 0;
	int usiro = 0;

	rep(i,n)
	{
		bool ok = false;
		bool notmae = false;
		bool notusiro = false;
		rep(j,s[i].size())
		{
			if(j > t.size()-1)
			{
				if(notusiro) mid++;
				else usiro += 1;
				ok = true;
				break;
			}

			if(s[i][j] == '?') 
			{
				if(t[j] != 'a' && t[j] != 'z')
				{
					mid++;
					ok=true;
					break;
				}

				if(t[j] == 'a')	notmae = true;
				if(t[j] == 'z') notusiro = true;

				if(notmae && notusiro)
				{
					mid++;
					ok=true;
					break;
				}
			}

			if(s[i][j]-0 < t[j]-0)
			{
				if(notmae) mid++;
				else mae += 1;
				ok = true;
				break;
			}
			else if(s[i][j]-0 > t[j]-0)
			{
				if(notusiro) mid++;
				else usiro += 1;
				ok = true;
				break;
			}

		}
		if(ok) continue;
		
		if(s[i].size() == t.size())	mid++;
		else
		{
			if(notmae) mid++;
			else mae++;
		}



	}


	rep(i,mid) cout << mae+1+i << " ";
	
	cout <<mae+1+mid<< endl;
	return 0;
}

Measured memory_bytes: 896
from collections import defaultdict


def main():
    # 同じ文字を2つつなげると回文になるので、最低限隣り合う文字が全部異なる必要がある。
    # また、abaのように、2つ先で一致してしまってもこれも回文になるのでNG。
    # となると結局「abcabc...」みたいに巡回する形の文字列しか回文回避の方法はない。
    # こういう巡回する形の文字列を作るには、a,b,cの数の最大と最小の差が1以内であればOK。
    S = input()
    counter = defaultdict(int)
    for s in S:
        counter[s] += 1
    counts = [counter[s] for s in "abc"]
    if max(counts) - min(counts) <= 1:
        print('YES')
    else:
        print('NO')


if __name__ == '__main__':
    main()

Measured memory_bytes: 9328
#include <iostream>
#include <cstdio>
#include <list>
#include <string>

using namespace std;

void printlst(list<char> str){
  for(list<char>::iterator i=str.begin(); i!=str.end(); i++)
    cout << *i;
  cout << endl;
}

int main(){
  int n;
  cin >> n;
  for(int i=0; i<n; i++){
    int m;
    list<char> str;
    string sstr;
    getline(cin,sstr);    getline(cin,sstr);
    cin >> m;

    for(int i=0; i<sstr.size(); i++) str.push_back(sstr[i]);
    list<char>::iterator cur=str.begin();
    //    printlst(str);

    for(int j=0; j<m; j++){
      string op1,op2;
      cin >> op1;
      if(op1=="insert"){
	char c;
	while((c=getchar())!='"') ;
	while((c=getchar())!='"') op2+=c;
	for(int i=0; i<op2.size(); i++)
	  str.insert(cur,op2[i]);
      }else{
	cin >> op2;
	if(op1=="forward"){
	  if(op2=="char"){
	    if(cur!=str.end())
	      cur++;
	  }else{
	    while(*cur==' ') cur++;
	    while(true){
	      if(*cur==' ' || cur==str.end())
		break;
	      cur++;
	    }
	  }
	}else if(op1=="backward"){
	  if(op2=="char"){
	    if(cur!=str.begin())
	      cur--;
	  }else{
	    if(cur!=str.begin())
	      cur--;
	    while(*cur==' ') cur--;
	    while(true){
	      if(*cur==' '){
		cur++;
		break;
	      }else if(cur==str.begin()){
		break;
	      }
	      cur--;
	    }
	  }
	}else if(op1=="delete"){
	  if(op2=="char"){
	    if(cur!=str.end())
	      str.erase(cur++);
	  }else{
	    list<char>::iterator cur2=cur;
	    while(*cur2==' ') cur2++;
	    if(cur2!=str.end()){
	      while(*cur==' ') str.erase(cur++);
	      while(true){
		if(*cur==' ' || cur==str.end())
		  break;
		str.erase(cur++);
	      }
	    }
	  }
	}
      }
      // str.insert(cur,'^');
      // printlst(str);
      // str.erase((--cur)++);
    }

    str.insert(cur,'^');
    printlst(str);
  }
}

Measured memory_bytes: 0
import random

def name(x):
    if len(x) > 20:
        return name()
    if len(x) < 3:
        return name()
    if x.isupper() == True:
        return name()
    if x.isalpha() == False:
        return name()
    else:
        l = list(x)
        w = random.randint(0, len(x) - 3)
        y = l[w]
        z = l.index(y)
        print(y + l[z+1] + l[z+2])
        
S=input()
name(S)

Measured memory_bytes: 9564
h, w = gets.chomp.split(' ').map(&:to_i)
if h % 3 == 0 || w % 3 == 0
  puts 0
else
  candidate1 = [
    [w * (h / 3), w / 2 * (h - h / 3), (w - w / 2) * (h - h / 3)],
    [w * (h / 3 + 1), w / 2 * (h - h / 3 - 1), (w - w / 2) * (h - h / 3 - 1)],
    [w * (h / 3), (w / 2 + 1) * (h - h / 3), (w - w / 2 - 1) * (h - h / 3)],
    [w * (h / 3 + 1), (w / 2 + 1) * (h - h / 3 - 1), (w - w / 2 - 1) * (h - h / 3 - 1)],
    [h * (w / 3), h / 2 * (w - w / 3), (h - h / 2) * (w - w / 3)],
    [h * (w / 3 + 1), h / 2 * (w - w / 3 - 1), (h - h / 2) * (w - w / 3 - 1)],
    [h * (w / 3), (h / 2 + 1) * (w - w / 3), (h - h / 2 - 1) * (w - w / 3)],
    [h * (w / 3 + 1), (h / 2 + 1) * (w - w / 3 - 1), (h - h / 2 - 1) * (w - w / 3 - 1)],
  ].map { |c| c.max - c.min }.min
  candidate2 = [h, w].min
  puts [candidate1, candidate2].min
end


Measured memory_bytes: 1788
#include<cstdio>
#include<cstring>
int main()
{
	char c[1000000];
	scanf("%s",&c);
	int n=strlen(c);
	if (c[0]==c[n-1])
	if (n%2==0)
	printf("First");
	else
	printf("Second");
	else
	if (n%2!=0)
	printf("First");
	else
	printf("Second");
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    t.pop_back();
    if (s == t) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 3608
# AGC039A - Connection and Disconnection
from itertools import groupby


def main():
    S = input().rstrip()
    K = int(input())
    cnt = [len(tuple(s)) for _, s in groupby(S)]  # count of continuous characters
    if S[0] == S[-1] and K > 1:
        if len(cnt) == 1:  # one character
            ans = cnt[0] * K // 2
        else:  # first (= last) character in S + characters inside S
            ans = cnt[0] // 2 + cnt[-1] // 2 + (cnt[0] + cnt[-1]) // 2 * (K - 1)
            ans += sum(i // 2 for i in cnt[1:-1]) * K
    else:
        ans = sum(i // 2 for i in cnt) * K
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long int
vector<int> W(101),V(101);
int n,w;
vector<vector<int>> dp(101,vector<int>(100001,-1));

int go(int i,int v){
    if(v==0)
        return 0;
    if(i==n)
        return 1e18;
    if(dp[i][v]!=-1)
        return dp[i][v];
    int take=1e18;
    int dontTake=1e18;
    if(v>=V[i])
    take = W[i] + go(i+1,v-V[i]);
    dontTake = go(i+1,v);
    return dp[i][v]=min(dontTake,take);
}

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,m,i,j,sum=0;
    cin>>n>>w;
    int total = 0;
    for(i=0;i<n;i++){
        cin>>W[i]>>V[i];
        total += V[i];
    }
    int mmax = 0;
    for(i=total;i>0;i--){
        int x = go(0,i);
        if(x<=w)
            mmax = max(mmax , i);
    }
    cout<<mmax<<'\n';


    return 0;
}


Measured memory_bytes: 80256
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <cmath>
#include <climits>
#include <cstdint>
using namespace std;

inline namespace atcoder {
    template <typename T, size_t Depth>
    struct vector_helper { using type = vector<typename vector_helper<T, Depth - 1>::type>; };
    template <typename T>
    struct vector_helper<T, 0> { using type = T; };
    template <typename T, size_t Depth>
    using vector_t = typename vector_helper<T, Depth>::type;

    template <typename T> using vec = vector_t<T, 1>;
    template <typename T> using vvec = vector_t<T, 2>;
    template <typename T> using vvvec = vector_t<T, 3>;
}

int main() {
    int n, k; cin >> n >> k;
    int ans = INT_MAX;
    for (int i = 0; i < (1 << n); ++i) {
        int a = 1;
        for (int j = 0; j < n; ++j) {
            if (i & (1 << j)) {
                a *= 2;
            }
            else {
                a += k;
            }
        }
        ans = min(ans, a);
    }
    cout << ans << endl;
}



Measured memory_bytes: 3556