akhauriyash/Code-Regression huggingface dataset:
import itertools
n, m, q = map(int, input().split())
queries = []
for i in range(q):
    a, b, c, d = map(int, input().split())
    queries.append((a, b, c, d))

max_score = 0

p = [1] * n
cur = n-1
while cur >= 0:
    score = 0
    for a, b, c, d in queries:
        if p[b - 1] - p[a - 1] == c:
            score += d
    max_score = max(score, max_score)
    updated = False
    for i in range(n - 1, -1, -1):
        if p[i] != m:
            p[i] += 1
            for j in range(i + 1, n):
                p[j] = p[i]
            updated = True
            break
    if not updated:
        break

print(max_score)


Measured memory_bytes: 68508
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> vec;
int dp[100007];
int solve(int index){

    if(index==n-1){
        return 0;
    }
    if(dp[index]!=-1){
        return dp[index];
    }
    
    int ret1 = INT_MAX;
    int ret2 = INT_MAX;
    if(index+1<n){
         ret1 = abs (vec[index]- vec[index+1]) + solve(index+1); 
    }
    if(index+2<n){
         ret2 = abs (vec[index]- vec[index+2]) + solve(index+2); 
    }


    return dp[index] = min(ret1,ret2);
}

int main(){
    cin>>n;
    memset(dp,-1,sizeof(dp));
    int num;
    for(int i = 0 ; i<n ; i++){
        cin>>num;
        vec.push_back(num);
    }
    cout<<solve(0)<<endl;
    return 0;
}


Measured memory_bytes: 8908
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int f(int a[],int b[],int c[],int p){
  int i;
  int m=0,n=0,s=0;
  if(p==9){
    for(i=0;i<9;i++){
      if(a[i]<b[c[i]])
	n+=a[i]+b[c[i]];
      else
	m+=a[i]+b[c[i]];
    }
    return m>n;
  }
  for(i=0;i<9;i++){
    if(c[i]==-1){
      c[i]=p;
      s+=f(a,b,c,p+1);
      c[i]=-1;
    }
  }
  return s;
}
int main(){
  int i,j;
  int a[9],b[9],c[9],n,s;
  cin>>n;
  for(i=0;i<n;i++){
    for(j=0;j<9;j++)
      cin>>a[j];
    for(j=0;j<9;j++)
      cin>>b[j];
    memset(c,-1,sizeof(c));
    s=f(a,b,c,0);
    printf("%.5lf %.5lf\n",(double)s/(9*8*7*6*5*4*3*2),(double)(9*8*7*6*5*4*3*2-s)/(9*8*7*6*5*4*3*2));
  }
  return 0;
}

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

int H,W;
char a[107][107];

int sx,sy;

void remove_x(int num){
//    cout << "横列消去: " << num << endl;
    for(int y = num;y < sy;y++){
        
        for(int x = 1;x < sx+1;x++){
            a[x][y] = a[x][y+1];
        }

    }

    for(int x = 1;x < sx+1;x++){
        a[x][sy] = '!';
    }

    sy--;
}

void remove_y(int num){
//    cout << "縦列消去: " << num << endl;

    for(int x = num;x < sx;x++){
        
        for(int y = 1;y < sy+1;y++){
            a[x][y] = a[x+1][y];
        }

    }

    for(int y = 1;y < sy+1;y++){
        a[sx][y] = '!';
    }

    sx--;
}

bool solve(){
    int p = 0;

    // 縦のラインをチェック
    for(int x = 1;x < sx+1;x++){
        p = 0;
        for(int y = 1;y < sy + 1;y++){
            if(a[x][y] == '.'){
                p++;
            }
            if(p == sy){
                remove_y(x);
                return false;
            }
        }
    }

//    cout << "横チェック" << endl;

    // 横のラインをチェック
    for(int y = 1;y < sy+1;y++){
        p = 0;
        for(int x = 1;x < sx + 1;x++){
            if(a[x][y] == '.'){
                p++;
            }
            if(p == sx){
                remove_x(y);
                return false;
            }
        }
    }

    return true;
}

int main(){
    cin >> H >> W;
    for(int y = 1;y < H+1;y++){
        for(int x = 1;x < W+1;x++){
            cin >> a[x][y];
        }
    }

    sx = W;
    sy = H;

    while(1){
        if(solve()){
            break;
        }
    }

    for(int y = 1;y < sy+1;y++){
        for(int x = 1;x < sx+1;x++){
                cout << a[x][y];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<int, ll> pli;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
// const ll MAXN = 

int n;
vector<ll> b;
/********** Good Luck :) **********/
int main () {
    TIME(main);
    IOS();

    cin >> n;
    b.eb(iNF);
    REP (i, n-1) {
        int d;
        cin >> d;
        b.eb(d);
    }
    b.eb(iNF);

    ll ans = 0;
    REP (i, n)
        ans += min(b[i], b[i+1]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 100000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;

LL a[N];
LL inv[N];
LL fac[N];
map<LL,int> bucket;
void init() {
    fac[0]=1;
    fac[1]=1;
    inv[0]=1;
    inv[1]=1;
    for(LL i=2; i<N; i++) {
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=(MOD-MOD/i)*inv[MOD%i]%MOD;
    }
    for(int i=1; i<N; i++)
        inv[i]=inv[i]*inv[i-1]%MOD;
}
LL C(LL n, LL m) {
    if(m>n)
        return 0;
    return ((fac[n]*inv[m]%MOD)*inv[n-m])%MOD;
}
int main() {
    init();
    LL n;
    scanf("%lld",&n);
    LL pos=0;
    for(int i=1;i<=n+1;i++){
        scanf("%lld",&a[i]);
        if(!bucket[a[i]])
            bucket[a[i]]=i;
        else
            pos=i;
    }
    for(int i=0;i<=n;i++){
        LL res=0;
        res=(res+C(n+1,i+1))%MOD;
        res=(res-C(n-pos+bucket[a[pos]],i))%MOD;
        while(res<0)
            res+=MOD;
        printf("%lld\n",res);
    }

    return 0;
}


Measured memory_bytes: 9856
k = int(input())
a,b = map(int,input().split())
ls = list()
for i in range(1,b+1):
  if a <= i*k and i*k <= b:
    ls.append(1)
  else:
    ls.append(0)

print('OK' if sum(ls) > 0 else 'NG')

Measured memory_bytes: 9128
#include <bits/stdc++.h>
#include <numeric>
#define ll long long
#define int long long

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define pb emplace_back
#define mp make_pair



using namespace std;

const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

typedef pair<ll, ll> P;

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

ll R, C, N, M, K, Q;

vector<ll> v[300000];
vector<ll> res(300000,0);

void dfs(ll node, ll p = 0){
    PRINT(node)
    PRINT(res[node])
    irep(itr,v[node]){
        if(*itr == p) continue;
        res[*itr] += res[node];
        dfs(*itr, node);
    }
    return;
}

signed main() {
    //cout << fixed << setprecision(10);
    cin >> N >> Q;

    rep(i, N-1){
        ll from,to; cin >> from >> to;
        from --;
        to --;
        v[from].pb(to);
        v[to].pb(from);
    } 
    rep(i,Q){
        ll node, val; cin >> node >> val;
        res[--node] += val;
    }

    dfs(0);

    rep(i, N){
        cout << res[i] << endl;
    }

    //cout << max << endl;
}


Measured memory_bytes: 27392
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

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);
    }
}
#pragma endregion

int main()
{
    int n;
    cin >> n;
    cout << n << ":";
    // -1 if prime
    // largest prime divisor if composite
    int rn = sqrt(n) + 1;
    vint p(rn, 0);
    rep(i, rn)
    {
        if (i < 2)
            continue;
        if (p[i])
            continue;
        p[i] = i;
        for (ll j = (ll)i * i; j < rn; j += i)
        {
            p[j] = i;
        }
        while (n % i == 0)
        {
            n /= i;
            cout << " " << i;
        }
    }
    if (n != 1)
        cout << " " << n;
    cout << endl;

    return 0;
}


Measured memory_bytes: 3236
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YY cout << "Yes" << endl;
#define NN cout << "No" << endl;
#define ve vector
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
// *max_element(all(d))
class UnionFind{
  private:
    vector<int>par;
  public:
    UnionFind(int n):par(n,-1){}
    int root(int x){
      if(par[x] < 0)return x;
      return par[x] = root(par[x]);
    }
    bool unite(int x,int y){
      x = root(x); y = root(y);
      if (x == y) return false;
      if (par[x] > par[y]) swap(x, y);
      par[x] += par[y];
      par[y] = x;
      return true;
    }
    bool same(int x,int y){
      return root(x) == root(y);
    }
    int size(int x) {
      return -par[root(x)];
    }
};
int solve(){
  ll a,b;
  cin >> a >> b;
  if(a <= 0 && 0 <= b)cout << "Zero" << endl;
  else if(0 < a)cout << "Positive" << endl;
  else{
    b = min(b,(ll)0);
    ll cnt = b - abs(a) + 1;
    if(cnt % 2)cout << "Negative" << endl;
    else cout << "Positive" << endl;
  }
  return 0; 
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

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

int main(void){
  int n,k; cin >> n >> k;
  double p[n];
  rep(i,n) cin >> p[i];
  double s[n],r[n];
  rep(i,n){
    s[i] = (p[i]+1)/2;
    if(i == 0) r[i] = s[i];
    else r[i] = r[i-1] + s[i];
  }
  double ans = r[k-1];
  for(int i = k; i < n; i++){
    ans = max(ans,r[i] - r[i-k]);
  }
  printf("%f",ans);
  return 0;
}


Measured memory_bytes: 4992
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import defaultdict
from bisect import bisect_left

n, k = li()
a = list(li())

a = a + a

# ジャンプ先
jump = defaultdict(lambda: -1)
buf = defaultdict(lambda: -1)
for i, ai in enumerate(a):
    if buf[ai] != -1:
        jump[buf[ai]] = i - buf[ai]

    buf[ai] = i

# 周期を求める
checkpoint = [0]
cur = 0

while cur == 0 or cur % n > 0:
    cur += jump[cur % n]
    cur += 1
    checkpoint.append(cur)

cycle = cur // n
mod = k % cycle

# あまり処理
if mod == 0:
    print()

else:
    last_idx = n * mod

    # シミュレーション
    start_idx = checkpoint[bisect_left(checkpoint, last_idx) - 1]
    s = []

    idx = start_idx
    while idx < last_idx:
        if idx + jump[idx % n] < last_idx:
            idx += jump[idx % n] + 1
        else:
            s.append(a[idx % n])
            idx += 1

    print(*s)


Measured memory_bytes: 121416
#include "bits/stdc++.h"
 
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<VVLL> VVVLL;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_LARGE = 1000000100;
 
 
//debug func
template<typename T>
void vecprint(vector<T> v) {
    for(auto x : v) {
        cerr << x << " ";
    }
    cerr << endl;
}
 
template<typename T>
void vecvecprint(vector<vector<T>> v) {
    for(auto x :v) {
        REP(i, x.size()-1) {
            cerr << x[i] << " ";
        }
        cerr << x[x.size()-1] <<endl;
    }
}
 
template<typename T>
void pqprint(priority_queue<T> q) {
    while(!q.empty()) {
        cerr << q.top() << " ";
        q.pop();
    }
    cerr << endl;
}
 
template<typename T>
void qprint(queue<T> q) {
    while(!q.empty()) {
        cerr << q.front() << " ";
        q.pop();
    }
    cerr << endl;
}
 
template<typename T>
void vecqprint(vector<queue<T>> v) {
    for(int i = 0; i < v.size(); i++) {
        qprint(v[i]);
    }
}
 
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}

inline double get_time_sec(void){
    return static_cast<double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count())/1000000000;
}

int main(void) {
    LL l, r;
    cin >> l >> r;
    LL res = LONG_MAX;
    FOR(i, l, r+1) {
        FOR(j, i+1, r+1) {
            LL tmp = ((i%2019) * (j%2019)) % 2019;
            if(tmp == 0) {
                cout << 0 << endl;
                return 0;
            }
            if(tmp < res) res = tmp;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a=nxt(),b=nxt();
    cout<<max({a+b,a-b,a*b})<<endl;

    
    
    return 0;   
}


 
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll mod=1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    cout<<min(c,b/a)<<endl;
    return 0;
    }


Measured memory_bytes: 256
#include <stdio.h>

int n;
int in[100010][3];
int dp[100010][3];

int max(int a, int b)
{
	if (a > b)
		return a;
	return b;
}

int main(int argc, char const *argv[])
{
	scanf("%d", &n);

	int i = 0;
	while(i < n)
	{
		scanf("%d %d %d", &in[i][0], &in[i][1], &in[i][2]);
		i++;
	}

	i=1;
	while (i < n + 1)
	{
		int j = 0;
		while (j < 3)
		{
			int k = 0;
			while(k < 3)
			{
				if (j == k)
				{
					k++;
					continue;
				}
				dp[i][j] = max(dp[i][j], dp[i-1][k] + in[i-1][j]);
				k++;
			}
			j++;
		}
		i++;
	}

	i=0;
	int res = 0;
	while(i < 3)
	{
		res = max(res, dp[n][i]);
		i++;
	}
	printf("%d", res);
	return 0;
}


Measured memory_bytes: 2560
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<bitset>
#include<random>
#include<cstdint>
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
#define DOUBLE setprecision(17)
#define DEBUG(a) cerr<<a<<" "
#define NEWLINE cerr<<"\n"
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false)

  
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
ll longinf=(1ll<<60);
const ll inf=1ll<<29;
int main(){
      int n;
      cin>>n;
      int a[n];
      int b[n];
      int c[n];
      rep0(i,n) cin>>a[i];
      rep0(i,n) cin>>b[i];
      rep0(i,n) cin>>c[i];
      sort(a,a+n);
      sort(b,b+n);
      sort(c,c+n);
      ll ans=0;
      rep0(i,n){
            ans+=(lower_bound(a,a+n,b[i])-a)*(n-(upper_bound(c,c+n,b[i])-c));
      }
      cout<<ans<<endl;
      return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>

 int main(void)
{

 int a, b;

 scanf("%d%d" ,&a,&b);

  if(a>=13)
    printf("%d\n",b);

  else if((a>=6) && (a<=12))
         printf("%d\n" ,b/2);

  else if(a<=5)
         printf("0");

return 0;
}


Measured memory_bytes: 128
first = 0
second = 0
third = 0
10.times do
	tmp = STDIN.gets.to_i
	if tmp > third then
		if tmp > second then
			if tmp > first then
				third = second
				second = first
				first = tmp
			else
				third = second
				second = tmp
			end
		else
			third = tmp
		end
	end
end
STDOUT.puts(first)
STDOUT.puts(second)
STDOUT.puts(third)

Measured memory_bytes: 6088
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int bin(int x) {
  int res = 0;
  while (x % 2 == 0) {
    ++res;
    x /= 2;
  }
  return res;
}

ll gcd(ll a, ll b) {
  return b == 0 ? a : gcd(b, a % b);
}

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

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  ll M;
  while (cin >> N >> M) {
    vector<ll> A(N);
    for (ll &x : A) cin >> x;
    set<int> S;
    ll L = 1;
    for (ll x : A) {
      S.insert(bin(x));
      L = lcm(L, x / 2);
      if (L > M) L = M + 1;
    }
    ll res = 0;
    if (S.size() == 1) {
      res = (M / L + 1) / 2;
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define INF 1000000000000
#define MOD 1000000007
#define PI 3.14159265359
#define dij priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>
typedef long long ll;
//
int main(){
  int n;cin>>n;
  vector<vector<int>> v(n,(vector<int>(2)));
  rep(i,n)cin>>v[i][0]>>v[i][1];
  bool flag=false;
  rep(i,n-2){
    if(v[i][0]==v[i][1]&&v[i+1][0]==v[i+1][1]&&v[i+2][0]==v[i+2][1])flag=true;
  }
  string ans;
  if(flag )ans="Yes";
  else ans="No";
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main()
{
	int a;
	cin>>a;
	for(int i=1;i<=9;i++)
	{
		for(int j=1;j<=9;j++)
		{
			if(a==i*j)
			{
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

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

using namespace std;

int main()
{
    int N;
    int X, Y;

    cin >> N >> X >> Y;
    X--, Y--;
    vector<int> dist(N);

    for (int i = 0; i < N; i++)
        for (int j = i + 1; j < N; j++)
            dist.at(min(min(abs(j - i), abs(X - i) + 1 + abs(Y - j)), abs(Y - i) + 1 + abs(X - j)))++;

    for (int i = 1; i < N; i++)
        cout << dist.at(i) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int mod = 1e9 + 7;
inline int mul( int x , int y ){ return 1LL * x * y % mod ;}
int power_mod( int x , int y ){int ret = 1;while( y ){if( y & 1 ) ret = mul( ret , x );y >>= 1;x = mul( x , x );}return ret;}
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;}
using namespace std;

vector < pair < int , int > > seg;
int N , C , K;

int main(int argc,char *argv[]){
	N = read() , C = read() , K = read();
	for(int i = 1 ; i <= N ; ++ i){
		int l = read();
		int r = l + K;
		seg.emplace_back( make_pair( l , r ) );
	}
	sort( seg.begin() , seg.end() );
	int ans = 0;
	for(int i = 0 ; i < seg.size() ; ){
		int j = i , r = seg[i].second;
		while( j < seg.size() && seg[j].first <= r && j - i < C )
			++ j;
		++ ans;
		i = j;
	}
	printf( "%d\n" , ans );
	return 0;
}

Measured memory_bytes: 1400
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

int main() {
	int N;
	cin >> N;
	vector<double> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	for (int i = 1; i < N; i++) {
		v[i] = (v[i] + v[i - 1]) / 2;
	}
	printf("%.15lf\n", v[N - 1]);
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}
template<typename T,typename U>
ll FindErase(T &v,U tar){
  ll cnt = 0;
  for(auto it = v.begin(); it != v.end();){
    if(*it == tar){
      it = v.erase(it);
      ++cnt;
    }
    else{
      ++it;
    }
  }
  return cnt;
}

template<typename T>
bool SuffixErase(T &v,size_t suf){
  if(suf > v.size()) return false;
  for(auto it = v.begin(); it != v.end();){
    if(distance(v.begin(),it) == suf){
      v.erase(it);
      return true;
    }
    else{
      ++it;
    }
  }
  return false;
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h,w;
  cin >> h >> w;
  vector<vector<int>> vc(h,vector<int>(w,-1));
  char c;
  rep(i,h){
    bool f = false;
    rep(j,w){
      if(j) cout << ' ';
      cin >> c;
      if(c == 'c'){
        vc[i][j] = 0;
        f = true;
      }
      else if(f){
        vc[i][j] = 1 + vc[i][j-1];
      }
      cout << vc[i][j] ;
    }
    cout << endl;
  }
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 200005;

int main(){
  FASTER;
  ll n, m;
  cin >> m >> n;
  ll sum = 0;
  for (int i = 0; i < n; i++){
    ll x;
    cin >> x;
    sum += x;
  }  
  if (sum <= m){
    cout << m - sum << "\n";    
  } else {
    cout << -1 << "\n";
  }
  return 0;
}


Measured memory_bytes: 3656
import sys
input = sys.stdin.readline

from collections import deque

N, M = map(int, input().split())

G = [[] for _ in range(N + 1)]
for _ in range(M):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)

d = [-1] * (N + 1)
ans = [-1] * (N + 1)
que = deque()
root = 1
ans[root] = 0
que.append(root)
while que:
    now = que.popleft()
    for next_ in G[now]:
        if ans[next_] == -1:
            que.append(next_)
            ans[next_] = now

for i in ans[1:]:
    if i == -1:
        print ('No')
        exit()
print ('Yes')
print (*ans[2:], sep = '\n')

Measured memory_bytes: 98776
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_2
{
    class Program
    {
        static void Main(string[] args)
        {
           string[] n = Console.ReadLine().Split(' ');
            int a = int.Parse(n[0]);
            int b = int.Parse(n[1]);

            if(a > b)
            {
                int c = a + (a - 1);
                Console.WriteLine(c);
            }
            else if(a < b)
            {
                int d = b + (b - 1);
                Console.WriteLine(d);
            }
            else
            {
                int e = a + b;
                Console.WriteLine(e);
            }
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>

using namespace std;

int main()
{
    int n;
    string s;
    cin >> n;
    cin >> s;
    int dem = 0;
    for  (int i = 0 ; i < n-2; i++ )
    {
        if ( s[i]=='A' && s[i+1] =='B' && s[i+2] == 'C')
        {
            dem ++;
            i+= 2;
        }
    }
    cout << dem;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }


int main(){
    ll n,k,ans=0;
    cin>>n;
    string s;
    cin>>s;
    ll x=s.length();
    if(x<=n)cout<<s;
    else{
        rep(i,0,n)cout<<s[i];
        cout<<"...";
    }
}

Measured memory_bytes: 3624
#include  <stdio.h>
int main(void)
{
	int a,b,d, r;
	double f;
	scanf("%d%d", &a,&b);
	d = a / b;
	r = a % b;
	f = 1.0*a / b;
	printf("%d %d %f\n", d, r, f);
	
	return 0;
}


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

using namespace std;

bool ok(vector<string>& a,int r,int c,int s)
{
	int rc=0,cc=0,sc=0;
	for(int i=0;i<a.size();i++){
		int j=a[i].find_first_not_of('.');
		if(rc*r+cc*c+sc*s!=j)
			return false;
		rc+=count(begin(a[i]),end(a[i]),'(')-count(begin(a[i]),end(a[i]),')');
		cc+=count(begin(a[i]),end(a[i]),'{')-count(begin(a[i]),end(a[i]),'}');
		sc+=count(begin(a[i]),end(a[i]),'[')-count(begin(a[i]),end(a[i]),']');
	}
	return true;
}

int main()
{
	for(int n,m;cin>>n>>m,n|m;){
		cin.ignore();
		vector<string> a(n),b(m);
		for(int i=0;i<n;i++) cin>>a[i];
		for(int i=0;i<m;i++) cin>>b[i];
		
		vector<int> rs,cs,ss;
		for(int i=1;i<=20;i++)
			for(int j=1;j<=20;j++)
				for(int k=1;k<=20;k++)
					if(ok(a,i,j,k)){
						rs.push_back(i);
						cs.push_back(j);
						ss.push_back(k);
					}
		
		vector<int> res;
		int rc=0,cc=0,sc=0;
		for(int i=0;i<b.size();i++){
			vector<int> cand;
			for(int j=0;j<rs.size();j++)
				cand.push_back(rc*rs[j]+cc*cs[j]+sc*ss[j]);
			sort(begin(cand),end(cand));
			if(unique(begin(cand),end(cand))-begin(cand)==1)
				res.push_back(cand[0]);
			else
				res.push_back(-1);
			rc+=count(begin(b[i]),end(b[i]),'(')-count(begin(b[i]),end(b[i]),')');
			cc+=count(begin(b[i]),end(b[i]),'{')-count(begin(b[i]),end(b[i]),'}');
			sc+=count(begin(b[i]),end(b[i]),'[')-count(begin(b[i]),end(b[i]),']');
		}
		
		for(int i=0;i<res.size();i++)
			cout<<(i?" ":"")<<res[i];
		cout<<endl;
	}
}

Measured memory_bytes: 1392
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using ll = long long;

int main() {
    int x[5];
    rep(i, 5) cin >> x[i];
    int ans;
    rep(i, 5) {
        if (x[i] == 0) {
            ans = i + 1;
            break;
        }
    }

    cout << ans << endl;
}

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

int main() {
    char s[201], p[101];
    char ch[101];
    
    scanf("%s", s);
    scanf("%s", p);
    strcpy(ch, s);
    strcat(s,ch);
    if (strstr(s, p) == NULL) printf("No\n");
    else printf("Yes\n");
    
    return 0;
    
    
}



Measured memory_bytes: 2672
n=int(input())
l=list(map(int,input().split()))

n_lis=[i for i in range(1,n+1)]
dic={i:j for i,j in zip(l,n_lis)}
num_lis=[str(dic[i]) for i in range(1,n+1)]
print(' '.join(num_lis))

Measured memory_bytes: 29792
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int n;
    cin>>n;
    ll res=0;
    rep(i,1,n+1){
        if(i%3==0||i%5==0)continue;
        else res+=i;
    }
    cout<<res<<endl;
    return 0;
}




Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
const int N = 1 * 1e6 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
ll f(ll x){
    ll ans = 1;
    for(ll i = 1; i <= x; i++)
        ans = (ans % mod * i % mod) % mod;
    return ans;
}

int main(){/*
    freopen("in","r",stdin);
    freopen("out","w",stdout);*/
    fast;
    int n;
    ll a,b;
    cin >> n >> a >> b;
    ll v[n + 1];
    ll ans = 0;
    fore(i, 0, n)
        cin >> v[i];
    fore(i, 1, n){
        ans += min((v[i] - v[i - 1]) * a,b);
    }
    cout << ans << '\n';
    return 0;   
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
#include<string.h>

typedef struct dice{
	int e[7]; /*Dice Eyes 1～6、0の目＝swapの退避用*/
}dice_t;

typedef struct question{
	int top;
	int fro;
}que_t;

/*ダイス奥回転*/
void DiceRoteN(dice_t* pDice){
	pDice->e[0] = pDice->e[1];
	pDice->e[1] = pDice->e[2];
	pDice->e[2] = pDice->e[6];
	pDice->e[6] = pDice->e[5];
	pDice->e[5] = pDice->e[0];
	return ;
}
/*ダイス時計回り回転*/
void DiceRoteE(dice_t* pDice){
	pDice->e[0] = pDice->e[1];
	pDice->e[1] = pDice->e[4];
	pDice->e[4] = pDice->e[6];
	pDice->e[6] = pDice->e[3];
	pDice->e[3] = pDice->e[0];
	return ;
}
/*ダイス右スピン*/
void DiceRoteS(dice_t* pDice){
	pDice->e[0] = pDice->e[2];
	pDice->e[2] = pDice->e[4];
	pDice->e[4] = pDice->e[5];
	pDice->e[5] = pDice->e[3];
	pDice->e[3] = pDice->e[0];
	return ;
}


int main(){
	int i,j;
	dice_t dice;
	dice_t* pDice = &dice;
	int q_num;
	que_t que[24];
	
	/*ダイス登録*/
	for(i=1; i<7; i++){
		scanf("%d", &dice.e[i]);
	}
	/*質問数*/
	scanf("%d", &q_num);
	/*質問登録*/
	for(i=0; i<q_num; i++){
		scanf("%d %d", &que[i].top, &que[i].fro);
	}
	
	for(i=0; i<q_num; i++){
		for(j=0; j<5; j++){
			if( dice.e[1] == que[i].top )	break;	/*奥回転で見つからない場合にやめる*/
			DiceRoteN( pDice );
		}
		if( dice.e[1] != que[i].top){
			while( dice.e[1] != que[i].top ) DiceRoteE( pDice );
		}
		while( dice.e[2] != que[i].fro) DiceRoteS( pDice );	/*前面が合うまで横回転*/
		printf("%d\n", dice.e[3]);
	}
	
	return 0;
}


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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const int INF = 100001;

int a, b;

int main()
{
    cin >> a >> b;
    int ans = a * b - a - b + 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int R=1,C=1,H[2000010],N[2000010];
//ティツゥツ陛、ツセツ。テゥツ鳴「テヲツ閉ーテッツシツ暗」ツ??」ツ?セテ」ツ?ッMAXテッツシツ?
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//テヲツ個ソテ・ツ?・テゥツ鳴「テヲツ閉ー
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//テ・ツ渉姪」ツつ甘・ツ?コテ」ツ?凖ゥツ鳴「テヲツ閉ー
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int lub(int l,int r,int n,int *d){
  int m=(l+r)/2;
  if(l==r)return m;
  return n<=d[m]?lub(l,m,n,d):lub(m+1,r,n,d);
}
int ub(int l,int r,int n,int *d){
  int m=(l+r)/2;
  if(l==r)return m;
  return n<d[m]?ub(l,m,n,d):ub(m+1,r,n,d);
}
int c[5010][5010];
int main(){
  int n,m,i,j,k,l,yr=0,xr=0,x[5010],y[5010],d[2][5010]={};
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++)scanf("%d %d",&x[i],&y[i]);
  for(i=0;i<n;i++)hin(x[i]);
  for(i=0;i<n;i++){
    d[0][xr++]=N[hout()];
    if(xr>1&&d[0][xr-1]==d[0][xr-2])xr--;
  }
  R=C=1;
  for(i=0;i<n;i++)hin(y[i]);
  for(i=0;i<n;i++){
    d[1][yr++]=N[hout()];
    if(yr>1&&d[1][yr-1]==d[1][yr-2])yr--;
  }
  //for(i=0;i<n;i++)printf("%d %d\n",d[0][i],d[1][i]);
  for(i=0;i<n;i++)c[lub(0,yr,y[i],d[1])+1][lub(0,xr,x[i],d[0])+1]++;
  for(i=1;i<=yr+1;i++){
    for(j=1;j<=xr+1;j++)c[i][j]+=c[i-1][j]+c[i][j-1]-c[i-1][j-1];
  }
  /*printf("        ");
  for(i=0;i<n+1;i++)printf("%3d ",d[0][i]);printf("\n");
  for(i=0;i<=n+1;i++){
    i?printf("%3d ",d[1][i-1]):printf("    ");
    for(j=0;j<=n+1;j++)printf("%3d ",c[i][j]);printf("\n");
    }//*/
  while(m--){
    scanf("%d %d %d %d",&i,&j,&k,&l);
    i=lub(0,xr,i,d[0]);
    j=lub(0,yr,j,d[1]);
    k=ub(0,xr,k,d[0]);
    l=ub(0,yr,l,d[1]);//printf("%d %d %d %d\n",i,j,k,l);
    printf("%d\n",c[j][i]-c[l][i]-c[j][k]+c[l][k]);
  }
  return 0;
}

Measured memory_bytes: 101940
/*input
PD?D??P
*/
#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 2;

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

  char s[N]; cin >> s;
  for (char *c = s; *c != '\0' ;c++) {
    cout << ((*c) == '?' ? 'D' : *c);
  }
  return 0;
}

Measured memory_bytes: 3852
import qualified Data.Map as M
import qualified Data.ByteString.Char8 as B

main = do
  B.getLine
  d <- mkdict . B.words <$> B.getLine
  B.getLine
  t <- B.words <$> B.getLine
  B.putStr $ solve d t
 
mkdict [] = M.empty
mkdict (x:xs) = M.insertWith f x 1 d
  where 
    f n o = succ o
    d = mkdict xs
 
solve d [] = B.pack "YES"
solve d (x:xs)
  | M.findWithDefault 0 x d == 0 = B.pack "NO"
  | otherwise = solve d' xs
  where d' = M.adjust pred x d

Measured memory_bytes: 68988
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}
const ll MOD = 1000000000+7;

ll sum(ll l, ll r){//等差数列の和
    return (l+r)*(r-l+1)/2;
}

int main(){
   int n, k;
   cin >> n >> k;
   ll ans = 0;
   for(int i = k; i <= n+1; i++){
       ll l = sum(0, i-1); //左からk個
       ll r = sum(n-i+1, n); //右からk個
       ans += r-l+1; //選ぶのがk個のときの和の個数
       ans %= MOD;
   }
   cout << ans << endl;
   return 0;
}
 

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i, a, b) for(int i = a; i < b; i++)
#define REP_(i, a, b) for(int i = a; i <= b; i++)
#define sl(n) scanf("%lld", &n);
#define si(n) scanf("%d", &n);
#define RepAll(a) for(auto x: a)
#define cout(ans) cout << ans << endl;
typedef long long ll;
//分数不为10的倍数的最大情况
using namespace std;

int main()
{
    int n, sum = 0, a;
    int MinAns = 256;
    cin>>n;
    REP(i, 0, n)
    {
        cin >> a;
        sum += a;
        if(a%10){
            MinAns = min(MinAns , a);
        }
    }

    if(sum%10)
        printf("%d\n", sum);
	else
        printf("%d\n", MinAns == 256 ? 0 :(sum-MinAns));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL<<60;
typedef pair<ll, ll> P;

/*bool same_2(int i, int j){ return i == j && i != 0;}
bool same(int i, int j, int k){
    return same_2(i, j) || same_2(j, k) || same_2(k, i);
}*/
bool zero(int m, const vector<int> v, vector<P> &range){
    bool res = false;
    for(P p : range){
        int num = 0;
        for(int a : v) num += a >= p.fi;
        if(p.se != num) {
            res = true;
            break;
        }
    }
    return res;
}


int main() {
    cin>>N>>M;
    vec l(M), r(M), x(M);
    vector<vector<P> > id(N + 1, vector<P>(0));
    rep(i,M){
        cin>>l[i]>>r[i]>>x[i];
        if(r[i] - l[i] + 1 < x[i]){
            cout<<0<<endl;
            return 0;
        }
        id[r[i]].emplace_back(l[i], x[i]);
    }
    vector<mat> dp(N + 1, mat(N + 1, vec(N + 1, 0)));
    ll ans = 0;
    dp[0][0][0] = 1;
    rep(i, N + 1){
        rep(j, N + 1){
            rep(k, N + 1){
                int m = max({i, j, k});
                if(zero(m, {i, j, k}, id[m]) || (i == j && i != 0) || (j == k && j != 0) || (k == i && k != 0)) {
                    dp[i][j][k] = 0;
                }else {
                    if(m == N){
                        (ans += dp[i][j][k])%=MOD;
                    }else {
                        (dp[m+1][j][k] += dp[i][j][k])%=MOD;
                        (dp[i][m+1][k] += dp[i][j][k])%=MOD;
                        (dp[i][j][m+1] += dp[i][j][k])%=MOD;
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, x;
	cin >> n >> x;
	if (x == 1 || x == 2 * n - 1) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	vector<int> a(2 * n - 1);
	a[n - 1] = x;
	a[n - 2] = x - 1;
	a[n] = x + 1;
	int tmp = 1;
	for (int i = 0; i < 2 * n - 1; i++) {
		if (i >= n - 2 && i <= n) {
			cout << a[i] << endl;
			continue;
		}
		if (tmp == x - 1) tmp = x + 2;
		a[i] = tmp;
		tmp++;
		cout << a[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 2304
# Contest: AtCoder Beginner Contest 142 (https://atcoder.jp/contests/abc142)
# Problem: A: Odds of Oddness (https://atcoder.jp/contests/abc142/tasks/abc142_a)

def rint():
    return int(input())


def rints():
    return list(map(int, input().split()))


n = rint()
print(0.5 if n % 2 == 0 else ((n + 1) // 2) / n)


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

int main()
{
	string a="ABC",b="ARC",c; 
	cin>>c;
	if(c==a)
	{
		cout<<b;
	}
	if(c==b)
	{
		cout<<a;
	}
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937 mt32(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt32);
}
/*--------Library Zone!--------*/

int n,a[200005];
signed main() {
	cin>>n;
	rep(i,n)cin>>a[i];
	int ok=mod,ng=0;
	REP(i,n){
		if(a[i-1]>=a[i])ng=1;
	}
	while(ok-ng>1){
		int mid=(ok+ng)/2;
		int ans[20];
		rep(i,min(a[0],20ll))ans[i]=1;
		for(int i=a[0];i<20;i++)ans[i]=0;
		REP(i,n){
			/*if(ok-ng==2){
				rep(j,20)cout<<ans[j]<<" ";
			    cout<<endl;
		    }*/
			if(a[i]>20){
               for(int j=a[i-1];j<20;j++)ans[j]=1;
               continue;
            }
			if(a[i]>a[i-1]){
				for(int j=a[i-1];j<min(20ll,a[i]);j++){
					ans[j]=1;
				}
			}else{
				for(int j=a[i];j<20;j++)ans[j]=0;
				for(int j=a[i]-1;j>=0;j--){
					if(ans[j]!=mid){
						ans[j]++;
						break;
					}else {
						ans[j]=1;
						if(!j)goto ng;
					}
				}
			}
		}
		goto ok;
		ng:;
		ng=mid;
		goto en;
		ok:;
		ok=mid;
		en:;
	}
	cout<<ok<<endl;
}


Measured memory_bytes: 1792