akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int indeg[100009], R[100009];
vector<int> adj[100009], rev[100009];

int main() {
    int N, M; scanf("%d%d",&N,&M);
    for(int i=0; i<N-1+M; i++) {
        int u, v; scanf("%d%d",&u,&v);
        adj[u].push_back(v);
        rev[v].push_back(u);
        ++indeg[v];
    }
    queue<int> que;
    for(int i=1; i<=N; i++) if(indeg[i] == 0) que.push(i);
    vector<int> S;
    while(que.size()) {
        int now = que.front(); que.pop();
        R[now] = S.size();
        S.push_back(now);
        for(auto& it: adj[now]) {
            if(--indeg[it] == 0) {
                que.push(it);
            }
        }
    }
    for(int i=1; i<=N; i++) {
        if((int)rev[i].size() == 0) puts("0");
        else {
            int mx = rev[i][0];
            for(auto& it: rev[i]) if(R[mx] < R[it]) mx = it;
            printf("%d\n",mx);
        }
    }
    return 0;
}


Measured memory_bytes: 13052
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();

		int ans = 0;

		int number[] = new int[N];

		for (int i = 0; i < N; i++) {
			number[i] = 0;
		}

		for (int i = 0; i < K; i++) {
			int d = scan.nextInt();
			for(int j =0;j<d;j++) {
				number[scan.nextInt()-1]++;
			}
		}


		for (int i = 0; i < N; i++) {
			if (number[i] == 0) {
				ans++;
			}
		}
		System.out.println(ans);
		scan.close();
	}
}


Measured memory_bytes: 46256
#include <iostream>

using namespace std;

const int MAX_N = 305;

int sol;
int fav [MAX_N][MAX_N];
int del [MAX_N];

int cnt [MAX_N];
void recalc (int n, int m) {
  for (int i = 1; i <= m; i++) {
    cnt[i] = 0;
  }

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (!del[fav[i][j]]) {
        cnt[fav[i][j]]++;
        break;
      }
    }
  }

  /*
  for (int j = 1; j <= m; j++) {
    cout << cnt[j] << " ";
  }
  cout << endl;
  */

  pair<int, int> mx = make_pair(-1, -1); // <cnt, idx>
  for (int i = 1; i <= m; i++) {
    if (!del[i]) {
      mx = max(mx, make_pair(cnt[i], i));
    }
  }

  sol = min(sol, mx.first);
  del[mx.second] = 1;
}

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

  sol = MAX_N;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> fav[i][j];
    }
  }

  for (int i = 1; i <= m; i++) {
    recalc(n, m);
  }
  cout << sol << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <stack>
#include <queue>
#include <array>
#include <random>
#include <chrono>

using namespace std;
#define rep(i, a, n) for (int i = a; i < n; ++i)
#define per(i, a, n) for (int i = n - 1; i >= a; --i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef int64_t i64;
typedef uint64_t ui64;
typedef pair<int, int> pi;

struct custom_hash {
    static ui64 splitmix64(ui64 x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(ui64 x) const {
        static const ui64 FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

template <class T, class U>
inline ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << p.first << ' ' << p.second;
    return os;
}
template <class T, class U>
inline istream& operator>>(istream& os, pair<T, U>& p) {
    os >> p.first >> p.second;
    return os;
}
template <class T>
inline ostream& operator<<(ostream& os, const vector<T>& v) {
    if (v.empty())
        return os;
    if (v.begin() != v.end())
        os << v.front();
    for (auto it = ++v.begin(); it != v.end(); ++it)
        os << ' ' << *it;
    return os;
}
template <class T>
inline istream& operator>>(istream& is, vector<T>& v) {
    for (auto& i : v)
        is >> i;
    return is;
}

template <class T, size_t N>
inline istream& operator>>(istream& is, array<T, N>& a) {
    for (auto& i : a)
        is >> i;
    return is;
}

inline void Solve(istream& is, ostream& os) {
    int n, m;
    is >> n;
    vi times(n);
    is >> times >> m;
    vector<pi> drinks(m);
    is >> drinks;

    int sum = accumulate(all(times), 0);
    for (const auto drink : drinks) {
        os << sum + drink.second - times[drink.first - 1] << '\n';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout << setprecision(20) << fixed;
    Solve(cin, cout);
    return 0;
}


Measured memory_bytes: 256
(defmacro avg (list)
  `(/ (apply #'+ ,list)
             (length ,list)))

(defun nearest (n)
  (values (floor (+ 0.5 n))))

(defparameter a nil)
(dotimes (i (read))
  (setf a (cons (read) a)))
(defparameter avg_a (nearest (avg a)))
 
(defparameter cost 0)
(print (dolist (i a cost)
         (incf cost (expt (- i avg_a) 2))))
(terpri)


Measured memory_bytes: 12512
//AnkitCode99 here....
//every ups and downs matter!

#include<bits/stdc++.h>
#define endl "\n"
#define Ryuga ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr)
typedef long long int ll;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back

using namespace std;

const ll sz=1e5+5;
const ll szz=1e6+6;
const ll mod=1e9+7;

int main()
{
	Ryuga;

	

	clock_t startTime=clock();

	char ch;
	cin>>ch;
	if(ch>='A' and ch<='Z')
	{
		cout<<"A";
	}
	else if(ch>='a' and ch<='z')
	{
		cout<<"a";
	}

	cerr << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;

}//Goodbye...

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

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

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC142
{
    class B
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int K = int.Parse(input[1]);
            int[] h = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            int count = 0;
            for (int i = 0; i < N; i++)
            {
                if (h[i] >= K)
                {
                    count++;
                }
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 17248
#include <stdio.h>
#include <stdlib.h>

struct job{
    long int A, B;
};

int asc(const void *a, const void *b){
    struct job *x = (struct job *)a;
    struct job *y = (struct job *)b;
    if(x->B > y->B)
        return 1;
    if(x->B < y->B)
        return -1;
    return 0;
}

int main(){
    int N, i;
    struct job AB[200000];
    long int total=0;

    scanf("%d", &N);

    for(i=0; i<N; i++)
        scanf("%ld %ld", &AB[i].A, &AB[i].B);
    
    qsort(AB, N, sizeof(struct job), asc);

    for(i=0; i<N; i++){
        total += AB[i].A;

        if(total > AB[i].B){
            printf("No\n");
            return 0;
        }
    }

    printf("Yes\n");

    return 0;
}

Measured memory_bytes: 6396
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))
#define MOD 1000000007
typedef long long ll;
ll powmod(ll x, ll e, ll mod){
    ll prod = 1%mod;
    for(int i=63;i>=0;--i){
        prod = prod*prod%mod;
        if(e&1LL<<i) prod=prod*x%mod;
    }
    return prod;
}

ll invmod(ll a, ll p){
    return powmod(a%p, p-2, p);
}


int main(){
    ll n,k; cin >> n >> k;
    for(long long int i=1;i<=k;i++){
        long long ans = 1;

        for(ll j=1; j<=i-1; j++){
            ans = (ans * (((k-j) * invmod(j, MOD)) % MOD)) % MOD;
        }
        for(ll j=1; j<=i ;j++){
            ans = (ans * (((n-k-j+2) * invmod(j,MOD)) % MOD)) % MOD;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.TreeSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DGatheringChildren solver = new DGatheringChildren();
        solver.solve(1, in, out);
        out.close();
    }

    static class DGatheringChildren {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            char[] c = s.next().toCharArray();
            int[] a = new int[c.length];
            int n = c.length;
            TreeSet<Integer> t = new TreeSet<>();
            for (int i = 0; i < n; i++) {
                if (c[i] == 'R' && c[i + 1] == 'L') {
                    t.add(i);
                }
            }
            for (int i = 0; i < n; i++) {
                int ind = 0;
                if (c[i] == 'R') {
                    ind = t.ceiling(i);
                } else {
                    ind = t.floor(i);
                }
                if ((i - ind) % 2 == 0) {
                    a[ind]++;
                } else a[ind + 1]++;
            }
            for (int i : a) w.print(i + " ");
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public String next() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            StringBuilder res = new StringBuilder();

            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 39500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

ll H, W;
vector<string> A;
vector<vector<ll>> cnt;

int main(){
    cin >> H >> W;
    A.resize(H);
    cnt.resize(H, vector<ll>(W, -1));
    rep(i, 0, H) cin >> A[i];

    queue<pair<ll,ll>> que;
    rep(h, 0, H){
        rep(w, 0, W){
            if(A[h][w] == '#'){
                cnt[h][w] = 0;
                que.push({h,w});
            }
        }
    }

    ll d1[4] = {1, -1, 0, 0};
    ll d2[4] = {0, 0, 1, -1};
    while(!que.empty()){
        auto t = que.front();
        que.pop();
        rep(i, 0, 4){
            ll h = t.first + d1[i];
            ll w = t.second + d2[i];
            if(h >= H || h < 0 || w >= W || w < 0) continue;
            if(cnt[h][w] != -1) continue;
            cnt[h][w] = cnt[t.first][t.second] + 1;
            que.push({h, w});
        }
    }

    ll ans = 0;
    rep(h, 0, H) ans = max(ans, *max_element(cnt[h].begin(), cnt[h].end()));
    cout << ans << endl;
    return 0;
}

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

string s;
bool tf = true;

void solve()
{
    for (int i = 0; i < s.size(); i++)
    {
        if (((i + 1) % 2 == 1) && (s[i] == 'L') || ((i + 1) % 2 == 0) && (s[i] == 'R'))
            tf = false;
    }

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

int main()
{
    cin >> s;

    solve();
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int a, b, c, d;

  scanf("%d %d %d %d", &a, &b, &c, &d);

  while (a > 0 && c > 0) {
    c = c - b;
    if (c > 0) a = a - d;
  }

  if (c <= 0)
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}

Measured memory_bytes: 1620
/**
 * @author derrick20
 */
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int K = sc.nextInt();
        int X = sc.nextInt();
        int end = Math.min(1000000, X + K - 1);
        for (int i = Math.max(-1000000, X - K + 1); i <= end; i++) {
            out.print(i);
            if (i != end) {
                out.print(" ");
            }
        }
        out.close();
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        FastScanner(FileReader s) {
            br = new BufferedReader(s);
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        String nextLine() throws IOException { return br.readLine(); }

        double nextDouble() throws IOException { return Double.parseDouble(next()); }

        int nextInt() throws IOException { return Integer.parseInt(next()); }

        long nextLong() throws IOException { return Long.parseLong(next()); }
    }
}

Measured memory_bytes: 20308
#include <iostream>

using namespace std;

int main() {
	int n, x;

	while (cin >> n >> x && n != 0 || x != 0) {
		int count = 0;
		for (int i = 1; i <= n - 2; i++)
			for (int j = 1 + i; j <= n - 1; j++)
				for (int k = 1 + j; k <= n; k++)
					if (i + j + k == x)
						count++;
		cout << count << endl;
	}
}


Measured memory_bytes: 3100
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using static System.Math;

class MainClass
{

    public static void Main(string[] args)
    {
        var _ = LnLngs();
        var N = _[0];
        var A = _[1];
        var B = _[2];
        var rem = N % (A + B);
        rem = rem > A ? A : rem;
        print(rem + N / (A + B) * A);
    }



    public static void print(object obj) { Console.WriteLine(obj); }
    public static long Gcd(long a, long b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int Gcd(int a, int b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int[] LnInts() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new int[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]); return ins; }
    public static int LnInt() { var vs = Console.ReadLine().Trim(); return int.Parse(vs); }
    public static long[] LnLngs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new long[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = long.Parse(vs[i]); return ins; }
    public static long LnLng() { var vs = Console.ReadLine().Trim(); return long.Parse(vs); }
    public static string[] LnStrs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return vs; }
    public static string LnStr() { var vs = Console.ReadLine().Trim(); return vs; }
}

Measured memory_bytes: 13140
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

ll c(ll n, ll k) 
{ 
  if (k==0 || k==n) 
    return 1ll;   
  return  c(n-1, k-1) + c(n-1, k); 
} 

int cnt[2];

int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    int n = readInt(), p = readInt();
    for (int i = 1; i <= n; i++) {
		cnt[readInt() % 2]++;
    }
  	ll mult = (1ll << cnt[0]);
  	ll ans = 0;
  	for (int i = 0; i <= cnt[1]; i++) {
		if ((i & 1) == p) {
			ans += (mult * c(cnt[1], i));			
		}  		
  	}
  	cout << ans;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int a = sc.nextInt();
      int b = sc.nextInt();
      int min = Math.min(b,n*a);
      System.out.println(min);
    }
}

Measured memory_bytes: 21844
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 100000007
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
 
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	int n,k;
	cin>>n>>k;
	int ans = 0;
	while(n){
		n/=k;
		ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	int sum = 0;
	vector<int> s(n);
	for(int i = 0;i < n;i++){
		cin >> s[i];
		sum += s[i];
	}

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

	if(sum % 10 != 0){
		cout << sum << endl;
		return 0;
	}
	for(int i = 0;i < n;i++){
		if((sum - s[i]) % 10 != 0){
			cout << sum - s[i] << endl;
			return 0;
		}
	}

	cout << 0 << endl;
}


Measured memory_bytes: 256
/*
  AUTHOR:SOURABH
  CREATED:09:02:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<ll , null_type, less< ll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

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

    //freopen("in.txt","r",stdin);
    //freopen(2 "out.txt","w",stdout);

    ll t,n,i;
    string s;
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>s;
        n=s.length();
        fn(i,n)
        s[i]='x';
        cout<<s<<"\n";
    }
    return 0;
}


























Measured memory_bytes: 256
open Printf
open Scanf

let (++) = Int64.add
let (--) = Int64.sub
let ( ** ) = Int64.mul
let (//) = Int64.div
let (%%) = Int64.rem
let landl = Int64.logand
let lorl = Int64.logor
let lnotl = Int64.lognot
let lxorl = Int64.logxor
let lsll = Int64.shift_left
let lsrl = Int64.shift_right_logical
let long = Int64.of_int
let succl = Int64.succ
let predl = Int64.pred

let read_int _ = scanf " %d " (fun x -> x)
let read_long _ = scanf " %Ld " (fun x -> x)
let read_str _ = scanf " %s " (fun x -> x)
let read_double _ = scanf " %f " (fun x -> x)

let m = 1_000_000_007L

let rec gcd a b = if b = 0L then a else gcd b (a %% b)

let rec mod_pow a = function
  | 0L -> 1L
  | b -> (if b %% 2L = 0L then 1L else a) ** mod_pow (a ** a %% m) (b//2L) %% m


let () =
  let s = read_str () in
  let ans = if s.[5] == '1' || s.[6] >= '5'
    then "TBD"
    else "Heisei" in
  printf "%s\n" ans


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 = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

bool dp[5100][10100];

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> ex(8,0);
    rep(i,m) {
        int a;
        cin >> a;
        int b;
        if(a == 1) b = 2;
        else if(a == 7) b = 3;
        else if(a == 4) b = 4;
        else if(a == 2 || a == 3 || a == 5) b = 5;
        else if(a == 6 || a == 9) b = 6;
        else b = 7;
        chmax(ex[b],a);
    }
     rep(i,5100) rep(j,10100) dp[i][j] = false;
    dp[0][0] = true;
    rep(i,5099) {
        rep(j,n+1) {
            if(!dp[i][j]) continue;
            rep2(k,2,8) if(ex[k] > 0) {
                dp[i+1][j+k] = true;
            }
        }
    }
    int mx;
    rrep(i,5100) {
        if(dp[i][n]) {
            mx = i+1;
            break;
        }
    }
    int now = n;
    for(int i = mx-1; i > 0; i--) {
        int can = 0;
        int use;
        rep2(j,2,min(8,now+1)) {
            if(ex[j] > can && dp[i-1][now-j]) {
                can = ex[j];
                use = j;
            }
        }
        now -= use;
        cout << can;
    }
    cout << endl;
}


Measured memory_bytes: 50560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll, ll> P;
#define ALL(v) v.begin(),v.end()

const int MOD = 1000000007;
const int MAX = 5100000;
ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    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;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// 以下から
const int MAX_N = 100000;
struct Edge {
    int to;
    int id;
};

const int D = 80 * 160 + 10;
const int D2 = D*2;
typedef bitset<D2> bs;
int a[100][100];
bs dp[90][90];



const int N = 20;
int h;
int w;
vector<vector<char>> maze(N, vector<char>(N,'#'));

const int MAX_WH = 21;
int d[MAX_WH][MAX_WH];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
const int INF = 100000;
int bfs(int x, int y) {
    queue<P> que;
    rep(i,MAX_WH) {
        rep(j,MAX_WH) {
            d[j][i] = INF;
        }
    }
    que.push(P(x,y));
    d[x][y] = 0;

    while (que.size()) {
        P p = que.front(); que.pop();
        for (int i=0; i< 4; i++) {
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            if (0 <= nx && nx < w && 0 <= ny && ny < h && maze[nx][ny] != '#' && d[nx][ny] == INF) {
                que.push(P(nx,ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
    int mx = 0;
    rep(i,h) rep(j,w) {
            if (d[j][i] == INF) continue;
            mx = max(mx, d[j][i]);
        }
    return mx;
}

bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.first < secondElof.first;
}
void dfs(){

}
const int MX = 100000;
vector<int> G[MX];
int main(){
    int n; cin >> n;
    vector<int> v;
    rep(i,n){
        int p; cin >> p;
        v.push_back(p);
    }
    int ans = 0;
    int mx = 200005;
    rep(i,n) {
        if (v[i] <= mx) {
            ans++;
            mx = min(v[i], mx);
        }
    }
    cout << ans << endl;
    return 0;
}


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

int A, B;

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

  cout << (A <= 8 && B <= 8 ? "Yay!" : ":(") << endl;
  return 0;
}


Measured memory_bytes: 256
#C問題
#先に入れるものほど1/2がかかる回数が増えるので
#小さいもの順に使う貪欲解法

n = int(input())
nums = list(map(lambda x : int(x), input().split()))

nums.sort()
ans = 0
for i in range(n):
    ans += nums[i]
    if i > 0:
        ans = ans / 2.0

print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N, W;
    cin >> N >> W;
    vector<long long> w(N), v(N);
    for(int i=0; i<N; i++)
        cin >> w[i] >> v[i];

    long long wmin = *min_element(w.begin(), w.end());

    for(int i=0; i<N; i++)
        w[i] -= wmin;

    vector<vector<long long>> dp(N+1, vector<long long>(400, 0));

    for(int i=0; i<N; i++){
        for(int j=N; j>=1; j--){
            for(int k=399; k>=w[i]; k--){
                dp[j][k] = max(dp[j][k], dp[j-1][k-w[i]]+v[i]);
            }
        }
    }

    long long ans = 0;
    for(int i=1; i<=N; i++){
        long long Weff = W - i*wmin;
        if(Weff < 0) continue;
        ans = max(ans, dp[i][min(399LL, Weff)]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
/*
 * I'm strong. Stronger than all of you. Extremely strong.
 * I can kill all those Titans there. Even if I'm alone.
 * You're either incompetent or you're spineless cowards.
 * How pathetic.
 * You can sit here and suck on your fingers. Yeah, do that.
 * ~ Mikasa Ackerman
 */

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> II;
typedef vector<II> VII;
typedef vector<int> VI;
typedef vector<VI> VVI;

typedef long long int LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(), a.end()
#define SET(a, b) memset(a, b, sizeof(a))
#define si(n) scanf("%d", &n)
#define dout(n) printf("%d\n", n)
#define sll(n) scanf("%lld", &n)
#define lldout(n) printf("%lld\n", n)

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
  const char *comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define fast_io                                                                \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL)

#define endl '\n'

int main() {
  fast_io;
  int n;
  cin >> n;
  int s = 0;
  int tn = n;
  while (n > 0)
    s += n % 10, n /= 10;
  cout << ((tn % s == 0) ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
//17571@nith.ac.in @Ankit Verma
#include <bits/stdc++.h>
#define ff  first
#define ss  second
#define pb  push_back
#define ll  long long
#define ld  long double
#define eb  emplace_back
#define ull unsigned long long
#define all(v) v.begin(), v.end()
#define rep(i,x,n)  for(int i=x;i<n;i++)
#define repr(i,x,n) for(int i=x;i>=n;i--)
#define bolt ios::sync_with_stdio(false)
using namespace std;

void IoI() {
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
}

int32_t main() {
	//IoI();
	bolt;
	cin.tie(nullptr);
	cout.tie(nullptr);
	ll x; cin >> x;
	ll div = x / 500;
	ll val = div * 1000;
	ll rm = x % 500;
	ll div1 = rm / 5;
	 val = val + div1 * 5;
	cout << val << endl;
	

	return 0;
}

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

int quick(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main(void) {
  int n, m, x[100002], mae = 0, ushiro, ans = 0;

  if(scanf("%d %d", &n, &m) == 1);

  ushiro = m - 1;

  for(int i = 0; i < m; i++) {
    if(scanf("%d", &x[i]) == 1);
  }

  qsort(x, m, sizeof(int), quick);

  if(n == 1) {
    ans = abs(x[0] - x[m - 1]);
  } else {
    for(int i = 0; i < m - 1; i++) {
      x[i] = abs(x[i] - x[i + 1]);
    }
    x[m - 1] = 0;
    qsort(x, m, sizeof(int), quick);
    for(int i = 1; i <= m - n; i++) {
      ans += x[i];
    }
  }

  printf("%d", ans);

  return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int P, Q, R;
  cin >> P >> Q >> R;
  int sum;
  sum = P + Q + R;
  if ( P >= Q && P >= R ) cout << sum - P << endl;
  else if ( Q >= P && Q >= R ) cout << sum - Q << endl;
  else if ( R >= Q && R >= P ) cout << sum - R << endl;
}

Measured memory_bytes: 256
program MSOLUTIONSB
    implicit none
    integer(8)::A,B,C,K
    read*,A,B,C,K

    do
        if(B>A .or. K<=0)exit
        B=B*2
        K=K-1
    end do

    C=C*(2**K)

    if(C>B .and. B>A)then
        print'(A)',"Yes"
    else
        print'(A)',"No"
    end if
end program MSOLUTIONSB

Measured memory_bytes: 2892
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String args[]) {
		String tar = sc.next();
		int N = sc.nextInt();
		int ans = 0;
		for(int i = 0; i < N; i++) {
			String s = sc.next();
			String con = s + s;
			if(con.contains(tar)) ans++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 12000
# include<stdio.h>
# define max_M 100
# define max_N 100
char garden[max_M][max_N];
int dx[4] = {-1,1,0,0};
int dy[4] = {0,0,1,-1};
int r, c;

void dfs(int x, int y){
	char temp = garden[x][y];
	garden[x][y] = '.';
	for(int i=0;i<4;i++){
		int nx = x + dx[i];
		int ny = y + dy[i];
		if(0<=nx&&nx<r&&0<=ny&&ny<c&&garden[nx][ny]==temp){
			dfs(nx,ny);
		}
	}
	return;
}

int solve(){
	int res = 0;
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			if(garden[i][j]!='.'){
				dfs(i,j);
				res += 1;
			}
		}
	}
	return res;
}

int main(){
	int res;
	while(scanf("%d%d",&r,&c)!=EOF&&r&&c){
		for(int i=0;i<r;i++){
			getchar();
			for(int j=0;j<c;j++){
				scanf("%c",&garden[i][j]);
			}
		}
		res = solve();
		printf("%d\n",res);
	}
	return 0;
}


Measured memory_bytes: 3064
#include <iostream>
#define ll long long
using namespace std;
ll dp[2][100001]={},ar[100][2]={};
int main()
{
	ll n,w;cin>>n>>w;
	for (ll i=0;i<n;i++)
	{
		for (int j=0;j<2;j++) {cin>>ar[i][j];}
	}
	for (ll i=1;i<=n;i++)
	{
		for (ll j=0;j<=w;j++)
		{
			dp[i%2][j] = dp[(i-1)%2][j];
			if (j>=ar[i-1][0])
			{
				dp[i%2][j] = max(dp[(i-1)%2][j],dp[(i-1)%2][j-ar[i-1][0]] + ar[i-1][1]);
			}
		}
	}
	cout<<dp[n%2][w]<<"\n";
	return 0;
}

Measured memory_bytes: 1792
import math
n, h = map(int, input().split())
a = []
b = []
ans = 0
for i in range(n):
    x, y=map(int, input().split())
    a.append(x)
    b.append(y)

b.sort(reverse=True)
a.sort(reverse = True)

for i in range(n):
    if b[i] >= a[0]:
        h -= b[i]
        ans += 1
    if h <= 0:
        break
if h > 0:
    ans += math.ceil(h / a[0])
print(ans)


Measured memory_bytes: 11312
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <iostream>
#include <cmath>
using namespace std;

int h[1000000];
int dp[1000000];

int cost(int x,int y){

      if(x==y)
        return 0;
      if(dp[x]!=-1)
        return dp[x];
      int c=abs(h[x]-h[x+1])+cost(x+1,y);
      if(x+2<=y)
        c= min(c,(cost(x+2,y)+abs(h[x+2]-h[x])));

        return  dp[x]=c;

    }


  int main(){

      int n;
      cin>>n;


      for(int i=1;i<=n;i++)
        cin>>h[i];


    memset(dp,-1,sizeof(dp));
    cout<<cost(1,n)<<endl;










  }














Measured memory_bytes: 14132
//
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<ctime>
#include<cassert>
#include<algorithm>
#include<cmath>

#include<cstring>
#include<string>
#include<cctype>
#include<utility>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<list>

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

const int OO=(int)2e9;
const ll INF=(ll)4e18;
const double EPS=(double)1e-12;

#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front

#define INL(i,a,b) ((a<=i)&&(i<=b))
#define EXL(i,a,b) ((a< i)&&(i< b))
#define REPP(i,a,b,c) for(int i=a;i<=b;i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a;i>=b;i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
using namespace std;

int l;
char o[55],e[55];

int main(){
	scanf("%s %s",o,e);
	l=strlen(o);
	REP(i,1,l){
		if(e[i-1]!='\0')printf("%c%c",o[i-1],e[i-1]);
		else printf("%c\n",o[i-1]);
	}
	return 0;
}

Measured memory_bytes: 256
from functools import reduce
n = int(input())
S = [list(input()) for _ in range(n)]
chars = sorted(list(reduce(lambda x, y: x & y, [set(s) for s in S])))
nums = [{c: s.count(c) for c in chars} for s in S]
for c in chars:
    c_num = min([num[c] for num in nums])
    print(c * c_num, end="")
print()


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    vector<pii> b(n);
    REP(i,n){
        int32 a;
        cin >> a;
        b[i] = pii(a, i+1);
    }
    sort(ALL(b));
    REP(i,n){
        cout << b[i].second << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2432
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import java.util.Map;

public class Main {

  public static void main(String[] args) {

    new Main().run();
  }

  public void run() {

    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n;
      Map<Integer,Integer> map = new HashMap<>();
      Set<Integer> set = new HashSet<>();
      StringBuilder buf = new StringBuilder();
  
      n = Integer.parseInt(br.readLine());
      while(true) {
        br.lines()
          .limit(n)
          .map( line -> {
            String[] lines = line.split(" ");
            Integer[] nums = new Integer[] {
              Integer.parseInt(lines[0]),
              Integer.parseInt(lines[1]) * Integer.parseInt(lines[2])
            };

            Integer val = map.get(nums[0]);
            if(val == null)
              map.put(nums[0],nums[1]);
            else
              map.replace(nums[0],nums[1]+=val);

            return nums;
          })
          .filter(nums -> nums[1] >= 1_000_000)
          .forEach(nums -> {
            if(set.add(nums[0]))
              buf.append(nums[0]).append("\n");
          });
        
        if(set.isEmpty()) buf.append("NA\n");

        if((n = Integer.parseInt(br.readLine())) == 0 ) break;
        map.clear();
        set.clear();
      }

      System.out.print(buf);
        
    } catch (IOException e) {
      System.err.println(e);
    }
  }
}


Measured memory_bytes: 31844
N,W=map(int,input().split())
w=[0 for _ in range(110)]
v=[0 for _ in range(110)]
for i in range(1,N+1):
    w[i],v[i]=map(int,input().split())
dp=[[0 for i in range(110000)] for j in range(110)]
for i in range(1,110000):
    dp[0][i]=10**15

for i in range(1,N+1):
    for j in range(110000):
        dp[i][j]=dp[i-1][j]
        if j-v[i]>=0:
            dp[i][j]=min(dp[i][j],dp[i-1][j-v[i]]+w[i])

ans=0
for V in range(110000):
    if dp[N][V]<=W:
        ans=max(ans,V)

print(ans)

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 1001001001;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

int main() {
    int h, w;
    cin >> h >> w;

    vector<string> s(h);

    rep(i, h) cin >> s[i];
    vector<vector<int>> cnt(h, vector<int>(w));

    rep(i, h) {
        vector<int> done(w);
        rep(j, w) {
            if (s[i][j] == '#') continue;
            if (done[j]) continue;
            int l = 0;
            while (j + l < w) {
                if (s[i][j + l] == '#')break;
                l++;
            }
            rep(k, l) {
                cnt[i][j + k] += l;
                done[j + k] = 1;
            }

        }
    }

    rep(j, w) {
        vector<int> done(h);
        rep(i, h) {
            if (s[i][j] == '#') continue;
            if (done[i]) continue;
            int l = 0;
            while (i + l < h) {
                if (s[i + l][j] == '#')break;
                l++;
            }
            rep(k, l) {
                cnt[i + k][j] += l;
                done[i + k] = 1;
            }
        }
    }

    int ans = 0;
    rep(i, h)rep(j, w) ans = max(ans, cnt[i][j] - 1);
    cout << ans << endl;

}



Measured memory_bytes: 20096
#include <iostream>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
#define INT_MAX 0x7FFFFFFF
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define ABS(a) ((a)<0?(-(a)):(a))
using namespace std;
typedef long long int LL;

int main(){
  int N, W;
  cin >> N >> W;
  LL sum[101][100001];
  REP(i, W) {
    sum[0][i] = 0;
  }
  for(int i=1; i<=N; ++i) {
    int w, v;
    cin >> w >> v;
    REP(j, W+1) {
      if(j-w>=0) {
        sum[i][j] = MAX(sum[i-1][j], sum[i-1][j-w]+v);
      } else {
        sum[i][j] = sum[i-1][j];
      }
    }
  }
  cout << sum[N][W] << endl;
}

Measured memory_bytes: 79104
n = int(input())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))

INF = 1<<20

dp = [[INF] * 55 for i in range(1<<n)]
dp[0][0] = 0

for b in range(1<<n):
    # 使ったカードの枚数
    bitcnt = bin(b).count("1")
    cur = bitcnt 
    rest = [] 
    for i in range(n):
        # i番目のbitが立っているかの判定
        if not (b & (1 << i)):
            rest.append((i,cur))
            cur += 1
    
    for s in range(51):
        if dp[b][s] >= INF:
            continue
        # 残ったカードで更新
        for i,cur in rest:
            if abs(bitcnt - i) % 2 == 0:
                num = As[i]
            else:
                num = Bs[i]
            if num >= s:
                d = abs(bitcnt - cur) 
                dp[b|(1<<i)][num] = min(dp[b|(1<<i)][num], dp[b][s] + d)
            

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


Measured memory_bytes: 174628
from itertools import product
H, W, K = map(int, input().split())
MOD = 10 ** 9 + 7

dp = [[0] * W for i in range(H + 1)]
dp[0][0] = 1


def calc(w):
    if w <= 0:
        return 1
    ret = 0
    for pattern in product([0, 1], repeat=w):
        pattern = ''.join(list(map(str, pattern)))
        if '11' not in pattern:
            ret += 1
    return ret


for h in range(H):
    for w in range(W):
        dp[h + 1][w] = (dp[h + 1][w] + dp[h][w] * calc(w - 1) * calc(W - w - 2)) % MOD
        if w + 1 < W:
            dp[h + 1][w + 1] = (dp[h + 1][w + 1] + dp[h][w] * calc(w - 1) * calc(W - w - 3) % MOD)
        if w - 1 >= 0:
            dp[h + 1][w - 1] = (dp[h + 1][w - 1] + dp[h][w] * calc(w - 2) * calc(W - w - 2) % MOD)

print(dp[H][K - 1] % MOD)


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

const static int MAX = 31;

int main()
{

    int N, M, x, y;
    char c;
    std::scanf("%d", &N);
    int arr[N];
    for (int i = 1; i <= N; i++) arr[i] = i;
    std::scanf("%d", &M);
    for (int i = 0; i < M; i++) {
        std::scanf("%d%c%d", &x, &c, &y);
        std::swap(arr[x], arr[y]);
    }
    for (int i = 1; i <= N; i++) std::printf("%d\n", arr[i]);

    return 0;
}



Measured memory_bytes: 3092
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<math.h>
#include<stdlib.h>
#include <iomanip>
using namespace std;
#define int long long
//#define double long double
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;
typedef pair<int, pii > pip;
typedef pair<pii, pii > piipii;
typedef pair<double, double> pdd;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define all(vec) vec.begin(), vec.end()
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60)
#define mod 1000000007
#define se second
#define fi first

int a, b, c, d;

signed main(){
    cin >> a >> b >> c >> d;
    if(a + 1 == c && d == 1){
        cout << 1 << endl;
    }
    else {
        cout << 0 << endl;
    }
    
    
    return 0;
}

/*

*/

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP=pair<P, int>;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			if (mod <= ans * x) ans = ans * x % mod;
			else ans *= x;
		}
		if (mod <= x * x) x = x * x % mod;
		else x *= x;
		n >>= 1;
	}
	return ans;
}

int fact_memo[114514];
int fact(int n) {
	int ans = 1;
	if (fact_memo[n]) return fact_memo[n];
	rep(i, n) {
		ans *= (i + 1);
		if (mod <= ans) ans %= mod;
		fact_memo[i + 1] = ans;
	}
	return (ans + mod) % mod;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) + mod) % mod;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod + mod) % mod;
}

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

bool pri(int p) {
	for (int i = 2; i * i <= p; i++) if (p % i == 0) return false;
	return p > 1;
}

P operator+(const P& a, const P& b) {
	return P(a.first + b.first, a.second + b.second);
}
P operator-(const P& a, const P& b) {
	return P(a.first - b.first, a.second - b.second);
}

int n;
int a[100010], b[100010];
bool can = true;
int asum, bsum, sum1;
priority_queue<int>que;
int ans;
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		asum += a[i];
	}
	rep(i, n) {
		cin >> b[i];
		bsum += b[i];
		if (a[i] < b[i]) {
			can = false;
			sum1 += b[i] - a[i];
			ans++;
		}
		if (a[i] > b[i]) {
			que.push(a[i] - b[i]);
		}
	}
	if (asum < bsum) {
		cout << -1 << endl;
	}
	else if (can) {
		cout << 0 << endl;
	}
	else {
		while (0 < sum1) {
			int p = que.top(); que.pop();
			sum1 -= p;
			ans++;
		}
		cout << ans << endl;
	}
}

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

ll lcm(ll a, ll b) {
	ll t = __gcd(a, b);
	return (a / t) * (b / t) * t;
}

int main() {
	int n;
	cin >> n;
	ll t[n];
	rep (i, n) cin >> t[i];


	ll ans = 1;
	rep (i, n) ans = lcm(ans, t[i]);

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

Measured memory_bytes: 256