akhauriyash/Code-Regression huggingface dataset:
import numpy as np
from collections import Counter
n = int(input())
a = np.array(list(map(int, input().split())))
ni = np.array([i for i in range(n)])

ap = a + ni
an = (a - ni) * -1

cp = Counter(ap)
cn = Counter(an)

ans = 0
for i in cp.keys():
  ans += cp[i] * cn[i] 

print(ans)

Measured memory_bytes: 75988
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

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

	int ar[3][3];
	int ch[3][3];
	for(int i=0;i<3;++i){
        for(int j=0;j<3;++j){
            cin>>ar[i][j];
            ch[i][j]=0;
        }
	}

	int n;
	cin>>n;
	for(int i=0;i<n;++i)
    {
        int x;
        cin>>x;
        for(int j=0;j<3;++j){
            for(int k=0;k<3;++k){
                if(ar[j][k]==x){
                    ch[j][k]=1;
                }
            }
        }
    }

    int f=0;
    for(int i=0;i<3;++i){
        if(ch[i][0]&&ch[i][1]&&ch[i][2]){f=1;}
    }
    for(int i=0;i<3;++i){
        if(ch[0][i]&&ch[1][i]&&ch[2][i]){f=1;}
    }
    if(ch[0][0]&&ch[1][1]&&ch[2][2]){f=1;}
    if(ch[0][2]&&ch[1][1]&&ch[2][0]){f=1;}

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

	return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define id(i,j) ((i) * 3000 + (j))
using namespace std;
typedef long long LL;
typedef pair<LL, int> PLI;
const int INF = 0x3f3f3f3f;
const LL LINF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 2e5 + 10;
int N, M, S;
struct edge
{
    int v, c;
};
vector<edge> g[maxn];
bool vis[maxn];
LL dist[maxn];
void Dijkstra(int s)
{
    memset(dist, 0x3f, sizeof(dist));
    priority_queue<PLI, vector<PLI>, greater<PLI> > q;
    dist[s] = 0;
    q.push(make_pair(dist[s], s));
    while(!q.empty())
    {
        int u = q.top().second;
        q.pop();
        if(vis[u])
            continue;
        else
            vis[u] = true;
        for(auto e : g[u])
        {
            int v = e.v, c = e.c;
            if(!vis[v] && dist[u] + c < dist[v])
            {
                dist[v] = dist[u] + c;
                q.push(make_pair(dist[v], v));
            }
        }
    }
}
int main()
{
    scanf("%d %d %d", &N, &M, &S);
    for(int i = 1; i <= M; i++)
    {
        int A, B, U, V;
        scanf("%d %d %d %d", &U, &V, &A, &B);
        for(int j = A; j <= 2500; j++)
        {
            g[id(U, j)].push_back(edge{id(V, j - A), B});
            g[id(V, j)].push_back(edge{id(U, j - A), B});
        }
    }
    for(int i = 1; i <= N; i++)
    {
        int C, D;
        scanf("%d %d", &C, &D);
        for(int j = 0; j < C; j++)
            for(int k = j + C; k <= 2500; k += C)
                g[id(i, k - C)].push_back(edge{id(i, k), D});
    }
    Dijkstra(id(1, min(S, 2500)));
    for(int i = 2; i <= N; i++)
    {
        LL ans = LINF;
        for(int j = 0; j <= 2500; j++)
            ans = min(ans, dist[id(i, j)]);
        printf("%lld\n", ans);
    }
    return 0;
}


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

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

    if(9 < a || 9 < b) {
        cout << -1 << endl;
    } else {
        cout << a * b << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    ll N,K;
    cin>>N>>K;
    ll ans=-INF;
    vi v(N);
    rep(i,0,N)cin>>v[i];
    rep(l,0,K+1){
        rep(r,0,(K+1)-l){
            ll res=0;
            if(l+r>N)break;
            priority_queue<int,vi,greater<int>>q;
            rep(tl,0,l)res+=v[tl],q.push(v[tl]);
            rep(tr,0,r)res+=v[N-1-tr],q.push(v[N-1-tr]);
            rep(ta,0,K-(l+r)){
                if(q.empty()==false&&q.top()<0)res-=q.top(),q.pop();
                else break;
            }
            chmax(ans,res);
        }
    }
    cout<<ans<<endl;
    return 0;
}




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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

int main()
{
    int N; cin >> N;
    vll x(N), y(N); rep(i, N) cin>>x[i]>>y[i];
    map<pll, int> m;

    for (int i = 0; i < N-1; i++) {
        for (int j = i+1; j < N; j++) {
            m[make_pair(x[i]-x[j], y[i]-y[j])]++;
            m[make_pair(x[j]-x[i], y[j]-y[i])]++;
        }
    }
    
    int ma = 0;
    for (auto it = m.begin(); it != m.end(); it++) {
        // cout << "p:" << it->first.first << ", q:" << it->first.second << ", c:" << it->second << endl;
        chmax(ma, it->second);
    }
    int ans = N - ma;
    
    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
	int n,k;
	cin >> n >> k;
	
	vector<P> vals(n);
	
	for(int i=0; i < n; i++) {
		int top, del;
		cin >> top >> del;
		
		vals[i] = make_pair(del, top);
	}
	
	sort(vals.begin(), vals.end(), greater<P>());
	priority_queue<int, vector<int>, greater<int>> q;
	set<int> s;
	
	ll m = 0;
	ll x = 0;
	for(int i=0; i < n; i++) {
		int d = vals[i].first;
		int t = vals[i].second;
		
		if(i < k) {
			if(s.find(t) == s.end()) {
				s.insert(t);
			}
			else {
				q.push(d);
			}
			
			x += d;
		}
		else if(s.find(t) == s.end() && !q.empty()) {
			int del = q.top();
			q.pop();
			s.insert(t);
			x += d - del;
		}
		
		if(i >= k-1) {
			ll w = s.size();
			m = max(m, x + w * w);
		}
	}
	
	cout << m;
	
	

	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, m, p;
    string s;
    cin >> n >> m;
    vector<int> ac(n, 0), penalty(n, 0);
    for(int i=0;i<m;++i) {
        cin >> p >> s;
        --p;
        if(s == "AC") {
            ac[p] = 1;
        } else {
            if(ac[p] == 0) {
                ++penalty[p];
            }
        }
    }

    int ac_cnt = 0, p_cnt = 0;
    for(int i=0;i<n;++i) {
        if(ac[i]) {
            ac_cnt += 1;
            p_cnt += penalty[i];
        }
    }

    cout << ac_cnt << " " << p_cnt << endl;
}


Measured memory_bytes: 1024
solver::String -> String -> Bool
solver str1 str2 = let rot = (str1++str1):[(tail ls)|ls<-rot] in
                   let n = length str1 in
                   let rot2 = map (take n) (take n rot) in
                   or (map (str2==) rot2)

main::IO()
main=do
  s<-getLine
  t<-getLine
  putStr (if solver s t then "Yes\n" else "No\n")


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}

const int MAX_N = 1e6 + 10;
int beg[MAX_N], nxt[MAX_N], cpy[MAX_N];
int cnt[3], n;

int slow() {
    for(int i = 0; i < n; i ++) {
        for(int j = 0; j < n - i; j ++) {
            cout << nxt[j];
        }
        cout << endl;
        for(int j = 0; j < n - i - 1; j ++) {
            nxt[j] = abs(nxt[j] - nxt[j + 1]);
        }
    }
    cout << endl;
    return nxt[0];
}

int cnt2(int x) {
    int ans = 0;
    while(x / 2 > 0) {
        ans += x / 2;
        x /= 2;
    }
    return ans;
}

bool comb(int x, int k) {
    return !(cnt2(x) - cnt2(x - k) - cnt2(k));
}

int solve() {
    if(n == 1) {
        return beg[0];
    }
    cnt[0] = cnt[1] = cnt[2] = 0;
    for(int j = 0; j < n - 1; j ++) {
        beg[j] = abs(beg[j] - beg[j + 1]);
        cnt[beg[j]] ++;
    }
    int semi;
    if(cnt[1]) {
        semi = 1;
    } else {
        semi = 2;
    }
    int ret = 0;
    for(int i = 0; i < n - 1; i ++) {
        if(beg[i] == semi) {
            ret ^= comb(n - 2, i);
        }
    }
    return ret * semi;
}

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n;
    for(int i = 0; i < n; i ++) {
        char c;
        cin >> c;
        beg[i] = c - '0';
    }
    cout << solve();
    return 0;
    return 0;
}




Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k;
	cin>>k;
	if(k%10==9)
	cout<<"Yes"<<endl;
	if(k>=90&&k<=98)
	cout<<"Yes"<<endl;
	if(k%10!=9&&k<=88)
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, D, X;
    cin >> N >> D >> X;
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++){
        int temp = 1;
        while(temp <= D){
            X++;
            temp += A[i];
        }
    }
    cout << X << endl;
}

Measured memory_bytes: 3500
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String line;
		try {
			br.readLine();
			while ((line = br.readLine()) != null) {
				String[] v = line.split(" ");
				int a = Integer.parseInt(v[0]);
				int b = Integer.parseInt(v[1]);
				int c = Integer.parseInt(v[2]);
				int max = Math.max(Math.max(a, b), c);

				if (max == a) {
					if (a * a == b * b + c * c) {
						System.out.println("YES");
					} else {
						System.out.println("NO");
					}
				} else if (max == b) {
					if (b * b == a * a + c * c) {
						System.out.println("YES");
					} else {
						System.out.println("NO");
					}
				} else {
					if (c * c == a * a + b * b) {
						System.out.println("YES");
					} else {
						System.out.println("NO");
					}
				}
			}
		} catch (Exception e) {
		}
	}
}

Measured memory_bytes: 26164
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <locale>

using namespace std;

int main(int argc, char *argv[]) {
	int a, b;
	cin >> a >> b;
	int ans = a >= 13 ? b : (a >= 6 ? b / 2 : 0);
	cout << ans << endl;
	return 0;
}


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

/*
  let's try computer shogi!!!
 */


/*
  K=0とK=1に注意されたし
  50
  50.. 50 = 50回

  50
  51...51 =100 回
  mod 50 = pについては
  50+50*p 50-p 50-p ... でOK。
 */

int main(){
  long long int K;
  cin >> K;
  if(K==0){
    cout << "10" <<endl;
    cout << "1 1 4 5 1 4 1 9 1 9" <<endl;
  }else if(K==1){
    cout << "2" <<endl;
    cout << "0 2"<<endl;
  }else if(K<=50){
    cout << K <<endl;
    for(int i=0;i<K;++i){
      cout<<K;
      if(i!=K-1){
	cout<<" ";
      }
    }
    cout << endl;
  }else{
    long long int basescale = 50 + K/50 -1;
    long long int upscale = K%50;
    cout << 50 <<endl;
    for(int i=0;i<50-upscale;++i){
      cout<< basescale - upscale<<" ";
    }
    for(int i=0;i<upscale;++i){
      cout << basescale + 50-upscale+1;
      if(i!=upscale-1){
	cout<<" ";
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
# from : https://atcoder.jp/contests/yahoo-procon2019-qual/submissions/4212377
H,W = map(int, input().split())
A = [ [int(j) for j in input().split()] for _ in range(H)]
MOD = 998244353

piv = 0

# Gaussian Elimination to calculate rank of the matrix A
for w in range(W): # fix column, 
    r = -1
    for h in range(piv, H):
        if A[h][w] == 1:
            r = h
            break
    if r == -1: # there is no odd cell for all the rows inside intersections.
        continue 

    # You want to set ODD ROW ( A[h][w] == 1 ) into pivot row.
    if r != piv: # already, skip.
        for j in range(W): # swap rows
            A[r][j], A[piv][j] = A[piv][j], A[r][j]

    # for h in 
    for h in range(H):
        if h != piv and A[h][w] == 1: # really needed?
            # for j in range(W):
            for k in range(piv, W):
                A[h][k] ^= A[piv][k]
                # A[h][j] ^= A[piv][j] # for other rows, erase ...
                # Hakidashi method: http://senkei.nomaki.jp/gaussian_elimination.html
                # https://ja.wikipedia.org/wiki/%E3%82%AC%E3%82%A6%E3%82%B9%E3%81%AE%E6%B6%88%E5%8E%BB%E6%B3%95 : Gaussian Elimination
    piv += 1


# print("----output matrix ----")
# for h in range(H):
#     print(A[h])
# exit(0)


# from pprint import pprint; pprint(A)

ret = 1
ret = pow(2, H, MOD)
# for h in range(H):
#     ret = ret * 2 % MOD

sub = 1
# for i in range(H-piv):
#     sub = sub * 2 % MOD
sub = pow(2, H-piv, MOD)


ret += MOD - sub          # ret = 2^N - 2^(N-r)
ret %= MOD

for i in range(W-1):      # ret *= 2^(M-1)
    ret = ret * 2 % MOD

# from editorial  : https://img.atcoder.jp/yahoo-procon2019-qual/editorial.pdf
# rank : r 
# 2^(N+M-1) - 2^(N+M-r-1)

print(ret % MOD) 

Measured memory_bytes: 3828
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result

arr_data = getinputdata()

s = arr_data[0][0]


print(s.rfind("Z")-s.find("A")+1)


Measured memory_bytes: 3512
#include<bits/stdc++.h>
using namespace std;
int main(){double A,B,H,M,X;
           cin>>A>>B>>H>>M;
  X=cos((H/6-M*11/360)*3.14159265358979);
    cout<<setprecision(15)<<sqrt(A*A+B*B-2*A*B*X)<<endl;}

Measured memory_bytes: 4216
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x, y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb3(x, y, z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

template <typename T>void print(T v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<v.size(); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(w)<<*i<<" ";cout<<endl;}
template <typename T>void print_vv(T v){if(v.size()==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<v[0].size(); j++)cout<<setw(w)<<j<<" ";cout<<endl;for(auto i= 0; i<v.size(); i++){cout<<i<<" {";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(w)<<v[i][j]<<",";}cout<<"},"<<endl;}cout<<endl;}
template <class T, class U> void print_m(map<T,U> m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}

int main(){
    int k;
    while(cin>>k){
        vector<string> a = {"1","2","3","4","5","6","7","8","9"};
        int sz = a.size();

        int i = 0;
        while(sz<k){
            string top = a[i];
            int bk = top.back()  - '0';
            int l = bk-1;
            int r = bk+1;
            if(bk==0) l = 0;
            if(bk==9) r = 9;
            for(int j=l; j<=r; ++j){
                string ntop = top + to_string(j);
                a.push_back(ntop);
                ++sz;
            } 
            ++i;
        }

        // print(a);

        cout<<a[k-1]<<endl;
        cout<<endl;
    }
}

Measured memory_bytes: 5764
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var nw = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int n = nw[0];
			int w = nw[1];

			var wv = new Tuple<long, long>[n];
			for (int i = 0; i < n; i++) {
				var temp = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
				wv[i] = new Tuple<long, long>(temp[0], temp[1]);
			}

			var dp = new long[n + 1, w + 1];
			for (int i = 0; i < n + 1; i++) {
				for (int j = 0; j < w + 1; j++) {
					dp[i, j] = -1;
				}
			}

			dp[0, 0] = 0;

			for (int i = 1; i <= n; i++) {
				for (int j = 0; j < w + 1; j++) {
					if (dp[i - 1, j] == -1) {
						continue;
					}

					long next = j + wv[i - 1].Item1;
					if (next <= w) {
						dp[i, next] = Math.Max(dp[i, next], dp[i - 1, j] + wv[i - 1].Item2);
					}

					dp[i, j] = Math.Max(dp[i, j], dp[i - 1, j]);
				}
			}

			long ans = 0;
			for (int i = 0; i < w + 1; i++) {
				if (dp[n, i] != -1) {
					ans = Math.Max(ans, dp[n, i]);
				}
			}

			Console.WriteLine(ans);
		}
	}
}

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

int main()
{
    int a, b, x;
    cin >> a >> b;
    if(a>=10)
        cout << b << endl;
    else if(a<10)
    {
        x=100*(10-a);
        cout << x+b << endl;
    }
    return 0;


}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <stdlib.h>
using namespace std;

int main(){
    int n;
    string str;
    cin>>n;
    cin>>str;
    int I=0,J=0,O=0,JO=0,IOI=0,JOI=0;
    for(int i=0;i<n;i++){
        /*
         if(str[i]=='O') {
         if(I-IOI+J>O) O++;
         if(J>JO) JO++;
         }
         */
        if(str[i]=='O'){
            if(I-IOI+J>O) O++;
            if(J>JO){
                JO++;
            }
        } else if(str[i]=='I'){
            I++;
            if(O*J*JO)J--,JO--,O--,JOI++;
            else if(O*I)O--,IOI++;
        } else {
            J++;
        }
    }
    cout<<JOI+min(IOI,(I-JOI)/2)<<endl;
}

Measured memory_bytes: 2072
#include<bits/stdc++.h>
 
using namespace std;
 
//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
 
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).end()) i=(c).end(); i!=(c).begin(); --i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
 
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())
 
#define PB(a) push_back(a)
#define PF(a) pop_front(a)

#define MP(a,b) make_pair(a,b)
 
#define FS first
#define SE second
 
#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
//---------interval scheduling----------------------
struct interval {
  int s, f;
  interval(int s, int f) : s(s), f(f) { }
};
bool compare_f(const interval &x, const interval &y) {
  return x.f < y.f;
}
vector<interval> interval_scheduling(vector<interval> J) {
  vector<interval> A;
  sort(J.begin(), J.end(), compare_f);
  int f = 0;
  for (int i = 0; i < J.size(); ++i) {
    if (J[i].s >= f) {
      A.push_back(J[i]);
      f = J[i].f;
    }
  }
  return A;
}
//grobal var
//------------------------------------------
const int MAX=500;

 
int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------
  int N,M;
  while(cin >> N >> M){
    int ans=0;
    vector<interval> V;
    REP(i,M){
      int a,b;
      cin >> a >> b;
      a--;
      b--;
      V.PB(interval(a,b));
    }
    vector<interval> V2 = interval_scheduling(V);
    cout << V2.end()-V2.begin() << endl;
  }
  return 0;
}

Measured memory_bytes: 2036
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

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

		long[][] c = new long[51][51];
		for (int i = 0; i <= n; i++) {
			for (int j = 0; j <= i; j++) {
				if (j == 0 || j == i) c[i][j] = 1;
				else c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
			}
		}

		Long[] v = new Long[n];
		for (int i = 0; i < n; i++) {
			v[i] = sc.nextLong();
		}

		Arrays.sort(v, Comparator.reverseOrder());

		double ave = 0.0;

		for (int i = 0; i < a; i++) {
			ave += v[i];
		}

		ave /= a;
		System.out.println(ave);

		int t = 0;
		int u = 0;
		for (int i = 0; i < n; i++) {
			if (v[i].equals(v[a - 1])) {
				u++;
				if (i < a) t++;
			}
		}

		if (u == 1) {
			System.out.println(1);
			return;
		}

		long count = 0L;
		if (a == t) {
			for (int j = t; j - t + a <= b && j <= u; j++) {
				count += c[u][j];
			}
		} else {
			count += c[u][t];
		}

		System.out.println(count);
	}
}


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

using namespace std;

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

#define INF 1<<30
#define F first
#define S second
#define MOD 1000000007

int n,m;
bool broken[100005]={};
int memo[100005];

int dp(int now){
  if(memo[now]!=-1){
    return memo[now];
  }else if(now>n||broken[now]){
    return 0;
  }else if(now==n){
    return 1;
  }else{
    return memo[now]=(dp(now+1)+dp(now+2))%MOD;
  }
}

int main(){
  
  scanf("%d %d",&n,&m);
  fill(memo,memo+100005,-1);

  for(int i=0;i<m;i++){
    int a;
    scanf("%d",&a);
    broken[a]=true;
  }

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


Measured memory_bytes: 3840
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n,x; cin >> n >> x;
    int ans = 0;
    int Min = 1000;
    rep(i,n) {
        int m; cin >> m;
        Min = min(m, Min);
        x -= m;
        if (x >= 0)
        {
            ans++;
        } else {
            cout << ans << endl;
            break;
        }
    }
    while (x >= Min) {
        ans++;
        x -= Min;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::Read;
use std::cmp::min;

fn pow(x: &Vec<i32>, n:&i32, p:&i32) -> Vec<i32>{
    if n == &1{
        x.clone()
    }
    else if n % 2 == 0{
        let half = pow(x, &(n / 2), &p);
        mult(&half, &half, &p)
    }
    else{
        let dec = pow(&x, &(n-1), &p);
        mult(&x, &dec, &p)
    }
}

fn mult(x: &Vec<i32>, y: &Vec<i32>, p:&i32)->Vec<i32>{
    let degx = x.len();
    let degy = y.len();
    let mut z = vec![0;min(degx+degy-1, *p as usize)];
    for i in 0..degx{
        for j in 0..degy{
            let mut k = (i + j) as i32;
            while k >= *p{
                k -= p-1;
            }
            z[k as usize] += x[i as usize] * y[j as usize];
            z[k as usize] %= *p;
        }
    }
    z
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let mut ans = vec![1];
    let p: i32 = iter.next().unwrap().parse().unwrap();
    for i in 0..p{
        let a: i32 = iter.next().unwrap().parse().unwrap();
        if a == 0{
            ans = mult(&ans, &vec![p-i, 1], &p);
        }
    }
    ans = pow(&ans, &(p-1), &p);
    while ans.len() < (p as usize){
        ans.push(0);
    }
    println!("{}", ans.into_iter().map(|x| {x.to_string()}).collect::<Vec<String>>().join(" "));
    
}


Measured memory_bytes: 4352
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

    int ret = 0;
    while(--n >= 0){
        string s1;
        cin >> s1;
        s1 += s1;
        if(s1.find(s) != string::npos)
            ++ ret;
    }
    cout << ret << endl;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <map>
using namespace std;
typedef pair<int,int> P;
int main(void){
	int n,q;
	while(cin >> n >> q ,n|q){
		pair <P,string> year[1000];
		for(int i=0;i<n;i++){
			string in;
			int num,start,end;
			cin >> in >> num >> end;
			start=end-num+1;
			year[i]=make_pair(P(start,end),in);
		}
		for(int i=0;i<q;i++){
			bool ok=false;
			int tar;
			cin >>tar;
			for(int i=0;i<n;i++)
				if(year[i].first.first <= tar && tar<=year[i].first.second)
					cout << year[i].second  << " " << tar-year[i].first.first+1 << endl,ok=true;
			if(!ok)
				cout << "Unknown" << endl;
		}
	}
	return 0;
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    
    if(c-b == b-a) {
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n = int(input())
A = tuple(map(int, input().split()))
C = [0]*3
for a in A:
  C[a-1] += 1
dp = [[[-1]*(n+1) for i in range(n+1)] for j in range(n+1)]
dp[0][0][0] = 0
def f(i, j, k):
  if dp[i][j][k] != -1:
    return dp[i][j][k]
  res = 1
  if i:
    res += f(i-1, j, k)*(i/n)
  if j:
    res += f(i+1, j-1, k)*(j/n)
  if k:
    res += f(i, j+1, k-1)*(k/n)
  res /= (i+j+k)/n
  dp[i][j][k] = res
  return res
ans = f(C[0], C[1], C[2])
print(ans)

Measured memory_bytes: 397884
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int main(){
  unsigned long long K;
  string S;
  cin>>S>>K;
  vector<int> num;
  for(int i=0;i<S.size();i++){
    num.push_back(S[i]-'0');
  }

  int ans=0;
  for(int i=0;i<num.size();i++){
    if(num[i]!=1){
      ans=num[i];
      break;
    }
    if(i==K-1){
      ans=num[i];
      break;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main(){

	
ll N, K;
	cin >> N >> K;
	ll ans = 0;

	if (K==0) {
		ce(N*N)
		return 0;
	}

	for (int b = K + 1; b <= N; b++) {
		ans += (N/b)*(b-K) + max((N%b)-K+1,0ll);
	}

	ce(ans)


    return 0;
}



Measured memory_bytes: 256
import itertools
N = int(input())
#N = int(input())
#N = int(input())
#S = input()
#M,N = map(int,input().split())
#M,N = map(int,input().split())
#A = list(map(int,input().split()))
#A = list(map(int,input().split()))
alp = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
check = 1
digit = 1
while True:
    if N < check:
        break
    check += 26**digit
    digit += 1
digit -= 1
check -= 26**digit
check -= 1
ans = [0]*digit
n = N - check
D = digit
for i in range(digit):
    syo = n // 26**(digit-1-i)
    if n % 26**(digit-1-i) == 0:
        syo-=1
    ans[i] = alp[syo]

    n -= syo*26**(digit-1-i)

print("".join(ans))

Measured memory_bytes: 9200
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner in = new Scanner(System.in);
		int x = in.nextInt();
		int y = in.nextInt();
		int[] array = { 0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1 };
		if (array[x] == array[y])
			System.out.println("Yes");
		else
			System.out.println("No");
	}

}


Measured memory_bytes: 23636
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.replace(/\n$/,"")).split("\n");
var n=Arr.shift();
for(var i=0;i<n;i++){
   var str=Arr[i];
   if(/>'(=+)#\1~/.test(str))console.log("A");
   else if(/>\^(Q=)+~~/.test(str))console.log("B");
   else console.log("NA");
}

Measured memory_bytes: 10788
#include <tuple>
#include <vector>
#include <map>
#include <set>
#include <iostream>
#include <limits>
#include <algorithm>
#include <queue>


template<class... Ts> using tuple_t = std::tuple<Ts...>;
template<class T, class U> using map_t = std::map<T, U>;
template<class T, class U> using pair_t = std::pair<T, U>;
template<class T> using vector_t = std::vector<T>;
template<class T> using set_t = std::set<T>;

uint64_t digit(uint64_t num, uint64_t base = 10)
{
	uint64_t i = 0;
	while(num)
	{
		++i;
		num /= base;
	}
	return i;
}

uint64_t digit_sum(uint64_t num, uint64_t base = 10)
{
	uint64_t i = 0;
	while(num)
	{
		i += num % base;
		num /= base;
	}
	return i;
}

int main()
{
	int N,K;
	vector_t<int> xs;
	std::cin>>N>>K;

	for(auto i = 0;i<N;++i)
	{
		int x;
		std::cin>>x;
		xs.push_back(x);
	}
	int min_cost = std::numeric_limits<int>::max();
	for(int i=K-1;i<N;++i){
		if(xs[i-K+1]>0 && xs[i]>0 || xs[i-K+1]<0 && xs[i]<0)
		{
			if(std::max(std::abs(xs[i - K + 1]), std::abs(xs[i])) < min_cost)
				min_cost = std::max(std::abs(xs[i - K + 1]), std::abs(xs[i]));
		}else{
			if(std::min(std::abs(xs[i-K+1])*2+std::abs(xs[i]),std::abs(xs[i-K+1])+2*std::abs(xs[i]))<min_cost)
				min_cost = std::min(std::abs(xs[i-K+1])*2+std::abs(xs[i]),std::abs(xs[i-K+1])+2*std::abs(xs[i]));
		}
	}
	std::cout<<min_cost<<std::endl;

	return 0;
}


Measured memory_bytes: 892
ii=lambda:int(input())
miis=lambda:map(int,input().split())
lmiis=lambda:list(map(int,input().split()))

n,m=miis()

k=lmiis()
st=set(k[1:])

for i in range(n-1):
  ki=lmiis()
  st=st&set(ki[1:])

print(len(st))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;

int N, endbit, Mask;
int dp[1 << 16][16];

int rec(int bit, int ptr){
  if(bit == endbit) return 0;
  if(~dp[bit][ptr]) return dp[bit][ptr];
  int ret = INF;
  for(int i = 0; i < N; i++){
    if((bit ^ endbit) & (1 << i)){
      for(int j = i + 1; j < N; j++){
        if((bit ^ endbit) & (1 << j) && ((bit >> i) & 1) ^ ((bit >> j) & 1)){
          int nextbit = bit&~((1 << i)|(1 << j))|(endbit & (1 << i))|(endbit & (1 << j));
          int cost = abs(ptr - i) + j - i;
          ret = min( ret, rec( nextbit, j) + cost);
          cost = abs(ptr - j) + j - i;
          ret = min( ret, rec( nextbit, i) + cost);
        }
      }
    }
  }
  return dp[bit][ptr] = ret;
}

int main(){
  int bit;
  string A, B;

  while(cin >> N, N){
    cin >> A >> B;

    Mask = (1 << N) - 1;
    bit = 0, endbit = 0;
    for(int i = 0; i < A.length(); i++){
      bit |= (A[i] == 'W') << i;
      endbit |= (B[i] == 'W') << i;
    }

    fill_n( *dp, (1 << 16) * 16, -1);
    int ret = INF;
    for(int i = 0; i < A.length(); i++){
      ret = min( ret, rec(bit, i));
    }
    cout << ret << endl;
  }
}

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

int main()
{
	int N;

	int *A;
    int i;
    int count =0;
    scanf("%d",&N);
    
    A = (int *)malloc(N * sizeof(int));

    for (i = 0; i < N; ++i)
    {
    	scanf("%d",&A[i]);
        if( A[i] % 2)++count;
    }
    if (count % 2)
    {
        printf("NO\n");
    }
    else printf("YES\n");

    free(A);
	return 0;
}

Measured memory_bytes: 512
# from pprint import pprint

N, M = map(int, input().split())
A = []
C = []
for _ in range(M):
    a, b = map(int, input().split())
    A.append(a)
    c = map(lambda x: int(x)-1, input().split())
    state = 0
    for ci in c:
        state |= 1 << ci
    C.append(state)

INF = 10**18
dp = [[INF]*2**N for _ in range(M)]
dp[0][0] = 0

for i in range(M-1):
    for state in range(1 << N):
        used = state | C[i]
        cur = dp[i][state]
        if dp[i+1][used] > cur + A[i]:
            dp[i+1][used] = dp[i][state] + A[i]

        if dp[i+1][state] > cur:
            dp[i+1][state] = cur

ans = dp[-1][-1]
print(ans if ans != INF else -1)


Measured memory_bytes: 78296
kazu = dict()
N=input()
A = [int(i) for i in input().split()]
for a in A:
    if a in kazu:
        kazu[a] += 1
    else:
        kazu[a] = 1

tori = 0
for k in kazu.values():
    tori += k*(k-1)//2
for a in A:
    print(tori - kazu[a]+1)

Measured memory_bytes: 86640
#include<stdio.h>

int main(void)
{
        int n,m,c,r=0, re=0;
        int i, j;
        int nn[1000], mm[1000];

        scanf("%d%d%d", &n,&m,&c);

        for(i = 0; i < m; i++) {
                scanf("%d", &mm[i]);
        }
        for(i = 0; i < n; i++) {
                r = 0;
                for(j = 0; j < m; j++) {
                        scanf("%d", &nn[j]);
                        r += nn[j]*mm[j];
                }
                r += c;
                if(r > 0) {
                        re++;
                }
        }
        printf("%d",re);
        return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
int prime[10001];
int twin_prime[10001];

void isprime(int n) {
    int i, k, l = 0, p1, q1;
    for(i = 2; i <= n; i++) {
        prime[i] = 1;
    }
    for(i = 2; i <= n; i++) {
        if(prime[i]) {
            for(k = 2*i; k <= n; k+=i) {
                prime[k] = 0;
            }
        }
        if(prime[i]) {
            twin_prime[l] = i;
            l++;
        }
    }
    for(i = 0; i < l; i++) {
        if(twin_prime[i+1]-twin_prime[i]==2) {
            p1 = twin_prime[i];
            q1 = twin_prime[i+1];
        }
    }
    printf("%d %d\n", p1, q1);
}

int main() {
    int i, n;
    for(i = 0; i < 10000; i++) {
        scanf("%d", &n);
        if(n == 0) break;
        isprime(n);
    }
    return 0;
}

Measured memory_bytes: 1736
// https://atcoder.jp/contests/abc154/tasks/abc154_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N;
  cin >> N;

  map<ll, ll> ct;
  rep(i, N) {
    ll v;
    cin >> v;
    ct[v]++;
  }

  for (auto p : ct) {
    if (p.se > 1) {
      drop("NO");
    }
  }

  drop("YES");
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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

const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

ll dp[110][100010];

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

Measured memory_bytes: 79360
n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for i in range(m)]
a.sort()
bc.sort(key=lambda x: x[1], reverse=True)
# print(a)
# print(bc)
cur = 0
count = 0
for i in range(n):
    if cur >= m:
        break
    a[i] = max(a[i], bc[cur][1])
    # print(a[i])
    count += 1
    if count == bc[cur][0]:
        cur += 1
        count = 0
print(sum(a))

Measured memory_bytes: 32968
import bisect

N = int(input())
L = list(map(int, input().split()))

L.sort()

cnt = 0
for x in range(N):
    for y in range(x+1, N):
        index = bisect.bisect_left(L, L[x]+L[y])
        if index - y - 1 >=0:
            cnt += (index - y - 1)

print(cnt)

Measured memory_bytes: 3316
//In the name of God
#include<bits/stdc++.h>
#define int long long

using namespace std;

const int N = 2010;
const int MOD = 924844033;

int n, k, f[N][N], dp[N*3][N*3], a[N*3], cnt = 1, sz, fact[N];
vector<int> g[N*2];
bool mark[N*2];

void dfs(int v){
	if(mark[v])	return;
	mark[v] = 1;
	sz ++;
	for(auto u : g[v])	dfs(u);
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> k;
	for(int i = 1; i <= n; i ++){
		if(i - k >= 1){
			g[i]. push_back(n + i - k);
			g[n + i - k]. push_back(i);
		}
		if(i + k <= n){
			g[i]. push_back(n + i + k);
			g[n + i + k]. push_back(i);
		}
	}
	for(int i = 1; i <= 2 * n; i ++)
		if(!mark[i]){
			sz = 0;
			dfs(i);
			a[cnt ++] = sz - 1;
		}
	for(int i = 0; i < N; i ++){
		f[i][0] = 1;	f[i][1] = i;
		for(int j = 2; j <= i; j ++)
			f[i][j] = (1LL * f[i - 1][j] + 1LL* f[i - 2][j - 1]) % MOD;
	}
	int sum = 0;
	dp[0][0] = 1;
	for(int i = 1; i < cnt; i ++){
		for(int j = 0; j <= sum; j ++)
			for(int x = 0; x <= a[i]; x ++){
				int now = 1LL * dp[i - 1][j] * f[a[i]][x] % MOD;
				dp[i][j + x] = (dp[i][j + x] + now) % MOD;
			}
		sum += a[i];
	}
	fact[0] = 1;
	for(int i = 1; i <= n; i ++)
		fact[i] = 1LL * i * fact[i - 1] % MOD;
	int res = 0;
	for(int i = 0; i <= n; i ++){
		int now = 1LL * dp[cnt - 1][i] * fact[n - i] % MOD;
		if(i%2)	now = -now;
		res = (res + now + MOD) % MOD;
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 222208
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");

function print(x) {
  console.log(x);
}

let inputString = "";
let currentLine = 0;

process.stdin.on("data", inputStdin => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ************************ Ignore above this Line ******************************
// **************************** Main Code Start *********************************

function main() {
  var n = Number(readline());
  var ar = readline().split(' ').map(x => parseInt(x));
  
  var ar2 = Array.from(new Set(ar));
  print(JSON.stringify(ar) == JSON.stringify(ar2) ? 'YES' : 'NO');

}



Measured memory_bytes: 73068
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

h1, m1, h2, m2, k = map(int, readline().split())
time = h2 * 60 + m2 - h1 * 60 - m1
ans = time - k
print(max(0, ans))


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

int main() { 
  int A, B;
  cin >> A >> B;
  int coin;

  if (A > B) {
    coin = A + (A-1);
  }
  else if (B > A) {
    coin = B + (B-1);
  }
  else {
    coin = A + B;
  }
  cout << coin << endl;
}

Measured memory_bytes: 256
open System

let N = Console.ReadLine() |> int
let arr = Console.ReadLine().Split(' ') |> Array.map int

let jugde (x:int[]) = 
    Array.sort x
    |> (fun y -> if (y.[0] <> y.[1]) && (y.[1] <> y.[2]) && (y.[0] <> y.[2]) && (y.[0] + y.[1] > y.[2]) then 1 else 0)

[|for i in [1..N] do
    for j in [i..N] do
        for k in [j..N] do
            yield if (i <> j) && (j <> k) && (i <> k) then [|arr.[i-1];arr.[j-1];arr.[k-1]|] else [|0;0;0|]|]
|> Array.sumBy jugde
|> printfn "%d"

Measured memory_bytes: 51600
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}
 
 
int main() {
    ll a,b,k,c,d,e;
    e = 0;
    cin >> a >> b >> k;
    if (a > 0) {
        if (k>=a) {
            c = 0;
            k = k-a;
        } else {
            c = a-k;
            k = 0;
        }
    }
    if (b > 0) {
        if (b-k <= 0) {
            d = 0;
        } else {
            d = b-k;
        }
    }
    if (a==0 && b==0){
        c = a;
        d = b;
    } 
    cout << c << " " << d << "\n";
}

Measured memory_bytes: 256
#define _CRT_DISABLE_PERFCRIT_LOCKS
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <iomanip>
#include <cmath>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include<math.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define ll long long
#define ld long double
#define vi vector<int>
#define pb push_back
#define ff first
#define ss second
#define ii pair<int,int>
#define iii pair<int,ii>
#define iiii pair<iii,int>
#define pll pair<ll,ll>
#define plll pair<ll,pll>
#define vv vector
#define endl "\n"

using namespace std;

int main()
{
  ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
  int t;cin>>t;
  int a1=0,a2=0,a3=0,a4=0;
      while(t--)
      {
          string s;
          cin>>s;
          if(s.compare("AC")==0)
            a1++;
          else if(s.compare("WA")==0)
            a2++;
          else if(s.compare("TLE")==0)
            a3++;
          else
            a4++;
      }
      cout<<"AC x "<<a1<<"\n";
        cout<<"WA x "<<a2<<"\n";
    cout<<"TLE x "<<a3<<"\n";
    cout<<"RE x "<<a4<<"\n";
}


Measured memory_bytes: 3580