akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(a) (a).begin(), (a).end()
#define ALLR(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EMP emplace
#define EMPB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
#define Bit(n) (1LL << (n))
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

int H, W, K;
int dp[110][8];

bool check(int ms) {
  REP(i, W-2) if ((ms & Bit(i)) && (ms & Bit(i+1))) return false;
  return true;
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> H >> W >> K;
  dp[0][0] = 1;
  REP(i, H) REP(ms, Bit(W-1)) {
    if (!check(ms)) continue;
    REP(j, W-1) {
      if (ms & Bit(j)) {
        (dp[i+1][j+1] += dp[i][j]) %= MOD;
        (dp[i+1][j] += dp[i][j+1]) %= MOD;
      } else if (j > 0 && !(ms & Bit(j-1))) {
        (dp[i+1][j] += dp[i][j]) %= MOD;
      }
    }
    if (!(ms & Bit(0))) (dp[i+1][0] += dp[i][0]) %= MOD;
    if (W-2 >= 0 && !(ms & Bit(W-2))) (dp[i+1][W-1] += dp[i][W-1]) %= MOD;
  }
  cout << dp[H][K-1] << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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 gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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 <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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

int main(){
ll a,b;
cin>>a>>b;
cout<<amarinasi((b-1),(a-1))<<endl;
}










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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

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

fastio _fast_io;

const int N = 1e5 + 5;
ll n, m, k, ans, sum;
int a[N];
unordered_map<int, int> mp;

int main() {
    cin >> n >> m;
    mp[0] = 1;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        sum += a[i];
        int d = sum % m;
        if (mp.count(d)) {
            ans += mp[d];
        }
        ++mp[d];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6960
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vvld vector<vector<ld> >
#define vll vector<ll>
typedef long long int ll;
typedef long double ld;
using namespace std;

//-------------------------------------------------------------------
struct segtree{
  ll M=1;
  vector<ll> dat;
  segtree(ll N, ll num){
    while(M<N) M*=2;
    for(int i=0;i<M*2-1;i++)  dat.push_back(num);
  }
  void upd(int x, int k, int l=0, int r=-1){
    if(r==-1) r = M;
    k+=M-1;
    dat[k] += x;
    while(k>0) k = (k-1)/2, dat[k] = max(dat[k*2+1], dat[k*2+2]);
  }
  ll find(int a, int b=-1, int k=0, int l=0, int r=-1){
    if(r==-1) r = M;
    if(b==-1) b = M;
    if(r<=a || b<=l) return 0;
    if(a<=l && r<=b) return dat[k];
    ll A = find(a, b, k*2+1, l, (l+r)/2);
    ll B = find(a, b, k*2+2, (l+r)/2, r);
    return max(A, B);
  }
};
//-------------------------------------------------------------------
int main(int argc, char const *argv[]) {
  ld x, y, x2, y2, a, b; std::cin >> x >> y >> x2 >> y2;
  ll n;std::cin >> n;
  vvld f = vv(0, 2, 0, ld);
  ll mode = 0;
  if(x>x2) swap(x, x2), swap(y, y2);
  if(y2>y) mode = 1;
  map<ll, ll> Y;
  set<ll> X, Z;
  bool yflag = true, xflag = true;
  for(int i=0;i<n;i++){
    std::cin >> a >> b;
    if(!(min(x, x2)<=a&&a<=max(x, x2)&&min(y, y2)<=b&&b<=max(y, y2))) continue;
    f.push_back(vector<ld> {a, b});
    Y.emplace(b, 0);
    if(min(y, y2)<b&&b<max(y, y2)) X.insert(a);
    if(min(x, x2)<a&&a<max(x, x2)) Z.insert(b);
    if(a==x||a==x2) yflag = false;
    if(b==y||b==y2) xflag = false;
  }
  ll c=0, k=0;
  for(auto itr=Y.begin();itr!=Y.end();itr++, c++) (*itr).second=c;
  multimap<ll, ll> num;
  sort(f.begin(), f.end());
  segtree seg(Y.size()+1, 0);

  for(int i=0;i<f.size();i++){
    if(mode==1) c = seg.find(0, Y.at(f[i][1]));
    else c = seg.find(Y.at(f[i][1]), Y.size()+1);
    k = max(k, c+1);
    seg.upd(c+1, Y.at(f[i][1]));
  }
  ll d = 0;
  //std::cout << k << " " << d << '\n';
  if((k==abs(x2-x)+1&&xflag)||(k==abs(y2-y)+1&&yflag)) d++;
  if(k==min(abs(x2-x)+1, abs(y2-y)+1)) k--;
  //std::cout << k << " " << d << '\n';
  std::cout << fixed << setprecision(20) << (ld)abs(x2-x)*100.0 + (ld)abs(y2-y)*100.0 - (ld)k*(20.0-5.0*M_PI) + (ld)d*(10.0*M_PI-20.0) << '\n';
  return 0;
}


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

int main(){

    int a, b, flag = 0;

    cin >> a >> b;


    if(a % 3 == 0 && (a != 1 || a != 0)){
        flag = 1;


    }
    else if(b % 3 == 0 && (b != 1 || b != 0)){
        flag = 1;

    }
    else if((a + b) % 3 == 0 && (a+b != 1 || a+b != 0)){
        flag = 1;

    }

    if(flag == 0){
        cout << "Impossible" << endl;
    }
    else{
        cout << "Possible" << endl;
    }

    return 0;

}



Measured memory_bytes: 3620
// https://atcoder.jp/contests/abc129/tasks/abc129_d

#include <bits/stdc++.h>

using namespace std;

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

const int H_MAX = 2'000;
const int W_MAX = 2'000;

int H, W;
char S[H_MAX][W_MAX + 1];
int r[H_MAX][W_MAX];
int c[H_MAX];

void solve() {
  int ans = 0;
  int prv;
  REP(i, H) {
    prv = 0;
    REP(j, W) {
      prv = r[i][j] = (S[i][j] == '.' ? prv + 1 : 0);
    }
    prv = 0;
    for (int j = W - 1; j >= 0; j--) {
      prv = r[i][j] = (prv > 0 && r[i][j] > 0 ? prv : r[i][j]);
    }
  }
  REP(j, W) {
    prv = 0;
    REP(i, H) {
      prv = c[i] = (S[i][j] == '.' ? prv + 1 : 0);
    }
    prv = 0;
    for (int i = H - 1; i >= 0; i--) {
      prv = c[i] = (prv > 0 && c[i] > 0 ? prv : c[i]);
      if (S[i][j] == '.') {
       ans = max(ans, r[i][j] + c[i] - 1);
      }
    }
  }
  printf("%d\n", ans);
}

void input() {
  scanf("%d%d", &H, &W);
  REP(i, H) scanf("%s", S[i]);
}

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


Measured memory_bytes: 19840
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	cin >> N;
	string S;
	cin >> S;

	int A[200001] = {};
	int B[200001] = {};
	rep(i, N) {
		if (S[i] == '#') A[i + 1] = A[i] + 1;
		else A[i + 1] = A[i];
	}
	rep(i, N) {
		if (S[N - i - 1] == '.') B[i + 1] = B[i] + 1;
		else B[i + 1] = B[i];
	}
	int kotae = 1e9;
	rep(i, N + 1) {
		kotae = min(kotae, A[i] + B[N - i]);
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 2196
from heapq import heappop, heappush
n,m=map(int,input().split())
A=list(map(int,input().split()))
B=sorted(map(lambda x: x * -1, A))
for i in range(m):
    a=heappop(B)
    a=-(-a//2)
    heappush(B,a)
print(-sum(B))

Measured memory_bytes: 14180
//break_the_bond
//jatt_james_bond
#include <bits/stdc++.h>
// #define int long long
#define endl "\n"
using namespace std;
#define MAX 1000000009
#define IOS std::ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
bool comp(pair<int, int> &a, pair<int, int> &b)
{
    return a.first < b.first;
}

void solve()
{
    string n;
    cin >> n;
    int sum{0};
    for (int i = 0; i < n.length(); ++i)
    {
        sum += (int)(n[i] - '0');
    }
    if (sum % 9 == 0)
    {
        cout << "Yes";
    }else
    {
        cout << "No";
    }
}
int32_t main()
{

    // cout << (-11 / -4);

    IOS int testcases = 1;
    // cin >> testcases;
    while (testcases--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3776
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
int main(){
  map<string, vector<int> > word;
  string s;
  int n;
  while(cin >>s>>n){
    word[s].push_back(n);
  }
  for(map<string, vector<int> >::iterator i=word.begin(); i!=word.end(); i++){
    sort(i->second.begin(),i->second.end());
    cout <<i->first<<endl<<i->second[0];
    for(int j=1; j<i->second.size(); j++){
      cout <<" "<<i->second[j];
    }
    cout <<endl;
  }
  return 0;
}

Measured memory_bytes: 1244
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(int argc, const char * argv[]) {
 
 
 
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    /////////////////////
    // Write code below /
    /////////////////////
    long long int n,k;
    
    cin >>n>>k;
    
    n=n% k;
    while(1){
        if(n-k < n && n-k > 0){
            n = n-k;
        }
        else if(k-n < n && k-n > 0){
            n = k-n;
        }
        else
            break;
    }
    cout <<n<<"\n";
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int r, c;
    cin >> r >> c;
    vector<vector<int> > a(r + 1, vector<int>(c + 1));
    for (int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            cin >> a.at(i).at(j);
        }
    }
    int sum;
    for (int i = 0; i < r; i++){
        sum = 0;
        for (int j = 0; j < c; j++){
            sum += a.at(i).at(j);
        }
        a.at(i).at(c) = sum;
    }
    int max = 0;
    for (int i = 0; i < c; i++){
        sum = 0;
        for (int j = 0; j < r; j++){
            sum += a.at(j).at(i);
        }
        a.at(r).at(i) = sum;
        max += sum;
    }
    a.at(r).at(c) = max;
    
    for (int i = 0; i < r + 1; i++){
        for (int j = 0; j < c + 1; j++){
            cout << a.at(i).at(j);
            if(j != c)
                cout << " ";
        }
        cout << endl;
    }
}



Measured memory_bytes: 3136
#include <stdio.h>
#include <iostream>

#include <sstream>
#include <fstream>
#include <cmath>
#include <vector>


using namespace std;

int main( int argc , char ** argv ){
	

	for(int i = 0 ; i < 3 ; i++){
		string name;
		cin >> name;
		cout << name[0];
	}
	cout << endl;

}



Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    if (n == 3)
    {
        cout << "2 5 63";
        return 0;
    }
    vector<int> a;
    int p2 = 0, p3 = 0;
    for (int i = 2; i <= 30000; ++i)
    {
        if (a.size() < n - 1)
        {
            if (i % 2 == 0 || i % 3 == 0)
            {
                a.push_back(i);
                if (i % 2 == 0)
                    ++p2;
                else
                    ++p3;
            }
        }
    }
    if (p3 % 2 == 1)
    {
        if (a.back() % 3 == 0 && a.back() % 2 == 1)
        {
            while (a.back() % 3 == 0 && a.back() % 2 == 1)
                ++a.back();
        }
        else
        {
            while (!(a.back() % 3 == 0 && a.back() % 2 == 1))
                ++a.back();
        }

    }
    int r3 = 0;
    for (int i = 0; i < a.size(); ++i)
    {
        if (a[i] % 2 != 0)
        {
            for (int j = 0; j < a.size(); ++j)
                r3 += a[j];
            r3 -= a[i];
            r3 %= 3;
            break;
        }
    }
    for (int i = a.back() + 1; i <= 30000; ++i)
    {
        if ((i + r3) % 3 == 0 && i % 2 == 0)
        {
            a.push_back(i);
            break;
        }
    }
    for (int i = 0; i < n; ++i)
        cout << a[i] << " ";
    return 0;
}


Measured memory_bytes: 640
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mod   1000000007
#define PI 2*acos(0.0)
#define all(r)(r).begin(),(r).end()
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define inf 1000000000000000000
#define N 110
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};


//=============================================ASIFAZAD==============================================

int32_t main()
{
    io;
    int n;
    cin>>n;
    map<string, int> cnt;
    int mx = 0;
    for(int i =0 ; i< n;i++)
    {
        string s;
        cin>>s;
        cnt[s]++;
        mx = max(mx, cnt[s]);
    }
    for(auto a: cnt)
        if(a.second == mx)
            cout<<a.first<<"\n";
    return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    ll K; cin >> K;
    ll a = K/50;
    ll b = K%50;
    cout << 50 << endl;
    REP(i,50-b) cout << 49-b+a << " ";
    REP(i,b) cout << 100-b+a << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)

void solve()
{
    int x,y,s;
    while(cin>>x>>y>>s,x|y|s){
        int mx=0;
        rep(i,1,s)rep(j,1,s){
            int sumx=(i*(100+x)/100)+(j*(100+x)/100);
            if(sumx==s){
                int sumy=(i*(100+y)/100)+(j*(100+y)/100);
                mx=max(mx,sumy);
            }
        }
        cout<<mx<<endl;
    }
}

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


Measured memory_bytes: 3152
#include <iostream>

using namespace std;

int main()
{
    int H, W;
    cin >> H >> W;
    int cnt[26] = {};
    for (int i = 0; i < H; i++)
    {
        string s;
        cin >> s;
        for (auto c : s)
        {
            cnt[c - 'a']++;
        }
    }

    int g4 = (H / 2) * (W / 2);
    int g2 = (H / 2) * (W & 1) + (W / 2) * (H & 1);
    int g1 = H & W & 1;
    int groups[] = {g4, g2, g1};
    int subs[] = {4, 2, 1};
    for (int g = 0; g < 3; g++)
    {
        for (int i = 0; i < groups[g]; i++)
        {
            bool ok = false;
            for (int j = 0; j < 26; j++)
            {
                if (cnt[j] >= subs[g])
                {
                    cnt[j] -= subs[g];
                    ok = true;
                    break;
                }
            }
            if (!ok)
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 384
import itertools
N = int(input())

syogens = []

for _ in range(N):
    a = int(input())
    syogens.append([list(map(int, input().split())) for _ in range(a)])


ans = 0
for flags in itertools.product([False, True], repeat=N):
    for f, xys in zip(flags, syogens):
        if not f:
            continue
        else:
            for x, y in xys:
                if y == 1 and not flags[x - 1]:
                    break
                elif y == 0 and flags[x - 1]:
                    break
            else:
                continue
            break
    else:
        ans = max(ans, sum(flags))

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define f(n) for(int i=0; i<n; i++)
#define endl '\n'
#define ll long long

int main() {


    int n;
    while(cin>>n){

        int c= n/500 * 1000 ;
        n%=500; //cout<<n<<endl;
        c+=( n/5) * 5;
        cout<<c ;
    }

    return 0;
}




Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <numeric>
using namespace std;

int main(void) {
	// TODO: submit前にprintf-debugの削除確認！
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	
	int xMax = -100;
	int Z = Y;
	
	for(int i=0; i<N; i++) {
		int x;
		cin >> x;
		xMax = max(xMax, x);
	}

	for(int i=0; i<M; i++) {
		int y;
		cin >> y;
		Z = min(Z, y);
	}

	if(X < Z && xMax < Z)
		cout << "No War";
	else
		cout << "War";
	return 0;
}


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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    u32 N;
    cin >> N;
    Vec<u64> A(N);
    for (u32 i = 0; i < N; i++) {
        cin >> A[i];
        if (A[i] == 0) {
            cout << "0" << endl;
            return;
        }
    }
    u64 ans = 1;
    for (u32 i = 0; i < N; i++) {
        u64 b = ans;
        ans *= A[i];
        if (ans / A[i] != b || ans > 1000000000000000000) {
            cout << "-1" << endl;
            return;
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 3944
#include <stdio.h>
#define maxn 200010
int L[maxn],R[maxn],lc,rc;
char s[maxn];
int main(){
	int n,k,c,i;
	scanf("%d%d%d%s",&n,&k,&c,s+1);
	for(i=1;i<=n;){//正向寻找
		if(s[i]=='o'){
			L[++lc]=i,i+=c;
			if(lc==k)break;
		}
		i++;
	}
	for(i=n;i>=1;){//反向寻找
		if(s[i]=='o'){
			R[++rc]=i,i-=c;
			if(rc==k)break;
		}
		i--;
	}
	for(i=1;i<=k;i++)//重合工作的寻找
		if(L[i]==R[k-i+1])printf("%d\n",L[i]);
	return 0;
}

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


int main()
{
    string s;
    cin >> s;
    string s_kami = s.substr(0, 2);
    string s_shimo = s.substr(2, 2);

    int kami = atoi(s_kami.c_str());
    int shimo = atoi(s_shimo.c_str());

    bool kami_mm_possible = (kami >= 1 && kami <= 12);
    bool shimo_mm_possible = (shimo >= 1 && shimo <= 12);
    string ans = kami_mm_possible ? (shimo_mm_possible ? "AMBIGUOUS" : "MMYY") : (shimo_mm_possible ? "YYMM" : "NA");

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

MOD = 2019  # type: int


def solve(L: int, R: int):
    if R - L >= 2019:
        return 0
    def f():
        for i in range(L, R):
            for j in range(i+1, R+1):
                yield i * j % MOD
    return min(f())


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    print(solve(L, R))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

bool check(int n) {
  int t7 = 0, t5 = 0, t3 = 0;
  for ( ; n > 0; n /= 10) {
    if (n%10 == 7) t7++;
    else if (n%10 == 5) t5++;
    else if (n%10 == 3) t3++;
    else return false;
  }

  if (t7 >= 1 && t5 >= 1 && t3 >= 1)
    return true;
  else
    return false;
}

int main()
{
  int n, ans = 0;
  cin>>n;

  int j = min(n+1, 777777754);
  for (int i = 357; i < j; ) {
    if (check(i)) ans++;

    if (i % 10 == 3) i += 2;
    else if (i % 10 == 5) i += 2;
    else if (i % 10 == 7) i += 16;
  }

  cout<<ans<<endl;

  return 0;
}


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;
    cin >> n;
    map<int, int> stu;
    int a;
    for (int i = 1; i <= n; i++) {
        cin >> a;
        stu.insert({a, i});
    }

    for (auto itr = stu.begin(); itr != stu.end(); ++itr) {
        cout << itr->second << ' ';
    }

    return 0;
}

Measured memory_bytes: 5504
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d %d", &a,&b);
    // 文字列の入力
    // 出力
  if((a*b)%2!=0)
  {
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int x;
signed main(){
    cin>>x;
    int ans=0;
    ans+=(x/500)*1000;
    x%=500;
    ans+=(x/5)*5;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 200005
#define ll long long
using namespace std;
inline ll read(){
	ll ans=0;
	char ch=getchar();
	while(!isdigit(ch))ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
	return ans;
}
ll n,k;
int main(){
	n=read(),k=read();
	if(k&1){
		ll ans=n/k;
		cout<<ans*ans*ans;
	}
	else{
		ll ans1=n/k,ans2=ans1;
		if(n%k>=k/2)++ans2;
		cout<<ans1*ans1*ans1+ans2*ans2*ans2;
	}
	return 0;
}

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

    using namespace std;

    typedef long long ll;
    typedef long double ld;

    const int N=100000+5;

    int n;
    ll v[N];

    int main()
    {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            cin>>v[i];
            v[i]%=2;
        }
        sort(v+1,v+n+1);
        int s=0;
        for(int i=1;i<=n;i++)
        {
            s+=v[i];
            s%=2;
        }
        if(v[n-1]==1)
        {
            cout<<"first\n";
            return 0;
        }
        if(s==1)
        {
            cout<<"first\n";
        }
        else
        {
            cout<<"second\n";
        }

        return 0;
    }
    /**
    
    
    0 0 0 1 1 0 0 0 
    
    
    **/


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <bitset>
#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
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

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

int main(){
    cin>>N;
    vec p(N), q(N), ord(N);
    rep(i,N) cin>>p[i], --p[i];
    rep(i,N) cin>>q[i], --q[i];
    rep(i,N) ord[i] = i;
    ll a = 0, b = 0;
    do{
        bool ok = true;
        rep(i,N){
            if(p[i] != ord[i]) ok = false;
        }
        if(ok) break;
        ++a;
    }while(next_permutation(ALL(ord)));
    rep(i,N) ord[i] = i;
    do{
        bool ok = true;
        rep(i,N){
            if(q[i] != ord[i]) ok = false;
        }
        if(ok) break;
        ++b;
    }while(next_permutation(ALL(ord)));
    cout<<abs(a - b)<<endl;
}

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

using namespace std;

int main() {
    /*入力 */
    int n, m;
    cin >> n >> m;

    vector<long long>L(m);
    for(int i = 0; i < m; i++) {
        cin >> L[i];
    }
    sort(L.begin(), L.end());

    /*座標間の距離を算出 */
    vector<long long> diffs;
    for(int i = 1; i < L.size(); i++) {
        diffs.push_back(L[i]- L[i-1]);
    }
    sort(diffs.begin(), diffs.end(), greater<long long>());

    /*距離が長い座標間がコマのカバー範囲が動かないのが最小 */
    /*コマが座標より大きいときは、(int)diffs.size()回引く=答えは0になる */
    long long res = L.back() -L[0];
    for (int i = 0; i < min((int)diffs.size(), n-1); ++i) {
        res -= diffs[i];
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 2168
#include<stdio.h>
int main()
{
    int num,num1,num2;
    scanf("%d",&num);
    num2=num%10;
    num1=num/10;
    if(num2==9||num1==9||num2==9&&num1==99)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 128
s=input()
n=len(s)
n1=((n-1)//2)
n2=(n+3)//2
s1=s[0:n1]
s2=s[n2-1:]
if s==s[::-1] and s1==s1[::-1] and s2==s2[::-1]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
import java.util.*;
public class Main {
	public static void main (String[] args) {
      Scanner sc = new Scanner(System.in);
      int A = sc.nextInt(), B = sc.nextInt(), C = sc.nextInt();
      int K = sc.nextInt();
      int[] array = {A,B,C};
      Arrays.sort(array);
      int ans = array[0]+array[1];
      int count = array[2];
      for (int i=0; i<K; i++) {
        count *= 2;
      }
      System.out.println(ans+count);
    }
}

Measured memory_bytes: 35656
use std::io;
use std::io::{BufRead, Write};

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut buf = String::new();
    input.read_line(&mut buf).unwrap();
    let _n: usize = buf.trim_right().parse().unwrap();
    buf.clear();
    input.read_line(&mut buf).unwrap();
    writeln!(
        output,
        "{}",
        buf.split_whitespace()
            .map(|x| x.parse::<usize>().unwrap())
            .map(|x| x.trailing_zeros())
            .sum::<u32>()
    ).unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }

    #[test]
    fn case1() {
        test(
            "3
5 2 4
", "3\n",
        );
    }

    #[test]
    fn case2() {
        test(
            "4
631 577 243 199
", "0\n",
        );
    }

    #[test]
    fn case3() {
        test(
            "10
2184 2126 1721 1800 1024 2528 3360 1945 1280 1776
", "39\n",
        );
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vd vector<double>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define vvb vector<vb>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";cout << '\n';
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

int h, w, ch, cw, dh, dw;
vs g;
vvb vis;
vvi cost;
queue<pii> q;

bool valid(int x, int y){
	if(x < 0 || x >= h || y < 0 || y >= w)return false;
	
	return g[x][y] == '.';
}

void dfs(int x, int y){
	if(!valid(x, y))return;
	if(vis[x][y])return;
	
	vis[x][y] = 1;
	cost[x][y] = 0;
	q.push({x, y});
			
	dfs(x+1, y);
	dfs(x-1, y);
	dfs(x, y+1);
	dfs(x, y-1);
}

void dfs2(int x, int y, int c, int ox, int oy){
	if(!valid(x, y))return;
	if((ox != x || oy != y) && cost[x][y] <= c)return;
	
	cost[x][y] = c;
	if(ox != x || oy != y)q.push({x, y});
	
	dfs2(x+1, y, c, ox, oy);
	dfs2(x-1, y, c, ox, oy);
	dfs2(x, y+1, c, ox, oy);
	dfs2(x, y-1, c, ox, oy);
}

void solve(){
	cin >> h >> w;
	cin >> ch >> cw;
	--ch, --cw;
	cin >> dh >> dw;
	--dh, --dw;
	
	g = vs(h);
	for(string& s : g)cin >> s;
	
	if(g[dh][dw] == '#'){
		cout << "-1";
		return;
	}
	
	vis = vvb(h, vb(w, 0));
	cost = vvi(h, vi(w, INT_MAX));
	dfs(ch, cw);
	
	if(vis[dh][dw]){
		cout << "0";
		return;
	}
	
//	for(int i=0 ; i<h ; ++i){
//		for(int j=0 ; j<w ; ++j){
//			cout << cost[i][j] << " ";
//		}
//		cout << endl;
//	}
	
	while(q.size()){
		int x = q.front().F, y = q.front().S;
		q.pop();
		
//		debug(x);debug(y);
		dfs2(x, y, cost[x][y], x, y);
//		for(int i=0 ; i<h ; ++i){
//			for(int j=0 ; j<w ; ++j){
//				cout << cost[i][j] << " ";
//			}
//			cout << endl;
//		}
		for(int i=max(x-2, 0) ; i<=min(x+2, h-1) ; ++i){
			for(int j=max(y-2, 0) ; j<=min(y+2, w-1) ; ++j){
//				debug(i);debug(j);
				if(g[i][j] == '#')continue;
				if(cost[x][y] + 1 < cost[i][j]){
//					cout << i << " " << j << endl;
					cost[i][j] = cost[x][y] + 1;
					q.push({i, j});
				}
			}
		}
	}
	
	if(cost[dh][dw] == INT_MAX){
		cout << "-1";
		return;
	}
	cout << cost[dh][dw];
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cout << fixed << setprecision(10);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


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

int main(){
  int N, M;
  cin >> N >> M;
  
  int n=0, m=0;
  
  for (int i=1 ; i<N ; i++)
    n += i;
  for (int i=1 ; i<M ; i++)
    m += i;
  
  cout << n+m << endl;
}

Measured memory_bytes: 3648
#include <cstdio>

constexpr int MAX_N = 500;
constexpr int MAX_M = 10000;

int N, M;
int e[MAX_N][MAX_N];
bool flag[MAX_N] = {false};

int dfs(int n = 0, int depth = 0){
	if(depth == 2){
		if(flag[n]){
			return 0;
		}
		else{
			flag[n] = true;
			return 1;
		}
	}


	int res = 0;
	if(!flag[n]){
		++res;
		flag[n] = true;
	}

	for(int i = 0; i < N; ++i){
		if(e[n][i]){
			res += dfs(i, depth + 1);
		}
	}

	return res;
}

int main(){
	while(true){
		scanf("%d%d", &N, &M);
		if(N == 0 && M == 0){
			break;
		}

		for(int i = 0; i < N; ++i){
			flag[i] = false;
			for(int j = 0; j < N; ++j){
				e[i][j] = false;
			}
		}
		flag[0] = true;
		
		for(int i = 0; i < M; ++i){
			int a, b;
			scanf("%d%d", &a, &b);
			--a, --b;
			e[a][b] = e[b][a] = true;
		}

		printf("%d\n", dfs());
	}
	return 0;
}

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    int N;
    cin >>N;
    bool is=false;
    int ans;
    for(int i=1;i<=9;i++){
        if(N<=111*i){
            ans=111*i;
            break;
        }
    }

    cout << ans <<endl;
    return (0);
}

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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int MOD = (1e9)+7;
const int N = 200005;

signed main()
{
    int M = 2019;
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n;
        string s;
        cin>>s;
        n = s.length();
        int dp[2][M];
        memset(dp,0,sizeof(dp));
        int ans = 0;
        for(int i=1;i<=n;i++)
        {
            for(int j=0;j<M;j++)dp[i%2][j]=0;
            dp[i%2][s[i-1]-'0']++;
            for(int j=0;j<M;j++)dp[i%2][((j*10)+s[i-1]-'0')%M]+=dp[(i-1)%2][j];
            ans+=dp[i%2][0];
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3760
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define rep(i,st,ed) for (int i=st;i<=ed;++i)
#define drp(i,st,ed) for (int i=st;i>=ed;--i)
#define lowbit(x) (x&-x)
#define fi first
#define se second

typedef std:: pair <int,int> pair;
const int MOD=1000000007;
const int N=200005;

struct data {int x,v,id;} r[N];

int s[N<<1],f[N],n;

pair p[N];

int read() {
	int x=0,v=1; char ch=getchar();
	for (;ch<'0'||ch>'9';v=(ch=='-')?(-1):(v),ch=getchar());
	for (;ch<='9'&&ch>='0';x=x*10+ch-'0',ch=getchar());
	return x*v;
}

void upd(int &x,int v) {
	x+=v; (x>=MOD)?(x-=MOD):0;
}

void add(int x,int v) {
	for (;x<=n;x+=lowbit(x)) upd(s[x],v);
}

int get(int x) {
	int res=0;
	for (;x;x-=lowbit(x)) upd(res,s[x]);
	return res;
}

int ask(int l,int r) {
	int tmp=get(r)-get(l-1)+MOD;
	(tmp>=MOD)?(tmp-=MOD):0;
	return tmp;
}

bool cmp1(data a,data b) {
	return a.x<b.x;
}

bool cmp2(data a,data b) {
	return a.v<b.v;
}

bool cmp3(pair a,pair b) {
	return (a.se!=b.se)?(a.se<b.se):(a.fi<b.fi);
}

int main(void) {
	n=read();
	rep(i,1,n) r[i].x=read(),r[i].v=read();
	std:: sort(r+1,r+n+1,cmp2);
	rep(i,1,n) r[i].id=i;
	std:: sort(r+1,r+n+1,cmp1);
	int mn=n+1,mx=0;
	rep(i,1,n) {
		mx=std:: max(mx,r[i].id);
		p[r[i].id].se=mx;
	}
	drp(i,n,1) {
		mn=std:: min(mn,r[i].id);
		p[r[i].id].fi=mn;
	}
	std:: sort(p+1,p+n+1,cmp3);
	rep(i,1,n) {
		if (p[i].fi==1) upd(f[i],1);
		int tmp=ask(std:: max(1,p[i].fi-1),p[i].se);
		upd(f[i],tmp);
		add(p[i].se,f[i]);
	}
	printf("%d\n", ask(n,n));
	return 0;
}

Measured memory_bytes: 6400
n, m = map(int, input().split())
a_list = list(map(int, input().split()))
bc_list = [list(map(int, input().split())) for _ in range(m)]
a_list.sort()
bc_list.sort(key=lambda i: -i[1])

a_idx = 0
bc_idx = 0
while bc_idx < len(bc_list):
    b, c = bc_list[bc_idx]
    finish = False
    for _ in range(b):
        if a_idx >= len(a_list):
            finish = True
            break
        if c > a_list[a_idx]:
            a_list[a_idx] = c
            a_idx += 1
        else:
            finish = True
            break
    if finish:
        break
    bc_idx += 1

print(sum(a_list))


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

int32_t main()
{
	int n,wt;
	cin>>n>>wt;
	vector<int> w(n),v(n);
	for(int i=0; i<n; i++)
		cin>>w[i]>>v[i];
	vector< vector<int> > dp(wt+1,vector<int>(n+1,0));
	for(int j=0; j<n; j++)
	{
	for(int i=1; i<=wt; i++)
	{
			dp[i][j+1]=dp[i][j];
			if(i-w[j]>=0)
			dp[i][j+1]=max(dp[i][j+1],dp[i-w[j]][j]+v[j]);
		}
	} 
	cout<<dp[wt][n];
	return 0;
}


Measured memory_bytes: 83840
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main() {
  long long N,a,b,c,d;
  cin>>N;
  a=N%11;
  b=(N/11)*2;
  c=b+1;
  d=c+1;
  if(a==0)
  cout<<b<<endl;
  else if(a<=6)
  cout<<c<<endl;
  else
  cout<<d<<endl;}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    use std::cmp::min;
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let a: u8 = read(&mut stdin_lock, &mut buf, b' ');
    let b: u8 = read(&mut stdin_lock, &mut buf, b'\n');
    let av = vec![char::from(0x30 + a); b as usize];
    let bv = vec![char::from(0x30 + b); a as usize];
    let s: String = av.into_iter().collect();
    let t: String = bv.into_iter().collect();
    println!("{}", min(s, t));
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

int main(){
  ll N, A, B;
  cin >> N >> A >> B;
  A -= B;
  vector<int> h(N);
  rep(i, N)
    cin >> h[i];

  auto check = [=](int n) {
    ll cnt = 0;
    rep(i, N)
      cnt += max(((h[i]-B*n)+A-1)/A, 0LL);
    return cnt <= n;
  };

  int l = 1e9, r = 0;
  while(l-r > 1) {
    int mid = (l+r)/2;
    if(check(mid))
      l = mid;
    else
      r = mid;
  }
  cout << l << endl;
  return 0;
}

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


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

    int n;
    cin>>n;
    double a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    double ans = 0;
    for(int i=0;i<n;i++){
        ans += (double)1/a[i];
    }
    ans = (double)1/ans;
    printf("%.12f",ans);

}

Measured memory_bytes: 256
#pragma region
#ifndef LOCAL_DEBUG
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif

#include <assert.h>
#include <math.h>

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <vector>
#define pb push_back
#define f(i, a, b) for (int i = a; i < b; i++)
#define revf(i, b, a) for (int i = b; i >= a; i--)
#define all(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define revsrt(v) sort(v.rbegin(), v.rend())
#define sp << ' ' <<
#define en << '\n'
#define precision(x) cout << fixed << setprecision(x);
#define fio                \
  ios::sync_with_stdio(0); \
  cin.tie(0);              \
  cout.tie(0);

using namespace std;

template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &v) {
  os << "{" << v.first << ", " << v.second << "}" en;
  return os;
}

template <typename T>
ostream &operator<<(ostream &os, set<T> &v) {
  for (T t : v) os << t << " ";
  os en;
  return os;
}

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  for (T t : v) os << t << " ";
  os en;
  return os;
}

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  int n = v.size();
  for (int i = 0; i < n; i++) is >> v[i];
  return is;
}

#define int long long
#define pii pair<int, int>
#define float long double
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define vvpii vector<vpii>
#pragma endregion

int mod = 1e9 + 7;  // 998244353;
const int MAX = 1e5 + 5;

void preprocessing() {}

void solvetestcase() {
  int n;
  cin >> n;
  vi v(n), pre(n + 1, 0);
  cin >> v;
  f(i, 1, n + 1) pre[i] = (pre[i - 1] + v[i - 1]) % mod;
  int ans = 0;

  f(i, 0, n) { ans = (ans + (pre[i] * v[i]) % mod) % mod; }
  cout << ans en;
}

#undef int
int main() {
  fio;
  preprocessing();

  int t = 1;
  // UNCOMMENT FOR TESTCASES	\
	cin >> t;

  f(T, 1, t + 1) {
    // UNCOMMENT FOR CODEJAM,HACKERCUP	\
		cout << "Case #" << T << ": ";
    solvetestcase();
    cout.flush();
  }

  return 0;
};

/*
    AUTHOR:     KUNAL TAWATIA
    EDUCATION:  INDIAN INSTITUTE OF TECHNOLOGY, JODHPUR
*/


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

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

	int n;cin>>n;
	string s;cin>>s;
	int ans=0;
	for(int l=0,r=n-1;l<r;){
		if(s[l]=='W'){
			if(s[r]=='R'){
				swap(s[l],s[r]);
				ans++;
				l++;
			}

			r--;
		}else{
			l++;
		}
	}

	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 3704
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var k, x int
	fmt.Scan(&k, &x)

	min := x - k + 1
	var result []int
	for ; min < x+k; min++ {
		result = append(result, min)
	}

	for _, v := range result {
		fmt.Printf("%v ", strconv.Itoa(v))
	}
}


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

using namespace std;

bool ok(string s) {
  int h = s.size() / 2;
  for (int i = 0; i < h; i++) {
    if (s[i] != s[h + i]) {
      return false;
    }
  }
  return true;
}


int main() {
  string S;
  cin >> S;

  for (int i = S.size() - 2; i >= 2; i-=2) {
    if(ok(S.substr(0, i))) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

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

using namespace std;
using ll =long long;
constexpr int mod = 1e9+7;
constexpr int md = mod;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k;
    string s;
    cin>>n>>k>>s;
    vector<int> v;
    int cur = 1;
    int count = 0;
    for(int i=0;i<n;++i){
        if(s.substr(i,1) == to_string(cur)){
            count++;
        }else{
            cur ^= 1;
            v.push_back(count);
            count = 1;
        }
    }
    if(count != 0) v.push_back(count);
    if(v.size()%2 == 1)v.push_back(0);
    int l,r;
    l = r = 0;
    int sum = 0;
    int ans = 0;
    for(int i=0;i<(int)v.size();i+=2){
        int nextl = i;
        int nextr = min(i + 2*k,(int)v.size()-1);
        while(l < nextl) sum-=v[l],l++;
        while(r <= nextr) sum+= v[r],r++;
        ans = max(ans , sum);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1020