akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> p(M);
    vector<string> S(M);
    vector<bool> AC(N, false);
    vector<ll> cnt_WA(N, 0);
    rep(i, M)
    {
        cin >> p[i] >> S[i];
        if (!AC[p[i] - 1])
        {
            if (S[i] == "WA")
            {
                cnt_WA[p[i] - 1]++;
            }
            else
            {
                AC[p[i] - 1] = true;
            }
        }
    }
    ll cnt_AC = 0, cnt_WA_final = 0;

    rep(i, N)
    {
        if (AC[i])
        {
            cnt_AC++;
            cnt_WA_final += cnt_WA[i];
        }
    }
    cout << cnt_AC << " " << cnt_WA_final;

    return 0;
}

Measured memory_bytes: 7296
import sys
def input():
	return sys.stdin.readline().strip()

N, Z, W = list(map(int, input().split()))
a = list(map(int, input().split()))

dp = [[0]*(N + 1) for i in range(N + 1)]
dp[0][N] = abs(a[N-1] - Z)
dp[N][0] = abs(a[N-1] - W)
for i in range(1, N):
	dp[i][N] = abs(a[N - 1] - a[i - 1])
	dp[N][i] = dp[i][N]

for i in range(N - 1, 0, -1):
	min_score = min(dp[i][i + 1: N + 1])
	for j in range(i - 1):
		dp[i][j] = min_score
	max_score = 0
	for j in range(i + 1, N + 1):
		max_score = max(max_score, dp[j][i])
	for j in range(i - 1):
		dp[j][i] = max_score

score = 0
for i in range(1, N + 1):
	score = max(score, dp[i][0])

print(score)

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

int main() {
  int n; cin >> n;
  int ans = 1;
  while (ans <= n) {
    ans *= 2;
  }
  cout << ans / 2 << endl;
  return 0;
}

Measured memory_bytes: 3524
#include <iostream>
using namespace std ;
int main()
{
  int N ;
  cin >> N ;
  
  int L[2*N] ;
  int nL[N] ;
  int sum = 0;
  
  for(int i=0; i<2*N; i++){
    cin >> L[i] ;
  }
  for(int j=0; j<2*N; j++){
   for(int m=j+1; m<2*N; m++){
     if(L[m]<L[j]){
       int Ls = L[m] ;
       L[m] = L[j] ;
       L[j] = Ls ;
     }
   }
  }
  for(int k=0; k<N; k++){
    nL[k] = L[2*k] ;
  }
  for(int l=0; l<N; l++){
    sum += nL[l] ;
  }
   cout << sum <<endl ;
  
  return 0 ;
}

Measured memory_bytes: 256
n, y = map(int, input().split())
for i in range(n + 1):
    for j in range(n - i + 1):
        if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
            print(i, j, n - i - j)
            exit()
print("-1 -1 -1")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
long long f[200001]={0};
char s[200001];
int main()
{
	int n,i;
    long long sum=0;
	scanf("%s",s);
	n=strlen(s);
	for(i=n-1;i>=0;i--)
	{
		f[i]=f[i+1];
		if(s[i]=='W')
			f[i]++;
	}
	for(i=0;i<n;i++)
		if(s[i]=='B')
			sum+=f[i];
	printf("%lld",sum);
	return 0;
}

Measured memory_bytes: 2048
#include <iostream>
using namespace std;
int count(int x, int c){
    if(x >= 500){
        return count(x-500, c+1);
    }
    if(x >= 100){
        return count(x-100, c+1);
    }
    if(x >= 50){
        return count(x-50, c+1);
    }
    if(x >= 10){
        return count(x-10, c+1);
    }
    if(x >= 5){
        return count(x-5, c+1);
    }
    if(x == 0){
        return c;
    }
    else {
        return count(x-1,c+1);
    }
}

int main (void){
    int x;
    while (true){
        cin >> x;
        if(x == 0) {
            break;
        }
        cout << count(1000 - x, 0) << endl;
    }
}


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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    
    for (int i = 1; i <= B; ++i) {
        if (A*i%B == C) {//iをなんでBまで回すのか不明
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define pb push_back
using namespace std;

int main(){
   int n;
   int sum=0;
   cin >> n;
   vector<int> a(n);
   for(int i=0;i<n;i++){
       cin >> a[i];
   }
   sort(a.begin(),a.end());
   for(int i=0;i<(n-1);i++){
       sum += a[i];
   }
   if(a[n-1] < sum) cout << "Yes" << endl;
   else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    string s;
    cin >> s;
    ll n = s.size();
    ll m = n/2;

    string x = s.substr(0, m);
    string y = s.substr(m+1, m);
    
    // sが回文かどうか判定
    rep(i, n/2) {
        if(s[i] != s[(n-1) - i]) {
            out("No");
            re0;
        }
    }

    // xが回文かどうか判定
    rep(i, m/2) {
        if(x[i] != x[(m-1) - i]) {
            out("No");
            re0;
        }
    }
    
    // yが回文かどうか判定
    rep(i, m/2) {
        if(y[i] != y[(m-1) - i]) {
            out("No");
            re0;
        }
    }

    out("Yes");
    re0;
}

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

#define ll long long


bool turn(string &s,int k){

    int n,i,bit = 0;

    n = s.size();

    int b;

    int u = k-1;

    int v = s[k]-'0';

    
    for(i= u;i>=0;--i){
        
        if(i+k-1<n){

            
            if(s[u]!= s[i])return 0;

            return 1;
        }
        if(s[i]!= s[u])return 0;
    }
    return 1;
    
}

int main(){
    string s;
    cin>>s;
    int n = s.size();
    int l =1, r = n, mid;

    while(l<r){
        mid = (l+r+1)/2;

        if(turn(s,mid))
            l = mid;
        else
            r = mid-1;
    }
    cout<<l<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

ll gcd(ll a, ll b){
    ll num1, num2;
    num1 = max(a, b);
    num2 = min(a, b);
    if(num1 % num2 == 0){
        return num2;
    }
    return gcd(num1 % num2, num2);
}

int main() {
    ll N, M, n, m, d;
    ll ans;
    string S, T;
    cin >> N >> M >> S >> T;

    d = gcd(N, M);
    n = N / d;
    m = M / d;

    bool hasAns = true;
    rep(i, d){
        if(S[i * n] != T[i * m]){
            hasAns = false;
            break;
        }
    }
    if(hasAns){
        ans = N * M / d;
    } else {
        ans = -1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll fact[500000];

ll comb(ll a, ll b) {
  ll ue=fact[a], shita1=1, shita2=1;
  ll tmpshita1, tmpshita2;
  ll two, h;
  h = mod - 2;
  while(h>0) {
    two = 1;
    tmpshita1 = fact[b];
    tmpshita2 = fact[a-b];
    while(2*two<h) {
      two *= 2;
      tmpshita1 *= tmpshita1;
      tmpshita2 *= tmpshita2;
      tmpshita1 %= mod;
      tmpshita2 %= mod;
    }
    h -= two;
    shita1 *= tmpshita1;
    shita2 *= tmpshita2;
    shita1 %= mod;
    shita2 %= mod;
  }
  return ue*shita1%mod*shita2%mod;
}

int main() {
  fact[0] = 1;
  for(ll i=1;i<500000;++i) {
    fact[i] = fact[i-1]*i%mod;
  }
  ll N, M;
  cin>>N>>M;
  vector<ll> prime;
  map<ll, int> amap;
  for(ll i=2;i*i<=M;++i) {
    if(M%i==0) prime.push_back(i);
    while(M%i==0) {
      amap[i]++;
      M /= i;
    }
  }
  if(M>1) prime.push_back(M);
  amap[M]++;
  ll ans = 1;
  for(int i=0;i<prime.size();++i) {
    ans *= comb(amap[prime[i]]+N-1, amap[prime[i]]);
    ans %= mod;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 7528
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).expect("read a line");
    let mut buffer: Vec<char> = Vec::with_capacity(10);
    for c in s.trim().chars() {
        match c {
            '0' => buffer.push(c),
            '1' => buffer.push(c),
            'B' => {
                buffer.pop();
                ()
            }
            _ => panic!("unexpected char"),
        }
    }
    print!("{}", buffer.into_iter().collect::<String>());
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
 
using namespace std;
 
#define MP make_pair
#define PB push_back
typedef long long LL;
typedef pair<int,int> PII;
const double eps=1e-8;
const double pi=acos(-1.0);
const int K=1e6+7;
const int mod=1e9+7;
 
int n,a,b,c,ans;
 
int main(void)
{
    scanf("%d",&n);
    for(int i=1,x;i<=n;i++)
    {
        scanf("%d",&x);
        if(x%4==0) c++;
        else if(x%2==0) b++;
        else a++;
    }
    c-=a;
    if(c>=0||(c==-1&&b==0)) puts("Yes");
    else    puts("No");
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split())) 
B = list(map(int, input().split())) 
C = list(map(int, input().split())) 

ans = 0

for i in range(N):
    ans += B[A[i]-1]
    if i>0:
        if A[i] - A[i-1] == 1:
            ans += C[A[i]-2]

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i< (n);i++)
#define rep1(i,n) for(int i=1;i<= (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

const static ll MOD = (1e+9)+7;

int main(){
    ll n,m;cin>>n>>m;
    ll sum = 0;
    rep(i,m){
        ll tmp;cin>>tmp;
        sum+=tmp;
    }
    if(sum > n){
        cout<<-1<<endl;
    }else{
        cout<<n-sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 3632
X = int(input())
if 400 <= X <= 599:
  print(8)
elif 600 <= X <= 799:
  print(7)
elif 800 <= X <= 999:
  print(6)
elif 1000 <= X <= 1199:
  print(5)
elif 1200 <= X <= 1399:
  print(4)
elif 1400 <= X <= 1599:
  print(3)
elif 1600 <= X <= 1799:
  print(2)
elif 1800 <= X <= 1999:
  print(1)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, k;
    cin >> a >> b >> k;
    int c = gcd(a, b);
    int cnt = 0;
    for(int i = 100; i >= 1; i--) {
        if(c % i == 0) cnt++;
        if(cnt == k) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3664
#include <iostream>
#include <iomanip>
#include <math.h>
#include <vector>
#include <map>
using namespace std;
int main() {
  int A, B;
  cin >> A >> B;
  if (A <= 9 && B <= 9) {
	  cout << A * B << endl;
	}
  else {
	  cout << -1 << endl;
	}
  return 0;
}


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

#define st first
#define nd second
#define make_pair com
#define sz(x) ((int)x.size())
#define mem(x, v) memset(x, v, sizeof(x))
#define rep(x, n) for (int x = 0      ; x <  (n); ++x)
#define per(x, n) for (int x = (n) - 1; i >= 0  ; --x)
#define exc(x, a, b) for (auto x = (a); x <  (b); ++x)
#define inc(x, a, b) for (auto x = (a); x <= (b); ++x)
#define cxe(x, a, b) for (auto x = (b) - 1; x >= (a); --x)
#define cni(x, a, b) for (auto x = (b)    ; x >= (a); --x)
#define debug(x) cerr <<__LINE__ << " " << #x << " = " << x << endl;

using namespace std;

const int mod = (int) 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef double dbl;
typedef pair<int, int> mti;

namespace math {
  inline void add(int &a, int b, int p = mod) {
    a + b >= p ? a = a + b - p : a = a + b;
  }
  inline void sub(int &a, int b, int p = mod) {
    a - b < 0 ? a = a - b + p : a = a - b;
  }
  inline int mul(int a, int b, int p = mod) {
    return (long long) a * b % p;
  }
  inline int modexp(int a, int x, int p = mod) {
    int res = 1;
    for (; x; x >>= 1) {
      if (x & 1) {
        res = mul(res, a, p);
      }
      a = mul(a, a, p);
    }
    return res;
  }
};
using namespace math;

namespace io {
  template <typename T = int>
  inline T read() {
    T x = 0;
    int f = 1;
    char ch = cin.get();
    for (; !isdigit(ch) && !cin.eof(); cin.get(ch)) {
      f = (ch == '-') ? -1 : 1;
    }
    for (; isdigit(ch) && !cin.eof(); cin.get(ch)) {
      x = x * 10 + ch - '0';
    }
    return f * x;
  }

  template <typename T = int>
  inline void write(T x, char ch = '\n') {
    static char stk[255];
    static int top = 0;
    if (x < 0) {
      cout.put('-');
      x = -x;
    }
    if (x == 0) {
      cout.put('0');
      cout.put(ch);
      return;
    }
    top = 0;
    while (x) {
      stk[top++] = x % 10 + '0';
      x /= 10;
    }
    while (top) {
      cout.put(stk[--top]);
    }
    cout.put(ch);
  }
}
using namespace io;

template <typename T>
vector<T>& operator << (vector<T> &v, T x) {
  return v.push_back(x), v;
}

const int N = 2e5 + 5;

int n;
int k;
int a[N];

long long sum[N];
int id[N];

bool cmp(const int &a, const int &b) {
  ll va = sum[a] - (long long) a * k;
  ll vb = sum[b] - (long long) b * k;
  return va == vb ? a < b : va < vb;
}

class fenwick {
public:

  int a[N];

  void add(int x) {
    ++x;
    for (; x <= n; x += x & -x) {
      a[x]++;
    }
  }

  int sum(int x) {
    int res = 0;
    ++x;
    for (; x; x -= x & -x) {
      res += a[x];
    }
    return res;
  }
} f;

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

  n = read();
  k = read();
  rep (i, n) {
    a[i] = read();
  }
  sum[0] = a[0];
  exc (i, 1, n) {
    sum[i] = sum[i - 1] + a[i];
  }
  rep (i, n) {
    id[i] = i;
  }
  sort(id, id + n, cmp);

  ll ans = 0;

  rep (i, n) {
    int v = id[i];
    ans = ans + f.sum(v);
    if (sum[v] / (v + 1) >= k) {
      ++ans;
    }
    f.add(v);
  }
  write(ans);
  
  flush(cout);
  return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#endif


typedef long long ll; 
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
 
#define mp make_pair
#define pb push_back

void solve() {
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  if (s[0] == s[2]) cout << "No"; else cout << "Yes";
}
 
int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
 
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stack>
#include<queue>
#define LL long long
using namespace std;
int n,k,tot,x,ans,tt;
int a[1011];
priority_queue<int, vector<int>, greater<int> > q;
int read()
{
	int _=0,__=1;char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-')__=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){_=_*10+ch-'0';ch=getchar();}
	return _*__;
}
int main()
{
	n=read();k=read();
	for(int i=1;i<=n;i++)
	a[i]=read();
	for(int i=0;i<=min(n,k);i++)
	{
		for(int j=0;(i+j)<=min(n,k);j++)
		{
			tot=max(0,k-(i+j));tt=0;
			for(int g=1;g<=i;g++)
			q.push(a[g]);
			for(int g=1;g<=j;g++)
			q.push(a[n-g+1]);
			while(!q.empty())
			{
				x=q.top();
				q.pop();
				if(x<0&&tot>0)
				tot--;
				else
				tt+=x;
			}
			ans=max(ans,tt);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  long long res = 0;

  res = K * pow(K - 1, N - 1);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    vector<int> ans(s.size()-2);
    for (int i = 0; i < s.size()-2; i++){
        int n;
        string temp;
        temp = s.at(i);
        temp+= s.at(i+1);
        temp+= s.at(i+2);
        n = stoi(temp);
        ans.at(i) = abs(n - 753);
    }
    sort(ans.begin(), ans.end());//小さい順に並べる
    cout << ans.at(0) << endl;
}

Measured memory_bytes: 3580
import fractions as f

A, B, C, D = list(map(int, input().split()))
A = A - 1
lcmCD = C * D // f.gcd(C, D)
underB = B - B // C - B // D + B // lcmCD
underA = A - A // C - A // D + A // lcmCD
print(underB - underA)


Measured memory_bytes: 5048
# -*- coding: utf-8 -*-
import bisect

# input
S = input()
# S = "abcdefghijklmnopqrstuvwzyx"
# S = "atcoder"
# S = "qpwoeirutyalskdjfhgzmxnvcb"

s = list(S)
a = []
for i in range(len(s)):
    a.append(ord(s[i]))

t = [chr(i) for i in range(97, 97+26)]
b = [i for i in range(97, 97+26)]


# function
def func(s_):
    ss_ = []
    for i in range(len(s_)):
        ss_.append(chr(s_[i]))
    ss_ = ''.join(ss_)
    return ss_


# solve
if (len(s) < 26):
    for i in range(len(s)):
        b.remove(a[i])
    a.append(min(b))
    print(func(a))

if (len(s) == 26):
    for i in reversed(range(len(s))):
        if (a[i] < a[i-1]):
            if (i == 1):
                print(-1)
                break
            else:
                continue
        else:
            c = a[0:i]
            d = a[i:len(a)]
            d = sorted(d)
            # a[i-1]よりも大きくて最も小さいものを探す
            num = c.pop()
            ind = bisect.bisect_left(d, num)
            c.append(d[ind])
            print(func(c))
            break


Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510;
const int MOD = 1000000007;

// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll d[MAX][MAX];
bool maze[MAX][MAX];

void dfs(ll x , ll y){
  ll z = d[x][y] + maze[x][y];
  // 距離が減るところをdfsで減らす
  rep(i,4){
    ll nx = x + dx[i];
    ll ny = y + dy[i];
    if(nx < 0 or ny < 0) continue;
    if(d[nx][ny] > z){
      d[nx][ny] = z;
      dfs(nx , ny);
    }
  }
}

int main(){
  ll N; cin >> N;
  ll ans = 0;
  // 外周までの距離の初期設定
  rep(i,N) rep(j,N) d[i][j] = min( min(i, j) , min(N - i - 1 , N - j - 1) );
  // pの入力
  vector<ll> p(N * N); rep(i,N * N) cin >> p[i]; rep(i, N * N) p[i]--;
  // 表示用
  // rep(i,N){ rep(j,N) { cout << d[i][j] << " "; } cout << endl; }
  // mazeの初期化、最初は全部通れない
  rep(i,MAX) rep(j,MAX) maze[i][j] = true;
  // dfsの操作
  rep(i, N * N){
    ll x = p[i] / N;
    ll y = p[i] % N;
    ans += d[x][y];
    // cout << i << " " << x << " " << y << " " << ans << endl;
    maze[x][y] = false;
    dfs(x, y);
  }
  cout << ans << endl;
}


Measured memory_bytes: 22900
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


int T, n, m, to[10101], f[404];
vector<int> v[404];
vector<P> G[404];
vector<vector<int>> dist(404, vector<int>(404, INF));
vector<int> route[404][404];
int now_t = 0;

void floyd(){
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			for(int k = 1; k <= n; k++){
				if(dist[j][k] > dist[j][i] + dist[i][k]){
					//route[j][k] = route[j][i]+route[i][k];
					route[j][k] = route[j][i];
					route[j][k].insert(route[j][k].end(),route[i][k].begin(),route[i][k].end());
					dist[j][k] = dist[j][i] + dist[i][k];
				}
			}
		}
	}
}

void input(){
	int a,b,c;
	cin >> a;
	for(int i = 0; i < a; i++){
		cin >> b >> c;
		v[c].push_back(now_t);
		to[now_t] = c;
	}
	cin >> a;
	for(int i = 0; i < a; i++){
		cin >> b;
	}
	now_t++;
}

void result(){
	string s;
	int a,b;
	cin >> s;
	cin >> a;
	for(int i = 0; i < a; i++){
		cin >> b;
	}
}

int main(){
	cin >> n >> m;
	for(int i = 0; i <= n; i++){
		dist[i][i] = 0;
	}
	for(int i = 0; i < m; i++){
		int a,b,c;
		cin >> a >> b >> c;
		G[a].push_back(P(b,c));
		G[b].push_back(P(a,c));
		dist[a][b] = c;
		dist[b][a] = c;
		route[a][b].push_back(b);
		route[b][a].push_back(a);
	}
	for(int i = 1; i <= n; i++){
		cin >> f[i];
	}
	cin >> T;
	
	floyd();
	
	input();
	
	int now = 1, next = 0;
	int have[404] = {0};
	for(int t = 0; t < T; t++){
		
		if(now == 1) have[to[t]]++;
		if(next > t) continue;
		
		int k, ma = -1;
		for(int i = 2; i <= n; i++){
			if(!have[i]) continue;
			if(dist[1][i] >= T-t) continue;
			int cnt = 0;
			for(int j = 0; j < route[1][i].size(); j++){
				cnt += have[route[1][i][j]];
			}
			if(ma < cnt * 1000 / dist[1][i]){
				ma = cnt;
				k = i;
			}
		}
		
		if(ma >= 1){
			next = t + dist[1][k]*2;
			int cnt = t;
			for(int j = 0; j < route[1][k].size(); j++){
				int npos = route[1][k][j];
				have[npos] = 0;
				for(int i = 0; i < dist[now][npos]; i++){
					if(cnt >= T) break;
					cnt++;
					cout << npos << endl;
					result();
					if(cnt != T) input();
				}
				now = npos;
			}
			for(int i = route[1][k].size()-2; i >= -1; i--){
				int npos;
				if(i == -1) npos = 1;
				else npos = route[1][k][i];
				for(int j = 0; j < dist[now][npos]; j++){
					if(cnt >= T) break;
					cnt++;
					cout << npos << endl;
					result();
					if(cnt != T) input();
				}
				now = npos;
			}
		}
		else{
			cout << -1 << endl;
			result();
			if(t != T-1) input();
		}
	}
	
	return 0;
}

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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

const int N = 1e5;
const int MOD = 1e9 + 7;

void add(int &x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
}
int mul(int a, int b) {
  return (a * 1LL * b) % MOD;
}
int binpow(int a, ll n) {
  int res = 1;
  while (n) {
    if (n & 1)
      res = mul(res, a);
    a = mul(a, a);
    n >>= 1;
  }
  return res;
}

int dp[401][401]; // pos, cnt
int a[401], b[401];

void solve() {
  int n, c; cin >> n >> c;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
  }
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int newcnt = 0; newcnt <= c; newcnt++) {
      int res = 0;
      for (int v = a[i]; v <= b[i]; v++) {
        add(res, binpow(v, newcnt));
      }
      for (int lastcnt = 0; lastcnt + newcnt <= c; lastcnt++) {
        add(dp[i][lastcnt + newcnt], mul(res, dp[i - 1][lastcnt]));
      }
    }
  }
  cout << dp[n][c];
}

// CHECK LIMITS (n <= 10^5)
// CHECK CORNER CASES (n == 1)

int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(20);
  //cout << 1.0 * clock() / CLOCKS_PER_SEC << endl;
  solve();
}


Measured memory_bytes: 4248
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t % mod;
    } else {
        return modpow(m, n - 1) * m % mod;
    }
}
long long power(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

const ll INF = 1LL << 60;

string change_binary(long long a) {
    string ret;
    for (int i = 31; i >= 0; i--) {
        ret += (a >> i & 1) + '0';
    }
    return ret;
}

ll nCkmod(ll n, ll k) {
    ll denomi = 1;
    for (int i = n; i > n - k; i--) {
        denomi *= i;
        denomi %= mod;
    }
    ll numera = 1;
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}
map<pair<char, char>, ll> cnt;
int main() {
    ll n, m;
    cin >> n;
    cin >> m;
    vector<P> ab(n);
    REP(i, n) { cin >> ab[i].first >> ab[i].second; }
    sort(ab.begin(), ab.end());
    ll x = 0;
    ll ans = 0;
    priority_queue<ll> pq;
    rep(i, 1, m + 1) {
        while (x < n && i == ab[x].first) {
            pq.push(ab[x].second);
            x++;
        }
        if (!pq.empty()) {
            ans += pq.top();
            pq.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5848
import java.util.*;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        long[] pos = new long[n];
        List<E>[] le = new List[n];
        List<E>[] re = new List[n];
        for(int i=0; i<n; i++) {
            pos[i] = Long.MAX_VALUE;
            le[i] = new ArrayList<E>();
            re[i] = new ArrayList<E>();
        }
        for(int i=0; i<m; i++) {
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            int d = sc.nextInt();
            E e = new E(l, r, d);
            le[l].add(e);
            re[r].add(e);
         }

         for(int i=0; i<n; i++) {
             if (pos[i] == Long.MAX_VALUE) {
                 Queue<Integer> q = new LinkedList<>();
                 q.add(i);
                 pos[i] = 0;
                 while (!q.isEmpty()) {
                     int a = q.poll();
                     for (E e : le[a]) {
                         if (e.v)
                             continue;
                         e.v = true;
                         if (pos[e.r] == Long.MAX_VALUE) {
                             q.add(e.r);
                             pos[e.r] = pos[a] + e.d;
                         } else {
                             if (pos[a] + e.d != pos[e.r]) {
                                 System.out.println("No");
                                 return;
                             }
                         }
                     }
                     for (E e : re[a]) {
                         if (e.v)
                             continue;
                         e.v = true;
                         if (pos[e.l] == Long.MAX_VALUE) {
                             q.add(e.l);
                             pos[e.l] = pos[a] - e.d;
                         } else {
                             if (pos[a] - e.d != pos[e.l]) {
                                 System.out.println("No");
                                 return;
                             }
                         }
                     }
                 }
             }
         }
         System.out.println("Yes");
    }

    private static class E {
        public int l;
        public int r;
        public int d;
        public boolean v = false;
        public E(int l, int r, int d) {
            this.l = l;
            this.r = r;
            this.d = d;
        }
    }
}


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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/

int main(){
    int n,m;cin>>n>>m;
    VP p(m);
    VP y(m);
    rep(i,m){
        cin>>p[i].first;
        cin>>y[i].first;
        y[i].second=i;
    }
    sort(ALL(y));
    V cnt(n);
    rep(i,m){
        int index=y[i].second;
        int city_num=p[index].first;
        p[index].second=cnt[city_num]++;
    }
    rep(i,m){
        cout<<setfill('0')<<setw(6)<<p[i].first<<setfill('0')<<setw(6)<<p[i].second+1<<endl;
    }
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define PI (acos(-1))
#define ct cout<<
#define cn cin>>
#define spc <<" "<<
#define nl puts("")
#define _fl(x) puts("FLAG " #x);
#define  _(x)  cout<< #x <<" is "<< x <<endl;
#define fs first
#define sc second
#define pb push_back
#define all(v)  (v).begin(), (v).end()
#define _109 (1000000000)
#define _0(arr) memset(arr,0,sizeof ( arr ) )
#define _1(arr) memset(arr,-1,sizeof ( arr ) )
#define _ninp(n,arr) for(int i=0; i<n;i++)cin>>arr[i];
#define _nout(n,arr) for(int i=0; i<n;i++)cout<<arr[i]<<" \n"[i==n-1];
double _eps=1e-6;
long long gcd(long long a, long long b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int cnt=0;
int giv;

void f(int i,int sz,bool fs,ll num){

   if(i==sz){
    cnt++;
    
    if(cnt==giv){
    	ct num;nl;
    	exit(0);
    }
    return;
   }
 
 if(fs){
   
    for(int k=1; k<=9; k++){
        
     ll nn=num*10+k;   
     f(i+1,sz,false,nn);
    }


 }
 else{
   
   int d=num%10;
   int u=d;
   if(u!=9)u++;

   if(d!=0)d-=1;

   for(int k=d; k<=u; k++){
     ll nn=num*10+k;   
     f(i+1,sz,false,nn);  
   }

 }



}


int main() {
   
   cn giv;


   for(int k=1; k<=10 ; k++){
       
       f(0,k,true,0);
   
   }


    return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr double DINF = 100000000000000000.0;
constexpr long long INF = 100000000000000000;
const double PI = acos(-1);

int ans[100][100];
string maze[100];

int main() {
	int h, w;
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		cin >> maze[i];
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (maze[i][j] == '#') {
				for (int k = -1; k <= 1; k++) {
					for (int l = -1; l <= 1; l++) {
						if (k == l&&k == 0)continue;
						if (i + k < 0)continue;
						if (j + l < 0)continue;
						ans[i + k][j + l]++;
					}
				}
			}
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (maze[i][j] == '#')cout << '#';
			else cout << ans[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
#define n_max 100000
#define N_max 100


int main()
{
	int c[3][3];	

	for(int i = 0; i < 3; i ++) {
		cin >> c[i][0] >> c[i][1] >> c[i][2];
	}
	
	for(int a1 = 0; a1 <= 100; a1++) { 
		if((c[0][0] - a1) <= 100 && (c[0][0] - a1) >= 0) {
				int b1 = c[0][0] - a1;
				int b2 = c[0][1] - a1;
				int b3 = c[0][2] - a1;
				int a2 = c[1][1] - b2;
				int a3 = c[2][2] - b3;
				#if 0
				cout << "b1" << b1 << endl;
				cout << "b2" << b2 << endl;
				cout << "b3" << b3 << endl;
				cout << "a2" << a2 << endl;
				cout << "a3" << a3 << endl;
				#endif
				if((a2 + b1 == c[1][0]) &&
				   (a2 + b3 == c[1][2]) &&
				   (a3 + b1 == c[2][0]) &&
				   (a3 + b2 == c[2][1])   ) {
				   cout << "Yes" << endl;
				   return 0;
				}
		}
	}

	cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n];
        int ans = 0;
        for(int i = 0; i < n; i++){
            a[i] = scanner.nextInt();
            ans ^= a[i];
        }
        if(ans == 0){System.out.println("Yes");}
        else{System.out.println("No");}
    }
}



Measured memory_bytes: 51084
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007
//#define mod 998244353

int X,Y,Z,K;
int A[1005];
int B[1005];
int C[1005];
vector<int> AB;
vector<int> ABC;
signed main(){
    scanf("%lld %lld %lld %lld",&X,&Y,&Z,&K);
    rep(i,X)scanf("%lld",&A[i]);
    rep(i,Y)scanf("%lld",&B[i]);
    rep(i,Z)scanf("%lld",&C[i]);
    sort(A,A+X);
    sort(B,B+Y);
    sort(C,C+Z);
    rep(i,X){
        rep(j,Y){
            AB.pb(A[i]+B[j]);
        }
    }
    sort(AB.begin(),AB.end(),greater<int>());
    rep(i,min(K,(int)AB.size())){
        rep(j,Z){
            ABC.pb(AB[i]+C[j]);
        }
    }
    sort(ABC.begin(),ABC.end(),greater<int>());
    rep(i,K){
        printf("%lld\n",ABC[i]);
    }
    return 0;
}

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

int main() {
  //d = i - 100*(10-k)
  //i = d + 100*(10-k)
  int k, d;
  cin >> k >> d;
  cout << (k < 10 ? d + 100*(10-k) : d) << '\n';
  return 0;}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define BUF_SIZE 5
int main(void) {
  FILE *fp = stdin;
  int map[101] = {0};
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  int num, i;
  sscanf(line, "%d", &num);

  int res = 0;
  for(i = 0; i < num; i++) {
    if(!fgets(line, BUF_SIZE, fp)) return 0;
    int n;
    sscanf(line, "%d", &n);
    if(!map[n]) res++;
    map[n]++;
  }
  printf("%d\n", res);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;

    vector<int> num{a,b,c};
    sort(num.begin(),num.end());

    cout << num[2]*10+num[1]+num[0] << endl;

    return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        a: usize,
        b: usize
    }
    if a == b || n == 2 {
        println!("{}", 1);
        return;
    }
    if a > b || n == 1 {
        println!("{}", 0);
        return;
    }
    println!("{}", (b - a) * (n - 2) + 1);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
bool compare_by_b(pair<pair<string,int>,int > a, pair<pair<string,int>,int > b) {
  if(a.first.first != b.first.first){
    return a.first.first < b.first.first;
  }else{
    if(a.first.second != b.first.second){
        return a.first.second > b.first.second;
    }else{
        return a.first.first < b.first.first;
    }
  }

}
signed main()
{
int x=0,y=0,z=0,w=0,n=0,m=0,a=0,b=0;
std::cin >> x;
std::vector< pair<pair<string,int>,int > > v(x);
rep(i,x){
  std::cin >> v[i].first.first>>v[i].first.second;
  v[i].second = i+1;
}
sort(all(v),compare_by_b);
rep(i,x){
  std::cout <<v[i].second<< '\n';
}
return 0;
}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
constexpr ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }

int n, m;
int a[1005], d[1005];
int dp[(1 << 12) + 5];
void solve() {
    cin >> n >> m;
    rep(i, m) {
        int b; cin >> a[i] >> b;
        rep(j, b) { int c; cin >> c; d[i] |= 1 << (c - 1); }
    }

    int e = 1 << n;
    fill((int*)dp, (int*)(dp + e), iinf);
    dp[0] = 0;
    rep(i, m) rep(s, e) {
        mins(dp[s | d[i]], dp[s] + a[i]);
    }

    if (dp[e - 1] != iinf) cout << dp[e - 1] << endn;
    else cout << -1 << endn;
}

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


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
    public static void main(final String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int D = in.nextInt();
		int X = in.nextInt();
		
		int[] ans = new int[11];
		ans[0] = X;
		
		for(int i = 1;i < 11;i++) {
			ans[i] = ans[i-1]*N-D;
			System.out.println(ans[i]);
		}
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
    // cin.tie(nullptr); ios::sync_with_stdio(false);
    int n; cin >> n;
    lint m; cin >> m;
    V<lint> l(n), r(n);
    for (int i = 0; i < n; ++i) {
        cin >> l[i] >> r[i];
    }
    auto vl = l, vr = r;
    auto v = l;
    v.insert(end(v), begin(r), end(r));
    sort(begin(v), end(v));
    v.erase(unique(begin(v), end(v)), end(v));
    for (auto&& e : l) {
        e = lower_bound(begin(v), end(v), e) - begin(v);
    }
    for (auto&& e : r) {
        e = lower_bound(begin(v), end(v), e) - begin(v);
    }
    for (auto&& e : vl) {
        e = lower_bound(begin(v), end(v), e) - begin(v);
    }
    for (auto&& e : vr) {
        e = lower_bound(begin(v), end(v), e) - begin(v);
    }
    sort(begin(vl), end(vl));
    sort(begin(vr), end(vr));

    map<int, int> mp;
    for (int i = 0; i < n; ++i) {
        mp[l[i]] = max<lint>(mp[l[i]], r[i]);
    }

    m = v.size() - 1;
    // cerr << m << endl;
    int x = 0, p = 0;
    auto itr = begin(mp);
    while (p < m) {
        int np = p;
        while (itr != end(mp) and itr->first <= p) {
            np = max(np, itr->second);
            ++itr;
        }
        p = np;
        // cerr << np << endl;
        ++x;
    }
    int y = 0;
    for (int i = 0; i < m; ++i) {
        int z = upper_bound(begin(vr), end(vr), i) - begin(vr);
        z += end(vl) - lower_bound(begin(vl), end(vl), i + 1);
        y = max(y, z);
        // cerr << i << ' ' << z << endl;
    }
    cout << x << ' ' << y + 1 << '\n';
}


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

int main(){
    int X, Y;
    cin >> X >> Y;
    if(Y % 2 == 1) cout << "No" << endl;
    else if(Y < 2 * X) cout << "No" << endl;
    else if(Y > 4 * X) cout << "No" << endl;
    else cout << "Yes" << endl;
}

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

long long dp[31];
int main(){
	
	dp[0]=0;
	dp[1]=1;
	dp[2]=2;
    dp[3]=4;
int i=4;
	while(i<31){
		dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
        //cout << i << endl;
        i++;
	}
    for(;;){
	int n;
	cin >> n;
    if(n==0)return 0;
     if(dp[n]%3650==0)
	   cout << (dp[n]/3650) << endl;
     else
       cout << (dp[n]/3650)+1 << endl;
}
}

Measured memory_bytes: 1152