akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())
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;
}
template<int MOD> struct Fp {
    ll val;
    constexpr Fp(ll v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        ll a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            ll t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, ll n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
constexpr ll MOD = 1e9 + 7;
using mint = Fp<MOD>;

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N;
    cin >> N;
    set<string> sset;
    REP(n, N) {
        string s;
        cin >> s;
        sset.insert(s);
    }
    cout << SIZE(sset) << endl;

    return 0;
}


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

int n,hh,mm;

int main(){
	scanf("%d",&n);
	for(int t = 0; t < n; t++){
		scanf("%d:%d",&hh,&mm);
		int rm = mm*12;
		int rh = hh*60+mm;
		int r = fabs(rm-rh);
		if(r < 30*2 || r > 330*2){
			puts("alert");
		}
		else if(r >= 90*2 && r <= 270*2){
			puts("safe");
		}
		else{
			puts("warning");
		}
	}

	return 0;
}



Measured memory_bytes: 3116
from sys import stdin,stdout

print = stdout.write
input = stdin.readline
INF = 1e10
n,W = map(int,input().split())

wgt = [0]
val = [0]
for i in range(n):
    w,v = map(int,input().split())
    wgt.append(w)
    val.append(v)

max_val=sum(val)    
dp=[[INF for x in range(max_val+1)] for x in range(n+1)]
for i in range(n+1):
    dp[i][0]=0
for i in range(1,n+1):
    vi = val[i];wi = wgt[i]
    for V in range(1,max_val+1):
        if vi<= V:
            dp[i][V] = min(wi+dp[i-1][V-vi],dp[i-1][V])
        else:
            dp[i][V]=dp[i-1][V]
res = 0
for i in range(max_val,-1,-1):
    if dp[n][i] <= W:
        res = i
        break
print(str(res))


Measured memory_bytes: 382644
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
long mod = (long) 1e9 + 7;
int n, m, q, a[50], b[50], c[50], d[50], ans = 0;

int bfs(vector<int> t){
    
    if(t.size() == n){
        int sum = 0;
        rep(i,q){
            if(t[b[i]] - t[a[i]] == c[i]) sum += d[i];
        }
        ans = max(ans, sum);
        
    } else {
        int back = 1;
        if(t.size() > 0) back = t.back();
        for(int i = back; i <= m; i++){
            t.push_back(i);
            bfs(t);
            t.pop_back();
        }
    }
    return 0;
}

int main(){
    
    cin >> n >> m >> q;
    
    rep(i,q) cin >> a[i] >> b[i] >> c[i] >> d[i];
    rep(i,q) a[i]--, b[i]--;
    
    bfs({});
    
    cout << ans << "\n";
    
    return 0;
}



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

int main() {
    while (true) {
        int n, a, b;
        cin >> n >> a >> b;
        if ((n | a | b) == 0) {
            break;
        }
        int representableNum = 0;
        bool* isRepresentable = new bool [n + 1];
        fill_n(isRepresentable, n + 1, false);
        isRepresentable[0] = true;
        for (int j = 0; j < a; j++) {
            int x = b * j;
            if (n < x) {
                break;
            }
            while (x <= n) {
                if (isRepresentable[x] == false) {
                    isRepresentable[x] = true;
                    representableNum++;
                }
                x += a;
            }
        }
        cout <<  n - representableNum << endl;
        delete[] isRepresentable;
    }
}

Measured memory_bytes: 0
from sys import stdin

def main():
    from collections import defaultdict
    input = stdin.readline

    n = int(input())
    a = sorted(list(map(int, input().split())))
    p = defaultdict(int)
    for x in a:
        p[x] += 1
    q = a[-1] + 1
    f = [True] * (q)
    for k, v in p.items():
        if v > 1:
            f[k] = False
        for i in range(k + k, q, k):
            f[i] = False
    print(sum(1 for x in a if f[x]))
main()

Measured memory_bytes: 38216
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int m,d;
  cin >> m >> d;
  if(d==31) cout << 1 << endl;
  else if(d==30){
    if(m==4||m==6||m==9||m==11) cout << 1 << endl;
    else cout << 0 << endl;
  }
  else if(m==2&&d==28) cout << 1 << endl;
  else cout << 0 << endl;
}

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

int main() {
  int n,a;cin>>n>>a;
  int ans = n*n-a;
  cout << ans << endl;
}


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

int main(){
  int64_t N , cnt = 0 ; 
  cin >> N ; 
  
  int64_t T = 1e13;
  
  
  for(int64_t i = 1 ; i <= sqrt(N) ; i++ ){
      //cout << i << " " << j << endl ; 
      if( N%i == 0 ){
        int64_t j = N/i ; 
        cnt = min(T , i+j -2) ; 
      }
    
    
  }
  
  cout << cnt << endl;
  
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define FOR(x, to) for(x=0; x<(to); x++)
using namespace std;

int main(){
    int X, A;
    cin >> X >> A;
    if(X < A)
        cout << '0' << endl;
    else
        cout << 10 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node {
	int key;
	Node *prev, *next;
};

Node *nil;

void init() {
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void printList() {
	Node *cur = nil->next;
	int i = 0;
	while(cur != nil) {
		if (i++ > 0) printf(" ");
		printf("%d", cur->key);
		cur = cur->next;
	}
	printf("\n");
}

Node* listSearch(int key) {
	Node *cur = nil->next;
	while(cur != nil && cur->key != key) {
		cur = cur->next;
	}
	return cur;
}

void insert(int key) {
	Node *x = (Node *)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	x->prev = nil;
	nil->next->prev = x;
	nil->next = x;
}

void deleteNode(Node *t) {
	if (t == nil) return;
	t->next->prev = t->prev;
	t->prev->next = t->next;
	free(t);
}

void deleteKey(int key) {
	deleteNode(listSearch(key));
}

void deleteFirst() {
	deleteNode(nil->next);
}

void deleteLast() {
	deleteNode(nil->prev);
}


int main() {
	int key, n;
	int size = 0;
	scanf("%d", &n);
	char cmd[20];
	init();
	for (int i = 0; i < n; i++) {
		scanf("%s%d", cmd, &key);
		if (cmd[0] == 'i') {
			insert(key);
		} else if (cmd[0] == 'd') {
			if (strlen(cmd) > 6) {
				if (cmd[6] == 'F') {
					deleteFirst();
				} else {
					deleteLast();
				}
			} else {
				deleteKey(key);
			}
		}
	}
	printList();

	return 0;
}

Measured memory_bytes: 32216
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> r(n + 1, 0), w(n + 1, 0);
    for(int i = 0; i < n; i++) {
        r[i + 1] = r[i] + (s[i] == 'R');
        w[i + 1] = w[i] + (s[i] == 'W');
    }
    int ans = INT_MAX;
    for(int i = 0; i <= n; i++) {
        ans = min(ans, max(w[i], r[n] - r[i]));
    }
    cout << ans << endl;
}


Measured memory_bytes: 5240
X, N = map(int, input().split())

try:
    p = list(map(int, input().split()))
except:
    p = []
i = 0

while True:
    if X + i not in p:
        ans = X + i
        if X - i not in p:
            ans = X - i
        break
    if X - i not in p:
        ans = X - i
        break
    
    i += 1

print(ans)

Measured memory_bytes: 9008
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<limits>
#include<algorithm>
#include<numeric>
#include<utility>
#include<iomanip>

using ULLI = unsigned long long int;
using LLI = long long int;

using namespace std;

template<class T>
class ModCal{
private:
    const ULLI MAX = 1000000;
    ULLI mod;

    std::vector<T> fac;
    std::vector<T> finv;
    std::vector<T> inv;

    void COMinit() {
        fac.resize(MAX);
        finv.resize(MAX);
        inv.resize(MAX);

        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++){
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod%i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
public:
    ModCal(ULLI _mod){
        this->mod = _mod;
        ModCal<T>::COMinit();
    }
    ModCal(){
        this->mod = 0;
    }

    T add(T a, T b){
        T tmp;
        tmp = a + b;
        if(mod != 0) tmp %= mod;
        return tmp;
    }

    T sub(T a, T b){
        T tmp;
        tmp = a - b;
        if(mod != 0){
            if(tmp < 0) tmp += mod;
            tmp %= mod;
        }
        return tmp;
    }

    T mul(T a, T b){
        T tmp;
        tmp = a * b;
        if(mod != 0) tmp %= mod;
        return tmp;
    }

    T modinv(T a, T m){
        T b = m, u = 1, v = 0;
        while (b) {
            T t = a / b;
            a -= t * b; std::swap(a, b);
            u -= t * v; std::swap(u, v);
        }
        u %= m;
        if (u < 0) u += m;
        return u;
    }

    T div(T a, T b){
        if(mod == 0){
            return a / b;
        }
        a %= mod;
        T tmp = a * ModCal<T>::modinv(b, mod) % mod;
        return tmp;
    }

    T pow(T a, T b){
        T tmp = 1;
        while(b > 0){
            if(mod != 0){
                if(b & 1) tmp = tmp * a % mod;
                a = a * a % mod;
            }else{
                if(b & 1) tmp *= a;
                a *= a;
            }
            b >>= 1;
        }
        return tmp;
    }

    // 以下の関数はMODを設定しない限り使えない
    // 無理やり使う場合は "ModCal<T> cal(Tの最大値)" でオブジェクトを作る
    T com(T n, T k){
        if(n < k) return 0;
        if(n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
    }

    T fact(T n){
        return fac[n];
    }
};

struct S{
    int A;
    int B;
    double v;

    S(int A, int B){
        this->A = A;
        this->B = B;
    }

    bool operator<(const S &l) const{
        return static_cast<double>(B)/A < static_cast<double>(l.B)/l.A;
    };
};

struct P{
    int x;
    int y;

    P(int x, int y){
        this->x = x;
        this->y = y;
    }
};

int main() {
    int N,M;

    cin >> N >> M;

    cout << ((N==M)?"Yes":"No") << endl;

    return 0;
}


Measured memory_bytes: 256
H, W, K = map(int, input().split())

c = []

for _ in range(H):
    c.append(list(input()))

ans = 0

for mask_r in range((1 << H)):
    for mask_c in range(1 << W):
        black = 0
        for i in range(H):
            for j in range(W):
                if (
                    ((mask_r >> i) & 1) == 0
                    and ((mask_c >> j) & 1) == 0
                    and c[i][j] == "#"
                ):
                    black += 1
        if black == K:
            ans += 1
print(ans)


Measured memory_bytes: 9140
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
using namespace std;

double a[114514];

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	sort(a, a + n);
	int ans1, ans2;
	ans1 = a[n - 1];
	double key = a[n - 1] / 2;
	double d = 1100000000;
	for (int i = 0; i < n - 1; i++) {
		if (fabs(a[i] - key) < d) {
			d = fabs(a[i] - key);
			ans2 = a[i];
		}
	}
	cout << ans1 << " " << ans2 << endl;
	return 0;
}

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

int a[10];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> a[0] >> a[1] >> a[2];

    sort(a, a + 3);

    if(a[0] == 5 && a[1] == 5 && a[2] == 7){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }

    return 0;
}

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

int main() {
  long N; cin >> N;
  long res = 0;
  for (long k = 1; k * k <= N; k++) {
    long m = N - k;
    if (m % k) continue;
    m /= k;
    if (k < m) res += m;
  }
  cout << res << endl;
}

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

int main() {
  int a;
  cin >> a;
  int b;
  b = a + 1;
  cout << ( b / 100 ) + 
    	( ( ( b % 100 - 1 ) - (b % 10 - 1) ) / 10 ) +
    	( b % 10 - 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define gsort(x) sort(x, x+n, greater<ll>()); 
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sync2 cout<<fixed<<setprecision(10)
const ll inf=1e9+7;
#define pi 3.14159265358979323846
#define REP(i,j,n) for (int i = (int)j; i <=(int)n; i++)
#define REPD(i,n,j) for (int i = (int)n; i>=(int)j; i--)
#define all(vv) vv.begin(),vv.end()
//priority_queue <int, vector<int>, greater<int>> mnheap;

ll arr[200005];
int main()
{
    sync;
    string st;
    cin>>st;
    int n=st.length();
    string pre="";
    int ans=0;
    int i=0;
    while(i<n)
    {
        string tmp=st.substr(i,1);
        if(pre==tmp)
        {
            if(i+1<n)
            {
                pre=st.substr(i,2);
                ans++;
                i+=2;
            }
            else
                i++;
        }
        else
        {
            pre=st.substr(i,1);
            i++;
            ans++;
        }
        //cout<<pre<<" "<<ans<<endl;
    }
    cout<<ans<<endl;
}
/*
aaaccacabaababc
*/

Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
 
const int MAXN = 1e5 + 5;
int h[MAXN], dp[MAXN];
int n, k;
 
void input();
void solve();
 
int main() {
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	input();
	solve();
	return 0;
}
 
void input() {
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> h[i];
}
 
void solve() {
	memset(dp, 63, sizeof dp);
	dp[0] = 0;
	for (int i = 0; i < n; i++)
		for (int j = 1; j <= k; j++)
			dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
	cout << dp[n - 1];
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<bitset>
#include<map>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
const int mod=998244353;
int n;
int x[205],y[205];
long long pow2[205];
int main()
{
	read(n);
	for(int i=1;i<=n;i++)
	{
		read(x[i]);
		read(y[i]);
	}
	pow2[0]=1;
	for(int i=1;i<=n;i++)
		pow2[i]=pow2[i-1]*2%mod;
	long long ans=(pow2[n]-1-n+mod)%mod;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
		{
			int cnt=0;
			for(int k=j+1;k<=n;k++)
				if((y[k]-y[j])*(x[j]-x[i])==(y[j]-y[i])*(x[k]-x[j]))
					cnt++;
			ans=(ans+mod-pow2[cnt])%mod;
		}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    if (n == (int) (i * 1.08)) {
      cout << i << endl;
      return;
    }
  }
  cout << ":(" << endl;
}

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

Measured memory_bytes: 3640
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();

        if((a * b)%2 == 0){
            System.out.println("Even");
        } else {
            System.out.println("Odd");
        }
    }
}

Measured memory_bytes: 21844
N = int(input())
F = [list(input().split()) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]

ans = -(10 ** 9)
for i in range(1, 2 ** 10):
    tmp = 0
    for j in range(N):
        f = int('0b' + ''.join(F[j]), 0)
        tmp += P[j][bin(i & f).count('1')]
    ans = max(ans, tmp)

print(ans)


Measured memory_bytes: 3064
#include<stdio.h>

int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if((a<b)&&(b<c))
        {
            printf("Yes\n");}
    else 
        { 
            printf("No\n");
        }
        return 0;
}


Measured memory_bytes: 2128
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n;
    cin>>n;
    int i=1;
    long long  sum=0;
    for(;; i++)
    {
        sum+=i;
        if(sum>=n)
        {
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long

int main(){
    int n,a,b,c,d;
    string s;
    cin>>n>>a>>b>>c>>d;
    cin>>s;

    int x[200005];
    if(s[0]=='#' && s[1]=='#') x[0]=1;
    else x[0]=0;
    rep(i,n-1){
        if(i!=0 && s[i]=='#' && s[i+1]=='#') x[i+1]=x[i]+1;
        else if(i!=0) x[i+1]=x[i];
    }

    int p=0;
    for(int i=b-1;i<d&&i<n-1;i++){
        if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.'){
            p=1;
            break;
        }
    }
    if(c<d && x[a-1]==x[c-1] && x[b-1]==x[d-1]) cout<<"Yes"<<endl;
    else if (c>d && x[a-1]==x[c-1] && x[b-1]==x[d-1] && p) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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


#define ll long long
const int MOD = 1e9+7,INF = 1e9;
int n, k,cnt1 = 0,cnt2 = 0;

int Rec(int curr,int mx,vector<int> &prices,vector<int> &pages)
{
    cnt1++;
    if(curr>=n||mx<=0)
        return 0;
    int temp1=0,temp2;
    if(mx-prices[curr]>=0)
        temp1 = pages[curr]+Rec(curr+1,mx-prices[curr],prices,pages); 
    temp2 = Rec(curr+1,mx,prices,pages);
    return max(temp1,temp2);
}
ll Memo(int curr,int mx,vector<int> &prices,vector<int> &pages,vector<vector<ll>> &memo)
{
    //cout << curr << " "<<mx<<'\n';
    if(curr>=n||mx<=0)
        return 0;
    if(memo[curr][mx]!=-1)
    {
       
        return memo[curr][mx];
    }
    ll temp1=0,temp2;
    
    if(mx-prices[curr]>=0)
        temp1 = (ll)pages[curr]+Memo(curr+1,mx-prices[curr],prices,pages,memo); 
    temp2 = Memo(curr+1,mx,prices,pages,memo);
    memo[curr][mx] = max(temp1,temp2);
    return memo[curr][mx];
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    vector<int> weights(n),values(n);
    vector<vector<ll>> memo(n+1,vector<ll>(k+1,-1));
    for(int i=0;i<n;i++)
    {
        cin >> weights[i];
        cin >> values[i];
        
    }

    cout << Memo(0,k,weights,values,memo)<<'\n';
}


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

int main(){

	while(true)
	{
		int m,l,r;
		cin >> m >> l >> r;
		if((m == -1)&&(l == -1)&&(r == -1)) break;

		int sum =0;
		sum = m + l;

		if((m == -1)||(l == -1)) cout << 'F' << endl;
		else if(sum >=80) cout << 'A' << endl;
		else if(sum >=65) cout << 'B' << endl;
		else if(sum >=50) cout << 'C' << endl;
		else if(sum >=30)
		{
			if(r == -1) cout << 'D' << endl;
			else if(r >= 50) cout <<'C' <<endl;
			else  cout << 'D' << endl;
		}else
			cout << 'F' << endl;
	}


	return 0;
}



Measured memory_bytes: 3048
#include <stdlib.h>
#include <stdio.h>
#include <math.h>

int main() {

    int n;
    while( scanf("%d", &n) != EOF) {
        int s = 0;
        int i, f = n;
        for(i = 0; i < 600; i+=f) {
            s += f * i * i;
        }

        printf("%d\n", s);
    }

    return 0;
}

Measured memory_bytes: 596
S = list(input())
count = 0
max_count = 0
for i in range(len(S)):
    a = S[i]
    if a == 'R':
       count += 1
    else:
       max_count = max(max_count, count)
       count = 0
max_count = max(max_count, count)
print(max_count)

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

int main(void){
  vector<int> x(3);
  for(int i=0;i<3;i++) cin >> x[i];
  sort(x.rbegin(),x.rend());
  cout << 10*x[0]+x[1]+x[2] << endl;
  
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
m = list(map(int, input().split()))
memo = [[-1]*2000 for _ in range(20)]
def solve(i, m):
    if memo[i][m] != -1:
        return memo[i][m]
    if m == 0:
        memo[i][m] = 1
        return True
    if m < 0:
        memo[i][m] = 0
        return False
    if i >= N:
        memo[i][m] = 0
        return False
    if i == N-1:
        memo[i][m] = (A[N-1] == m)
        return (A[N-1] == m)
    res = solve(i+1, m) or solve(i+1, m-A[i])
    memo[i][m] = res
    return res
for mi in m:
    if solve(0, mi):
        print("yes")
    else:
        print("no")


Measured memory_bytes: 5944
//#inclde <bits/stdc++.h>
//using namespace std;
#include <iostream>
#include <string>


   // int mokemoke,hogehoge;
   // std::cin >> mokemoke >> hogehoge;
   // std::cout << mokemoke << hogehoge << std::endl;

int main(){

    int a,b,c,d;
    std::cin >> a >> b >> c >> d;
    if(a > b){
        int e,f,g;
        e = b * c;
        g = a - b;
        f = g * d;
        std::cout << e + f << std::endl;
    }

    else {
        std::cout << a * c << std::endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	ll n,l,t;
	cin >> n >> l >> t;
	vl wa,wb;
	for(int i=0;i<n;i++) {
		ll x, dir;
		cin >> x >> dir;
		if(dir == 1) {
			wa.push_back(x);
		} else {
			wb.push_back(x);
		}
	}
	ll ot = t;
	t *= 2;
	ll dif = 0;
	for(int i=0;i<wa.size();i++) {
		wa[i] += t;
		dif += wa[i]/l;
		wa[i] %= l;
	}
	wb.insert(wb.end(),wa.begin(),wa.end());
	sort(wb.begin(),wb.end());
	vl res(n,0);
	for(int i=0;i<wb.size();i++) {
		int id = (((i-dif)%n)+n)%n;
		res[id] = wb[i];
	}
	for(int i=0;i<n;i++) {
		res[i] = (((res[i]-ot)%l)+l)%l;
		cout << res[i] << '\n';
	}
}


Measured memory_bytes: 5536
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))
import math
 
N, K = mi()
A = li()
 
if K == 0:
    print(max(A))
    exit()
 
left = 0
right = max(A)
 
def count(num):
    cnt = 0
    for i in range(N):
        cnt += math.ceil(A[i] / num) - 1
    return cnt
 
while True:
    mid = (left + right) // 2
    if mid == 0:
        mid += 1
        break
    tmp = count(mid)
    if tmp == K:
        break
    elif tmp > K:
        if left == mid:
            mid = right
            break
        left = mid
    else:
        right = mid
 
if mid == 0 or mid == 1:
    print(mid)
    exit()
 
right = mid
 
while True:
    tmp = count(mid)
    if tmp == K and tmp != count(mid-1):
        print(mid)
        break
    elif tmp == K:
        right = mid
    else:
        if left == mid:
            print(right)
            break
        left = mid
    mid = (left + right) // 2
    if mid == 0:
        print(1)
        break

Measured memory_bytes: 31028
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
typedef pair<int, int> P;

const int INF = (int)1e9;

int board[128][128];

int main()
{
    int w, h;

    while (scanf("%d %d", &w, &h), w){
        int xs, ys;
        int xg, yg;
        scanf("%d %d", &xs, &ys);
        scanf("%d %d", &xg, &yg);

        int n;
        scanf("%d", &n);
        memset(board, 0, 128 * 128);
        while (n-- > 0){
            int c, d, x, y;
            scanf("%d %d %d %d", &c, &d, &x, &y);

            board[y][x] = board[y][x + 1] = c;
            board[y + 1][x] = board[y + 1][x + 1] = c;
            if (d == 0){
                board[y][x + 2] = board[y][x + 3] = c;
                board[y + 1][x + 2] = board[y + 1][x + 3] = c;
            }
            else {
                board[y + 2][x] = board[y + 3][x] = c;
                board[y + 2][x + 1] = board[y + 3][x + 1] = c;
            }
        }

        queue<P> que;
        bool flag = false;
        int color = board[ys][xs];

        if (!color){
            puts("NG");
            continue;
        }

        for (que.push(P(xs, ys)); que.size(); que.pop()){
            P p = que.front();
            int x = p.first;
            int y = p.second;

            if (board[y][x] != color) continue;

            if (x == xg && y == yg){
                flag = true;
                break;
            }
            board[y][x] = !color;
            que.push(P(x + 1, y));
            que.push(P(x - 1, y));
            que.push(P(x, y + 1));
            que.push(P(x, y - 1));
        }

        puts(flag ? "OK" : "NG");
    }

    return 0;
}

Measured memory_bytes: 1068
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
#include <unordered_map>
#include <stack>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define INF 21474836

int N;
string X[200004];

int main() {

	cin >> N;
	rep(i, N)cin >> X[i];
	
	unordered_map<string, int> mp;
	set<string> st;


	rep(i, N) {
		st.insert(X[i]);
		mp[X[i]] ++;
	}
	
	int max = 0;
	set<string> sttr;
	vector<string> stt,ans;

	for (auto itr = st.begin(); itr != st.end(); ++itr) {
		if (mp[*itr] > max) {
			sttr.clear();
			sttr.insert(*itr);
			max = mp[*itr];
		}
		if (mp[*itr] == max) {
			sttr.insert(*itr);
		}
	}

	for (auto itr = sttr.begin(); itr != sttr.end(); ++itr) {
		stt.push_back(*itr);
	}

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

	for (auto itr = stt.begin(); itr != stt.end(); ++itr) {
		cout << *itr << "\n";
	}


	cout << endl;
}


Measured memory_bytes: 47044
#include <iostream>
#include <cstdio>
using namespace std;
int n,ans = 0;
bool vis[202020];
int main()
{
	scanf("%d",&n);
	vis[0] = 1;
	for(int i = 1; i <= n; i++)
	{
		int x;
		scanf("%d",&x);
		if(vis[x-1])	vis[x] = 1, ans = max(ans, x);
	}
	if(ans)	printf("%d",n-ans);
	else	printf("-1");
	return 0;
}

Measured memory_bytes: 384
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int A = input[0];
            int B = input[1];
            int max1 = Math.Max(A + B, A - B);
            int max2 = Math.Max(A * B, max1);
            Console.WriteLine(max2);
        }
    }
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n = in();
    vint t = in(n);
    int m = in();
    vint p(m), x(m);
    rep(i, m)
    {
        cin >> p[i] >> x[i];
        --p[i];
    }

    int sum = accumulate(ALL(t), 0);

    rep(i, m)
    {
        int ans = sum - t[p[i]] + x[i];
        cout << ans << endl;
    }
}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <list>
#include <functional>
#include <algorithm>

using namespace std;

int main(int, char**){
    int a,b,c,d,e;
    cin >> a>>b>>c>>d>>e;
    vector<int> v = {a,b,c,d,e};
    std::sort(v.begin(),v.end(),greater<int>());
    //for(auto e: v) cout << e << ' ';
    cout << v[0] << ' ' << v[1] << ' ' << v[2] << ' ' << v[3] << ' ' << v[4] << endl;
    return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define erep(i, n) for (int i = 0; i <= (n); i++)
#define erep1(i, n) for (int i = 1; i <= (n); i++)
using namespace std;
using ll = long long;
#define INF 100000000

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    int a[13][13] = {0};
    vector<int> c(n);
    rep(i, n) {
        cin >> c[i];
        rep(j, m) {
            cin >> a[i][j];
        }
    }
    int ans = 0;
    int min = INF;
    
    for (int bit = 0; bit < (1 << n); ++bit) {
        ans = 0;
        int b[13] = {0};
        for (int i = 0; i < n; ++i) {
            if (bit & (1 << i)) {
                ans += c[i];
                rep(j, m) {
                    b[j] += a[i][j];
                }
            }
        }
        rep(i, m) {
            if (b[i] >= x) {
                continue;
            } else {
                ans = INF;
                break;
            }
        }
        if (min > ans) {
            min = ans;
        }
    }
    if (min == INF) {
        cout << "-1" << endl;
    } else {
        cout << min << endl;
    }
}


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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define MAX 1000010

using namespace std;

int n,A[MAX],cnt;

void insertionSort(int g){
  REP(i,g,n){
    int v = A[i];
    int j = i - g;
    while( j >= 0 && A[j] > v ){
      A[j+g] = A[j];
      j = j - g;
      cnt++;
    }
    A[j+g] = v;
  }
}

void shellSort(){
  cnt = 0;
  /*
  int m = rand() % min(n,100) + 1;
  int *G = new int[m];
  G[0] = 1;
  set<int> used;
  used.insert(1);
  REP(i,1,m){
    int v = rand() % n + 1;
    while( used.find(v) != used.end() ) v = rand() % n + 1;
    used.insert(v);
    G[i] = v;
  }
  sort(G,G+m);
  */
  int m = 1;
  vector<int> G;
  G.push_back(1);
  while( G.back()*3+1 <= n && m < 100 ){
    m++;
    G.push_back(G.back()*3+1);
  }
  reverse(G.begin(),G.end());
  rep(i,m)insertionSort(G[i]);
  cout << m << endl;
  rep(i,m){
    if( i ) cout << ' '; 
    cout << G[i];
  } cout << endl;
  cout << cnt << endl;
  rep(i,n)cout << A[i] << endl;
  //delete [] G;
}

int main(){
  srand((unsigned int)time(NULL));
  cin >> n;
  rep(i,n)cin>>A[i];
  shellSort();
  return 0;
}

Measured memory_bytes: 7016
#include <bits/stdc++.h>
#define INT long long int
#define N 3
#define PA pair<INT, INT>
#define oo 9876543219876543
#define MOD 1000000007
using namespace std;
INT T, n, m, k, x, y, z, a[500050], b[500040], c[500050], ans, Z, Y, dt[300030][2];
set<INT> u, d;
string s, t;

int main()
{
    ios::sync_with_stdio(false);
    T = 1; //cin>>T;
    while( T-- )
    {
        cin>>n>>m>>x>>y;
        cout<<max(n*x, max(n*y, max(m*x, m*y)));

    }
    return 0;
}


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

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

	int n, x;
	vector<int> a;
	cin >> n;
	for (int i = 0; i < n; ++i){
		cin >> x;
		a.push_back(x);
	}
	sort(a.begin(), a.end());
	cout << a[n-1] - a[0] << endl;
	return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

struct UnionFind{
    public:
        UnionFind(int n): _n(n), parent_or_size(n, -1){}

        void unite(int a, int b){
            int x = root(a), y = root(b);
            if(x == y) return;
            if(-parent_or_size[x] < -parent_or_size[y]) swap(x, y);
            parent_or_size[x] += parent_or_size[y];
            parent_or_size[y] = x;
            return;
        }

        bool same(int a, int b){
            return root(a) == root(b);
        }

        int root(int a){
            if(parent_or_size[a] < 0) return a;
            return parent_or_size[a] = root(parent_or_size[a]);
        }

        int get_size(int a){
            return -parent_or_size[root(a)];
        }

        std::vector<std::vector<int>> groups(){
            std::vector<int> leader_buf(_n), group_size(_n);
            for (int i = 0; i < _n; i++) {
                leader_buf[i] = root(i);
                group_size[leader_buf[i]]++;
            }
            std::vector<std::vector<int>> result(_n);
            for (int i = 0; i < _n; i++) {
                result[i].reserve(group_size[i]);
            }
            for (int i = 0; i < _n; i++) {
                result[leader_buf[i]].push_back(i);
            }
            result.erase(
                std::remove_if(result.begin(), result.end(),
                            [&](const std::vector<int>& v) { return v.empty(); }),
                result.end());
            return result;
        }

    private:
        int _n;
        //root node: -1*component size
        //otherwise: parent
        vector<int> parent_or_size;
};

int main()
{
    ll i,j;
    ll n, q;
    cin >> n >> q;
    UnionFind uf(n);
    rep(i,q){
        ll c;
        cin >> c;
        ll u,v;
        cin >> u >> v;
        if(c) cout << uf.same(u, v) << endl;
        else uf.unite(u,v);
    }

    return 0;
}

Measured memory_bytes: 3932
#include<iostream>
using namespace std;
int main()
{

    int n;
    cin>>n;
    int arr[n][3];
    for(int i = 0 ; i < 3 ; i++)
    {

        cin>>arr[0][i];
    }
    for(int i = 1 ; i < n ; i++)
    {
        for(int j = 0 ; j < 3 ; j++)
        {
            cin>>arr[i][j];
            int maxi = 0;
            for(int k = 0 ; k < 3 ; k++)
            {

                if(k != j)
                {
                    if(arr[i-1][k] > maxi )
                        maxi = arr[i-1][k];
                }
            }
            arr[i][j] = arr[i][j] + maxi;

        }

    }
    int maxi = 0;
    for(int i = 0 ; i < 3 ; i++)
    {
        if(arr[n-1][i] > maxi)
            maxi = arr[n-1][i];

    }
    cout<<maxi;
}


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

void LCS(string s, string t) {
    vector<vector<ll>> dp(MAX_N + 1, vector<ll>(MAX_M + 1));
    vector<vector<pair<int, int>>> root(MAX_N + 1,
                                        vector<pair<int, int>>(MAX_M + 1));

    rep(i, s.size()) {
        rep(j, t.size()) {
            if(s[i] == t[j]) {
                dp[i + 1][j + 1] = dp[i][j] + 1;
                root[i + 1][j + 1].first = i;
                root[i + 1][j + 1].second = j;
            } else {
                if(dp[i + 1][j] > dp[i][j + 1]) {
                    dp[i + 1][j + 1] = dp[i + 1][j];
                    root[i + 1][j + 1].first = i + 1;
                    root[i + 1][j + 1].second = j;
                } else {
                    dp[i + 1][j + 1] = dp[i][j + 1];
                    root[i + 1][j + 1].first = i;
                    root[i + 1][j + 1].second = j + 1;
                }
            }
        }
    }
    string res;
    int rx = t.size();
    int ry = s.size();
    int ny = root[s.size()][t.size()].first;
    int nx = root[s.size()][t.size()].second;
    if((rx - nx) == 1 && (ry - ny) == 1) {
        res = s[ny] + res;
    }

    while(nx != 0 && ny != 0) {

        rx = nx;
        ry = ny;
        ny = root[ry][rx].first;
        nx = root[ry][rx].second;
        if((rx - nx) == 1 && (ry - ny) == 1) {
            res = s[ny] + res;
        }
    };
    cout << res << endl;
}
int main() {
    string s;
    string t;
    cin >> s;
    cin >> t;
    LCS(s, t);

    return 0;
}

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

int main() {
    ll n, x = -1, y = -1;
    cin >> n;
    for (ll i = (ll)sqrt(n); i >= 2; i--) {
        if (n % i == 0) {
            x = i;
            y = n / i;
            break;
        }
    }
    if (x == -1)
        cout << n - 1 << endl;
    else
        cout << x + y - 2 << endl;
    return 0;
}

Measured memory_bytes: 256
/***
 *                  ___====-_  _-====___
 *            _--^^^#####//      \\#####^^^--_
 *         _-^##########// (    ) \\##########^-_
 *        -############//  |\^^/|  \\############-
 *      _/############//   (@::@)   \\############\_
 *     /#############((     \\//     ))#############\
 *    -###############\\    (oo)    //###############-
 *   -#################\\  / VV \  //#################-
 *  -###################\\/      \//###################-
 * _#/|##########/\######(   /\   )######/\##########|\#_
 * |/ |#/\#/\#/\/  \#/\##\  |  |  /##/\#/  \/\#/\#/\#| \|
 * `  |/  V  V  `   V  \#\| |  | |/#/  V   '  V  V  \|  '
 *    `   `  `      `   / | |  | | \   '      '  '   '
 *                     (  | |  | |  )
 *                    __\ | |  | | /__
 *                   (vvv(VVV)(VVV)vvv)
 *                        神龙护体
 *                       ´ 代码AC
 ***/
#include<iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#include <math.h>
#include<algorithm>
#include <stack>
#include <string>
#include <queue>-
#define ll long long int
using namespace std;



int main()
{
    int m;
    cin>>m;
    cout<<48-m<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var k, x int
	fmt.Scanf("%d %d", &k, &x)

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

	sort.Ints(coordinates)
	for _, v := range coordinates {
		fmt.Printf("%d ", v)
	}
}


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

//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
typedef long long ll;

int main(){
    ll r = 0,mod = 1e9+7;
    int N,c;
    cin >> N;
    vector<int> v(N+1,0);
    vector<ll> ac(N+1,1);
    map <int,vector<int>> mp;
    
    for (int i=1;i<=N;++i){
        cin >> c;
        v[i] = c;
        mp[c].push_back(i);
        if (mp[c].size()>=2 && mp[c][mp[c].size()-2]<i-1){
            int tmp = mp[c].size()-2;
            tmp = mp[c][tmp];
            r = ac[tmp]+ac[i-1];
        }
        else {
            r = ac[i-1];
        }
        r%=mod;
        ac[i] = r; 
    }
    cout << ac[N]%mod << endl;
}

Measured memory_bytes: 24448
s = int(input())
L = [s]
cnt = 2
while True:
    if s%2 == 0:
        s = s/2
        if s in L:
            print(cnt)
            break
        else:
            L.append(s)
            cnt += 1
    else:
        s = 3*s+1
        if s in L:
            print(cnt)
            break
        else:
            L.append(s)
            cnt += 1

Measured memory_bytes: 3060
#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;
#define   sz(s)         s.size()
#define   ll            long long int
#define   ull           unsigned ll
#define   ld            long double
#define   print(v)      for(ll i=0;i<v.size();i++)cout<<v[i]<<" "
#define   printpair(v)  for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<"\n"
#define   bmd           1000000007
#define   bmd1          998244353
#define   umll          unordered_map<ll,ll>
#define   mll           map<ll,ll>
#define   mcl           map<char,ll>
#define   pll           pair<ll,ll>
#define   F             first
#define   S             second
#define   setp(x)       setprecision(x)
#define   pb            push_back
#define   all(v)        v.begin(),v.end()
#define   tr(a)         for(auto it=a.begin();it!=a.end();it++)
#define   trr(a)        for(auto it1=a.begin();it1!=a.end();it1++)
#define   vll           vector<long long int>
#define   sorty(v)      sort(v.begin(),v.end())
#define   rsort(v)      sort(v.rbegin(),v.rend())
#define   PI            3.1415926535897932384626
#define   db()          cout<<"\n"<<"here"<<"\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


//---------------------------------------------------------------------------
const int MOD = bmd;
const int N=2e5+100;
inline  ll sqr(ll x){return x*x;}
inline  void normal(ll &a) { a = (a+MOD)%MOD; }
inline  ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline  ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline  ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline  ll modPow(ll b, ll p) { ll r = 1;b=b%MOD; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline  ll modInv(ll a) { return modPow(a, MOD-2); }
inline  ll modDiv(ll a,ll b) { return modMul(a, modInv(b)); }
//---------------------------------------------------------------------------
void solve()
{
    ll n,w;
    cin>>n>>w;
    ll wt[n+2],val[n+2];
    for(ll i=0;i<n;i++)
        cin>>wt[i]>>val[i];
    ll dp[n+2][w+2];
    //memset(dp,0,sizeof(dp));
    for(ll i=0;i<=n;i++){
        for(ll j=0;j<=w;j++){
            if(i==0 || j==0)
                dp[i][j]=0;
            else if(wt[i-1]<=j)
                dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    cout << dp[n][w];

}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);//first give all input then gives output
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 79360
#include <bits/stdc++.h>
#include<string>
#define mod 1000000007
using ll = long long;
using namespace std; 

int main(){
    int n; cin >> n;
    if (n%1000==0){
        cout << 0 << "\n";
    }
    else cout << 1000-n%1000 <<  "\n";
}



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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

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

    string a;
    string b;
    cin >> a;
    cin >> b;
    bool c = true;
    for(int i = 0; i < a.size(); i++){
        if(a[i] != b[i])
            c = false;
    }
    if(b.size() != a.size() + 1)
        c = false;
    if(c)
        cout << "Yes";
    else
        cout << "No";
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define N 3010
#define pb push_back
#define fi first
#define se second
#define si size()
#define ll long long
#define mp make_pair
#define iter ::iterator
#define all(v) v.begin(), v.end()
#define pp pop_back
#define mapiter map<int, int>::iterator
#define forn(i, n) for(int i = 0; i < n; ++i)
#define forn1(i, n) for(int i = 1; i <= n; ++i)
#define forr(i, n)	for(int i = n - 1; i >= 0; --i)
#define forr1(i, n)	for(int i = n; i >= 1; --i)
#define r0 return 0
#define barnarnar ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define lld long double
#define elif else if
 
const ll inf = 1e12 + 7;
const lld EPS = 0.00000001;
const ll modw = 1e9 + 7;

using namespace std;

int dp[N][N];

int main()
{
	barnarnar
	string s, t;
	cin >> s >> t;
	int n = s.si, m = t.si;
	s = '1' + s;
	t = '1' + t;
	forn1(i, n)
	{
		forn1(j, m)
		{
			if(s[i] == t[j])	dp[i][j] = dp[i - 1][j - 1] + 1;
			else
			{
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}
	int x = n, y = m;
	string ans = "";
	while(x != 0 && y != 0)
	{
		if(dp[x][y] == dp[x - 1][y])	x--;
		elif(dp[x][y] == dp[x][y - 1])	y--;
		else
		{
			ans = s[x] + ans;
			x--;
			y--;
		}
	}
	cout << ans;
	return 0;
}



Measured memory_bytes: 35584
a, b = list(map(int,input().split()))
i = [1,3,5,7,8,9,10,12]
j = [4,6,9,11]
k = i.count(a)
l = i.count(b)
m = j.count(a)
n = j.count(b)
if k+l ==2 or m+n == 2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;
 
void Main()
{
	int r;
  
  	cin >> r;
  
    printf("%d", r * r);
	
	
}
 
int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 256