akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

template <class T> inline bool chmin(T &a, const T &b) {
  return (a > b) ? a = b, true : false;
}

template <class T> inline bool chmax(T &a, const T &b) {
  return (a < b) ? a = b, true : false;
}

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  // Input
  int H, W;
  std::cin >> H >> W;
  std::vector<std::string> S(H);
  for (int i = 0; i < H; ++i)
    std::cin >> S[i];

  std::vector<std::vector<char>> B(1 + H + 1);
  B[0] = std::vector<char>(1 + W + 1, '-');
  B[H + 1] = std::vector<char>(1 + W + 1, '-');
  for (int i = 1; i <= H; ++i) {
    B[i].assign(1 + W + 1, '-');
    for (int j = 1; j <= W; ++j)
      B[i][j] = S[i - 1][j - 1];
  }

  // Main
  std::vector<std::vector<int>> yoko(1 + H + 1);
  std::vector<std::vector<int>> tate(1 + H + 1);
  for (int i = 0; i <= H + 1; ++i) {
    yoko[i].assign(1 + W + 1, 0);
    tate[i].assign(1 + W + 1, 0);
  }

  // Yoko
  for (int i = 1; i <= H; ++i) {
    std::vector<int> left;
    std::vector<int> right;
    bool on = false;
    for (int j = 0; j <= W + 1; ++j) {
      if (not on and B[i][j] == '.') {
        // Startup
        left.push_back(j);
        on = true;
      } else if (on and B[i][j] != '.') {
        // Shutdown
        right.push_back(j);
        on = false;
      }
    }
    // assert(left.size() == right.size());
    for (int k = 0; k < left.size(); ++k) {
      int l = left[k];
      int r = right[k];
      for (int j = l; j < r; ++j) {
        yoko[i][j] = r - l;
      }
    }
  }

  // Tate
  for (int j = 1; j <= W; ++j) {
    std::vector<int> left;
    std::vector<int> right;
    bool on = false;
    for (int i = 0; i <= H + 1; ++i) {
      if (not on and B[i][j] == '.') {
        left.push_back(i);
        on = true;
      } else if (on and B[i][j] != '.') {
        right.push_back(i);
        on = false;
      }
    }
    // assert(left.size() == right.size());
    for (int k = 0; k < left.size(); ++k) {
      int l = left[k];
      int r = right[k];
      for (int i = l; i < r; ++i) {
        tate[i][j] = r - l;
      }
    }
  }

  // Output
  int res = 0;
  for (int i = 1; i <= H; ++i) {
    for (int j = 1; j <= W; ++j) {
      if (B[i][j] != '.')
        continue;
      chmax(res, yoko[i][j] + tate[i][j] - 1);
    }
  }
  std::cout << res << std::endl;

  return 0;
}


Measured memory_bytes: 39808
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define PP pair<P,P>
using namespace std;

//const int mod = 998244353;
const int mod=1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

// 出力は.xで！！！！

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
  int k; string s; cin  >> k >> s;
  int sl=s.length();

  combination c(2000010);

  mint ans=0;

  mint fund=1;
  rep(i,k){
    fund*=26;
  }
  mint fund2=1;

  rep(i,k+1){
    mint tmp=0;
    tmp+=fund2*c(sl+i-1,i);
    tmp*=fund;
    fund/=26;
    fund2*=25;
    ans+=tmp;
  }
  cout << ans.x << endl;
return 0;
}



Measured memory_bytes: 35636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int p=1e9+7;
ll qmi(ll a, ll k)
{
    ll res = 1;
    while (k)
    {
        if (k & 1) res = (ll)res * a % p;
        a = (ll)a * a % p;
        k >>= 1;
    }
    return res;
}


ll C(int a, int b) 
{
    ll res = 1;
    for (ll i = 1, j = a; i <= b; i ++, j -- )
    {
        res = (ll)res * j % p;
        res = (ll)res * qmi(i, p - 2) % p;
    }
    return res;
}


ll lucas(ll a, ll b)
{
    if (a < p && b < p) return C(a, b);
    return (ll)C(a % p, b % p) * lucas(a / p, b / p) % p;
}
int main()
{
	ll n, a, b;
	cin >>n>>a>>b;
//	cout <<qmi(2,n)<<endl;
//	cout <<lucas(n,a)<<endl;
//	cout <<lucas(n,b)<<endl;
	cout <<(qmi(2,n)-(lucas(n,a)%p+lucas(n,b)%p)%p-1+p)%p<<endl;
}

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

int getDir(int x1, int y1, int x2, int y2)
{
  if(x1 == x2) {
    if(y1 < y2) return(1);
    else        return(3);
  } else {
    if(x1 < x2) return(0);
    else        return(2);
  }
}

int main()
{
  int N;
  while(cin >> N, N) {
    vector< vector< pair< int, int > > > lines(N + 1);
    vector< vector< pair< int, int > > > relines(N + 1);

    for(int i = 0; i <= N; i++) {
      int M;
      cin >> M;
      vector< int > x(M), y(M);
      for(int j = 0; j < M; j++) cin >> x[j] >> y[j];

      for(int k = 0; k < 2; k++) {

        for(int j = 1; j < M; j++) {
          lines[i].push_back({abs(x[j] - x[j - 1]) + abs(y[j] - y[j - 1]), getDir(x[j - 1], y[j - 1], x[j], y[j])});
        }
        int base = lines[i][0].second;
        for(auto& l : lines[i]) l.second = (l.second - base + 8) % 4;
        reverse(x.begin(), x.end());
        reverse(y.begin(), y.end());
        swap(lines, relines);
      }
    }

    for(int i = 1; i <= N; i++) {
      if(lines[i] == relines[0] || lines[i] == lines[0]) cout << i << endl;
    }
    cout << "+++++" << endl;
  }
}

Measured memory_bytes: 3072
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

import string

def main():
    n = i_input()
    a = i_list()
    even = []
    odd = []
    for i,k in enumerate(a):
        if i%2==0:
            even.append(k)
        else:
            odd.append(k)

    even.reverse()
    even.extend(odd)
    if n%2==0:
        even.reverse()
    print(" ".join(map(str, even)))



if __name__=="__main__":
    main()


Measured memory_bytes: 37756
N,X,Y =map(int,input().split())

count = [0] * (N-1)


for i in range(1,N):
    for j in range(i+1,N+1):
        dist = min(j-i, abs(X-i)+1+abs(Y-j))
        count[dist-1] +=1


print("\n".join(map(str,count)))

Measured memory_bytes: 73756
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,d,a,x,h,ans=0;cin>>n>>d>>a;
  vector<P> mons(n);rep(i,n) {cin>>x>>h;mons[i]=P(x,h);}
  sort(ALL(mons));
  queue<P> prev_attacks;
  ll damage=0;
  for(ll tag=0;tag<n;tag++) {
    while(prev_attacks.size()&&prev_attacks.front().first<mons[tag].first) {
      damage-=a*prev_attacks.front().second;prev_attacks.pop();
    }
    mons[tag].second-=damage;
    ll num=(mons[tag].second+a-1)/a;
    if(num>0) {
      ans+=num;
      damage+=a*num;
      prev_attacks.emplace(mons[tag].first+2*d,num);
    }
  }
  print(ans);
  return 0;
}

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

int main() {
    string s;
    cin>>s;
    string dream="maerd",dreamer="remaerd",erase="esare",eraser="resare";
    reverse(s.begin(),s.end());
    bool ans= true;
    long long pos=0;
    while(pos<s.size()){
        if(s[pos]=='m'){
            if(s.substr(pos,5)==dream){
                pos=pos+5;
            }else {
                ans=false;
            }
        }else if(s[pos]=='e'){
            if(s.substr(pos,5)==erase){
                pos=pos+5;
            }else{
                ans=false;
            }
        }else if(s[pos]=='r'){
            if(s.substr(pos,6)==eraser){
                pos=pos+6;
            }else if(s.substr(pos,7)==dreamer){
                pos=pos+7;
            }else{
                ans=false;
            }
        }else{
            ans=false;
        }
        if(!ans) pos=s.size()+1;
    }
    if(ans){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 512
/*
___ is a raging sadist.
*/

//Destroy all WA at test 2

#include <bits/stdc++.h>
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double
#define pow power
#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define endl "\n"
#define PI 3.14159265358979323846
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll MOD1 = 998244353;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7; 
using namespace std;

ll power(ll x, ll y) 
{ 
   ll res = 1;      
  
   
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (long long)(res*x); 
  

        y = y>>1; 

        if (x<=100000000)
        x = (long long)(x*x);

        //cout<<x<<'\n'; 
    } 
    return res; 
} 






int main()
{

#ifndef ONLINE_JUDGE    
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif

fastio();


ld a,b,h,m;
cin>>a>>b>>h>>m;

ld hour=30*h+(m/2);
ld min=6*m;

ld dif=abs(hour-min);

//cout<<dif<<endl;

ld ans=sqrtl(a*a+b*b-2*a*b*cos(dif*PI/180));

cout<<fixed<<setprecision(15)<<ans;

return 0;
}

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

typedef long long ll;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    string ans ="";
    while(n>0){
        n--;
        ans+= 'a' + n%26;
        n/=26;
    }
    reverse(ans.begin(),ans.end());
    cout << ans <<endl;
}


Measured memory_bytes: 3596
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 1000000007
#define testcases() int t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
 //----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	fast;
    int n;
    cin>>n;
    float sum=0;
    float x;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        sum+=1/x;
    }
    sum=1/sum;
    cout<<sum;
    return 0;
}

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

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

	long long ans = H * W / 2;
	if( H % 2 && W % 2 ) ans++;
	if( H == 1 || W == 1 ) ans = 1;

	cout << ans << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;

int cost[100000][3], dp[100000][3];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N;  cin >> N;
	for (int i = 0; i < N; i++) for (int j = 0; j < 3; j++) cin >> cost[i][j];
	dp[0][0] = cost[0][0], dp[0][1] = cost[0][1], dp[0][2] = cost[0][2];
	for (int i = 1; i < N; i++) {
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + cost[i][0];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + cost[i][1];
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + cost[i][2];
	}
	cout << max(dp[N - 1][0], max(dp[N - 1][1], dp[N - 1][2])) << '\n';
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a, b) << " " << max(0, a + b - n) << endl;
    return 0;
}


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

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define CHMIN(a,b) (a) = min((a),(b))
#define CHMAX(a,b) (a) = max((a),(b))
#define ALL(v) (v).begin(), (v).end()

int main()
{
    int s[300005]={};
    int leftw[300005]={};
    int righte[300005]={};
    long int n;
    scanf("%ld\n",&n);
    char k;
    for(long int p=0;p<n;p++)
    {
        scanf("%c",&k);
        if(k=='E')s[p]=1;
        else s[p]=0;
    }
    if(s[0]==0)leftw[0]=1;
    else leftw[0]=0;
    if(s[n-1]==1)righte[n-1]=1;
    else righte[n-1]=0;
    for(long int p=1;p<n;p++)
    {
        leftw[p]=leftw[p-1]+(1-s[p]);
        righte[n-1-p]=righte[n-p]+s[n-1-p];
    }
    long int min=300005;
    for(long int p=0;p<n;p++)
    {
        long int comp=righte[p]+leftw[p];
        if(min>comp)min=comp;
    }
    printf("%ld\n",min-1);
    return 0;
}

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

int n, r;
string s;

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

    r = 0;
    for (int i = 0; i < n; i++){
        if (s[i] == 'R') r++;
    }
    cout << ((r > n - r) ? "Yes" : "No");
}

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

#define rep(a,b) for(int ii=a;ii<b;ii++)
#define ll long long int
#define test() int tt; cin>>tt; while(tt--) 
#define fst_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl '\n'
#define lg 1000000000

int main()
{
  int x;
  cin >> x;
  if(x) cout << 0 << endl;
  else cout << 1 << endl;
  return 0;	
}

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

ll kto[300000],sum[300000];
int ara[300000],my[300000],id;
int main()
{

    int i,j,k,l,m,n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&ara[i]);
    }
    for(int i=1;i<=n;)
    {
        my[++id]=ara[i];
        for( j=i;j<=n&&ara[i]==ara[j];j++)
        {
        }
        i=j;
    }
    kto[0]=1;
    for(int i=1;i<=id;i++)
    {
         ll d=0;
         d+=kto[i-1];
         d+=sum[my[i]];
         d%=mod;
         sum[my[i]]+=kto[i-1];
         sum[my[i]]%=mod;
         kto[i]=d;
    }
    kto[id]%=mod;
    cout<<kto[id]<<endl;


}



Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    int a, b;
    cin >> a >> b;
    vi p(n);
    rep(i, n) cin >> p[i];
    vector<int> x(3);
    rep(i, n) {
        if (p[i]<=a) x[0]++;
        else if (p[i]>b) x[2]++;
        else x[1]++;
    }
    int ans = 10000;
    rep(i, 3) chmin(ans, x[i]);
    
    pr(ans);
    return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#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=(n-1); i>=0; i--)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define SQ(x) (x)*(x)
#define MN(a,b) a = min(a,(__typeof__(a))(b))
#define MX(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#ifdef BALBIT
#define IOS()
#define bug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define bug(...)
#endif

#define int ll

const int iinf = 1<<29;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;


void GG(){cout<<"-1\n"; exit(0);}

ll mpow(ll a, ll n, ll mo = mod){ // a^n % mod
    ll re=1;
    while (n>0){
        if (n&1) re = re*a %mo;
        a = a*a %mo;
        n>>=1;
    }
    return re;
}

ll inv (ll b, ll mo = mod){
    if (b==1) return b;
    return (mo-mo/b) * inv(mo%b) % mo;
}

const int maxn = 3e2+5;

bool g[maxn][maxn];
int c[maxn][maxn];

main(){
    IOS();
    int n, m; cin>>n>>m;
    int k; cin>>k;
    int nat = 1;
    REP(i,n) REP(j,m){
        char x; cin>>x; g[i][j] = (x=='#');
        if (g[i][j]) c[i][j] = nat ++;
    }
    int r = 0;
    REP(i,n) {
        FOR(j,1,m)
            if (c[i][j] == 0) {
                c[i][j] = c[i][j-1];
            }
        RREP(j,m-1){
            if (c[i][j] == 0) {
                c[i][j] = c[i][j+1];
            }
        }
    }
    REP(j,m) {
        FOR(i,1,n)
            if (c[i][j] == 0) {
                c[i][j] = c[i-1][j];
            }
        RREP(i,n-1){
            if (c[i][j] == 0) {
                c[i][j] = c[i+1][j];
            }
        }
    }
    REP(i,n) REP(j,m){
        cout<<c[i][j]<<" \n"[j==m-1];
    }
} 


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define int long long
#define ll long long
using namespace std;
int a,b;
signed main(){
    cin>>a>>b;
    if (b%2==1||a*2>b||a*4<b)
    {
        cout<<"No"<<endl;
    }
    else cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>
#include<math.h>
int main(void){
  int N,i,j;
  scanf("%d",&N);
  int p[9],q[9];
  for(i=0;i<N;i++){
scanf("%d",&p[i]);
  }
   for(i=0;i<N;i++){
scanf("%d",&q[i]);
  }
  int a=0,b=0,asum=0,bsum=0;
  for(i=0;i<N-2;i++){
      for(j=i+1;j<N;j++){
        if(p[i]>p[j])asum++;
      }
    a+=asum*kaijou(N-i-1);
    asum=0;
  }
  if(p[N-2]>p[N-1])a+=2;
  else a++;
  
   for(i=0;i<N-2;i++){
     for(j=i+1;j<N;j++){
       if(q[i]>q[j])bsum++;
     }
    b+=bsum*kaijou(N-i-1);
     bsum=0;
  }
  if(q[N-2]>q[N-1])b+=2;
  else b++;
  
  printf("%d",abs(a-b));
  return 0;
}
int kaijou(int M){
  if(M>1)return M*kaijou(M-1);
  else return 1;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
int x,y,z;
y=0;
z=0;
cin>>x;
while(x>=60){
x=x-60;
y=y+1;
}
while(y>=60){
y=y-60;
z++;
}
cout<<z<<":"<<y<<":"<<x<<endl;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.0000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
ll e[100009],c[100009];
ll power(ll x,ll y)
{
    ll res=1;
  
    while(y>0)
    {
        if(y&1)
            res=res*x;
        res%=mod;
        y=y>>1;
        x=x*x;
        x%=mod;
    } 
    return res; 
}
ll inv(ll x)
{
    return power(x,mod-2);
}
void solve()
{
	ll n,k;
	cin>>n>>k;
	e[1]=1;
	vll v;
	for(ll i=2;i<=k;i++)
	{
		if(c[i]==0)
		{
			v.pb(i);
			e[i]=i-1;
		}
		for(auto j:v)
		{
			if((i*j)>k)
				break;
			c[i*j]=1;
			if(i%j==0)
			{
				e[i*j]=e[i]*j;
				break;
			}
			e[i*j]=e[i]*e[j];
		}
	}
	ll ans=0;
	for(ll i=1;i<=k;i++)
	{
		ll x=e[i];
		ll y=k/i;
		y=power(y,n);
		x*=y;
		x%=mod;
		ans+=x;
		ans%=mod;
	}
	cout<<ans;
}
int main()
{
    FAST
    #ifdef ayk_16
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
    #endif
    time_taken_start
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++)
    {
        //cout<<"Case #"<<i+1<<":"<<endl;
        solve();
    }
    time_taken_end
}

Measured memory_bytes: 5344
#include<iostream>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a<b){
        cout<<"a < b"<<endl;
    }else if(a>b){
        cout<<"a > b"<<endl;
    }else if(a==b){
        cout<<"a == b"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#define _GLIBCXX_DEBUG

#include"bits/stdc++.h"
using namespace std;

//loops
#define REP(i,n) for(int i=0;i<(ll)(n);i++)
#define REPD(i,n) for(int i=(ll)(n)-1;i>=0;i--)
#define OneToN(i,n) for(int i=1;i<(ll)(n+1);i++)
#define ZeroToN(i,n) for(int i=0;i<(ll)(n+1);i++)
#define AToB(i,a,b) for(int i=a;i<(ll)(b+1);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

//bitsearch
#define BITSEARCH(bit, n) for (int bit = 0; bit < (1<<n); ++bit)
#define isOne(bit, i) bit & (1<<i)


//arrays
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define add push_back


#define remove_unique(v) v.erase(unique(ALL(v)), v.end())

//comparision
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

//pair
#define fir first
#define sec second
#define mp make_pair

//types
#define ll long long
#define vec vector
#define cord2d pair<int,int>
//UNCOMMENT WHEN NEEDED
//#define int ll

//input
template <class T> T get(){ T s; cin >> s; return(s);}
#define gi get<int>()
#define gs get<string>()

template <class T> vector<T> getv(int n) { vec<T> v(n); REP(i, n) cin >> v[i]; return v; }
#define gim(n) getv<int>(n)
#define gsm(n) getv<string>(n)

//output
void print(int a){ cout << a << endl; }
void print(long long a){ cout << a << endl; }
void print(string a){ cout << a << endl; }
void print(char a){ cout << a << endl; }
void print(double a){ cout << a << endl; }
void print(double a, int dig){ cout << std::setprecision(dig) << a << endl; }

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T = int>
void print(vec<T> v){ cout << v << endl; }

template <class T = int>
void print2dVec(vec<vec<T>> v2d){for(vec<T> v: v2d) {print(v);}}

void YesNo1(bool i = true){ return print(i?"Yes":"No"); }
void YESNO2(bool i = true){ return print(i?"YES":"NO"); }

//debug output
#define var_name(var) #var
template <class T> void debug(T &var, int nest = 0, string before = "") { cout << string("          ", nest) << before; print(var); }

//name replacement
#define y0 y0__
#define y1 y1__
#define j0 j0__
#define j1 j1__

//bool lambdas
#define lamb(exp) [](auto i){return exp;}
#define isEven [](int i){return i % 2 == 0;}
#define isOdd [](int i){return i % 2 != 0;}

//constants
const ll INF = 1e18;
const int MOD = 10000007;

//maths
int factorial(int k){ int sum = 1; for (int i = 1; i <= k; ++i) { sum *= i; } return sum; }
int gcd(int a, int b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

void Main() {
    //code here
    string s = gs;
    sort(ALL(s));
    //print(s);
    if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) {
        print("Yes");
    } else {
        print("No");
    }
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Main();
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<int>());
    int all = accumulate(a.begin(), a.end(), 0);

    bool ans = true;
    for (int i = 0; i < m; i++) {
        if (a[i] * 4 * m < all) {
            ans = false;
            break;
        }
    }

    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    ll x;
    cin >> x;
    ll now = 100;
    int ans = 0;
    while (now < x) {
        ++ans;
        now = now * 1.01;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


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

    vector<int> a(n);
    int i;
    for(i=0; i<m; i++) {
        int tmp0,tmp1;
        scanf("%d%d", &tmp0, &tmp1); tmp0--; tmp1--;
        a[tmp0]++;
        a[tmp1]++;
    }

    int cnt=0;
    for(i=0; i<n; i++) {
        if(a[i]%2) cnt++;
    }
    if(cnt>0) {
        printf("NO\n");
    }
    else {
        printf("YES\n");
    }

    return 0;
}


Measured memory_bytes: 640
S = input()
n = len(S)
# bit全探索
for i in range(2 ** (n - 1)):
    ope = S
    cur = 0
    for j in range(n - 1):
        if (i >> j) & 1:
            ope = ope[:-j - cur - 1] + '+' + ope[-j - cur - 1:]
        else:
            ope = ope[:-j - cur - 1] + '-' + ope[-j - cur - 1:]
        cur += 1
    if eval(ope) == 7:
        print(ope + '=7')
        break


Measured memory_bytes: 8980
#include<bits/stdc++.h>
const int P=1e9+7;
int n,m,k,ans=0,f[5007][5007];
void fix(int&a){a-=P,a+=a>>31&P;}
bool eq(int x,int y){return (x-y)%k==0;}
int main(){
	scanf("%d%d%d",&n,&m,&k);
	--k;
	f[0][0]=1;
	for(int i=1;i<=(n+m-1)/k;++i){
		for(int j=0;j<=k;++j){
			for(int a=0,b;b=j+a,b<=n;++a){
				fix(f[i][b]+=f[i-1][a]);
				if(j&&eq(b,n)&&i*k-b<=m-1&&eq(i*k-b,m-1))fix(ans+=f[i-1][a]);
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

#define ll long int 

int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
  
 
ll findlcm(int arr[], int n) 
{ 
   
    ll ans = arr[0]; 
  
  
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (gcd(arr[i], ans))); 
  
    return ans; 
} 


int main(){
    
    long int n,i;
    cin>>n;
    double arr[n];
    for(i=0;i<n;i++) cin>>arr[i];
  
    sort(arr,arr+n);
      
    double res=arr[0];
    for(i=1;i<n;i++){
        res = (res+arr[i])/2;
    }
    cout<<setprecision(9)<<res;
    
    return 0;
}




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

int main() {
  int N;
  cin >> N;
  
  for (int i=0; i<N; i++) {
    string S;
    cin >> S;
    if (S == "Y") {
      cout << "Four" << endl;
      break;
    }
    else if (i == N-1) {
      cout << "Three" << endl;
    }
    else if (S != "Y") {
      continue;
    }
  }
}

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

using namespace std;

#define MOD 1000000007
#define MAX_H 1000
#define MAX_N 1000

bool calculated[MAX_H][MAX_N];
long long dp[MAX_H][MAX_N];
char grid[MAX_H][MAX_N];
int H, W;

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

    cin >> H >> W;

    for (int i = 0; i < H; i++) {
        string row;
        cin >> row;

        for (int j = 0; j < row.size(); j++)
            grid[i][j] = row[j];
    }

    dp[0][0] = 1;

    for (int i = 0; i < W; i++) {
        dp[0][i] = (grid[0][i] == '.' and (i == 0 or dp[0][i - 1] == 1));
    }

    for (int i = 0; i < H; i++) {
        dp[i][0] = (grid[i][0] == '.' and (i == 0 or dp[i - 1][0] == 1));
    }

    for (int i = 1; i < H; i++) {
        for (int j = 1; j < W; j++) {
            if (grid[i][j] == '#') dp[i][j] = 0;
            else dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
        }
    }

    cout << dp[H - 1][W - 1] << "\n";

    // --------------------
    return 0;
}

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

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	vector<int> B(N);
	int INF = (int)1 << 60;
	int res = INF;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> B[i];
	}

	for (int i = 0; i < (1 << N); i++) {
		int ans = 0;
		vector<int> V(N, 0);
		bool ok = true;
		for (int p = 0; p < N; p++) {
			int mnj = -1;
			int mn = INF;
			int tmn = INF;
			int ad = -1;
			int tmp = 0;
			for (int j = 0; j < N; j++) {
				if (V[j] == 0) {
					if (i & (1 << j)) {
						tmn = min(tmn, A[j]);
						if (mn > A[j]) {
							if (abs(p - j) % 2 == 0) {
								mn = A[j];
								mnj = j;
								ad = tmp;
							}
						}
					} else {
						tmn = min(tmn, B[j]);
						if (abs(p - j) % 2 == 1) {
							if (mn > B[j]) {
								mn = B[j];
								mnj = j;
								ad = tmp;
							}
						}
					}
					tmp++;
				}
			}
			if (mn != tmn || mnj == -1) {
				ok = false;
				break;
			}
			ans += ad;
			V[mnj] = 1;
		}
		if (ok) {
			res = min(res, ans);
		}
	}
	if (res == INF) res = -1;
	cout << res << endl;
}

Measured memory_bytes: 256
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
int p[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d",p+i);
	}
	int ret=0;
	int cur=0;
	for(int i=0;i<a;i++){
		if(i==0||p[i]<=p[i-1])cur++;
		else cur=1;
		ret=max(ret,cur);
	}
	printf("%d\n",ret-1);
}

Measured memory_bytes: 512
#include<iostream>

using namespace std;

int main(){
  long W,a,b; cin >> W >> a >> b;

  if( (a<=b && a+W>=b) ||
          (a>=b && a<=b+W) ){
      cout << 0 <<endl;
  }
  else{
    if(a<b){
      cout << b - (a+W) << endl;
    }
    else{
      cout << a - (b+W) << endl;
    }
  }
}


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

using namespace std;
typedef long long LL;

int main() {
	int N, L;
	cin >> N >> L;
	LL diff = 1e9;
	LL ans;
	LL sum = L * N + N * (N + 1) / 2 - N;
	for (int i = 1; i <= N; i++) {
		LL tmp = sum - (L + i - 1);
		if (diff > abs(tmp - sum)) {
			diff = abs(tmp - sum);
			ans = tmp;
		}	
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
// import std = require('tstl')

{
  type Print = void | string | number | string[] | number[]
  let outs: Print[] = []

  const main = (): Print => {
    const r = _io()
    const [X, Y] = r.nn()

    // t + k = x
    // t * 2 + k * 2 = x * 2
    // t * 2 + k * 4 = y
    // 2k = y - 2x
    const k = (Y - 2 * X) / 2

    if ((Y - 2 * X) % 2 !== 0) return 'No'
    if (k < 0 || k > X) return 'No'
    // const t = X - k

    return 'Yes'
  }

  const _io = (i = 0) => {
    const str = require('fs').readFileSync('/dev/stdin', 'utf8')
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')

    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map((v) => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  outs.push(main())

  console.log(
    outs
      .map((line) => (typeof line === 'object' ? line.join(' ') : String(line)))
      .join('\n')
  )
}


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

int main() {
	string r, g, b;
	cin >> r >> g >> b;
	int n = stoi("" + r + g + b);
	string ans = "NO";
	if (n % 4 == 0) {
		ans = "YES";
	}
	cout << ans << endl;
	return 0;
}

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

def th_cnt(arr, th):
    old = 0
    cnt = 0
    for a in arr:
        if old == 0 and th < a:
            cnt += 1
            old = 1
        if a <= th:
            old = 0
    return(cnt)

ret = 0
for i in range(max(arr)):
    ret += th_cnt(arr, i)

print(ret)

Measured memory_bytes: 3316
import sys
def input(): return sys.stdin.readline().rstrip()


# Python3 code to find number of
# distinct numbers in a subarray
MAX = 1000001

# structure to store queries


class Query:
    def __init__(self, l, r, idx):
        self.l = l
        self.r = r
        self.idx = idx

# updating the bit array


def update(idx, val, bit, n):
    while idx <= n:
        bit[idx] += val
        idx += idx & -idx

# querying the bit array


def query(idx, bit, n):
    summ = 0
    while idx:
        summ += bit[idx]
        idx -= idx & -idx
    return summ


def answeringQueries(arr, n, queries, q):

    # initialising bit array
    bit = [0] * (n + 1)

    # holds the rightmost index of
    # any number as numbers of a[i]
    # are less than or equal to 10^6
    last_visit = [-1] * MAX

    # answer for each query
    ans = [0] * q

    query_counter = 0
    for i in range(n):

        # If last visit is not -1 update -1 at the
        # idx equal to last_visit[arr[i]]
        if last_visit[arr[i]] != -1:
            update(last_visit[arr[i]] + 1, -1, bit, n)

        # Setting last_visit[arr[i]] as i and
        # updating the bit array accordingly
        last_visit[arr[i]] = i
        update(i + 1, 1, bit, n)

        # If i is equal to r of any query store answer
        # for that query in ans[]
        while query_counter < q and queries[query_counter].r == i:
            ans[queries[query_counter].idx] = query(
                queries[query_counter].r + 1, bit, n) - query(queries[query_counter].l, bit, n)
            query_counter += 1

    # print answer for each query
    for i in range(q):
        print(ans[i])

# Driver Code

# This code is contributed by
# sanjeev2552


def main():
    # Driver Code
    n, q = list(map(int, input().split()))
    a = list(map(int, input().split()))
    queries = []
    for i in range(q):
        l, r = map(int, input().split())
        queries.append(Query(l-1, r-1, i))
    queries.sort(key=lambda x: x.r)
    answeringQueries(a, n, queries, q)


if __name__ == '__main__':
    main()

Measured memory_bytes: 234852
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int k, q;
    cin >> k >> q;

    vector <ll> D(k);
    for (int i = 0; i < k; i++) cin >> D[i];

    while (q--) {
        ll n, x, m;
        cin >> n >> x >> m;

        ll sum = 0;
        vector <ll> d(k);
        for (int i = 0; i < k; i++) {
            d[i] = D[i] % m;
            if (d[i] == 0) d[i] = m;
            sum += d[i];
        }

        sum *= ((n - 1) / k);
        for (int i = 0; i < (n - 1) % k; i++) sum += d[i];

        cout << n - 1 - ((sum + x) / m - x / m) << '\n';
    }

    return 0;
}

Measured memory_bytes: 888
#import<cstdio>
int main(){int a,c=1,r=0,t;for(char d[]="123546",s[9];t=scanf("%s",s),*s>60;r+=*d%8)*s%6-4?a=*s%5+*s%2*2+c&3,t=*d,*d=d[++a],d[a]=d[5],d[5]=d[a=++a%4+1],d[a]=t:c+=*s+3;r&&printf("%d\n",r+1);~t?main():0;}

Measured memory_bytes: 0
import heapq
import math
h = []
N,M = map(int,input().split())
pr = list(map(int,input().split()))
for i in pr:
    heapq.heappush(h, -i)
for i in range(M):
    point = -heapq.heappop(h)
    heapq.heappush(h, -(point // 2))
print(-sum(h))

Measured memory_bytes: 64792
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;

int main(){
    vector<vector<int>> grid(1e3+1, vector<int>(1e3+1, 0));
    vector<vector<long long>> dp(1e3+2, vector<long long>(1e3+2, 0));

    int h, w; cin >> h >> w;
    for (int i=1; i<=h; i++){
        string s; cin >> s; s = 'x'+s;
        for (int j=1; j<=w; j++){
            if (s[j]=='.') grid[i][j]=1;
        }
    }

    for (int i=h; i>=1; i--){
        for (int j=w; j>=1; j--){
            if ((i==h and j==w)) dp[i][j] = 1;
            else if (!grid[i][j]) dp[i][j] = 0;
            else dp[i][j] = (dp[i+1][j] + dp[i][j+1]) % MOD;
        }
    }
    cout << dp[1][1] << endl;

    
    return 0;

}

Measured memory_bytes: 15432
import numpy as np
n = int(input())
v = list(map(int, input().split()))
v_odd = []
v_even = []
for i in range(n):
  if i%2 == 0:
    v_odd.append(v[i])
  else:
    v_even.append(v[i])

vs_odd = np.array(v_odd)
vs_even = np.array(v_even)
count_odd = np.bincount(vs_odd)
count_even = np.bincount(vs_even)
mode_odd = np.argmax(count_odd)
mode_even = np.argmax(count_even)
a = v_odd.count(mode_odd)
b = v_even.count(mode_even)
if mode_odd != mode_even:
  print(n-a-b)
else:
  if len(v_odd) != v_odd.count(mode_odd):
    v_odd2 = [i for i in v_odd if i != mode_odd]
    vs_odd2 = np.array(v_odd2)
    count_odd2 = np.bincount(vs_odd2)
    mode_odd2 = np.argmax(count_odd2)
    a2 = v_odd.count(mode_odd2)
  else:
    a2 = 0
  if len(v_even) != v_even.count(mode_even):
    v_even2 = [i for i in v_even if i != mode_even]
    vs_even2 = np.array(v_even2)
    count_even2 = np.bincount(vs_even2)
    mode_even2 = np.argmax(count_even2)
    b2 = v_even.count(mode_even2)
  else:
    b2 = 0
  if a2 > b2:
    print(n-a2-b)
  else:
    print(n-a-b2)

Measured memory_bytes: 23384
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
#include<iomanip>
#include<map>
#include<unordered_map>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

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


int main(void)
{
	int n, m;

	cin >> n >> m;
	
	vector<int> a(m+1);
	vector<bool> s(m + 1);
		int ac = 0;
		int wa = 0;

		for (int i = 1; i <= m; i++)
		{
			string j;
			int now;
			cin >> now >> j;

			if (j == "AC")
			{
				a[i] = now;
				s[i] = true;
			}
			else
			{
				a[i] = now;
				s[i] = false;
			}
		}

		vector<int> kariwa(n + 1);
		vector<bool> acnow(n + 1);

		for (int i = 1; i <= m; i++)
		{
			if (!acnow[a[i]])
			{

				if (s[i] == true)
				{
					ac++;
					wa += kariwa[a[i]];
					acnow[a[i]] = true;

				}
				else
				{
					kariwa[a[i]] ++;
				}
			}
		}


	


	cout << ac << " " << wa << endl;
}



Measured memory_bytes: 1024
n,a,b=map(int,input().split())
s=input()
ac=0
bc=0
cc=0
for c in s:
    if c=='a':
        ac+=1
        if cc<a+b:
            print('Yes')
            cc+=1
        else:
            print('No')
    elif c=='b':
        bc+=1
        if cc<a+b and bc<=b:
            print('Yes')
            cc+=1
        else:
            print('No')
    else:
        print('No')

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

typedef long long ll;

const int MAXN = 3e3 + 5;
const int INF = 0x3f3f3f3f;

int n, m, d[MAXN][MAXN] = {0}, v[MAXN][MAXN] = {0};
char s[MAXN], t[MAXN], ans[MAXN];
int cnt = 0;

void backtrace(int i, int j) {
    if (i == 0 || j == 0) return;
    if (v[i][j] == 1) {
        backtrace(i - 1, j - 1);
        putchar(s[i]);
    }
    else if (v[i][j] == 2) backtrace(i - 1, j);
    else backtrace(i, j - 1);
}

int main() {
    scanf("%s", s + 1);
    scanf("%s", t + 1);
    n = strlen(s + 1);
    m = strlen(t + 1);
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j) {
            //printf("%d, %d: %c %c\n", i, j, s[i - 1], t[j - 1]);
            if (s[i] == t[j]) {
                d[i][j] = d[i - 1][j - 1] + 1;
                v[i][j] = 1;
            }
            else if (d[i - 1][j] >= d[i][j - 1]) {
                d[i][j] = d[i - 1][j];
                v[i][j] = 2;
            }
            else {
                d[i][j] = d[i][j - 1];
                v[i][j] = 3;
            }
        }
    backtrace(n, m);
    return 0;
}


Measured memory_bytes: 70784
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define INF (1<<30)
#define LINF (1LL<<60)

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int w, d;
	while (cin >> w >> d) {
		if (w == 0 && d == 0)break;
		int ans = 0;
		vector<int> h1(w), h2(d);

		int D[21] = { 0 };

		for (int i = 0; i < w;i++) {
			cin >> h1[i];
			ans += h1[i];
			D[h1[i]]++;
		}

		for (int i = 0; i < d;i++) {
			cin >> h2[i];
			if (D[h2[i]] == 0) {
				ans += h2[i];
			}
			else {
				D[h2[i]]--;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3100
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

ll solve(const ll N) {
    ll two_count = 0;
    ll five_count = 0;

    // two
    {
        for (ll i = 2; i <= N; i *= 2) {
            // printf("%lld: %lld\n", i, N / i);
            two_count += N / i;
        }
    }

    // five
    {
        for (ll i = 5 * 2; i <= N; i *= 5) {
            // printf("%lld: %lld\n", i, N / i);
            five_count += N / i;
            // printf("%lld\n", five_count);
        }
    }

    return min(two_count, five_count);
}

int main(void) {
    ll N;
    cin >> N;

    if (N % 2 != 0) {
        cout << "0" << endl;
        return 0;
    }

    cout << solve(N) << endl;

    return 0;
}


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

// Template START
#define endl "\n"
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long int
#define all(y) y.begin(), y.end()
#define present( x, y ) (x.find( y ) != x.end())
const int mod = (int)1e9 + 7 ;
template<class T>
auto matrix( int r, int c, T v ){
    return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
template<class T>
auto matrix( int o1, int o2, int o3, T v ){ 
    return vector<vector<vector<T>>>( o1, vector<vector<T>>( o2, vector<T>( o3, v ) ) ) ;
}
#define v vector
// Template END

int power( int x, int n ){
    if( n == 0 ) return 1 ;
    else if( n & 1 ) return ( x * power( (x*x) % mod, n / 2 ) ) % mod ;
    return power( (x*x) % mod, n / 2 ) % mod ;
}



signed main(){
    string s ; cin >> s ;
    int len = s.size() ;
    if( s[len-1] == 's' ) s += "es" ;
    else s += "s" ;
    cout << s ;
    return 0 ;   
}          

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

int main(){

    int n, m;
    cin >> n >> m;

    int a[n][m], b[m], c[n];
    for(int i=0; i<n; i++){
        c[i] = 0;
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin >> a[i][j];
        }
    }
    for(int i=0; i<m; i++){
        cin >> b[i];
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            c[i] += a[i][j] * b[j];
        }
        cout << c[i] << "\n";
    }

    return 0;
    

}


Measured memory_bytes: 3108