akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <iomanip>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll N;
    string S;
    cin >> N >> S;
    ll x = 0;
    ll M = 0;
    for (int i = 0; i < N; ++i) {
        if(S[i] == 'I'){
            x++;
        }else{
            x--;
        }
        M = max(x,M);
    }
    cout << M << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main()
{
    ll k, a, b;
    cin >> k >> a >> b;
    ll ans = 1;
    if(b - a <= 2) {
        ans += k; 
    }
    else {
        ans += a - 1;
        if((k - a + 1) % 2 == 1) {
            ans++;
            k--;
        }
        ans += (k - a + 1) / 2 * (b - a);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int n;
    cin >> n;
    vector<pii> a(n);
    rep(i, n) cin >> a[i].fi >> a[i].se;
    sort(all(a), [&](pii x, pii y){return x.fi + x.se < y.fi + y.se;});
    ll x = -INF;
    int ans = 0;
    rep(i, n) {
        if(x <= a[i].fi - a[i].se) {
            x = a[i].fi + a[i].se;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
  long long n, m, x;
  cin >> n >> m >> x;
  long long a[n], b[m];
  for(long long i = 0; i < n; i++) cin >> a[i];
  for(long long i = 0; i < m; i++) cin >> b[i];

  long long ans = 0, sum = 0, i = 0, j = 0;
  while(i < n && sum + a[i] <= x) {
    sum += a[i];
    i++;
  }
  ans = i;

  while(j < m) {
    sum += b[j];
    j++;
    while(sum > x && i > 0) {
      i--;
      sum -= a[i];
    }
    if(sum <= x && i + j > ans) ans = i + j;
  }

  cout << ans << endl;
}


Measured memory_bytes: 6724
class UnionFind:
    def __init__(self, n :int):
        self.d = [-1] * n

    def find(self, x :int) -> int:
        if self.d[x] < 0: return x
        return self.find(self.d[x])
    
    def unite(self, x, y :int):
        xr, yr = self.find(x), self.find(y)
        if xr == yr:
            return

        if -self.d[xr] < -self.d[yr]:
            xr, yr = yr, xr

        self.d[xr] += self.d[yr]
        self.d[yr] = xr

    def is_same(self, x, y :int) -> bool:
        return self.find(x) == self.find(y)

    def size(self, x :int) -> int:
        return - self.d[self.find(x)]


def main():
    n, m = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(m)]
    ab = [[a-1, b-1] for a, b in ab]

    uf = UnionFind(n)

    for a, b in ab:
        uf.unite(a, b)

    mx = 0
    for i in range(n):
        s = uf.size(i)
        if s > mx:
            mx = s

    print(mx)


if __name__ == "__main__":
    main()

Measured memory_bytes: 75664
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int n,l,r;
    while(cin >> n >> l >> r,n + l + r){
        vector<int> v(n);
        erep(e,v) cin >> e;
        int ans = 0;
        for(int num = l;num <= r;num++){
            bool flag = false;
            rep(i,v.size()){
                if(num % v[i] == 0){
                    flag = true;
                    ans += !(i%2);
                    break;
                }
            }
            if(flag == false){
                ans += !(n % 2);
            }
        }
        cout << ans << endl;
    }
}





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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli n,k;

int main(){
  cin >> n >> k;
  if(n%k == 0) cout << 0 << endl;
  else cout << 1 << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int X = sc.nextInt();

    int n = X/ 500;
    int count = 0;

    for(int i = 0 ;i <=n && i <= A ;i++){
      int XX = X -500 * i;
      int m = XX/100;
      for(int j = 0;j <= m && j <= B ;j++){
        int XXX = XX - 100 * j;
        if(XXX/50 <= C){
          int p = XXX/50;//使用した50円玉
          int q = j;//使用した100円玉
          int r = i;//使用した500円玉
          count += 1;
        }
      }
    }


  System.out.println(count);
  }
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &it: a) cin >> it;

    vector<int> dp(n);
    dp[0] = 0;
    dp[1] = abs(a[0]-a[1]);
    for (int i = 2; i < n; ++i) {
        dp[i] = min(dp[i-1] + abs(a[i]-a[i-1]), dp[i-2] + abs(a[i]-a[i-2]));
    }
    cout << dp[n-1] << endl;

    return 0;
}


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

#define mp make_pair
#define pb push_back
#define ll long long int
#define sd(x) scanf("%lld",&x)
#define inf 1e18+9
#define pll pair<ll,ll>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define bits(x) __builtin_popcountll(x)
#define ld long double
#define test() ll test; cin>>test; while(test--)
#define fi first
#define se second


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


inline ll GCD(ll x, ll y) {
    if(x<y) swap(x,y);
    if(x==0) return y;
    if(y==0) return x;
    return GCD(x%y,y);
}

ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while(n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if(n > 1)
        result -= result / n;
    return result;
}

ll power(ll x, ll n, ll mod) {
    ll res = 1;
    x %= mod;
    while(n) {
        if(n&1) {
            res = ((res*x)%mod+mod)%mod;
        }
        x = ((x*x)%mod+mod)%mod;
        n>>=1;
    }

    return res;
}


int main() {
    fastio;
    ll x;
    cin>>x;

    cout<<(x==0?1:0)<<endl;

}






Measured memory_bytes: 3648
#include<iostream>

using namespace std;

string toL(string in,int n){
  string out;
  for(int i = 0; i < in.length(); i++){
    if(in[i] == '_'){
      if(in[i+1] >= 'a' && in[i+1] <= 'z'){
	out += in[i+1]-('a' - 'A');
      }else out += in[i+1];
      i++;
    }else{
      //  if(in[i] >= 'A' && in[i] <= 'Z') out += in[i]+('a'-'A');
      //else out += in[i];
      out += in[i];
    }
  }
  if(n && out[0] >= 'A' && out[0] <= 'Z') out[0] += ('a'-'A');
  if(!n && out[0] >= 'a' && out[0] <= 'z' ) out[0] -= ('a'-'A'); 
  return out;
}

string toD(string in){
  string out;
  for(int i = 0; i < in.length(); i++){
    if(in[i] >= 'A' && in[i] <= 'Z'){
      if(i)out += "_";
      out += in[i] + ('a'-'A');
    }else out += in[i];
  }
  return out;
}
int main(){
  
  string in;
  char c;
  while(cin >> in >> c){
    if(c == 'X') break;
    if(c == 'L') in = toL(in,1);
    if(c == 'U') in = toL(in,0);
    if(c == 'D') in = toD(in);
    cout << in << endl;
  }
  return 0;
}

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

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
    int n, k;
    cin >> n >> k;

    int a;
    map<int, int> keymap;
    for(int i = 0; i < n; i++){
        cin >> a;
        keymap[a]++;
    }

    vector< pair<int, int> > P;
    pair<int, int> q;
    int type = keymap.size();
    for(auto itr = keymap.begin(); itr != keymap.end(); ++itr) {
        q.first =  itr->second;
        q.second = itr->first;
        P.push_back(q);
    }

    /*for(int i = 0; i < type; i++){
        cout << P[i].first << " " << P[i].second << endl;
    }*/

    sort(P.begin(), P.end());

    /*for(int i = 0; i < type; i++){
        cout << P[i].first << " " << P[i].second << endl;
    }*/

    int ans = 0;
    for(int i = 0; i < type - k; i++){
        ans += P[i].first;
    }

    cout << ans << endl;

}

Measured memory_bytes: 11768
using System;

namespace B___Snake_Toy
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var n = int.Parse(input[0]);
            var k = int.Parse(input[1]);
            var input1 = Console.ReadLine().Split(' ');
            var l = new int[n];
            var ans = 0;
            for (var i = 0; i < n; i++)
            {
                l[i] = int.Parse(input1[i]);
            }
            Array.Sort(l);
            Array.Reverse(l);
            for (var i = 0; i < k; i++)
            {
                ans += l[i];
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
def getNum():
    N,Z,W = map(int,input().split())
    cards = input()
    cards = cards.split()
    return N,Z,W,cards

def cal(N,Z,W,cards):
    if len(cards) > 1:
        cand1 = abs(W - int(cards[-1]))
        cand2 = abs(int(cards[-1]) - int(cards[-2]))
        if cand1 >= cand2:
            print(cand1)
        else:
            print(cand2)
    else:
        print(abs(W - int(cards[-1])))

def main():
    N,Z,W,cards = getNum()
    cal(N,Z,W,cards)

main()


Measured memory_bytes: 3188
import collections
n = int(input())
v = list(map(int,input().split()))
v1 = []
v2 = []
for i in range(n):
    if i % 2 == 0:
        v1.append(v[i])
    else:
        v2.append(v[i])
c1 = collections.Counter(v1)
c2 = collections.Counter(v2)
c1Common = c1.most_common(2)
c2Common = c2.most_common(2)
answer = 0
if c1Common[0][0] != c2Common[0][0]:
    c1Count = n // 2 - c1Common[0][1]
    c2Count = n // 2 - c2Common[0][1]
    answer = c1Count + c2Count
else:
    c1Count = n // 2 - c1Common[0][1]
    c2Count = n // 2 - c2Common[0][1]
    if len(c1Common) > 1:
        c1Count2 = n // 2 - c1Common[1][1]
    else:
        c1Count2 = n // 2
    if len(c2Common) > 1:
        c2Count2 = n // 2 - c2Common[1][1]
    else:
        c2Count2 = n // 2
    case1 = c1Count + c2Count2
    case2 = c2Count + c1Count2
    if case1 < case2:
        answer = case1
    else:
        answer = case2
print(answer)

Measured memory_bytes: 23528
#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include <cstdio>
#include <cstdint>
#define READINTA(X) while((ct=readchar())>='0')(X)=(X)*10+ct-'0';
#define READINTB(X) while((ct=*ci++)>='0')(X)=(X)*10+ct-'0';
using namespace std;

uint16_t d, k;
uint32_t M = 0;
int_fast64_t c, sd = 0, sc = 0;
const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;

inline char readchar() {
    if(ci-cn==cm){fread_unlocked(cn,1,cm,stdin);ci=cn;}
    return *ci++;
}

int main() {
    READINTA(M);
    while(M--) {
        c = 0;
        if(ci-cn+20>cm) {
            d = readchar() - '0';
            readchar();
            READINTA(c);
        } else {
            d = *ci++ - '0';
            ci++;
            READINTB(c);
        }
        sc += c;
        sd += c * d;
    }
    printf("%lld\n", --sc + --sd / 9);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FLASH ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"

int32_t main()
{
    FLASH;
    int a,b;
    cin>>a>>b;
    int count=0,c;
    c=b;
    while(b!=0)
    {
        count++;
        b=b/10;
    }
    int x=a*pow(10,count)+c;
    int f=0;
    for(int i=0;i<10000;i++)
    {
        if(i*i==x)
            {
                f=1;
                break;
            }
    }
    if(f==1)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }

}

Measured memory_bytes: 3864
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

struct UnionFind {
  vector<int> d;
  UnionFind(int n = 0) : d(n, -1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -d[find(x)]; }
};

int main(void) {
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    uf.unite(a, b);
  }
  int ans = 0;
  rep(i, n) ans = max(ans, uf.size(i));
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF = 1e9+7;
ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ii,ll>
#define iiii pair<ii,ii>
#define f(i,a,b) for(long long i = a;i < b;i++)
#define rf(i,a,b) for(long long i=a;i>=b;i--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define w(t) while(t--)
#define c(n); cin>>n;
#define p(n) cout<<n;
#define pl(n) cout<<n<<endl;
#define ps(n); cout<<n<<" ";
#define F first
#define S second
#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()
#define ull unsigned long long
#define vll vector<ll>
#define vii vector<ii>
#define mkp make_pair
#define ld long double
#define arrin(a,n) f(i,0,n){cin>>a[i];}
#define arrout(a,n) f(i,0,n){cout<<a[i]<<" ";}
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define PI (2*acos(0))
const long long N = 1e6+5;
vll visit,dist,taken;
vector<vll> adj;
vector<vii> adj2;
priority_queue<ii,vector<ii>, greater<ii> > pq;
ll bit[N]={0};
ll siz;
ll res = 0;
ll lcm(ll a,ll b){return (a * b) / __gcd(a,b);}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll power(ll a,ll b){if(b == 0)return 1;if(b == 1)return a;ll ans = power(a,b/2) % MOD;ans *= ans;ans %= MOD;if(b % 2 == 1)ans *= a;return ans%MOD;}
ll inverse(ll x){x%=MOD;return power(x,MOD-2);}
void BITup(ll k, ll x){while(k <= siz){bit[k]+=x;k += k & -k;}}
ll BITq(ll k){ll s=0;while(k>=1){s+=bit[k];k -= k &-k;}return s;}
struct node{ll lazy,val;}seg[4000000];
struct point{ll x,y;};
void dfs(ll v){visit[v] = 1;for(auto x:adj[v]){if(!visit[x])dfs(x);}}
void bfs(ll s){visit[s] = 1;queue<ll>q;q.push(s);while(!q.empty()){ll u = q.front();ps(u);q.pop();for(auto x:adj[u]){if(!visit[x]){visit[x] = 1;q.push(x);}}}}
void dijkstra(ll s){pq.push(ii(0,s));dist[s] = 0;while(!pq.empty()){ii f = pq.top();pq.pop();ll w = f.F;ll u = f.S;if(w > dist[u]){continue;}for(auto v:adj2[u]){if(dist[u] + v.S < dist[v.F]){dist[v.F] = dist[u] + v.S;pq.push(ii(dist[v.F],v.F));}}}}
void prim(ll edge) {taken[edge] = 1;for(auto v:adj2[edge]) {if (taken[v.first]==0)pq.push(ii(v.second, v.first));}}
ll mst(ll s){taken.assign(N, 0);prim(s);ll cost = 0;while(!pq.empty()){ii front = pq.top();pq.pop();ll w = front.first;ll u = front.second;if(taken[u]==0)cost += w;prim(u);}return cost;}
void YESNO(ll a){if(!!a){pl("YES");}else{pl("NO");}}
void filesin(void){freopen("input.in","r",stdin);}
void filesout(void){freopen("output.out","w",stdout);}
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Educational DP Contest
int main(void){
    fastio;
    ll n,k;
    c(n);
    INF = 1e18;
    c(k);
    ll arr[n];
    arrin(arr,n);
    ll dp[n+5];
    f(i,0,n+5){
        dp[i] = INF;
    }
    dp[0] = 0;
    dp[1] = 0;
    f(i,1,n+1){
        f(j,1,k+1){
            if(i + j <= n){
                dp[i+j] = min(dp[i+j],dp[i] + abs(arr[i-1] - arr[i+j-1]));
            }
        }
    }
    pl(dp[n]);
}


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

main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	char wo[200];
	scanf("%s",wo);
	int len=strlen(wo);
	int la=wo[len-1]-'0';
	if(la%2==0)
	{
		printf("%d",a-b);
	}
	else
	{
		printf("%d",b-a);
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	private static int go(int n) {
		int c = 0;
		for (int x = 1; x < n; ++x) {
          	if (x * x + 1 + 1 + x + 1 + x > n) break;
			for (int y = 1; y < n; ++y) {
	          	if (x * x + y * y + 1 + x * y + y + x > n) break;
				for (int z = 1; z < n; ++z) {
					if (x * x + y * y + z * z + x * y + y * z + z * x == n) c++;
					if (x * x + y * y + z * z + x * y + y * z + z * x > n) break;
				}
			}
		}
		return c;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		
		for (int i = 0; i < N; ++i) {
			System.out.println(go(i + 1));
		}
		
	}
}


Measured memory_bytes: 39988
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)
#define debug(var) cout << "[" << #var << "] " << var << endl

const int INF = 1<<29;
const double EPS=1e-9;
const int MOD=998244353;

signed main() {
    int X, Y;
    cin >> X >> Y;
    if (Y % 2 == 0 && Y >= 2 * X && Y <= 4 * X) Yes();
    else No();
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _20170409_AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            int sec = int.Parse(Console.ReadLine());
            int h = sec / 3600;
            int m = (sec - h * 3600) / 60;
            int s = sec % 60;
            Console.WriteLine("{0}:{1}:{2}", h, m, s);
            Console.Read();
        }
    }
}

Measured memory_bytes: 9144
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <set>
#include <map>
#include <numeric>

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
// constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

namespace detail {
template <typename Tp, size_t N>
std::vector<Tp> make_vector(
    std::vector<size_t>& sizes,
    typename std::enable_if<(N == 1), Tp const&>::type x
) {
  return std::vector<Tp>(sizes[0], x);
}
template <typename Tp, size_t N>
auto make_vector(
    std::vector<size_t>& sizes,
    typename std::enable_if<(N > 1), Tp const&>::type x
) {
  size_t size = sizes[N-1];
  sizes.pop_back();
  return std::vector<decltype(make_vector<Tp, N-1>(sizes, x))>(
      size, make_vector<Tp, N-1>(sizes, x)
  );
}
}  // detail::

template <typename Tp, size_t N>
auto make_vector(size_t const(&sizes)[N], Tp const& x) {
  std::vector<size_t> s(N);
  for (size_t i = 0; i < N; ++i) s[i] = sizes[N-i-1];
  return detail::make_vector<Tp, N>(s, x);
}

intmax_t f(std::string const& t, int r, int s, int p) {
  size_t n = t.length();
  auto dp = make_vector<intmax_t>({n, 3_zu}, 0);

  int R = 0;
  int S = 1;
  int P = 2;
  if (t[0] == 'r') {
    dp[0][P] = p;
  } else if (t[0] == 's') {
    dp[0][R] = r;
  } else {
    dp[0][S] = s;
  }


  for (size_t i = 1; i < n; ++i) {
    if (t[i] == 'r') {
      dp[i][P] = std::max(dp[i-1][R], dp[i-1][S]) + p;
      dp[i][R] = std::max(dp[i-1][P], dp[i-1][S]);
      dp[i][S] = std::max(dp[i-1][R], dp[i-1][P]);
    } else if (t[i] == 'p') {
      dp[i][P] = std::max(dp[i-1][R], dp[i-1][S]);
      dp[i][R] = std::max(dp[i-1][P], dp[i-1][S]);
      dp[i][S] = std::max(dp[i-1][R], dp[i-1][P]) + s;
    } else if (t[i] == 's') {
      dp[i][P] = std::max(dp[i-1][R], dp[i-1][S]);
      dp[i][R] = std::max(dp[i-1][P], dp[i-1][S]) + r;
      dp[i][S] = std::max(dp[i-1][R], dp[i-1][P]);
    }
  }

  return *std::max_element(dp[n-1].begin(), dp[n-1].end());
}

int main() {
  size_t n, k;
  scanf("%zu %zu", &n, &k);

  int r, s, p;
  scanf("%d %d %d", &r, &s, &p);

  char buf[131072];
  scanf("%s", buf);
  std::string t = buf;

  intmax_t res = 0;
  for (size_t i = 0; i < k; ++i) {
    std::string u;
    for (size_t j = i; j < n; j += k)
      u += t[j];

    res += f(u, r, s, p);
  }

  printf("%jd\n", res);
}


Measured memory_bytes: 6016
/*
  The Island Was Silent before.
  .....
  And One day again it became Silent.
*/
#include<bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define ll  long long
#define modd(a,b) ((a+2*b)%b)
#define debug(a) cout << #a << ": " << (a) << "\n"
#define ioso ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define rtt cerr << "Time: " << clock()*1.0 / CLOCKS_PER_SEC << endl;
#define ffe freopen("input.txt","r",stdin), freopen("output.txt","w",stdout);
 
int main() {
  ioso
  #ifndef ONLINE_JUDGE
  ffe
  #endif
  ll n,d; cin >> n >> d;
  int cn=0;
  ll x, y;
  for(int i=0;i<n;i++) {
    cin >> x >> y;
    if((double)sqrt((x*x) + (y*y)) <=d) {
      cn++;
    }
  }
  cout << cn << endl;
}

Measured memory_bytes: 3584
import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

nums = []
for i in range(N):
    nums.append(i + 1)
S = list(itertools.permutations(nums))

print(abs(S.index(P) - S.index(Q)))


Measured memory_bytes: 8052
cnt = [0 for i in range(4)]

for i in range(3):
    a, b = map(int, input().split())
    cnt[a-1] += 1
    cnt[b-1] += 1

if cnt.count(2) == 2 and cnt.count(1) == 2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
using namespace std;

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    if(0 < a){
        printf("Positive\n");
    }else if(a == 0){
        printf("Zero\n");
    }else if(a < 0 && b >= 0){
        printf("Zero\n");
    }else{
        if((b - a) % 2 == 0){
            printf("Negative\n");
        }else{
            printf("Positive\n");
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for (int i = k; i < (int)(n); i++)
#define repd(i, n) for (int i = n-1; i >= 0; i--)
#define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--)
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
//V,Pは大文字i,l,bは小文字
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int,int>;
using Pll = pair<ll, ll>;
const ll mod = 1000000007;
const ll inf = 1000000000000;//10の12乗

int main() {
  int n,m;
  cin >> n >> m;
  Vi v(3,-1);
  bool b=1;
  rep(i,m){
    int x,y;
    cin >> x >> y;
    x--;
    if(v[x]!=-1&&v[x]!=y) b=0;
    v[x]=y;
    if(x==0&&y==0&&n!=1) b=0;
  }
  if(v[0]==-1)chmax(v[0],1);
  chmax(v[1],0);
  chmax(v[2],0);
  if(n==1&&m==0) v[0]=0;
  if(b)rep(i,n) cout << v[i];
  else cout << -1 << endl;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    
    int ans;
    if (a >= 1 && a <= 9 && b >= 1 && b <= 9) {
        ans = a * b;
    } else {
        ans = -1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 200200;
typedef long long ll;
const int mod = 998244353;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
int a[maxn], b[maxn], n;
bool chk(int x) {
	rep(i, 1, n + n - 1) b[i] = a[i] >= x;
	rep(i, 0, n - 2) {
		if(b[n - i] == b[n - i - 1]) return b[n - i];
		if(b[n + i] == b[n + i + 1]) return b[n + i];
	}
	return b[n] ^ (n & 1) ^ 1;
}
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	rep(i, 1, n + n - 1) cin >> a[i];
	int l = 1, r = n + n;
	for(;l + 1 != r;) {
		int mid = l + r >> 1;
		if(chk(mid)) l = mid;
		else r = mid;
	}
	cout << l << '\n';
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K,S;
  cin >> K >> S;
  int count = 0;
  for (int i = 0; i <= K; i++){
    for (int j = 0; j <= K; j++){
      int k = S - j - i;
      if (k >= 0 && k <= K) count++;
    }
  }
   
  cout << count << endl;
}

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

int main() {
    int n,k,q;
    cin>>n>>k>>q;
    vector<int> mao(q);
    for(int i=0; i<q; i++) cin>>mao.at(i);

    if(k>q) {
        for(int i=0; i<n; i++) cout<<"Yes"<<endl;
    }

    else {
        vector<int> score(n);
        for(int i=0; i<q; i++) {
            score.at(mao.at(i)-1)++;
        }
        for(int i=0; i<n; i++) {
            if(score.at(i)>q-k) cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }
        return 0;
    }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 300
#define INF (1<<29)
typedef long long ll;
 
bool ok(int x){
    return (0 <= x && x < 10000);
}
 
ll getNum(int *idx,string &str){
    ll res = 0;
    while(isdigit(str[*idx])){
	res *= 10;
	res += str[*idx]-'0';
	(*idx)++;
    }
    return res;
}
 
ll calc(int idx,string &str){
    ll num,num2;
    if(str[idx] == '-'){
	idx++;
	num = -getNum(&idx,str);
	if(!ok(num)) return INF;
    }else if(str[idx] == '+'){
	idx++;
	num = getNum(&idx,str);
	if(!ok(num)) return INF;
    }else{
	num = getNum(&idx,str);
	if(!ok(num)) return INF;
    }
    while(str[idx] != '='){
	switch(str[idx]){
	case '+':
	    idx++;
	    num2 = getNum(&idx,str);
	    if(!ok(num2)) return INF;
	    num += num2;
	    break;
	case '-':
	    idx++;
	    num2 = getNum(&idx,str);
	    if(!ok(num2)) return INF;
	    num -= num2;
	    break;
	case '*':
	    idx++;
	    num2 = getNum(&idx,str);
	    if(!ok(num2)) return INF;
	    num *= num2;
	    break;
	}
	if(!ok(num)) return INF; 
    }
    if(!ok(num)) return INF;
    return num;
}
 
int main(){
    string str;
    while(cin >> str){
	string nstr;
	int len = str.size();
	for(int i = 0 ; i < len-1 ; i++){
	    nstr += str[i];
	    if(!isdigit(str[i]) && !isdigit(str[i+1])){
		nstr += '0';
	    }
	}
	nstr += '=';
	int res = calc(0,nstr);
	if(res == INF){
	    cout << "E" << endl;
	}else{
	    cout << res << endl;
	}
    }
    return 0;
}

Measured memory_bytes: 3084
N, M = map(int, input().split())
n = [0]*N
judge = True

for i in range(M):
    s, c = map(int, input().split())
    if judge:
        s -= 1
        if n[s] == 0 or n[s] == c:
            if N > 1 and c == 0 and s == 0:
                judge = False
            else:
                n[s] = c
        else:
            judge = False
if judge:
    if N > 1 and n[0] == 0:
        n[0] = 1
    print(int(''.join(map(str, n))))
else:
    print(-1)

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

using namespace std;
typedef long long ll;
#define MOD 1000000007

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

  ll n, k;
  cin >> n >> k;

  ll total = 0;
  for (ll i = k; i < n + 1; i++)
  {
    ll max = (n + n - i + 1) * i / 2;
    ll min = (i - 1) * i / 2;
    ll val = max - min + 1;

    total += val;
    total %= MOD;
  }

  if (total < 0)
    total += MOD;

  total += 1;
  total %= MOD;
  cout << total << endl;
  return 0;
}


Measured memory_bytes: 3652
import bisect
n = int(input())
a = list(map(int,input().split()))

a.sort()

ai = a[-1]

ind = bisect.bisect_left(a,ai//2+1)

if a[ind-1] < ai-a[ind]:
    aj = a[ind]
else:
    aj = a[ind-1]

print(ai,aj)


Measured memory_bytes: 14428
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN   
#define linf LLONG_MAX
#define lninf LLONG_MIN   
const ll mod=1e9+7;
const int N=1e6+4;

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

	ll ans = max({lninf,a*c,a*d,b*c,b*d});

	lpri(ans);
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int h, n;
  cin >> h >> n;
  int tot = 0;
  rep(i,n) {
    tot += in();
  }
  if (tot >= h) yn;
  return 0;
}

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

typedef unsigned char uc;

int const N = 185, A = 16;
uc v[A + 1][N + 2][N + 2][N + 2], h[A + 1][N + 2][N + 2][N + 2];
char s[N + 1][N + 2];
int g[N + 1][N + 1];

inline int sm(int r1, int c1, int r2, int c2) { return g[r2][c2] - g[r2][c1 - 1] - g[r1 - 1][c2] + g[r1 - 1][c1 - 1]; }
inline bool good(int r1, int c1, int r2, int c2) { int t = sm(r1, c1, r2, c2); return t == 0 || t == (r2 - r1 + 1) * (c2 - c1 + 1); }
inline void up(uc &x, uc y) { if (y > x)x = y; }

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	f(i, 1, n + 1)scanf("%s", s[i] + 1);
	f(i, 1, n + 1)f(j, 1, m + 1)g[i][j] = (s[i][j] == '#') + g[i - 1][j] + g[i][j - 1] - g[i - 1][j - 1];
	f(l, 1, n + 1)f(r, l, n + 1)for (int i = m; i > 0; --i)if (good(l, i, r, i))v[0][l][r][i] = 1 + (s[l][i] == s[l][i + 1] ? v[0][l][r][i + 1] : 0);
	f(l, 1, m + 1)f(r, l, m + 1)for (int i = n; i > 0; --i)if (good(i, l, i, r))h[0][l][r][i] = 1 + (s[i][l] == s[i + 1][l] ? h[0][l][r][i + 1] : 0);
	if (good(1, 1, n, m)) { printf("0\n"); return 0; }
	f(c, 1, A + 1){
		f(l, 1, n + 1)f(r, l, n + 1)f(i, 1, m + 1)up(v[c][l][r][i], v[c - 1][l][r][i] + v[c - 1][l][r][i + v[c - 1][l][r][i]]), up(h[c][i][i + v[c][l][r][i] - 1][l], r - l + 1);
		f(l, 1, m + 1)f(r, l, m + 1)f(i, 1, n + 1)up(h[c][l][r][i], h[c - 1][l][r][i] + h[c - 1][l][r][i + h[c - 1][l][r][i]]), up(v[c][i][i + h[c][l][r][i] - 1][l], r - l + 1);
		f(l, 1, n + 1)for (int r = n - 1; r >= l; --r)f(i, 1, m + 1)up(v[c][l][r][i], v[c][l][r + 1][i]);
		f(l, 1, m + 1)for (int r = m - 1; r >= l; --r)f(i, 1, n + 1)up(h[c][l][r][i], h[c][l][r + 1][i]);
		if (v[c][1][n][1] == m) { printf("%d\n", c); return 0; }
	}
}

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

int main() {
    string s;
    cin>>s;
    int ans = 0;
    for(int i=0;i<s.size();++i){
        if(i%2==0){
            if(s[i]=='p'){
                ans--;
            }
        }
        else {
            if(s[i]=='g'){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
    #define m ((long long)1e9+7)
    typedef long long ll;
    using namespace std;
     
    int main() {
        ios_base::sync_with_stdio(false);cin.tie(NULL);
    	ll n,w;
    	cin>>n>>w;
    	ll dp[n+1][w+1],a[n][2];
    	for(ll i=0;i<n;i++)
    	{
    	    cin>>a[i][0]>>a[i][1];
    	}
    	for(ll i=0;i<n+1;i++)
    	{
    	    for(ll j=0;j<w+1;j++)
    	    {
    	        if(i==0||j==0)
    	        dp[i][j]=0;
    	        else if(a[i-1][0]<=j)
    	        dp[i][j]=max(a[i-1][1]+dp[i-1][j-a[i-1][0]],dp[i-1][j]);
    	        else
    	        dp[i][j]=dp[i-1][j];
    	    }
    	}
    	cout<<dp[n][w]<<endl;
    	return 0;
    }

Measured memory_bytes: 79232
package main

import (
  "fmt"
)

func main() {
  var a,b,c int
  fmt.Scanf("%v%v%v", &a, &b, &c)
  if (a<c && c<b) || (a>c && c>b) {
    fmt.Println("Yes")
  } else {
    fmt.Println("No")
  }
}


Measured memory_bytes: 1832
import operator

while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op == '?':
        break
    elif op == '+':
        print(operator.add(a, b))
    elif op == '-':
        print(operator.sub(a, b))
    elif op == '*':
        print(operator.mul(a, b))
    else:
        print(operator.floordiv(a, b))




Measured memory_bytes: 5680
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.20f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

int main() {
	ll n, k;
	cin >> n >> k;
	vector<int> a(n+1);
	rep (i, n) cin >> a[i+1];

	vector<int> cnt(n+1, 0);

	int now = 1;
	cnt[now]++;
	for (int i = 0; i < k; i++) {
		now = a[now];
		cnt[now]++;
		if (cnt[now] == 3) break;
	}

	if (*max_element(rng(cnt)) != 3) {
		cout << now << endl;
		return 0;
	}

	int cnt1 = 0, cnt2 = 0;
	rrep (i, n) {
		if (cnt[i] == 1) cnt1++;
		if (cnt[i] == 2) cnt2++;
	}


	k -= cnt1;
	k %= cnt2 + 1;
	rep (i, k) now = a[now];
	cout << now << endl;
	return 0;
}

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

#define for0(i, n) for (int i = 0; i < (int)(n); ++i) 
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) 
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i)
#define deb(x) cout << #x << "= " << x << endl
#define pb push_back
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define tr(x) for(auto it = x.begin(); x != x.end(); it++)
#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD 1000000007

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

int main() {
    fast;
    int t=1;
    while(t--){
        //begin code here
        int n; cin>>n;
        ll arr[n]; ll sum=0;
        for0(i,n){
            cin>>arr[i];
            sum+=arr[i];
            sum%=MOD;
        }
        ll ans=0;
        for0(i,n){
            sum-=arr[i];
            if(sum<0){
                sum+=MOD;
            }
            ans+=(sum*arr[i]);
            ans%=MOD;
        }
        cout<<ans;
    }
}

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

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

  int l, r;
  l = 10 * (s[0] - '0') + (s[1] - '0');
  r = 10 * (s[2] - '0') + (s[3] - '0');

  bool l_m, r_m;
  if (l == 0 || l >= 13) l_m = false;
  else l_m = true;
  if (r == 0 || r >= 13) r_m = false;
  else r_m = true;

  if (!l_m && !r_m) {
    cout << "NA" << endl;
  } else if (l_m && r_m) {
    cout << "AMBIGUOUS" << endl;
  } else if (l_m) {
    cout << "MMYY" << endl;
  } else {
    cout << "YYMM" << endl;
  }

  return 0;

}

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

const long long maxn = 2e5 + 10;
const long long mod = 1e9 + 7;

long long n;
long long p[maxn];
long long ans;

void in();
void solve();
void out();
long long pwr(long long a, long long b);

int main(){
    in();
    solve();
    out();
}

void in(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    cin >> n;
    for(long long i = 0; i < n; i++)
        cin >> p[i];
}

void solve(){
    sort(p, p + n);
    for(long long i = 0; i < n; i++){
        ans += p[i] * ((pwr(2, n - i - 1) + (n - i - 1) * pwr(2, n - i - 2) % mod) % mod) % mod * pwr(2, i) % mod;
        ans %= mod;
    }
    ans = ans * pwr(2, n) % mod;
}

void out(){
    cout << ans;
}

long long pwr(long long a, long long b){
    if(b == 0)
        return 1;
    if(b < 0)
        return 0;
    long long c = pwr(a, b / 2);
    if(b % 2)
        return c * c % mod * a % mod;
    return c * c % mod;
}


Measured memory_bytes: 1792
/*********************************************JMD**********************************************/
//                                  |\  |     | |   |   /\                                   //
    //                              | \ |     | |---|  /--\                              //
        //                          |  \| |___| |   | /    \1999                     //
/*******************************************************************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define mem(x,val) memset(x,val,sizeof(x))
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define f(i,n) forr(i,0,n)
#define sz(x) ll((x).size())
#define all(x) ((x).begin(),(x).end())
#define asc(x) ((int)(x))
#define precision(x) cout<<fixed<<setprecision((x));

const ll mod=1e9 + 7;

/*******************************************************************************************/

void solve()
{
    ll a,b,c;
    cin>>a>>b>>c;

    if(a+b+c>=22) cout<<"bust";
    else cout<<"win";

    return;
}

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

    ll t=1;
    //cin>>t;
    clock_t launch=clock();

    while(t--)
    {
        solve();
    }

    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = ~0U>>1;
using namespace std;
int A, B, C;
int ans;
int X, Y;
int main(){
	cin >> A >> B >> C >> X >> Y;
	ans = INF;
	for(int i = 0; i <= max(X, Y); ++i) {
		ans = min(ans, 2 * C * i + max(X - i, 0) * A + max(Y - i, 0) * B);
	}
	cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<string.h>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<time.h>
#include<assert.h>
#include<iostream>
using namespace std;
typedef long long LL;
typedef pair<int,int>pi;
string s="CODEFESTIVAL2016";
int main(){
	string tmp;cin>>tmp;
	int ans=0;
	for(int i=0;i<16;i++)if(tmp[i]!=s[i])ans++;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x)                   cout << '>' << #x << ':' << x << endl;
typedef long long int ll;
int main()
{
    int n,k,arr[100010];
    priority_queue<pair<int,int> > PQ;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>k;
        PQ.push({k*-1,i});
    }
    while(!PQ.empty())
    {
        int id=PQ.top().second;
        cout<<id<<" ";
        PQ.pop();
    }
    cout<<endl;
}



Measured memory_bytes: 1780
N, M, X = map(int, input().split())
D = 12*100001
m = D
Clst = []

for i in range(N):
    Ci = list(map(int, input().split()))
    Clst.append(Ci)

for i in range(2**N):
    ch = True
    buy = []
    total = 0
    for j in range(N):
        if ((i>>j)&1):
            buy.append(Clst[j])
            total += Clst[j][0]
            if total >= m:
                ch = False
                break

    if ch:
        for l in range(1,M+1):
            skill = 0
            for k in buy:
                skill = skill + k[l]

            if skill < X:
                ch = False
                break
    
    if ch:
        m = total
    

if m == D:
    print(-1)
else:
    print(m)

Measured memory_bytes: 9108