akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };


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



//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}

/*最小公倍数*/
template<typename T>
T lcm(T x, T y) {
	T tmp = gcd(x, y);
	return x * y / tmp;
}


int main() {

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


	string o, e;
	cin >> o >> e;
	string ans;
	for (int i = 0; i < min(o.size(),e.size()); i++)
	{
		ans.push_back(o[i]);
		ans.push_back(e[i]);

	}
	if (o.size() != e.size()) {
		ans.push_back(o.back());
	}


	cout << ans << endl;





	return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc128/tasks/abc128_d

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 50;
const int K_MAX = 100;
const int V_I_MAX = 1e7;
const int INF = 1e9;

int N, K;
int V[N_MAX];

int dpl[N_MAX + 1][N_MAX + 1];
int dpr[N_MAX + 1][N_MAX + 1];


void solve() {
  fill(dpl[0], dpl[N + 1], -INF);
  dpl[0][0] = 0;
  REP(i, N) {
    dpl[i + 1][0] = 0;
    FOR(j, 1, i + 1) {
      dpl[i + 1][j] = max(dpl[i][j], dpl[i][j - 1] + V[i]);
    }
  }
  // DUMP2D(dpl, N + 1, N + 1);
  fill(dpr[0], dpr[N + 1], -INF);
  dpr[0][0] = 0;
  REP(i, N) {
    dpr[i + 1][0] = 0;
    FOR(j, 1, i + 1) {
      dpr[i + 1][j] = max(dpr[i][j], dpr[i][j - 1] + V[N - 1 - i]);
    }
  }
  // DUMP2D(dpr, N + 1, N + 1);
  int ans = -INF;
  FOR(li, 0, N) FOR(ri, 0, N) {
    if (li + ri > N) continue;
    FOR(lj, 0, li)  FOR(rj, 0, ri) {
      if (li * 2 - lj + ri * 2 - rj > K) continue;
      ans = max(ans, dpl[li][lj] + dpr[ri][rj]);
    }
  }
  printf("%d\n", ans);
}

void input() {
  scanf("%d%d", &N, &K);
  REP(i, N) scanf("%d", V + i);
}

int main() {
  input();
  solve();
  return 0;
}


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

int main () {
  vector<int> line(3) ;
  for ( int i = 0 ; i < 3 ; i++ ){
    cin >> line.at(i) ;
  }
  
  sort ( line.begin() , line.end() ) ;
  
  if ( line.at(0) + line.at(1) == line.at(2) ) {
    cout << "Yes" << endl ;
  } else {
    cout << "No" << endl ;
  }
}

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

int main(){
    int N, M;
    ll K;
    cin >> N >> M >> K;
    vector<ll> A(N+1), B(M+1);
    for (int i = 1; i <= N; i++) cin >> A[i];
    for (int i = 1; i <= M; i++) cin >> B[i];
    vector<ll> asum(N+1, 0), bsum(M+1, 0);
    for (ll i = 1; i <= N; i++) asum[i] = asum[i-1]+A[i];
    for (ll i = 1; i <= M; i++) bsum[i] = bsum[i-1]+B[i];
    ll ans = 0;
    for (ll i = 0; i <= N; i++) {
        if (asum[i] > K) break;
        auto it = lower_bound(bsum.begin(), bsum.end(), K-asum[i]+1);
        ans = max(ans, i + distance(bsum.begin(), it)-1);
    }
    cout << ans << endl;
    
    return 0;
}

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


const int maxn=1e6+7;
vector<int>vec[maxn];

int s,t;

bool vis[maxn];

ll d[maxn];

struct cmp {
    bool operator ()(int a,int b) {
        return d[a]>d[b];
    }
};


void bfs(){
    memset(d,-1,sizeof(d));
    memset(vis,0,sizeof(vis));
    priority_queue<ll,vector<int>,cmp>q;
    q.push(s),d[s]=0;
    while(!q.empty()){
        int now=q.top();
        q.pop();
        if(vis[now]) continue;
        vis[now]=1;
        for(int x:vec[now]){
            if(!vis[x]) d[x]=d[now]+1,q.push(x);
        }
    }
    if(d[t]>=0) cout<<d[t]/3<<endl;
    else cout<<-1<<endl;
}

int main (){
    int n,m;scanf("%d %d",&n,&m);
    for(int i=0;i<m;i++){
        int x,y;scanf("%d %d",&x,&y);
        vec[x].push_back(y+n);
        vec[x+n].push_back(y+2*n);
        vec[x+2*n].push_back(y);
    }
    cin>>s>>t;
    bfs();
    return 0;
}


Measured memory_bytes: 41856
N = int(input())
P = [int(x) for x in input().split()]

a = [(i+1)*2* 10**4  for i in range(N)]
b= list(reversed(a))



for i in range(N):
    #P[i] =2* i
    p = P[i]-1
    a[p]+=i

print(" ".join(map(str,a)) )
print(" ".join(map(str,b)) )


def check():
    tmp =0
    for i in P:
        i-=1
        if not (tmp<a[i]+b[i]):
            raise
        tmp=a[i]+b[i]
    return True

#check()

Measured memory_bytes: 7284
s = str(input())
k = int(input())

List = []

for i in range(len(s)):
    for j in range(min(len(s)-i+1, k+1)):
        List.append(s[i:i+j])

set_List = set(List)
List = list(set_List)
List = sorted(List)
List.remove('')

ans = List[k-1]
print(ans)

Measured memory_bytes: 5044
N = int(input())
 
def base(x, n):
  ret = []
  while x != 0:
    ret.append( x % abs(n))
    if n < 0:
      x = - ( (-x)//n )
    else:
      x //= n
  return ret
 
if N == 0:
  print(0)
else:
  print("".join(map(str, reversed(base(N, -2)))))

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

int main(){
  int N; std::cin >> N;
  std::vector<int64_t> A(N);
  for(int i = 0; i < N; ++i) std::cin >> A[i];

  std::sort(A.rbegin(), A.rend());

  int64_t ans = 0;
  std::priority_queue<int64_t> pq;

  ans += A[0];
  pq.push(A[1]);

  for(int i = 2; i < N; ++i){
    if(pq.size() == 1){
      ans += pq.top();
      pq.push(A[i]);
      pq.push(A[i]);
    }else{
      ans += pq.top();
      pq.pop();
      pq.push(A[i]);
      pq.push(A[i]);
    }
  }
  

  std::cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 6832
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    string s;
    cin >> s;
    int n=s.size();
    vector<int> x(n);
    {
        int j=0;
        REP(i,n){
            x[j]++;
            if(s[i]==s[i+1])continue;
            j++;
        }
        x.resize(j);
    }
    {
        int j=0;
        for(int i=0;i<n;i++){
            if(s[i]=='R' && s[i+1]=='L'){
                printf("%d %d ",(int)ceil((double)x[j]/2)+x[j+1]/2,(int)ceil((double)x[j+1]/2)+x[j]/2);
                i++;j+=2;
            }
            else printf("0 ");
        }
    }
    return 0;
}

Measured memory_bytes: 3948
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	double a,b;
	cin>>a>>b;
	int aal,aar,bbl,bbr;
	for(aal=0;floor((double)aal*0.08)<a;aal++);
	for(aar=aal;floor((double)aar*0.08)==a;aar++);
	aar--;
	for(bbl=0;floor((double)bbl*0.1)<b;bbl++);
	for(bbr=bbl;floor((double)bbr*0.1)==b;bbr++);
	bbr--;
	if(bbl<=aal&&aal<=bbr||bbl<=aar&&aar<=bbr||aal<=bbl&&bbr<=aar||bbl<=aal&&aar<=bbr) cout<<max(aal,bbl)<<endl;
	else cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
AAA = [int(i) for i in input().split()]
cardlist = [0 for i in range(100010)]
for A in AAA:
    cardlist[A] += 1
for cardnumber, howmany in enumerate(cardlist):
    if howmany>=3:
        if howmany%2==0:
            cardlist[cardnumber]=2
        else:
            cardlist[cardnumber]=1

numof2 = sum([1 for i in cardlist if i==2])

if numof2%2==0:
    print(sum([1 for i in cardlist if i!=0]))
else:
    print(sum([1 for i in cardlist if i!=0])-1)


Measured memory_bytes: 14396
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n >> m;
  rep(i, n) a[i] = 2;
  rrep(i, n, n + m) a[i] = 1;
  rep(i, n + m) {
    rrep(j, i + 1, n + m) {
      if ((a[i] + a[j]) % 2 == 0) ans++;
    }
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll n;
    cin >> n;
    vector<multiset<ll>> vs(1 << n);
    for(int i = 0; i < (1 << n); ++i) {
        ll a;
        cin >> a;
        vs[i].insert(a);
    }
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < (1 << n); ++j) {
            if(!(j & (1 << i))) continue;
            multiset<ll>& _vs = vs[j ^ (1 << i)];
            for(auto it = _vs.begin(); it != _vs.end(); ++it) vs[j].insert(*it);
            while(vs[j].size() > 2) vs[j].erase(vs[j].begin());
        }
    }
    ll last_ans = 0;
    vll ans(1 << n);
    for(int i = 1; i < (1 << n); ++i) {
        ll ans = *vs[i].begin() + *vs[i].rbegin();
        chmax(ans, last_ans);
        cout << ans << endl;
        last_ans = ans;
    }
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

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

int main() {
  int n;
  cin >> n;
  vector<int> t(n), x(n), y(n);
  for (int i = 0; i < n; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }

  for (int i = 0; i < n; i++) {
    if (t[i] < x[i] + y[i]) {
      cout << "No" << endl;
      return 0;
    }
    if (t[i] % 2 == 0 && (x[i] + y[i]) % 2 == 0) {
    } else if (t[i] % 2 == 1 && (x[i] + y[i]) % 2 == 1) {
    } else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;

struct point{
    ll x, y;
};

/*FUNCs=================================================*/



/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int n, k, a, answer =0; cin >> n >> k;
    vi a_vec(n + 1, 0); 
    for(int i = 0; i < n; i++){
        cin >> a;
        a_vec[a]++;
    }
    sort(a_vec.begin(), a_vec.end());

    int p = a_vec.size() - k;
    for(int i = 0; i < p; i++) answer += a_vec[i];
    cout << (answer >= 0? answer : 0) <<'\n';
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

signed main() {
  int n = read();
  vi a;
  REP(i, n) { a.PB(read() - (i + 1)); }
  sort(ALL(a));
  int ans = 0;
  REP(i, n) { ans += abs(a[i] - a[i / 2]); }
  print(ans);
}


Measured memory_bytes: 2420
N = int(input())
a = list(map(int, input().split()))
for i in range(N):
  a[i] -= i + 1
a.sort()
center1 = a[N//2]
center2 = a[(N-1)//2]
ans1 = 0
ans2 = 0
for i in range(N):
  ans1 += abs(a[i] - center1)
  ans2 += abs(a[i] - center2)
print(min(ans1, ans2))
  

Measured memory_bytes: 26180
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define pb(v) push_back(v)
#define mp(x, y) make_pair(x, y)
#define fi first
#define se second
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using P = pair<int ,int>;
using Graph = vector<vector<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    int n; cin >> n;
    ll ans = 0;
    FOR(i, 1, n+1) {
        if ((i%3!=0) && (i%5!=0)) ans += i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
const int MAXN = 1e5+7;
pll aux[MAXN], sm[MAXN];
int main(){
    fastio;
    int n; ll k; cin>>n>>k;
    for(int i=0; i<n; i++){
        int ai,bi; cin>>ai>>bi;
        aux[i] = {ai, bi};
    }
    sort(aux, aux+n);
    ll cur = 0;
    for(int i=0; i<n; i++){
        cur += aux[i].second;
        sm[i] = {aux[i].first, cur};
    }
    int bl=0, br=n-1;
    while(bl != br){
        int bm = (bl+br)/2;
        if(sm[bm].second < k)bl = bm+1;
        else br = bm;
    }
    cout<<sm[bl].first<<endl;
}

Measured memory_bytes: 3328
class Node:
    def __init__(self, id):
        self.id = id
        self.link = []

def bfs(node, check, ban_a, ban_b):
    check[node.id] = True
    ret = 1
    ban = -1
    if node.id == ban_a:
        ban = ban_b
    elif node.id == ban_b:
        ban = ban_a
    for next in node.link:
        if not check[next.id] and next.id != ban:
            ret += bfs(next, check, ban_a, ban_b)
    return ret





N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(M)]

nodes = [Node(i) for i in range(N)]

for i in range(M):
    a, b = ab[i]
    a -= 1; b -= 1;
    nodes[a].link.append(nodes[b])
    nodes[b].link.append(nodes[a])

ans = 0
root = nodes[0]
for i in range(M):
    a, b = ab[i]
    a -= 1; b -= 1;
    check = [False] * N
    if N != bfs(root, check, a, b):
        ans += 1
print(ans)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String args[]){
		Scanner cin = new Scanner(System.in);

		int x = cin.nextInt();
		int y = cin.nextInt();

		cin.close();

		String groupx;
		String groupy;

		if(x==2){
			groupx = "3";
		}else if((x<7&&x%2==0)||x>8&&x%2==1){
			groupx = "2";
		}else{
			groupx = "1";
		}
		if(y==2){
			groupy = "3";
		}else if((y<7&&y%2==0)||y>8&&y%2==1){
			groupy = "2";
		}else{
			groupy = "1";
		}

		if(groupx.equals(groupy)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

	}
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

typedef bitset<10001> bit;
int n;
char s[12525][25];
char t[25];

int check(char s[25], char t[25]){
  int n = strlen(s);
  int ret = 0;  // 1 : le, 2 : ge
  char x[25];
  x[n] = '\0';
  // minimize
  REP(i,n)x[i] = s[i]=='?' ? 'a' : s[i];
  if(strcmp(x,t)<=0)ret |= 1;
  // maximize
  REP(i,n)x[i] = s[i]=='?' ? 'z' : s[i];
  if(strcmp(x,t)>=0)ret |= 2;
  return ret;
}

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%s",s[i]);
  scanf("%s",t);
  bit ans;
  ans.set(0);
  REP(i,n){
    int o = check(s[i], t);
    bit nxt;
    if(o & 1)nxt |= ans<<1;
    if(o & 2)nxt |= ans;
    ans = nxt;
  }
  vi v;
  REP(i,n+1)if(ans[i])v.push_back(i+1);
  REP(i,v.size()){
    printf("%d%c",v[i],i==v.size()-1?'\n':' ');
  }
  return 0;
}


Measured memory_bytes: 512
def solve():
    from collections import deque
    from copy import deepcopy
    W, H = map(int, input().split())
    a = [[0]*(W+2)] + [list(map(int, ("0 "+input()+" 0").split())) for _ in [0]*H] + [[0]*(W+2)]
    result = 0

    visited = deepcopy(a)
    dq = deque([(0, 0)])
    append, popleft = dq.append, dq.popleft

    while dq:
        x, y = popleft()
        neighbour = [(-1, 0), (1, 0)] + ([(-1, -1), (0, -1), (-1, 1), (0, 1)] if y%2 == 0 else [(0, -1), (1, -1), (0, 1), (1, 1)])
        for dx, dy in neighbour:
            nx, ny = dx+x, dy+y
            if 0 <= nx < W+2 and 0 <= ny < H+2:
                result += a[ny][nx]

        for dx, dy in neighbour:
            nx, ny = x+dx, y+dy
            if 0 <= nx < W+2 and 0 <= ny < H+2 and visited[ny][nx] == 0:
                visited[ny][nx] = 1
                append((nx, ny))

    print(result)


if __name__ == "__main__":
    solve()

Measured memory_bytes: 8452
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
typedef long double lb;
// typedef vector<int,vector<int>> vvec;
typedef long double ld;
typedef pair<int,int> P;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
// inline ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
// inline ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }

//----***定数***----
const int MOD=1e9+7;
#define INF 1e9;
#define EPS 1e-9;

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
#define here  cout<<"Here"<<endl;


//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}initial_;


ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}

signed main(){
  int N,M,a;cin>>N>>M;
  vector<int> v(N);
  int two_m=0;
  set<int> st;
  REP(i,0,N){
    cin>>a;
    int tmp=a,tmp2=0;
    while(tmp%2==0){
      tmp2++;
      tmp/=2;
    }
    // debug(i);
    // print((a%512==0));
    // debug(tmp2);
    st.insert(tmp2);
    v[i]=a/2;
  }
  if(st.size()!=1){
    print(0)
    return 0;
  }
  int lcm_=v[0];
  REP(i,1,N){
    lcm_=lcm(lcm_,v[i]);
    if(lcm_>M){
      print(0);
      return 0;
    }
  }
  
  // while(cm%2==0){
  //   two_m++;
  //   cm/=2;
  // }
  //two_m=powl(2,two_m);
  //debug(lcm_);
  int ans=0;//(lcm_%2==0?1:0);
  int cm=lcm_;

  while(cm<=M){
    ans++;
    cm+=2*lcm_;
  }
  print(ans)

}


Measured memory_bytes: 1024
s = list(input())
l = ["A", "C", "G", "T"]
l2 = []
cnt = 0
for i in range(len(s)):
    if s[i] in l:
        cnt += 1
    else:
        l2.append(cnt)
        cnt = 0
l2.append(cnt)
print(max(l2))

Measured memory_bytes: 3060
r, c = map(int, input().split())
tbl = [[] for _ in range(r)]
cSum = [0 for _ in range(c+1)]

for i in range(r):
  tblS = input()
  tbl[i] = list(map(int, tblS.split()))
  print(tblS, end = '')
  print(' ', sum(tbl[i]), sep = '')

  for j in range(c):
    cSum[j] += tbl[i][j]
  cSum[c] += sum(tbl[i])

print(' '.join(map(str, cSum)))



Measured memory_bytes: 5676
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<int> vec;

void solve() {
	int n; cin >> n;
	string s; cin >> s;
	int ans = 0;
	rep(i, 1000) {
		string t = to_string(i);
		while (t.size() < 3) {
			t = "0" + t;
		}
		int cur = 0;
		rep(j, n) {
			if (t[cur] == s[j]) {
				cur++; if (cur == 3)break;
			}
		}
		if (cur == 3)ans++;
	}
	cout << ans << endl;
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init();
	solve();
	//stop
	return 0;
}

Measured memory_bytes: 384
using System;
using System.Linq;

namespace ABC127_D
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var num = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse).OrderBy(x=>x).ToArray();
            var hoge = Enumerable.Repeat(0, nm[1]).Select(x => Console.ReadLine().Split(' ').Select(long.Parse).ToList()).OrderByDescending(x => x[1]).ToArray();
            var aptr = 0;
            foreach(var qu in hoge)
            {
                var count = qu[0];
                var nu = qu[1];
                for (var i = 0; i < count && aptr < num.Length && num[aptr] < nu; i++, aptr++)
                    num[aptr] = nu;
            }
            Console.WriteLine(num.Sum());
        }
    }
}


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

using ll = long long;
static const int MAX = 1e5;
static const int INF = 1e9;

// 隣接リストを用いた幅優先探索 O(|V|+|E|)
int n;
vector<pair<ll, ll>> G[MAX]; // 頂点数がnのグラフを表す隣接リスト
vector<ll> d(MAX, INF); // 始点sから頂点iまでの最短距離をd[i]に記録
// main関数からこれらを削除すること

void bfs(int s) {
  queue<int> q;
  q.push(s);
  d[s] = 0;
  while(!q.empty()){
    int u = q.front();
    q.pop();
    for(int v = 0; v < G[u].size(); v++){
      if(d[G[u][v].first] == INF){
        d[G[u][v].first] = d[u] + G[u][v].second;
        q.push(G[u][v].first);
      }
    }
  }
}

int main() {
  // 重み付き無向(有向)グラフの隣接リスト
  ll u, v, w;
  cin >> n;
  
  for(int i = 0; i < n - 1; i++){
    cin >> u >> v >> w;
    u--;
    v--;
    G[u].push_back(make_pair(v, w));
    G[v].push_back(make_pair(u, w)); // 有向グラフではこの行をコメントアウト
  }
  
  int q, k;
  cin >> q >> k;
  
  bfs(k - 1);
  
  int x, y;
  for(int i = 0; i < q; i++){
    cin >> x >> y;
    cout << d[x - 1] + d[y - 1] << endl;
  }
}

Measured memory_bytes: 9984
s=input()
x=int(s[:2])
y=int(s[2:])
if 1<=x<=12:
  if 1<=y<=12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 1<=y<=12:
    print("YYMM")
  else:
    print("NA")

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

int ans = 0 ;
char mass[3] = {0} ;

int main()
{
  cin >> mass ;
  for ( int i = 0 ; i < 3 ; i++ )
  {
    if ( mass[i] == '1' ) ans++ ;
  }
  printf("%d\n", ans) ;
  return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
struct PLANT{
	double income_raito;
	int sum_bene;
	int sum_time;
	string L;
	int P, A, B, C, D, E, F, S, M;

	bool operator<( const PLANT & right ) const {
		return (income_raito != right.income_raito ? income_raito > right.income_raito : L < right.L );
	}
};

int main()
{
	ios_base::sync_with_stdio(0);
	int N;
	while (cin >> N, N ){
		PLANT p[N];
		rep (i, N ) p[i].income_raito = 0., p[i].sum_bene = 0, p[i].sum_time = 0;
		rep (i, N ){
			cin >> p[i].L >> p[i].P >> p[i].A >> p[i].B >> p[i].C >> p[i].D >> p[i].E >> p[i].F >> p[i].S >> p[i].M;
			p[i].sum_time = p[i].A + p[i].B + p[i].C + p[i].M*(p[i].D + p[i].E);
			p[i].sum_bene = p[i].M*p[i].F*p[i].S - p[i].P;
			p[i].income_raito = (double)p[i].sum_bene/(double)p[i].sum_time;
		} // end rep
		sort (p, p+N );
		rep (i, N ){
			cout << p[i].L << endl;
		} // end rep
		cout << '#' << endl;
	} // end while
		
	return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e18
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;
  if(x-r>=0&&x<=W-r&&y-r>=0&&y<=H-r){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}



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

int main() {
	int N, ans = 0;
	map<int, int> A;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		A[a]++;
	}
	for (auto it = A.begin(); it != A.end(); it++) {
		ans += (*it).second % 2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n) - 1; i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

template<typename T>
inline void setmax(T& a, T b) {
    if (a < b) a = b;
}

template<typename T>
inline void setmin(T& a, T b) {
    if (a > b) a = b;
}

template<typename T, typename S>
istream& operator>> (istream& in, pair<S, T>& p) {
    in >> p.fs >> p.sn;
    return in;
}
template<typename T, typename S>
ostream& operator<< (ostream& out, pair<S, T>& p) {
    out << p.fs << ' ' << p.sn << ' ';
    return out;
}

template<typename T>
istream& operator>> (istream& in, vector<T>& v) {
    for (T& x : v) in >> x;
    return in;
}
template<typename T>
ostream& operator<< (ostream& out, vector<T>& v) {
    for (T& x : v) out << x << ' ';
    return out;
}

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); 
    srand((unsigned)chrono::high_resolution_clock::now().time_since_epoch().count());
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    map<ll, int> cnt;
    ll sum = 0;
    ++cnt[sum];
    for (int x : a) {
        sum += x;
        ++cnt[sum];
    }
    ll ans = 0;
    for (auto p : cnt)
        ans += 1ll * p.sn * (p.sn - 1) / 2;
    cout << ans << '\n';

}


Measured memory_bytes: 13568
N = int(input())
nowT = 0
nowX = 0
nowY  = 0
for _ in range(N):
  nextT, nextX, nextY = map(int, input().split())
  d = abs(nowX - nextX) + abs(nowY - nextY)
  if d > (nextT - nowT) or (nextT - nowT) % 2 != d % 2:
    print('No')
    exit()
  nowT = nextT
  nowX = nextX
  nowY = nextY
print('Yes')

Measured memory_bytes: 3064
#include <stdio.h>
int main (){
int k=0,o=0,a[8]={0},yo=0,max=0,min=0,l,i;
  scanf ("%d",&k);
  for (i=0;i<k;i++){scanf ("%d",&o);
if (0<o && o<400){a[0]=1;}
else if (399<o && o<800){a[1]=1;}
else if (799<o && o<1200){a[2]=1;}
else if (1199<o && o<1600){a[3]=1;}
else if (1599<o && o<2000){a[4]=1;}
else if (1999<o && o<2400){a[5]=1;}
else if (2399<o && o<2800){a[6]=1;}
else if (2799<o && o<3200){a[7]=1;}
else if (3199<o){yo=yo+1;}}
 for (l=0;l<8;l++){
 min=min+a[l];
 }
   max=min+yo;
  if (min==0){
    min=1;
  max=yo;
  }
  printf ("%d %d",min,max);
return 0;
}


Measured memory_bytes: 128
N = gets.to_i
M = 1000000007

zeros = 0
counts = Hash.new(0)
N.times do 
    a,b = gets.split.map &:to_i
    if a==0 && b==0 then
        zeros += 1
    else
        gcd = a.gcd b
        a /= gcd
        b /= gcd
        if a<0 then
            a=-a
            b=-b 
        end
        b = -1 if a==0
        a = 1 if b==0
        counts[[a,b]] += 1
    end
end

ans = 1
counts.each do |(a,b),c|
    comb = ((2**c-1) + 1) % M

    if b<0 then
        a=-a
        b=-b 
    end
    if c = counts.delete([b,-a]) then
        comb += (2**c-1) % M
    end

    ans = (ans * comb) % M
end

p (ans + zeros - 1) % M

Measured memory_bytes: 34348
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
  
using namespace std;

#define pi 3.141592653589793

int main()
{
	int cnt;
	cin >> cnt;
	int ginko[20000][2];
	// ginko[i * i + j * j] = ginko[i * i + j * j][0]^2 + ginko[i * i + j + j][1]^2
	// つまりginko[i * i + j + j][0]にはiが、[1]にはjが入っている
	for(int i = 0; i < 20000; i++){
		ginko[i][0] = -1;
		ginko[i][1] = -1;
	}
	for(int i = 0; i * i < 20000; i++){
		for(int j = i; i * i + j * j < 20000; j++){
			ginko[i * i + j * j][0] = i;
			ginko[i * i + j * j][1] = j;
		}
	}
	int mi, ni;
	for(int j = 0; j < cnt; j++){
		int ans = 0;
		cin >> mi >> ni;
		int mn = mi * mi + ni * ni;
		for(int i = 1; i <= mn; i++){
			if(ginko[i][0] == -1 || mn % i != 0 || ginko[mn/ i][0] == -1) continue;
			// cout << ginko[i][0] << " " << ginko[i][1] << endl;
			// int m = ginko[i][0];
			// int n = ginko[i][1];
			// int p = ginko[mn][0];
			// int q = ginko[mn][1];
			// if((m * p + n * q) % mn == 0 && (m * q - n * p) % mn == 0) ans += 2;
			ans += 4;
			if(ans > 8){
				cout << "C" << endl;
				break;
			}
			// cout << ans << endl;
			if(i == mn) cout << "P" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1308
#include <bits/stdc++.h>
#define maxn 100086

using namespace std;

typedef long long ll;

int n;
int x, y;
ll a = 1, b = 1;

int main(){
	scanf("%d", &n);
	while(n--){
		scanf("%d%d", &x, &y);
		ll i = max((a + x - 1) / x, (b + y - 1) / y);
		a = i * x, b = i * y;
	}
	printf("%lld\n", a + b);
}

Measured memory_bytes: 3816
J=list(input())
n=len(J)

def dfs(i,f,sum_num):
    if i==n-1:
        if sum_num==7:
            print(f+"=7")
            exit()
    else:
        dfs(i+1,f+"+"+J[i+1],sum_num+int(J[i+1]))
        dfs(i+1,f+"-"+J[i+1],sum_num-int(J[i+1]))
dfs(0,J[0],int(J[0]))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define rep(i, l, r) for(int i = (l); i <= (r); i++)
#define per(i, r, l) for(int i = (r); i >= (l); i--)
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> os;

int B, A, C;
int main(){
  cin >> A >> B >> C;
  cout << C - min(A - B, C);
	return 0;
}


Measured memory_bytes: 256
s = int(input())

def cou(a):
    if a % 2 == 0:
        a //= 2
    else:
        a = 3*a +1
    return a

a = cou(s)
a_list = [s]
while True:
    if a in a_list:
        print(len(a_list)+1)
        break
    a_list.append(a)
    a = cou(a)


Measured memory_bytes: 2940
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int r, d, x;
  readf("%s %s %s\n", &r, &d, &x);
  foreach (i; 0..10) {
    x = r * x - d;
    x.writeln;
  }
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
	int n;
	std::cin >> n;
	int num_minus = 0;
	std::vector<ll> v(n);
	for (size_t i = 0; i < v.size(); i++) {
		std::cin >> v[i];
		if (v[i] < 0) {
			num_minus++;
		}
	}

	ll vmin = abs(v[0]);
	ll ans = 0;
	for (size_t i = 0; i < v.size(); i++) {
		ans += abs(v[i]);
		vmin = min(vmin, abs(v[i]));
	}

	if (num_minus % 2 == 0) {
		std::cout << ans << '\n';
	}
	else {
		std::cout << ans - 2 * vmin << '\n';
	}


	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef pair<ll,P> PP;
ll dp[100001][4];
int main() {
	string s; cin >> s; int n = s.length();
	dp[n][3] = 1; dp[n][2]=dp[n][1] = dp[n][0] = 0;
	per(i, n) {
		if (s[i] == '?') {
			dp[i][3] = (ll)3 * dp[i + 1][3] % MOD;
			rep(j, 3) {
				dp[i][j] = ((ll)3 * dp[i + 1][j] + dp[i + 1][j + 1]) % MOD;
			}
		}
		else {
			dp[i][3] = dp[i + 1][3];
			rep(j, 3) {
				if (s[i] == char('A' + j)) {
					dp[i][j] = (dp[i + 1][j] + dp[i + 1][j + 1]) % MOD;
				}
				else {
					dp[i][j] = dp[i + 1][j];
				}
			}
		}
	}
	cout << dp[0][0] << endl;
	return 0;
}

Measured memory_bytes: 3584
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import comb

# 再帰がやばいとき
# import sys
# sys.setrecursionlimit(10**9)

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

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e50)
MOD = int(1e9)+7 # 10^9 + 7

# field[H][W]
def create_grid(H, W, value = 0):
    return [[ value for _ in range(W)] for _ in range(H)]

########

def main():
    H, W = l_inpl()
    N = i_inpl()
    a = l_inpl()

    t = [ [i+1]*ai for i, ai in enumerate(a)]
    from itertools import chain
    t = list(chain.from_iterable(t))

    field = create_grid(H, W)
    for i in range(H):
        for j in range(W):
            ind = W*i+j
            if i % 2 == 0:
                field[i][j] = str(t[ind])
            else:
                field[i][W-j-1] = str(t[ind])

    ans = ""
    for fi in field:
        ans += " ".join(fi) + "\n"
    print(ans[:-1])

if __name__ == "__main__":
    main()


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

int main() {
    int n; cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    set<int> st;
    int ans = 1;
    st.insert(p[0]);
    for(int i = 1;i < n;i++){
        if(*st.begin() >= p[i]) ans++; 
        st.insert(p[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 13528
#include<iostream>
#include<vector>
#include<string>
#include<cstdlib>
#include<sstream>
#include<queue>
#include<deque>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#define INF 2147483647
#define lli long long int
#define MOD 1000000007
#define pb push_back

using namespace std;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
int main() {
	int n,m,t; cin >> n >> m >> t;
	vi a(n+2);
	a[0] = 0;
	a[n+1] = t;
	int ans = 0;
	for (int i = 1 ; i <= n; i++){
		cin >> a[i];
	}
	if (a[1] - a[0] >= m){
		ans += m;
	}
	for (int i = 1; i < n; i++){
		if (a[i+1] - a[i] > 2*m){
			ans += 2*m;
		}else{
			ans += a[i+1] - a[i];
		}
	}
	if (a[n+1] - a[n] >= m){
		ans += m;
	}else{
		ans += a[n+1] - a[n];
	}
	cout << t - ans << endl;
	

	return 0;
}

Measured memory_bytes: 3104
for$i(@N=1..<>){${-$_}+=grep$i%$'**$_<1,//..6for grep{(1x$_)!~/^(11+)\1+$/}2..@N}for$a(@@=-@N..0){$z+=$a-$_&&($$a>3&&$$_>13)+($$a>1&&$$_>23)+($$a>1&&$$_>3&&grep$a-$_&&$$_>3,$_+1..0)for@@}print$z+(@N>77)

Measured memory_bytes: 512
//  Copyright © 2020 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 200005
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
using namespace std;
typedef long long i64;

int main()
{
    optimiza_io
    string s;
    cin >> s;
    sort( s.begin() , s.end() );
    if( s[0] != s[3] && s[1] == s[0] && s[2] == s[3] )
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

// CHECAR LIMITES 

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

int main() {
	string s;
	cin>>s;
	int n=s.size();
	int i2;
	bool ss=true;
	char x[n];
	for(int i=0;i<n;i++){
	    x[i]=s[i];
	}
	for(int i=n-1;i<=0,i--;){
	    if(i%2==1){
	        i2=(i+1)/2;
	        ss=true;
	        for(int j=0;j<i2;j++){
	            if(x[j]!=x[j+i2]){
	                ss=false;
	            }
	        }
	        if(ss){
	            cout<<i+1<<endl;
	            break;
	        }
	    }
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
ll Nagaemon1;
void swap(ll i,ll j){
  Nagaemon1=i;
  i=j;
  j=Nagaemon1;
}
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b&&b==c)cout << 1 << endl;
  else if(a!=b&&b!=c&&a!=c)cout << 3 << endl;
  else cout << 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

#define p(a, b) make_pair(a, b)
typedef pair<ll, int> pli;

ll P[100001];
ll L[2][100002];
ll R[2][100002];


int main()
{
	int N;
	ll ans = 0;
	priority_queue<pli, vector<pli>, greater<pli> > pq;
	queue<pli> q;

	cin >> N;
	repc(i, 1, N) cin >> P[i];

	rep(i, 2) repc(j, 1, N) {
		L[i][j] = -1;
		R[i][j] = -1;
	}

	rep(i, 2) {
		L[i][0] = 0;
		R[i][N + 1] = (ll)N + 1;
	}

	repc(i, 1, N) {
		while (!pq.empty()) {
			pli item = pq.top();
			ll v = item.first;
			int id = item.second;

			if (v >= P[i]) break;
			pq.pop();

			if (R[0][id] == -1) {
				R[0][id] = i;
				q.push(item);
			}
			else R[1][id] = i;
		}
		pq.push(p(P[i], i));
		while (!q.empty()) {
			pq.push(q.front());
			q.pop();
		}
	}

	while (!pq.empty()) {
		int id = pq.top().second; pq.pop();
		rep(i, 2) if (R[i][id] == -1) R[i][id] = (ll)N + 1;
	}

	rrepc(i, N, 1) {
		while (!pq.empty()) {
			pli item = pq.top();
			ll v = item.first;
			int id = item.second;

			if (v >= P[i]) break;
			pq.pop();

			if (L[0][id] == -1) {
				L[0][id] = i;
				q.push(item);
			}
			else L[1][id] = i;
		}
		pq.push(p(P[i], i));
		while (!q.empty()) {
			pq.push(q.front());
			q.pop();
		}
	}

	while (!pq.empty()) {
		int id = pq.top().second; pq.pop();
		rep(i, 2) if (L[i][id] == -1) L[i][id] = 0;
	}

	repc(i, 1, N) {
		ll Lnum = (L[0][i] - L[1][i]) * (R[0][i] - i);
		ll Rnum = (i - L[0][i]) * (R[1][i] - R[0][i]);
		ans += P[i] * (Lnum + Rnum);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 7156
#include <iostream>
#include <algorithm>
#include <set>

using namespace std;

int main() {
    int n;
    cin >> n;
    set<int> s;
    for (int i=0; i<n; i++) {
        int a; cin >> a;
        s.insert(a);
    }
    cout << max(1, (int)(s.size()+1)/2*2-1) << '\n';
    return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

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

    vector<vector<ll>> dp(11, vector<ll>(11));
    repf(i,1,n+1) {
        int a = i%10;
        int b = i;
        while (b >= 10) {
            b /= 10;
        }
        dp[a][b]++;
    }

    ll ans = 0;
    repf(i,1,11) repf(j,1,11) {
        ans += dp[i][j]*dp[j][i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256