akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int a[N],n,num;
long long  ans=0;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++) 
		{
			cin>>a[i];
			a[i]-=i;
		}
    sort(a+1,a+n+1);
	num=a[(n+1)/2];
    for(int i=1;i<=n;i++) 
		ans+=abs(num-a[i]);
    cout<<ans<<endl;
    return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const ll MAX = 10000;
static const ll INFTY = 1e12;

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

// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
using P = pair<ll, ll>;
// 入力
// 入力
ll h, w;
ll startX, startY, endX, endY;
vector<vector<char>> s;
vector<vector<ll>> cnts; // 魔法使った回数


int main() {

  ll N, Y;
  cin >> N >> Y;

  REP(i, N+1){
    ll M = N - i;
    REP(j, M+1){
      ll k = M - j;
      if(10000 * i + 5000 * j + 1000 * k == Y){
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
   
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

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

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> memoA(n+1,0), memoB(n+1,0), memoC(n+1,0);
    int a,b,c;
    for(int i = 1; i <= n; ++i) {
        cin >> a >> b >> c;
        memoA[i] = max(memoA[i], a + memoB[i-1]);
        memoA[i] = max(memoA[i], a + memoC[i-1]);
        memoB[i] = max(memoB[i], b + memoA[i-1]);
        memoB[i] = max(memoB[i], b + memoC[i-1]);
        memoC[i] = max(memoC[i], c + memoA[i-1]);
        memoC[i] = max(memoC[i], c + memoB[i-1]);
    }
    cout << max(memoA[n], max(memoB[n], memoC[n])) << '\n';
    return 0;
}


























Measured memory_bytes: 2560
#include <stdio.h>
int main()
{
	int p,q,r;
	scanf("%d%d%d",&p,&q,&r);
  
  int arr[3],l,i;
   arr[0]=p+q;
   arr[1]=q+r;
   arr[2]=r+p;
   
    l=arr[0];
   for(i=0;i<3;i++)
   {
   	  if(l>arr[i])
   	  l=arr[i];
   }
   printf("%d",l);
}

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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
typedef long long ll;
typedef vector<int> vi;typedef vector<vi> vvi;typedef pair<int,int> pii;typedef vector<pii> vpii;

void Main() {
  int N;
  scanf("%d", &N);
  vi A(N);
  rep(i, N) scanf("%d", &A[i]);

  ll ans = 0;
  rep(i, N) {
    ll add = A[i] / 2;
    ans += add;
    A[i] -= add * 2;
    if (i + 1 < N && A[i] && A[i+1]) {
      ans++;
      A[i]--;
      A[i+1]--;
    }
  }
  _p("%lld\n", ans);
}
int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll a;

int main()
{
  std::cin >> a;
  
  std::cout << a+a*a+a*a*a << std::endl;

  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define met(a,x) memset(a,x,sizeof(a))
#define inf 0x3f3f3f3f
using namespace std;
const int mod=1e9+7;
const int N=1e6+10;
int a[10010],b[10010],dp[10010][10010];
int v[100009];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int i,j,k,m;
    cin>>m;
    deque<pair<int, int> > q;
    met(v,0);
    q.push_back(make_pair(1,1));
    while(!q.empty())
    {
        pair<int, int> n=q.front();
        q.pop_front();
        if(v[n.first])
            continue;
        v[n.first] = 1;
        if(!n.first)
        {
            cout<<n.second<<endl;
            break;
        }
        q.push_front(make_pair(n.first*10 % m, n.second));
        q.push_back(make_pair((n.first+1) % m, n.second+1));
    }
    return 0;
}




Measured memory_bytes: 1536
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

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



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;




int main() {
	int x;
	cin >> x;
	if (x >= 30) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int n;
    cin >> n;

    int ans = 0, maxv = -1;
    rep(i, 0, n) {
        int h;
        cin >> h;
        if (maxv <= h) { ++ans; }
        maxv = max(maxv, h);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <map>
#include <queue>
using namespace std;
#define N 16

struct data{
  int f[N];
  int move;
  int m;
  int cost;

  bool operator < (const data &p) const {
    for(int i = 0;i < N;i++){
      if(f[i] == p.f[i]) continue;
      return f[i] < p.f[i];
    }
    return false;
  }
};

struct node{
  data puzzul;
  int e;
  
  bool operator < (const node &s) const {
      return e > s.e;
  }
};

static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};
static const char where[4] = {'r', 'u', 'l', 'd'};
int M[N][N];

int getmd(data);
int astar(data);

int main(){
  data a;
  int i,j;
  string c; ///////

  for(i = 0;i < N;i++){
    for(j = 0;j < N;j++){
      M[i][j] = abs(i / (N/4) - j / (N/4)) + abs(i % (N/4) - j % (N/4));
    }
  }
  for(i = 0;i < N;i++){
    cin >> a.f[i];
    if(a.f[i] == 0){
      a.f[i] = N;
      a.move = i;
    }
  }
  cout << astar(a) << endl;

  return 0;
}

int getmd(data p){
  int i,sum = 0;
  
  for(i = 0;i < N;i++){
    if(p.f[i] == N) continue;
    sum += M[i][p.f[i] - 1];
  }
    return sum;
}

int astar(data p){
  priority_queue<node> PQ;
  map<data,bool> V;
  data x,y; ////////x=u,y=v
  node ini;
  node pt,ne; ////st=pt
  int px,py,tx,ty,i;/////////////////
  p.m = getmd(p);
  p.cost = 0;
  ini.puzzul = p;
  ini.e = getmd(p);
  PQ.push(ini);
  
  while(!PQ.empty()){
    pt = PQ.top(); PQ.pop();
    x = pt.puzzul;
    if(x.m == 0) return x.cost;
    V[x] = 1;
    px = x.move / (N/4);
    py = x.move % (N/4);
    for(i = 0;i < 4;i++){
      tx = px + dx[i];
      ty = py + dy[i];
      if(tx < 0 || ty < 0 || tx >= (N/4) || ty >= (N/4)) continue;
      y = x;
      y.m -= M[tx * (N/4) + ty][y.f[tx * (N/4) + ty] - 1];
      y.m += M[px * (N/4) + py][y.f[tx * (N/4) + ty] - 1];
      swap(y.f[px * (N/4) + py],y.f[tx * (N/4) + ty]);
      y.move = tx * (N/4) + ty;
      if(!V[y]){
	y.cost++;
	ne.puzzul = y;
	ne.e = y.cost + y.m;
	PQ.push(ne);
      }
    }
  }
  return -1;
}



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

#define REP(i,s,n) for(int i=s; i<n; ++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

typedef long long ll;
typedef pair<int, int> ii;

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

  if(s[0] == s[1] && s[1] == s[2]) cout << "No" << endl;
  else cout << "Yes" << endl;

	return 0;
}


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

def main():
    sa = input().split(' ')
    N = int(sa[0])
    K = int(sa[1])
    sa = input().split(' ')
    A = [int(s) for s in sa]

    d = dict()
    for a in A:
        if a in d:
            d[a] = d[a] + 1
        else:
            d[a] = 1

    items = sorted(d.items(), key = lambda x:x[1], reverse = True)

    r = 0
    if K < len(items):
        n = 0
        for k in range(K):
            n += items[k][1]
        r = N - n

    print(r)


if __name__ == '__main__':
    main()


Measured memory_bytes: 52636
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#define ff first
#define ss second
#define M 1000000007
typedef long long int ll;
using namespace std;
ll power(ll a,ll b){
    ll ans = 1;
    while(b>0){
        if(b%2!=0){
            ans = ((ans)*(a));
        }
        a = ((a)*(a));
        b=b/2;
    }
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    vector <ll> a(n+1);
    for(ll i=1;i<=n;i++){
        cin>>a[i];
    }
    vector <vector <ll>> dp(n+1,vector <ll> (k+1,0));
    vector <vector <ll>> pre(n+1,vector <ll> (k+1,0));
    for(ll i=0;i<=n;i++){
        dp[i][0]=1;
        pre[i][0]=1;
    }
    pre[0][0]=1;
    for(ll j=1;j<=k;j++){
        pre[0][j]=1;
    }
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=k;j++){
            if(j-a[i]>=1){
                dp[i][j]=((pre[i-1][j])%M-(pre[i-1][j-a[i]-1])%M)%M;

            }
            else
                dp[i][j]=pre[i-1][j]%M;
            while(dp[i][j]>M)
                    dp[i][j]=dp[i][j]%M;
            if(dp[i][j]<0)
                dp[i][j]+=M;
            pre[i][j]=((dp[i][j]%M+pre[i][j-1]%M))%M;
            while(pre[i][j]>M)
                pre[i][j]=pre[i][j]%M;

        }
    }
    cout<<dp[n][k]<<endl;
    return 0;
}


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

int main(){
    string S; cin>>S;
    int size=S.size();
    int ans=0;
    for(int i=1;i<size;i++){
        if(S[i]==S[i-1]){
            if(S[i]=='0'){
                S[i]='1';
            }
            else{
                S[i]='0';
            }
            ans++;
        }
    }
    cout<<ans;
    return 0;
}

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

#define fi first
#define se second
#define forn(i,n) for(int i=0; i< (int)n; ++i)
#define for1(i,n) for(int i=1; i<= (int)n; ++i)
#define fore(i,l,r) for(int i=(int)l; i<= (int)r; ++i)
#define ford(i,n) for(int i=(int)(n) - 1; i>= 0; --i)
#define fored(i,l,r) for(int i=(int)r; i>= (int)l; --i)
#define pb push_back
#define el '\n'
#define d(x) cout<< #x<< " " << x<<el
#define ri(n) scanf("%d",&n)

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<char,int> pci;
typedef tuple<int, int, int> tiii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cout<< setprecision(20)<< fixed;
  double a, b;
  ll n;
  cin>> a>> b>> n;
  ll ans = -1;
  if(b>n){
    ans= n;
  }else{
    ans = (ll(b)-1)%n;
  }
  ans = floor(a*ans/b) - ll(a)*floor(double(ans)/b);
  cout<< ans<<el;
}




Measured memory_bytes: 3696
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 1e5 + 7;
ll i,n,a1, a2;
ll a[N], x[N], b[N];
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n;
    rep(i,1,n + 2){
        cin>>a[i];
        b[i] = a[i];
    }
    rep(i,1,n + 1){
        cin>>x[i];
        ll g = a[i] + a[i + 1];
        if(x[i] >= g){
            a1 += g;
            a[i + 1] = 0;
        }
        else{
            a1 += x[i];
            if(a[i] >= x[i])
                a[i] -= x[i];
            else
                a[i + 1] -= x[i] - a[i];
            
        }
    }
    revrep(i,n,1){
        ll g = b[i] + b[i + 1];
        if(x[i] >= g){
            a2 += g;
            b[i] = 0;
        }
        else{
            a2 += x[i];
            if(b[i + 1] >= x[i]) b[i + 1] -= x[i];
            else
                b[i] -= x[i] - b[i + 1];
        }
    }
    cout<<max(a1, a2);
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h> 
using namespace std;
 int main() {
 int N; 
cin >> N;
 vector<int> a(N);
vector<int> b(N);
vector<int> c(N-1);
for(int i=0;i<N;i++){
cin>>a.at(i);
}
for(int i=0;i<N;i++){
cin>>b.at(i);
}
for(int i=0;i<N-1;i++){
cin>>c.at(i);
}
int64_t ans=0;
for(int i=0;i<N;i++){
ans+=b.at(i);
}
for(int i=0;i<N-1;i++){
if(a.at(i)+1==a.at(i+1)){
ans+=c.at(a.at(i)-1);
}
}
cout<<ans;
 }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int countAB(string s){
  int N = s.size();
  int cnt = 0;
  rep(i,N-1){
    if (s.substr(i,2)=="AB") cnt++;
  }
  return cnt;
}

int main(){
  int N; cin >> N;
  int A=0, B=0, BA=0;
  int ans = 0;
  rep(i,N){
    string s;
    cin >> s;
    ans += countAB(s);
    if (s[0]=='B' && s[s.size()-1]=='A') BA++;
    else if (s[0]=='B') B++;
    else if (s[s.size()-1]=='A') A++;
  }
  
  if (A==0 && B==0) ans += max(0,BA-1);
  else ans += min(A,B) + BA;

  cout << ans << endl;
  






  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 3600
using System;
using static System.Console;

class Program
{
    public static void Main()
    {
	int n = int.Parse(ReadLine());
	int[] a = new int[n];

	for (int i = 0; i < n; i++)
	{
	    a[i] = int.Parse(ReadLine());
	}

	int cur = 1;
	for (int i = 0; i < n; i++)
	{
	    int next = a[cur - 1];
	    if (next == 2)
	    {
		WriteLine(i+1);
		return;
	    }
	    else
	    {
		cur = next;
	    }
	}

	WriteLine(-1);
    }
}


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

#define ll long long
#define ld long double
#define pb push_back
#define x first
#define y second
#define sz(v) (int)(v.size())
#define all(v) v.begin(),v.end()

using namespace std;

int main()
{
    //freopen("test.in","r",stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    int k; cin>>k;
    vector<string> v1,v2;
    if(k<10)
    {
        cout<<k;
        return 0;
    }
    for(int i=1;i<=9;i++) v1.pb(to_string(i));
    int i=9;
    while(1)
    {
        v2.clear();
        for(string s:v1)
        {
            int x=s.back()-'0';
            if(x!=0)
            {
                i++;
                v2.pb(s+to_string(x-1));
                if(i==k)
                {
                    cout<<v2.back();
                    return 0;
                }
            }
            i++;
            v2.pb(s+to_string(x));
            if(i==k)
            {
                cout<<v2.back();
                return 0;
            }
            if(x!=9)
            {
                i++;
                v2.pb(s+to_string(x+1));
                if(i==k)
                {
                    cout<<v2.back();
                    return 0;
                }
            }
        }
        v1=v2;
    }
    return 0;
}


Measured memory_bytes: 4600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    int a, b, c; cin >> a >> b >> c;
    if(a < b and b < c) cout << "Yes" << endl;
    else cout <<"No" << endl;
}


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

typedef long long ll;
typedef pair <int , int> pii;
typedef long double ld;

const int N = 5e5+10 , mod = 1e9+7;

vector <int> col[N];
vector <pii> v[N];
int c[N] , fen[N] , ans[N] , cur[N];

void add(int x , int val){
   for( ; x < N ; x += x & -x)
      fen[x] += val;
}

int get(int x){
   int ret = 0;
   for( ; x ; x -= x & -x)
      ret += fen[x];
   return ret;
}

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int n , q;
   cin >> n >> q;
   for(int i = 1 ; i <= n ; i++){
      cin >> c[i];
      if(col[c[i]].empty())
         add(i , 1);
      col[c[i]].push_back(i);
   }
   for(int i = 0 ; i < q ; i++){
      int l , r;
      cin >> l >> r;
      v[l].push_back({r , i});
   }
   for(int i = 1 ; i <= n ; i++){
      for(pii x : v[i])
         ans[x.second] = get(x.first);
      add(i , -1);
      cur[c[i]]++;
      if(cur[c[i]] < col[c[i]].size()){
         add(col[c[i]][cur[c[i]]] , 1);
      }
   }
   for(int i = 0 ; i < q ; i++)
      cout << ans[i] << "\n";
   return 0;
}


Measured memory_bytes: 60672
n,x,y=map(int,input().split())
ans=[0]*(n-1)
for i in range(n):
  for j in range(i+1,n):
    nagasa=min(abs(j-i),(abs(x-(i+1))+1+abs((j+1)-y)),(abs(y-(i+1))+1+abs((j+1)-x)))
    #print(i,j,nagasa)
    ans[nagasa-1]+=1
for i in range(n-1):
  print(ans[i])

Measured memory_bytes: 48476
SA = input()
SB = input()
SC = input()

A, B, C = len(SA), len(SB), len(SC)
a, b, c = 1, 0, 0
s = SA[0]

while True:
  if s == 'a':
    if a < A:
      s = SA[a]
      a += 1
    else:
      print("A")
      break
    
  elif s == 'b':
    if b < B:
      s = SB[b]
      b += 1
    else:
      print("B")
      break
  else:
    if c < C:
      s = SC[c]
      c += 1
    else:
      print("C")
      break

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

int main(){
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> vecA(M);
  for(int i=0; i<M; i++){
    cin >> vecA.at(i);
  }
  vector<vector<int>> vecB(N,vector<int>(M));
  for(int j=0; j<N; j++){
    for(int k=0; k<M; k++){
    cin >> vecB.at(j).at(k);
    }
  }
  
  int count = 0;
  for(int l=0; l<N; l++){
    int ans = 0;
    for(int m=0; m<M; m++){
      ans = ans + (vecA.at(m) * vecB.at(l).at(m));
    }
    ans = ans + C;
    if(ans > 0){
      count++;
    }
  }  
  cout << count << endl;
}

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

int count(int n, int x) {
	int cnt = 0;
	for (int i = 1; i <= n - 2; i++) {
		for (int j = i + 1; j <= n - 1; j++) {
			for (int k = j + 1; k <= n; k++) {
				if (i + j + k == x)cnt++;
			}
		}
	}
	return cnt;
}
int main() {
	int n, x;
	while (1) {
		cin >> n >> x;
		if (n == 0 && x == 0)break;
		cout << count(n, x) << endl;
	 }
	return 0;
}

Measured memory_bytes: 3116
N, M, K = map(int, input().split())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))

S = 0
a_idx = 0
for a in A:
    if S + a > K:
        break
    S += a
    a_idx += 1

b_idx = 0
for b in B:
    if S + b > K:
        break
    S += b
    b_idx += 1

ans = a_idx + b_idx
while a_idx > 0:
    a_idx -= 1
    S -= A[a_idx]
    while b_idx < M and S + B[b_idx] <= K:
        S += B[b_idx]
        b_idx += 1
    ans = max(ans, a_idx + b_idx)
print(ans)


Measured memory_bytes: 39972
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define DEBUG(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int H, W; cin >> H >> W;
	int N; cin >> N;
	vector<int> v(N);
	vector<int> a;
	rep(i, N) {
		cin >> v[i];
		rep(j, v[i])
			a.push_back(i);
	}
	int vv[H][W];
	memr(vv, 0);
	bool rdir = true;
	int k = 0;
	rep(i, H){
		if(rdir){
			rep(j, W){
				vv[i][j] = a[k]+1;
				k++;
			}
		}
		else{
			rrep(j, W){
				vv[i][j] = a[k]+1;
				k++;
			}
		}
		rdir = !rdir;
	}

	rep(i, H){
		rep(j, W){
			if(j) cout << " ";
			cout << vv[i][j];
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
//long long num[100000];
int main(){
	int n,t;
	cin>>n>>t;
	int c[n],a[n],min=1001;
	for(int i=0;i<n;i++){
		cin>>c[i]>>a[i];
		if(a[i]<=t){
			int tmp=c[i];
			if(c[i]<min){
				min=c[i];
			}
		}
	}
	if(min==1001) cout<<"TLE"<<endl;
	else cout<<min<<endl;
	return 0;
}

Measured memory_bytes: 256
from fractions import gcd
n = int(input())
a = list(map(int,input().split()))
left,right = [a[0]]+[0]*(n-1),[0]*(n-1)+[a[n-1]]
arr = [0]*n
for i in range(0,n-1):
  left[i+1] = gcd(left[i],a[i+1])
  right[n-2-i] = gcd(right[n-1-i],a[n-2-i])
arr[0] = right[1]
arr[n-1] = left[n-2]
for i in range(1,n-1):
  arr[i] = gcd(left[i-1],right[i+1])
print(max(arr))


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



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

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define MX              200005
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // int t;
    // cin>>t;
    // while(t--){
    //     cout<<"h"<<endl;
    // }
    int n,m;cin>>n>>m;
    int a[n];int sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    int f=1;
    int x=sum/4;
    if(x*4!=sum)f=0;
    int d=(x)/m;//cout<<d<<endl;
    if(d*m!=x)f=0;
    sort(a,a+n);
    for(int i=n-1;i>=0;i--){
        if(f==1&&m>0){
            if(a[i]>=d)
            m--;

        }else if(f==0&&m>0){
            if(a[i]>d)m--;
        } else break;
    }
    if(m==0){
        cout<<"Yes"<<endl;
    }else cout<<"No"<<endl;

    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define ar array 
#define For(i,n) for(int i=0;i<n;i++)
const long mxN =5e5+2 ;
int n,q,a[mxN],ans[mxN];
ll st[4*mxN+1];
void upd(int l1,ll x ,int i=1,int l2=1,int r2=n){
  if(l2==r2){
    st[i]+=x;
    return ;
  }
  int m2 =(l2+r2)/2 ;
  if(l1<=m2)
    upd(l1,x,2*i,l2,m2);
  else
    upd(l1,x,2*i+1,m2+1,r2);
  st[i]=st[2*i]+st[2*i+1] ;
}
ll qry(int l1,int r1,int i=1,int l2=1,int r2=n){
  if(l1<=l2 && r1>=r2)
    return st[i] ;
  int m2=(l2+r2)/2 ;
  return (l1<=m2?qry(l1,r1,2*i,l2,m2):0) + (r1>m2?qry(l1,r1,2*i+1,m2+1,r2):0) ;
}
int main() {
  cin >> n >> q ;
  For(i,n)
    cin >> a[i] ;
  vector<ar<int,3>>Q ;
  For(i,q){
    int a,b;cin >> a >> b ;
    Q.push_back({a,b,i}) ;
  }
  sort(Q.begin(),Q.end(),[&](const ar<int,3> &i,const ar<int,3>&j){
    return i[1]<j[1] ;
  });
  map<int,int>mp;int c=0 ;
  For(i,n)mp[a[i]]=-1 ;
  for(int i=0;i<n;i++){
    if(mp[a[i]]!=-1)
      upd(mp[a[i]]+1,-1) ;
    mp[a[i]]=i ;
    upd(i+1,1);
    for(;Q[c][1]==i+1;c++)
      ans[Q[c][2]]=qry(Q[c][0],Q[c][1]) ;
  }
  For(i,q)
    cout << ans[i] <<endl ;
	return 0;
}

Measured memory_bytes: 45168
#include<stdio.h>
int main()
{
             int n,k,i,j,t,s=0;
                scanf("%d%d",&n,&k);
                int a[n];
             for(i=0;i<n;i++)
             {
                 scanf("%d",&a[i]);
             }
             for(i=0;i<n;i++)
             {
                 for(j=i+1;j<n;j++)
                 {
                     if(a[i]>a[j])
                     {
                         t=a[i];
                         a[i]=a[j];
                         a[j]=t;
                     }
                 }
             }
             for(i=0;i<k;i++)
             {
                 s+=a[i];
             }
             printf("%d\n",s);




    return 0;


}













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

using namespace std;

typedef long long ll;
typedef long double ld;

const int INF = (int) 1e9 + 123;
const ll LINF = (ll) 1e18 + 123;
const ld EPS = (ld) 1e-12;
const ll MOD = (ll) 1e9 + 7;

#define sz(x) (int) (x).size()
#define mp(x, y) make_pair(x, y)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lb(s, t, x) (int) (lower_bound(s, t, x) - s)
#define ub(s, t, x) (int) (upper_bound(s, t, x) - s)
#define rep(i, f, t) for (auto i = f; i < t; i++)
#define per(i, f, t) for (auto i = f; i >= t; i--)

ll power(ll x, ll y, ll mod = MOD) {
    if (y == 0) {
        return 1;
    }
    if (y & 1) {
        return power(x, y - 1, mod) * x % mod;
    } else {
        ll tmp = power(x, y / 2, mod);
        return tmp * tmp % mod;
    }
}

void add(ll &x, ll y, ll mod = MOD) {
    x += y;
    if (x >= mod) x -= mod;
    if (x < 0) x += mod;
}

ll sum(ll x, ll y, ll mod = MOD) {
    add(x, y, mod);
    return x;
}

ll mult(ll x, ll y, ll mod = MOD) {
    return (x * y) % mod;
}

ll div(ll x, ll y, ll mod) {
    return x * power(y, mod - 2, mod);
}

template<typename A, typename B> bool mini(A &x, const B &y) {
    if (y < x) {
        x = y;
        return true;
    }
    return false;
}

template<typename A, typename B> bool maxi(A &x, const B &y) {
    if (y > x) {
        x = y;
        return true;
    }
    return false;
}

template<typename T> void read(T first, T last) {
    while (first != last) {
        cin >> *(first++);
    }
}

template<typename T> void print(T first, T last) {
    while (first != last) {
        cout << *(first++) << " ";
    }
    cout << "\n";
}

void run();

#define TASK ""

int main() {
#ifdef LOCAL
    if (strlen(TASK) > 0) {
        cerr << "Reminder: you are using file i/o, filename: " TASK "!" << endl << endl;
    }
#endif
#ifndef LOCAL
    if (strlen(TASK)) {
        freopen(TASK ".in", "r", stdin);
        freopen(TASK ".out", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#endif
    cout << fixed << setprecision(12);
    run();
    return 0;
}

// == SOLUTION == //

void run() {
    map<int, int> cnt;
    int n;
    cin >> n;
    rep(i, 0, n) {
        int x;
        cin >> x;
        cnt[x]++;
    }
    ll ans = 0;
    multiset<ll> ok;
    ok.insert(0);
    ok.insert(0);
    for (auto &it : cnt) {
        rep(i, 0, it.second / 2) {
            ok.insert(it.first);
        }
    }
    multiset<ll> tmp = ok;
    for (ll x : tmp) {
        ok.erase(ok.find(x));
        maxi(ans, x * (*ok.rbegin()));
        ok.insert(x);
    }
    cout << ans << "\n";
}


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

const int maxn=1e5+100;
int dp[maxn],arr[maxn];

int main() {
	std::ios::sync_with_stdio(false);
	int N,K;
	cin >> N >> K;
	for(int i=1; i<=N; i++) {
		cin >> arr[i];
		dp[i] = 0x3f3f3f3f;
	}
	dp[0] = dp[1] = 0;
	for(int k=2; k<=N; k++)
		for(int i=min(k-1,K); i>0; i--) dp[k] = min(dp[k],dp[k-i]+abs(arr[k]-arr[k-i]));
	cout << dp[N] << endl;
	return 0;
}



Measured memory_bytes: 1024
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List
-- import qualified Data.Vector.Unboxed as VU
-- import qualified Data.Vector.Unboxed.Mutable as VUM
-- import Control.Monad
-- import Control.Monad.ST
-- import Debug.Trace
-- trace _ = id

c = 50

solve :: Int -> (Int, [Int])
solve bK = (c, replicate t (b+c+1) ++ replicate (c-t) b)
  where
  (s,t) = divMod bK c
  b     = c - 1 + s - t

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> (Int, [Int])
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_bK]:remLines1 = remLines0
      bK = readBInt bs_bK
  in solve bK

outAnswer :: (Int, [Int]) -> IO ()
outAnswer (n,as) = do
  putStrLn $ show $ n
  putStrLn $ unwords $ map show $ as

main :: IO ()
main = outAnswer . tmain =<< B.getContents


-------------------------------------------------------------------------------

inp1 = "0\n"
inp2 = "1\n"
inp3 = "2\n"
inp4 = "3\n"
inp5 = "1234567894848\n"
tv1 = tmain $ B.pack inp1
tv2 = tmain $ B.pack inp2
tv3 = tmain $ B.pack inp3
tv4 = tmain $ B.pack inp4
tv5 = tmain $ B.pack inp5



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

int main()
{
    ll h,w,i,j;
    cin>>h>>w;
    ll a[h][w],b[h][w];
    for(i=0;i<h;i++)
    {
        string s;
        cin>>s;
        for(j=0;j<w;j++)
        {
            if(s[j]=='.')
            {
                a[i][j]=0;
            }
            else
            {
                a[i][j]=1;
            }
        }
    }
    memset(b,0,sizeof(b));
    for(i=0;i<h;i++)
    {
        if(i==0)
        {
            b[i][0]=(a[i][j]+1)%2;
        }
        else
        {
            if(a[i][0]==0)
                b[i][0]=b[i-1][0];
        }
    }
    for(j=0;j<w;j++)
    {
        if(j==0)
        {
            b[0][j]=(a[i][j]+1)%2;
        }
        else
        {
            if(a[0][j]==0)
                b[0][j]=b[0][j-1];
        }
    }
    for(i=1;i<h;i++)
    {
        for(j=1;j<w;j++)
        {
            if(a[i][j]==0)
                b[i][j]=(b[i-1][j]+b[i][j-1])%1000000007;
        }
    }
    cout<<b[h-1][w-1]<<endl;
}

Measured memory_bytes: 15872
if __name__ == "__main__":
    while True:
        N = int(input())
        if N == 0:
            break
        L = []
        for i in range(N):
            l, p, a, b, c, d, e, f, s, m = input().split()
            L.append(
                [
                    l,
                    int(p),
                    int(a),
                    int(b),
                    int(c),
                    int(d),
                    int(e),
                    int(f),
                    int(s),
                    int(m),
                ]
            )
        income_efficiency = []
        for l in L:
            value = (l[7] * l[9]) * l[8] - l[1]
            need_time = (l[2] + l[3] + l[4]) + (l[5] + l[6]) * l[9]
            income_efficiency.append([l[0], value / need_time])

        income_efficiency.sort(key=lambda x: x[0])
        [
            print(ie[0])
            for ie in sorted(income_efficiency, key=lambda x: x[1], reverse=True)
        ]
        print("#")



Measured memory_bytes: 5628
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N, L;
    cin >>N>>L;
    string s[100];
    for(int i=0; i<N; ++i)
        cin>>s[i];
    sort(s, s+N);
    for(int i=0; i<N; ++i)
        cout <<s[i];
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define SZ 200005
#define INF 100000000000000LL
typedef long long ll;
typedef pair<ll, int> P;

struct edge
{
  int to, cost;
  edge(int to, int cost) : to(to), cost(cost) {}
};

int N, M;
vector<ll> dist(SZ), path(SZ);
vector<edge> E[SZ];

void dijkstra(int s)
{
  rep(i, N)
  {
    dist[i] = INF;
    path[i] = 0;
  }
  dist[s] = 0;
  path[s] = 1;

  priority_queue<P, vector<P>, greater<P>> Q;
  Q.push(P(0, s));

  while (!Q.empty())
  {
    P p = Q.top();
    Q.pop();

    int u = p.second;
    if (dist[u] < p.first)
      continue;

    rep(i, E[u].size())
    {
      edge e = E[u][i];
      if (dist[e.to] > dist[u] + e.cost)
      {
        dist[e.to] = dist[u] + e.cost;
        Q.push(P(dist[e.to], e.to));
        path[e.to] = path[u];
      }
      else if (dist[e.to] == dist[u] + e.cost)
      {
        path[e.to] += path[u];
        if (path[e.to] >= MOD)
          path[e.to] -= MOD;
      }
    }
  }
}

int main()
{
  int S, T;
  scanf("%d%d%d%d", &N, &M, &S, &T);
  S--, T--;
  rep(i, M)
  {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    a--, b--;
    E[a].push_back(edge(b, c));
    E[b].push_back(edge(a, c));
  }

  dijkstra(S);
  vector<ll> ds(dist);
  vector<ll> ps(path);
  dijkstra(T);
  vector<ll> dt(dist);
  vector<ll> pt(path);

  ll ans = ps[T] * pt[S] % MOD;
  ll len = ds[T];

  rep(i, N)
  {
    if (ds[i] + dt[i] == len && ds[i] == dt[i])
    {
      ll ex = ps[i] * pt[i] % MOD;
      ex = ex * ex % MOD;
      ans -= ex;
      if (ans < 0)
        ans += MOD;
    }
  }

  rep(i, N)
  {
    for (auto p : E[i])
    {
      int j = p.to;
      if (ds[i] + dt[j] + p.cost == len)
      {
        if (ds[i] * 2 < len && dt[j] * 2 < len)
        {
          ll ex = ps[i] * pt[j] % MOD;
          ex = ex * ex % MOD;
          ans -= ex;
          if (ans < 0)
            ans += MOD;
        }
      }
    }
  }

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


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

#define  vt            vector
#define  db            long double
#define  int           long long
#define  pb            push_back
#define  inf           (int)1e20
#define  mxn           (int)2e5+5
#define  pii           pair<int,int>
#define  pq            priority_queue

#define  si(x)         (int)x.size()
#define  all(x)        x.begin(),x.end()
#define  mem(a,x)      memset(a,x,sizeof(a))
#define  forr(i,n)     for(int i=0;i<n;i++)

#define deb(x)   cout<<"> "<<#x<<" : "<<x<<endl
#define pnr(a)   for(auto x:a){cout<<x<<" ";}cout<<endl;
#define pnr2(a)  for(auto x:a){cout<<x.first<<" "<<x.second<<endl;}

int mainx()
{
	int n , w;
	cin >> n >> w;
	int wt[n] , val[n];
	forr(i , n)
	{
		cin >> wt[i];
		cin >> val[i];
	}
	int dp[n + 1][w + 1];
	for (int i = 0 ; i <= n ; i++)
	{
		for (int j = 0 ; j <= w ; j++)
		{
			if (i == 0 or j == 0)
				dp[i][j] = 0;
			else if (wt[i - 1] > j)
				dp[i][j] = dp[i - 1][j];
			else
			{
				dp[i][j] = max(dp[i - 1][j] , dp[i - 1][j - wt[i - 1]] + val[i - 1]);
			}
		}
	}
	cout << dp[n][w] << endl;
	return 0;
}


inline void include() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt","w",stdout);
#endif
}
int32_t main() {
	//include();
	ios::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
	//cout << fixed << setprecision(20);

	int tt = 1;
	//cin>>tt;
	for (int t = 1 ; t <= tt ; t++ )
	{
		mainx();
	}
	return 0 ;
}


Measured memory_bytes: 82504
#include <bits/stdc++.h>
using namespace std;
#define PI (3.14159265358979323846)
#define ld long double
#define int long long
#define MOD 1000000007
#define w(x) int x; cin >> x; while(x--)
#define F first
#define S second
#define PB push_back
     
const char nl = '\n';
const int N = 1e4 + 5;


void solve(){
 
    string s; cin >> s;

    if(s[s.size()-1] == 's')
    {
        s += "es";
    }else s += "s";    

    cout << s << nl;

}   


int32_t main(){
         
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
        
    int t = 1;
    //cin >> t;
    while(t--) 
        solve();

}

Measured memory_bytes: 3656
using System;

class A {
  
  static void Main(string[] args) {
    var input = Console.ReadLine().Split();
    int a = int.Parse(input[0]);
    int b = int.Parse(input[1]);
    int x = int.Parse(input[2]);
    
    if (a <= x && x <= a+b) Console.WriteLine("YES");
    else Console.WriteLine("NO");
  }
}

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

int main() {
  int a, b, c, d, e;
  cin >> a >> b;
  c = a+b;
  d = a-b;
  e = a*b;
  if (c >= d && c >= e) {
  	cout << c << endl;
  } else if(d >= c && d >= e) {
  	cout << d << endl;
  } else if(e >= d && e >= c) {
  	cout << e << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	float t,x;
	cin>>t>>x;
	cout<<t/x<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n ; ++i)
const ll INF = 1e9;
const ll MOD = 1e9+7;
int main()
{
    ll N, T;
    cin >> N >> T;
    vector<ll> t(N);
    rep(i, N) { cin >> t[i]; }

    ll x = T;
    rep(i, N - 1) {
        x += min(t[i + 1] - t[i], T);
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
int d[6][4]={{2,3,5,4}, {1,4,6,3}, {1,2,6,5}, {1,5,6,2}, {1,3,6,4}, {2,4,5,3}};

struct dice{ int t,r; }; //topの数字、回転数
dice cube[3][3][3];
int t[3][3],f[3][3];
bool ans[55];

void solve(int x, int y, int z){
	if(z==3){
		int sum=0;
		REP(i,3) REP(j,3){
			sum += d[cube[2][i][j].t][(cube[2][i][j].r+1)%4];
		}
		ans[sum] = true;
		return;
	}
	
	int nx=x, ny=y, nz=z;
	if(x<2) nx++;
	else{
		nx = 0;
		if(y<2) ny++;
		else{ ny = 0; nz++; }
	}
	
	REP(top,6) REP(rot,4){
		//上面・前面不一致
		if(z==0 && t[y][x]!=0 && (top+1)!=t[y][x]) continue;
		if(y==2 && f[z][x]!=0 && d[top][rot]!=f[z][x]) continue;
		//隣接面不一致
		if(x!=0 && d[cube[x-1][y][z].t][(cube[x-1][y][z].r+1)%4]!=d[top][(rot+1)%4]) continue;
		if(y!=0 && d[cube[x][y-1][z].t][(cube[x][y-1][z].r)]!=d[top][rot]) continue;
		if(z!=0 && cube[x][y][z-1].t != top) continue;
		cube[x][y][z].t = top;
		cube[x][y][z].r = rot;
		solve(nx, ny, nz);
	}
}


int main(){
	int rep;
	cin >> rep;
	for(int r=0; r<rep; r++){
		memset(ans, 0, sizeof(ans));
		REP(i,3) REP(j,3) cin >> t[i][j];
		REP(i,3) REP(j,3) cin >> f[i][j];
		solve(0, 0, 0);
		bool nosol = true;
		REP(i,55){
			if(ans[i]) nosol = false;
		}
		if(nosol){
			cout << 0 << endl;
		}else{
			vector<int> a;
			REP(i,55){
				if(ans[i]) a.push_back(i);
			}
			REP(i, (int)a.size()-1) cout << a[i] << " ";
			cout << a[a.size()-1] << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3068
n = input()
X = set(map(int, input().split()))
E = [x for x in X if x % 2 == 0]
EE = [e for e in E if (e % 3 == 0 or e % 5 == 0)]
if len(E) == len(EE):
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 38384
N = int(input())
a = list(map(int, input().split()))
a = sorted(a)
sum1 = 0
sum2 = 0
for i in reversed(range(0,len(a))):
	if(i%2==0):
		sum1+=a[i]
	if(i%2==1):
		sum2+=a[i]
print(abs(sum1-sum2))

Measured memory_bytes: 3064
K,S = map(int,input().split())

count = 0
if S % 3 == 0:
    count += 1
for x in range(K):
    if 0 <= S-2*x and S-2*x <= K and x != S-2*x:
        count += 3
for x in range(K):
    for y in range(x+1,K):
        if y >= S-x-y:
            break
        elif 0 <= S-x-y and S-x-y <= K:
            count += 6

print(count)


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

int main(){//シーザー暗号
    int N;
    string S;
    cin >> N >> S;
    //ASCIIコード表を用いる。-26という数字は適当に方程式を書けば求められる。
    for(int i=0;i<S.size();i++){
        int c = static_cast<int>(S[i]);
        if(c+N > 90){
            cout << static_cast<char>(c+N-26);
        }else{
            cout << static_cast<char>(c+N);
        }
    }
}


Measured memory_bytes: 256
#include<stdio.h>
main(){
  int n;
  int a[100];
  int i,j,k;
  int key;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    printf("%d",a[i]);
    if(i==n-1){
      printf("\n");
    }else{
      printf(" ");
    }
  }
  for(i=1;i<n;i++){
    key = a[i];
    j = i - 1;
    while(j >= 0 && a[j] > key){
      a[j+1] = a[j];
      j --;
    }
    a[j+1] = key;
    for(k=0;k<n;k++){
      printf("%d",a[k]);
      if(k==n-1){
        printf("\n");
      }else{
        printf(" ");
      }
    }
  }
}

Measured memory_bytes: 1032
N,T = map(int,input().split())

intervals = [int(x) for x in input().split()]
intervals.sort()

# その区間のおかげで追加された部分を加算していく
answer = 0
prev = -10*T

for x in intervals:
  if x >= prev + T:
    # 完全新規
    answer += T
  else:
    answer += x-prev
  prev = x

print(answer)

Measured memory_bytes: 25196
import collections

# input
n, a = map(int, input().split())
X = [int(i) - a for i in input().split()]

sums = collections.Counter([0, X[0]])
# Xから1枚以上選んで作ることが可能な和:作り方の場合の数
# 1枚も選ばない＝0:1通り
# X[0]のみ選ぶ＝X[0]:1通り

for i in X[1:]: # 選べるカードを増やしていく (X[0] ~ X[i] から選ぶ)
    sums2 = collections.Counter()
    for s, c in sums.items():
        sums2[s + i] += c # X[0] ~ X[i - 1] で作れる和に X[i] を足す
    sums += sums2

print(sums[0] - 1) # 1枚も選ばないのはルール違反

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

#define v(type) vector<type>
#define p(type1, type2) pair<type1 , type2>
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    int n ;
    cin>>n;
    int a[n];
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    sort(a , a + n);
    int pre[n];
    pre[0] = a[0];
    for(int i = 1 ; i <n ; i++){
        pre[i] = pre[i-1] + a[i];
    }
    int sub = 0;
    for(int i = 0 ; i < n -1 ; i++){
        if(2 * pre[i] < a[i + 1])
            sub = i + 1;
    }
    cout<< n - sub<<endl;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int H, W; cin >> H >> W;
    vs C(H); REP(i, H) cin >> C[i];
    REP(i, H)
    {
        cout << C[i] << endl;
        cout << C[i] << endl;
    }
}

Measured memory_bytes: 3628