akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <deque>
#include <vector>
using namespace std;

int main() {
	int n,r,p,c,tmp;
	while(cin >> n >> r){
	if(n==0)
		break;
	deque<int> library;
	vector<int> stack;
	for(int i=1;i<=n;i++)
	library.push_back(n-i+1);
	for(int i=0;i<r;i++){
		cin >> p >> c;
		for(int j=p+c-1;j<library.size();){
			stack.push_back(library.back());
			library.pop_back();
		}
		for(int j=0;j<c;j++){
			tmp=library.back();
			library.pop_back();
			library.push_front(tmp);
		}
		while(!stack.empty()){
			library.push_back(stack.back());
			stack.pop_back();
		}
	}
	cout << library.front() << endl;
	library.clear();
	stack.clear();
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define sz size()
#define y1 dfsdsfsdfsd
#define next fdsfsdfjkl
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
double pi = acos(-1.0);
const int inf = 1e9+7;
const ll INF = 1e18+7;
//////////////////////////////////////////

int n;
int a[100100];

int cnt0=0;
int cnt1=0;                    
int main(){speed;
	  cin>>n;
	  for(int i=1;i<=n;i++)
	  {
	     int x;
	     cin>>x;
	     if(x%2==0) cnt0++;
	     else cnt1++;
	  }
	
	  if(cnt1%2==1)
	  {
	   	cout<<"NO";
	   	return 0;
	  }
	  cout<<"YES";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,P=1000000007;
int dp[3000000];
long long match(long long mask,int i,int *a){
	if(mask==0)
		return 1;
	if(dp[mask]==-1){
		long long sum=0;
		for(int j=0;j<n;j++){
			if(a[i*n+j]==1 and mask&(1<<j))
				sum=(sum+match(mask^(1<<j),i+1,&a[0]))%P;
		}
		dp[mask]=sum;
	}
	return dp[mask];
}
int main(){
	cin >> n;
	int a[n][n];
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			cin >> a[i][j];
	cout << match((1<<n)-1,0,&a[0][0]) << endl;
}

Measured memory_bytes: 11904
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int n = s.size();
	ll ans = 0, cnt = 0;
	for(int i = n-1; i >= 0; --i){
		if(s[i] == 'W') ++cnt;
		else ans += cnt;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 720
#include<stdio.h>
#define n 100000
int main()
{
    int num,sum=0,i,a[n];
    scanf("%d",&num);
    for(i=0;i<num;i++)
    {
        scanf("%d",&a[i]);
        sum=sum+(a[i]-1);
    }
    printf("%d",sum);
    return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    ll tmp = 0;
    REP(i, m) {
        cin >> a[i];
        tmp += a[i];
    }
    if(tmp > n) 
        cout <<  -1 << endl;
    else 
        cout << n - tmp << endl;
    return 0;
}

Measured memory_bytes: 3672
// C - Tax Increase
#include <bits/stdc++.h>
using namespace std;
int A,B;

int solve(){
	for(int i=1; i<1250; ++i)
		if(int(i*0.08)==A && int(i*0.10)==B) return i;
	return -1;
}

int main(){
	cin>>A>>B;
	cout<< solve() <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

char s[200005];

int main() {
    int n;
    scanf("%d",&n);
    scanf("%s",s+1);
    ll ans = 1, num = 0;
    for(int i = 1;i<=n*2;i++) {
        if(s[i]=='W') {
            if(i&1) {
                ans = ans*num%mod;
                if(--num<0) {
                    cout<<0<<'\n'; return 0;
                }
            } else {
                num++;
            }
        } else  {
            if(i&1) {
                num++;
            } else {
                ans = ans*num%mod;
                if(--num<0) {
                    cout<<0<<'\n'; return 0;
                }
            }
        }
    }
    if(num) {
        cout<<0<<'\n'; return 0;
    }
    for(int i = 1;i<=n;i++) ans = ans * i % mod;
    printf("%I64d\n",ans);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<ll> a(n);
	vector<pair<ll, ll>> b(m);
	rep(i, n) cin >> a[i];
	rep(i, m) cin >> b[i].second >> b[i].first;
	sort(rall(a));
	sort(rall(b));
	
	int q = 0;
	int w = 0;
	ll ans = 0;
	bool elf1 = false, elf2 = false;
	rep(i, n) {
		ll res = 0;
		if (elf1) {
			res += b[q].first;
			b[q].second--;
			ans += res;
			continue;
		}
		if (elf2) {
			res += a[w];
			w++;
			ans += res;
			continue;
		}
		if (b[q].first > a[w]) {
			res += b[q].first;
			b[q].second--;
		}
		else {
			res += a[w];
			w++;
		}
		if (b[q].second == 0) q++;
		ans += res;
		if (w == n) elf1 = true;
		if (q == m) elf2 = true;
	}

	dunk(ans);

	return 0;
}


Measured memory_bytes: 2560
n, m = map(int, input().split())
fr = [[] for _ in range(n)]
for _ in range(m):
    a, b = list(map(int, input().split()))
    fr[a-1].append(b-1)
    fr[b-1].append(a-1)
max_gr = 0
check = [False for _ in range(n)]
ans = 0

for per in range(n):
    if check[per]:
        continue

    else:
        tank = [per]
        count = 0
        while tank:
            now = tank.pop()
            if check[now]:
                continue
            else:
                check[now] = True
                count += 1
                for j in fr[now]:
                    if not check[j]:
                        tank.append(j)

        ans = max(ans, count)

print(ans)


Measured memory_bytes: 44484
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 4e5 + 5;

ll a[N], b[N];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    for(int i = 0; i < n + 1; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        cin >> b[i];
    }
    ll z = 0, sum = 0;
    for(int i = 0; i < n; i++){
        ll kam = min(b[i], a[i]);
        b[i]-=kam;
        sum += kam;
        kam = min(b[i], a[i + 1]);
        a[i+1] -= kam;
        sum += kam;
    }
    cout << sum;


    return 0;
}


Measured memory_bytes: 3072
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n)
	fmt.Scan(&k)

	amari := n % k

	if amari == 0 {
		fmt.Println(0)
	} else {
		diff := k - amari
		if amari > diff {
			fmt.Println(diff)
		} else {
			fmt.Println(amari)
		}
	}
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;

int n;
int a[14];
void saiki(int ind)
{
	if(ind==n)
	{
		rep(i,n)
		{
			cout<<(char)('a'+a[i]);
		}
		cout<<endl;
	}
	else if(ind==0)
	{
		a[ind]=0;
		saiki(1);
	}
	else
	{
		int p=0;
		rep(i,ind)
		{
			if(p<a[i])p=a[i];
		}
		for(int i=0;i<=p+1;i++)
		{
			a[ind]=i;
			saiki(ind+1);
		}
	}
}
int main()
{
	cin>>n;
	saiki(0);
	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

int main() {
    int q;
    while (cin >> q && q) {
        vector<string> v;
        while (q--) {string w; cin >> w; v.push_back(w);}
        int c[] = {5, 7, 5, 7, 7};
        int now = 0;
        int sum = 0;
        int flg = 0;
        rep(i, v.size()) {
            rrep(j, i, v.size()) {
                sum += v[j].size();
                //cout << sum << endl;
                if (sum == c[now]) {
                    sum = 0;
                    now++;
                    if (now == 5) {
                        cout << i + 1 << endl;
                        flg = 1;
                        break;
                    }
                } else if (sum > c[now]) {
                    now = 0;
                    sum = 0;
                    break;
                }
            }
            if (flg) break;
        }
    }
}




Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N,L;
    cin >> N >> L;
    vector<string> res(N);
    REP(i,N) cin >> res[i];
    sort(res.begin(),res.end());
    REP(i,N) cout << res[i];
    cout << endl;
}

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

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

Measured memory_bytes: 1660
// #include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

// #define int long long

// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define all(v) v.begin(), v.end()
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
// union of two containers
template <typename T>
void container_union(T &c1, T &c2, T &c3) {
  std::vector<int> vec;
  std::set_union(c1.begin(), c1.end(),
                 c2.begin(), c2.end(),
                 std::back_inserter(vec));
  T tmp(vec.begin(), vec.end());
  c3 = tmp;
}

// chmax, chmin
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

// grid-search
std::vector<int> dx = {1, -1, 0,  0};
std::vector<int> dy = {0,  0, 1, -1};
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// type alias
using VI = std::vector<int>;
using VII = std::vector<VI>;
using VB = std::vector<bool>;
using VBB = std::vector<VB>;
using VS = std::vector<std::string>;
using PII = std::pair<int, int>;

// yes/no
std::string yes = "Yes";
std::string no = "No";
std::string YES = "YES";
std::string NO = "NO";

void solve();

signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  solve();
  return 0;
}

void solve() {
  int n, k;
  std::cin >> n >> k;
  VI p(n);
  std::vector<int> e(n);
  REP(i, n) {
    std::cin >> p.at(i);
    e.at(i) = p.at(i) + 1;
  }

  int max = 0;
  int sum = 0;
  REP(i, n - k + 1) {
    if (i == 0) {
      REP(j, k) {
        sum += e.at(j);
      }
    } else {
      sum -= e.at(i-1);
      sum += e.at(i+k-1);
    }
    chmax(max, sum);
  }
  cout(max / 2 << (max % 2 == 0 ? ".0" : ".5"));
}


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

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

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(Args&&... args) const { print(std::forward<Args>(args)...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(T&& head, Tail&&... tail) const { std::cout << head, print_rest(std::forward<Tail>(tail)...); }
        template <class T, class... Tail>
        void print_rest(T&& head, Tail&&... tail) const { std::cout << sep << head, print_rest(std::forward<Tail>(tail)...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
    template <class T>
    void print_vec(const std::vector<T>& vec, const char* sep = " ", const char* term = "\n") const {
        const size_t sz = vec.size();
        for (size_t i = 0; i < sz; i++) std::cout << vec[i] << (i == sz - 1 ? term : sep);
    }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    string S;
    cin >> S;
    ll ans = 0;
    ll cnt = 0;
    for (ll i = 0; i < 3; i++) {
        if (S[i] == 'R') {
            ++cnt;
        }
        else {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    if (cnt) {
        ans = max(ans, cnt);
    }
    prints()(ans);
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc079/tasks/abc079_c

string abcd;
string op;

bool dfs(int sum, string opc) {
    int len = opc.length();
    if (len == 3) {
        op = opc;
        return sum == 7;
    }

    if (dfs(sum + (abcd[len + 1] - '0'), opc+"+")) return true;

    if (dfs(sum - (abcd[len + 1] - '0'), opc+"-")) return true;

    return false;
}

int main() {
    cin >> abcd;

    if (dfs(abcd[0] - '0', "")) {
        printf("%c%c%c%c%c%c%c=7\n", abcd[0], op[0], abcd[1], op[1], abcd[2], op[2], abcd[3]);
    } else {
        cout << "NO" << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding:utf-8 -*-

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

alphabet = "".join([chr(i) for i in range(ord('A'), ord('Z') + 1)])

H, W = map(int, input().split())
for i in range(H):
    s = input()
    if 'snuke' in s:
        for w, a in zip(s.split(), alphabet):
            if w == 'snuke':
                print("{}{}".format(a, i+1))


Measured memory_bytes: 3188
n = int(input())
a = list(map(int, input().split()))
b = [0]*(n+1)
l = [i for i in range(n+2)]
r = [i for i in range(n+2)]
ans = 0
for i in range(n):
    b[a[i]] = i

for i in range(n, 0, -1):
    m = b[i]
    x, y = l[m], r[m]
    ans += i*(m-x+1)*(y-m+1)
    l[y+1], r[x-1] = x, y
print(ans)


Measured memory_bytes: 35776
let () =
  Scanf.scanf "%d\n" @@ fun n ->
  let a = Array.init n @@ fun i -> Scanf.scanf "%d " @@ fun d -> (i+1,d) in
  let _ = Array.fast_sort (fun (_,x) (_,y) -> compare x y) a in
  for i = 0 to n - 2 do
    print_int (fst a.(i)); print_string " ";
  done;
  print_int (fst a.(n-1)); print_newline ();

Measured memory_bytes: 9800
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll n, ans;
ll d[205][205][205];

int main()
{
    cin>>n;
    for(ll i = 1; i <= n; i++)
    {
        for(ll j = i; j <= n; j += i)
        {
            for(ll k = i; k <= n; k += i)
            {
                for(ll l = i; l <= n; l += i)
                {
                    d[j][k][l] = i;
                }
            }
        }
    }
    for(ll i = 1; i <= n; i++)
    {
        for(ll j = 1; j <= n; j++)
        {
            for(ll k = 1; k <= n; k++)
            {
                ans += d[i][j][k];
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 68488
n, l = list(map(int, input().split()))

wordlist = []
output_word = ""

for i in range(n):
  wordlist.append(input())

while wordlist:
  minimumword = wordlist[0]
  for i in range(len(wordlist)):
    minimumword = wordlist[i] if wordlist[i] < minimumword else minimumword

  output_word += minimumword
  del wordlist[wordlist.index(minimumword)]

print(output_word)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;

 
int main() {
	map<vector<int>, long long> m;
	long long n, ans = 0;
	cin >> n;
	string s;
	for(int i = 0; i < n; ++i){
		cin >> s;
		vector<int> l(26, 0);
		for(int j = 0; j < 10; ++j) l[(int)(s[j] - 'a')]++;
		m[l]++;
		if(m[l] != 0) ans += m[l] - 1;
		l.clear();
	}
	cout << ans;
}

Measured memory_bytes: 18944
#include <iostream>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

int main(void){
    double r,s,t;
    cin >> r;
    s = r * 2 * M_PI;
    t = r * r * M_PI;
    cout  << fixed << r * r * M_PI << " " <<  r * 2 * M_PI << endl;
    return 0;
}


Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  vector<int> B(N+10);
  REP(i, N) { B[A[i]] = B[A[i] - 1] + 1; }
  cout << N - *max_element(B.begin(), B.end()) << endl;
}

Measured memory_bytes: 4848
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
using namespace std;
using ll = long long;

int main() {
  int n, W;
  cin >> n >> W;
  vector<int> w(n), v(n);
  for (int i = 0; i < n; ++i) {
    cin >> w[i] >> v[i];
  }
  vector<ll> dp(W + 1, 0);
  for (int i = 0; i < n; ++i) {
    vector<ll> new_dp(W + 1, 0);
    for (int j = 0; j <= W; ++j) {
      if (i > 0) {
        new_dp[j] = max(new_dp[j], dp[j]);
      }
      if (j-w[i] >= 0) {
        new_dp[j] = max({new_dp[j], (i > 0 ? dp[j-w[i]]: 0) + v[i]});
      }
    }
    dp = new_dp;
  }

  cout << dp[W] << '\n';
  return 0;
}


/* 0-1 knapsack
 *
 * dp[i][j] = max value (first i object, with weight <= j)
 */


Measured memory_bytes: 4816
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
    cin >> n;
	string a,b,s;
    cin >> a >> b;
    for(int i=0;i<n;i++)
    {
    	s += a[i];
        s += b[i];
    }
    cout << s;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);


int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    ll N; cin>>N;
    vector<ll> A(N+1,0);
    rep1(i,N) cin>>A[i];
    vector<ll> next(N+1);
    vector<ll> next2(N);
    rep(i,N){
        next[i]=abs(A[i+1]-A[i]);
    }
    next[N]=abs(A[N]);
    rep(i,N-1){
        next2[i]=abs(A[i+2]-A[i]);
    }
    next2[N-1]=abs(A[N-1]);
    
    ll sum=0;
    rep(i,N+1){
        sum+=next[i];
    }
    
    rep1(i,N){
        cout<<sum-next[i-1]-next[i]+next2[i-1]<<endl;
    }
}


Measured memory_bytes: 5620
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<set>
typedef long long ll;
typedef unsigned un;
typedef std::string str;
typedef std::pair<ll,ll> pll;
ll read(){ll x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}return f*x;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
void umax(ll& a,ll t){if(t>a)a=t;}
const ll INF=1ll<<58;
#define MAXN 200011
ll a[MAXN];
ll n,m,v,k,ans=0;
bool check(ll x)
{
	if(x>=a[n-k+1])return 1;
	if(x+m<a[n-k+1])return 0;
	ll c1=0,c2=0, p=0,r=0;
	for(ll i=1;i<=n;++i)
		if(a[i]<=x)++c1;
		else if(a[i]>a[n-k+1])++c2;
		else
		{
			r+=(m+x-a[i]);
			if(r>=m)//r+(m+x-a[i])>=m
			{
				++p;
				r-=m;
			}
		}
	return c2<k&&c1+c2+p>=v;
}
int main()
{
	n=read(),m=read(),v=read(),k=read(),ans=0;
	for(ll i=1;i<=n;++i)std::cin>>a[i];
	std::sort(a+1,a+n+1);
	ll l=1,r=n;
	while(l<r)
	{
		ll mid=(l+r)>>1;
		if(check(a[mid]))r=mid;
		else l=mid+1;
	}
	for(ll i=1;i<=n;++i)ans+=(a[i]>=a[l]);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 4432
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	m := getNextInt(scanner)

	edges := make([][]int, n)
	for i := 0; i < n; i++ {
		edges[i] = make([]int, n)
	}
	for i := 0; i < m; i++ {
		a := getNextInt(scanner) - 1
		b := getNextInt(scanner) - 1
		edges[a][b] = 1
		edges[b][a] = 1
	}

	p := permutation(n - 1)
	ans := 0
	for _, list := range p {
		if reach(edges, list) {
			ans++
		}
	}

	fmt.Fprintln(writer, ans)

	writer.Flush()
}
func reach(edges [][]int, list []int) bool {
	l := len(list)
	if edges[0][list[0]] == 0 {
		return false
	}
	for i := 1; i < l; i++ {
		if edges[list[i-1]][list[i]] == 0 {
			return false
		}
	}
	return true

}
func permutation(n int) [][]int {
	if n == 1 {
		return [][]int{
			[]int{
				1,
			},
		}
	}

	p := permutation(n - 1)
	l := len(p)
	for i := 0; i < l; i++ {
		ll := len(p[i])
		for ii := 0; ii <= ll; ii++ {
			ap := make([]int, ll+1)
			for iii := 0; iii < ii; iii++ {
				ap[iii] = p[i][iii]
			}
			ap[ii] = n
			for iii := ii + 1; iii <= ll; iii++ {
				ap[iii] = p[i][iii-1]
			}
			p = append(p, ap)
		}
	}

	return p[l:]
}


Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
using ll = long long;

struct UnionFind {
    vector<int> parent;

    UnionFind(){}
    
    UnionFind(int nmemb) {
        init(nmemb);
    }

    void init(int nmemb) {
        parent.clear();
        parent.assign(nmemb, -1);
    }

    int root(int x) {
        if (parent[x] < 0) {
            return x;
        }
        return parent[x] = root(parent[x]);
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);

        if (x == y) return;

        parent[x] += parent[y];
        parent[y] = x;
        
        return;
    }
};
//===

UnionFind uf(305);
struct Edge { ll len, to, from; };
auto cmp = [](const Edge &x, const Edge &y) {
               if(x.len < y.len) return true;
               else return false;
           };

ll n;
ll a[305][305];
ll tmp[305][305];
vector<Edge> e;
ll ans;

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (i == j) tmp[i][j] = 0;
            else tmp[i][j] = 1ll << 60ll;
            
            cin >> a[i][j];
            
            e.push_back((Edge){a[i][j], i, j});
        }
    }

    sort(e.begin(), e.end(), cmp);

    for (int i = 0; i < e.size(); i++) {
        Edge s = e[i];

        if (tmp[s.to][s.from] > s.len) {
            tmp[s.to][s.from] = s.len;
            tmp[s.from][s.to] = s.len;
            ans += s.len;

            int k = s.from;
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= n; j++) {
                    tmp[i][j] = min(tmp[i][j], tmp[i][k] + tmp[k][j]);
                }
            }

            k = s.to;
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= n; j++) {
                    tmp[i][j] = min(tmp[i][j], tmp[i][k] + tmp[k][j]);
                }
            }

        }
    }

    for (int k = 1; k <= n; k++) {
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                tmp[i][j] = min(tmp[i][j], tmp[i][k] + tmp[k][j]);
            }
        }
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (tmp[i][j] != a[i][j]) {
                cout << -1 << endl;
                return 0;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define DEBUG(x) cerr << #x << " = " << x << endl

const int MOD = 1000000007;

template <class T, class U>
ostream &operator <<(ostream &os, const pair<T, U> &value) {
  os << '(' << value.first << ' ' << value.second << ')';
  return os;
}

int power(int x, int y) {
  int res = 1;
  for(; y > 0; y >>= 1, (x *= x) %= MOD) {
    if(y & 1) (res *= x) %= MOD;
  }
  return res;
}

int N, C;
int A[400], B[400];

int powerCache[401][401];

int powerSum(int i, int k) {
  int ret = powerCache[B[i]][k] - powerCache[A[i] - 1][k];
  // cerr << "powerCache[" << B[i] << "][" << k << "]=" << powerCache[B[i]][k] << endl;
  // cerr << "powerCache[" << A[i] << "][" << k << "]=" << powerCache[A[i] - 1][k] << endl;
  // DEBUG(powerCache[A[i]][k]);
  // DEBUG(powerCache[B[i]][k]);
  if(ret < 0) ret += MOD;
  return ret % MOD;
}

// combination, sum
pair<int, int> dp[401][401];
bool vis[401][401];

pair<int, int> solve(int n, int c) {
  if(n == 0) {
    if(c == 0) return make_pair(1, 1);
    else return make_pair(0, 0);
  }
  if(vis[n][c]) return dp[n][c];
  pair<int, int> ret(0, 0);
  for(int k = 0; k <= c; ++k) {
    pair<int, int> value = solve(n - 1, c - k);
    ret.first += value.first;
    ret.first %= MOD;
    ret.second += powerSum(N - n, k) * value.second;
    // DEBUG(N - n);
    // DEBUG(k);
    // DEBUG(powerSum(N - n, k));
    ret.second %= MOD;
  }
  vis[n][c] = true;
  dp[n][c] = ret;
  // cerr << "n=" << n << " c=" << c << " ret=" << ret << endl;
  return ret;
}

signed main() {
  cin >> N >> C;
  memset(vis, 0, sizeof(vis));
  REP(i,N) cin >> A[i];
  REP(i,N) cin >> B[i];
  REP(i,401) {
    REP(j,C+1) {
      powerCache[i][j] = 0;
      for(int k = 0; k <= i; ++k) {
        powerCache[i][j] += power(k, j);
      }
    }
  }
  cout << solve(N, C).second << endl;
}


Measured memory_bytes: 4224
import math
N = int(input())
dp=[100000]*(100000+1)
dp[0]=0
dp[1:5]=range(1,6)
dp[6:9]=range(1,4)
for n in range(9,N+1):
  k9=0
  k6=0
  while n//(9**k9)>=9:
    k9+=1
  while n//(6**k6)>=6:
    k6+=1
  dp[n]=min(dp[n],dp[n-6**k6]+1,dp[n-9**k9]+1,dp[n-1]+1)
print(dp[N])

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
using namespace std;
typedef long long ll;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
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; }
const int INF = 1e9;

int main() {
    char c;
    cin >> c;
    cout << ++c << endl;
    return 0;
}


Measured memory_bytes: 256
// E - NEQ
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
#define MOD 1000000007
#define madd(a,b) (((a)+(b))%MOD)
#define mmul(a,b) (((a)*(b))%MOD)
vl fac{1,1}, inv{0,1}, finv{1,1};

void finv_init(int n){
	for(int i=2; i<=n; ++i){
		fac.push_back(mmul(fac.back(), i));
		inv.push_back(madd(MOD, -mmul(inv[MOD%i], MOD/i)));
		finv.push_back(mmul(finv.back(), inv.back()));
	}
}

ll nPr(ll n, ll r){ return mmul(fac[n], finv[n-r]); }

int main(){
	int n, m; cin>>n>>m;
	finv_init(m);
	ll ans = 0;
	for(int d=0; d<=n; ++d){
		ll a = mmul(mmul(nPr(n, d), finv[d]), nPr(m-d, n-d));
		ans = madd(ans, d&1? -a:a);
	}
	ans = mmul(ans, nPr(m, n));
	cout<< madd(ans, MOD) <<endl;
}


Measured memory_bytes: 15240
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=998244353,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  cin >> n;
  ll a[n];
  rep(i,n) cin >> a[i];
  sort(a,a+n);
  ll ans=1;
  rep(i,n) {
    ans*=__gcd(i,a[i]);
    ans%=MAX;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    ll x; cin >> x;
    vector<ll> ls;
    for(ll i=0; i<=1000; i++){
        ls.pb(i*i*i*i*i);
    }
    //cout << ls << endl;
    REP(i, 1001){
        REP(j, 1001){
            if(ls[i]-ls[j] == x){
                cout << i << " " << j << endl;
                exit(0);
            }
            if(ls[i]+ls[j] == x){
                cout << i << " " << -(j) << endl;
                exit(0);
            }
        }
    }
}

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

Measured memory_bytes: 3668
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

template <class T>
using vec = vector<T>;
template <class T>
using vec2 = vector<vec<T>>;
template <class T>
using vec3 = vector<vec2<T>>;

constexpr int INF = numeric_limits<int>::max();
constexpr ll INFL = numeric_limits<ll>::max();
constexpr ll MOD = 1000000007; // 10^9+7

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

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

    if (n >= 10)
        cout << r << endl;
    else
        cout << r + 100 * (10 - n) << endl;

    return 0;
}


Measured memory_bytes: 3592
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

X = int(input())
double = X*10+1
s = set()
for i in range(2, double):
    if i in s:
        continue
    if i>=X:
        print(i)
        break
    cnt = 1
    while cnt*i<=double:
        s.add(i*cnt)
        cnt += 1

Measured memory_bytes: 202068
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
//#include<algorithm>
//#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	char c;
	ll N = 0, K = 0;
	while ((c = getchar_unlocked()) >= '0') N = N * 10 + c - '0';
	while ((c = getchar_unlocked()) >= '0') K = K * 10 + c - '0';

	ll A[60][50][50] = {};
	rep(i, N) rep(j, N) {
		A[0][i][j] = getchar_unlocked() - '0';
		getchar_unlocked();
	}
	const ll mod = 1e9 + 7;
	rep(i, 59) {
		rep(j, N) {
			rep(x, N) {
				rep(k, N) {
					A[i + 1][j][k] += A[i][j][x] * A[i][x][k];
					A[i + 1][j][k] %= mod;
				}
			}
		}
	}

	ll B[50];
	rep(i, N) B[i] = 1;
	rep(i, 60) {
		if (K >> i & 1) {
			ll C[50] = {};
			rep(j, N) {
				rep(k, N) {
					C[j] += A[i][j][k] * B[k];
					C[j] %= mod;
				}
			}
			rep(j, N) B[j] = C[j];
		}
	}

	ll kotae = 0;
	rep(i, N) kotae += B[i];
	printf("%lld", kotae % mod);

	Would you please return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

int a[200000], dp[200000], s[200000];
vector<int> vs;
signed main(){
	int n, g = 1;
	scanf("%lld", &n);
	rep(i,n)scanf("%lld", &a[i]);
	int mx = *max_element(a, a+n);
	repi(i,2,40000){
		while(mx%i == 0){mx /= i;vs.pb(i);}
		if(mx == 1)break;
	}
	dp[1] = 1;
	rep(j,vs.size()){
		drep(i,40000,1){
			if(i*vs[j] <= 40000 and dp[i])dp[i*vs[j]] = 1;
		}
	}
	drep(i,40000,1){
		if(dp[i] == 1)s[i] = i;
		else s[i] = s[i+1];
	}
	
	int ans = 0;
	rep(i,n)ans += s[a[i]]-a[i];
	printf("%lld\n", ans);
	//rep(i,10)printf("%lld ", s[i]);
	return 0;
}







Measured memory_bytes: 4236
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll x;
    cin >> x;
    ll ans = 0;
    ll angle = 0;
    while(true) {
        ++ans;
        angle += x;
        if(angle >= 360) angle -= 360;
        if(angle == 0) break;
    }
    cout << ans << endl;
    return;
}

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

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

int main(){
string a;
bool sud=false,nord=false,est=false,west=false;
cin>>a;
for(int i=0;i<a.size();i++){
	if(a[i]=='N')
	nord=true;
	if(a[i]=='S')
	sud=true;
	if(a[i]=='W')
	west=true;
	if(a[i]=='E')
	est=true;
}
if((nord&&sud)&&(est&&west))
cout<<"Yes"<<endl;
else{
	if((nord&&sud)&&!(est||west))
	cout<<"Yes"<<endl;
	else{
		if(!(nord||sud)&&(est&&west))
		cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;
	}
}
return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.uni;

void main() {
    string w = readln.chomp;
    int cnt = 0;
    while (true) {
        string t = readln.chomp;
        if (t == "END_OF_TEXT") break;
        string[] s = t.toLower.split;
        foreach (x; s) {
            if (x == w) ++cnt;
        }
    }
    cnt.writeln;
}


Measured memory_bytes: 2504
N=int(input())

A=[int(input()) for i in range(N)]

A.sort()

ansl=A[0]
ansr=A[-1]
l=1
r=-2
n=[0]*4
ansn=abs(A[0]-A[-1])
for i in range(N-2):
    n[0]=abs(A[l]-ansl)
    n[1]=abs(A[l]-ansr)
    n[2]=abs(A[r]-ansl)
    n[3]=abs(A[r]-ansr)
    if n[0]==max(n):
        ansn+=n[0]
        ansl=A[l]
        l+=1
    elif n[1]==max(n):
        ansn+=n[1]
        ansr=A[l]
        l+=1
    elif n[2]==max(n):
        ansn+=n[2]
        ansl=A[r]
        r-=1
    elif n[3]==max(n):
        ansn+=n[3]
        ansr=A[r]
        r-=1

print(ansn)

Measured memory_bytes: 7516
a, b, c, x, y = map(int, input().split())
pmin = 10**10
for i in range(0, 2*max(x, y)+1, 2): # i枚のABピザを買う
    bx = max(0, x - i//2)
    by = max(0, y - i//2)
    pay = a*bx + b*by + c*i
    pmin = min(pmin, pay)


print(pmin)

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

int main() {
	long long N; cin >> N;
	long long A, B; cin >> A >> B;
	long long ans = 0;
	if (N%(A + B) <= A)ans = A*(N/(A + B))+ N%(A + B);
	else ans = A*(N/(A + B)) + A;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long int X;
  cin >> X;

  long int cnt = 0;
  long int Y = 100;

  while(Y < X){
    //cout << Y / 100 << endl;
    Y += Y / 100;
    cnt++;
  }

  cout << cnt << endl;

}

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

using namespace std;
const int INF = 1<<30;
typedef long long int ll;

int main(){
	int n;cin>>n;
	vector<ll> s(n+1);
	s[0]=0;
	for(int i=0;i<n;i++){
		int a;cin>>a;
		s[i+1]=s[i]+(ll)a;
	}
	map<ll, int> count;
	for(int i=0;i<=n;i++){
		count[s[i]]++;
	}
	ll ans=0;
	for(auto itr=count.begin();itr!=count.end();itr++){
		ll num=itr->second;
		if(num<=1)continue;
		ans+=(num-1)*num/2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define fo(i,a,n) for (i = a; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;


void solve(){
    int n, k, cnt = 0;
    cin>>n>>k;
    int a[n+10] = {0};
    f(i,k){
        int d;
        cin>>d;
        f(j,d){
            int x;
            cin>>x;
            a[x] = 1;
        }
    }
    for(int i = 1; i <=n; i++)if(a[i] == 0)cnt++;
    cout<<cnt;
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x << ':' << x << endl;
#define loop3(i, k, n) for(i=k; i<n; i++)
#define ll  long long 
#define loop(i,n) for(int i=0;i<n;i++)
#define loop2(i,n) for(int i = 1;i<=n;i+=1)
#define pb push_back
#define mp make_pair
#define v1d vector<ll> 
#define v2d vector<vector<ll>>
const int INF = 1e9 +5 ;
int main()
{
    string s;
    ll a;
    cin>>a>>s;
    
    if(a>=3200)
    {
        cout<<s;
    }
    else
    {
        cout<<"red";
    }
    
}

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

#define rep(i, first, to) for(ll i = first; i < to; ++i)

using namespace std;
typedef long long ll;

void solve() {
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	int n1 = (n > k ? k : n);
	int n2 = (n > k ? n - k : 0);
	cout << (n1 * x + n2 * y) << endl;
}

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

Measured memory_bytes: 256
a=[1,1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k=int(input())
if(k==1):
    print(a[0])
elif(k==2):
    print(a[1])
elif(k==3):
    print(a[2])
elif(k==4):
    print(a[3])
elif(k==5):
    print(a[4])
elif(k==6):
    print(a[5])
elif(k==7):
    print(a[6])
elif(k==8):
    print(a[7])
elif(k==9):
    print(a[8])
elif(k==10):
    print(a[9])
elif(k==11):
    print(a[10])
elif(k==12):
    print(a[11])
elif(k==13):
    print(a[12])
elif(k==14):
    print(a[13])
elif(k==15):
    print(a[14])
elif(k==16):
    print(a[15])
elif(k==17):
    print(a[16])
elif(k==18):
    print(a[17])
elif(k==19):
    print(a[18])
elif(k==20):
    print(a[19])
elif(k==21):
    print(a[20])
elif(k==22):
    print(a[21])
elif(k==23):
    print(a[22])
elif(k==24):
    print(a[23])
elif(k==25):
    print(a[24])
elif(k==26):
    print(a[25])
elif(k==27):
    print(a[26])
elif(k==28):
    print(a[27])
elif(k==29):
    print(a[28])
elif(k==30):
    print(a[29])
elif(k==31):
    print(a[30])
elif(k==32):
    print(a[31])


Measured memory_bytes: 3316
<?php

$t = str_split(fgets(STDIN));
$s = str_split(fgets(STDIN));
array_pop($t);
array_pop($s);

$roop = count($t)-count($s);
$result = count($s);

for($i=0;$i<=$roop;$i++){
    $new_res = count($s);
    for($j=0;$j<count($s);$j++){
        // echo $t[$i+$j],$t[$j],"\n";
        if($t[$i+$j] == $s[$j]){
            $new_res--;
        }
    }
    if($result>$new_res){
        $result=$new_res;
    }
}
echo $result."\n";

Measured memory_bytes: 16256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int h,w,d;
int a[500][500];
struct node
{
    int x,y;
    node(){}
    node(int x,int y):x(x),y(y){}
}p[90005];

int pre[90005];

int dis(int q,int w){
    return abs(p[q].x-p[w].x)+abs(p[q].y-p[w].y);
}

int main()
{
    cin>>h>>w>>d;
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++){
        scanf("%d",&a[i][j]);
        p[a[i][j]].x=i;p[a[i][j]].y=j;
    }
    int q;cin>>q;
    int l,r;

    int maxv = h*w;

    if(d<100)
    {
        for(int i=d+1;i<=maxv;i++){
            pre[i] = pre[i-d] + dis(i,i-d);
        }
        while(q--){
            scanf("%d%d",&l,&r);
            printf("%d\n",pre[r]-pre[l]);
        }
    }
    else{
        while(q--){
            scanf("%d%d",&l,&r);
            int ans=0;
            for(int i=l;i<r;i+=d){
                ans+=dis(i,i+d);
            }
            printf("%d\n",ans);
        }
    }
    return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int A, B, C;

int main(void){
	
	scanf("%d %d %d", &A, &B, &C);
	
	int ans = 0;
	ans = max(ans, 10 * A + B + C);
	ans = max(ans, 10 * B + A + C);
	ans = max(ans, 10 * C + A + B);
	printf("%d\n", ans);
	
    return 0;
}


Measured memory_bytes: 256