akhauriyash/Code-Regression huggingface dataset:
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<utility>
#include <cmath>
#include <string.h>
#include <math.h> 


#define For(i,begin,end) for(int i=(begin);i<(end);i++)
#define FORD(i,begin,end) for(int i=(begin);i>(end);i--)
#define FOR(l) for(auto p = l.begin(); p != l.end(); p++)
#define ALL(k) (k).begin(),(k).end()
#define e1 first
#define e2 second
#define mp make_pair
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef unsigned long long LLU;
typedef long double LD;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> Vl;


ll dp[1005][1005];
ll H,W;
char mat[1005][1005];

int isValid(ll x,ll y)
{
	if(0 <= x && x < H)
		if(0 <= y && y < W)
			if(mat[x][y] == '.')
				return 1;

	return 0;
}
ll dp_fun(ll x, ll y)
{
	if(dp[x][y] != -1)
		return dp[x][y];

	if(mat[x][y] == '#')
		return 0;

	if(x == H-1 && y == W-1)
		return 1;

	ll ans = 0;
	if(isValid(x + 1,y))
		ans = (ans + dp_fun(x + 1,y))%1000000007;
	if(isValid(x,y + 1))
		ans = (ans + dp_fun(x,y + 1))%1000000007;
	return dp[x][y] = ans%1000000007;
}

int main()
{	
	memset(dp, -1, sizeof dp);
	cin>>H>>W;
	For(i,0,H)
		For(j,0,W)
			cin>>mat[i][j];

	cout<<dp_fun(0,0)<<endl;
	


	return 0;
}

Measured memory_bytes: 9216
#include<stdio.h>
int main(void){
	int a,b;
	scanf("%d",&a);
	scanf("%d",&b);
	if(a==b){
		printf("a == b\n");}
		else if(a>b){
			printf("a > b\n");}
			else{
				printf("a < b\n");}
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
const int inf=1e9+7;
const ll INF=1e18;


int main() {
 int n;
  cin>>n;
  vin a(n);
  rep(i,n) cin>>a[i];
  //////map
  ll ans=0;
  map<int,int> mp;
  rep(i,n){
    mp[a[i]]++;
  }
  for(auto v:mp){
    if(v.first >v.second){
      ans+=v.second;
    }
    else if(v.first<v.second){
       ans+=v.second-v.first;
    }
  }
  cout<<ans<<endl;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};


int main() {
    ll s, c;
    cin >> s >> c;

    if (s * 2 > c) {
        // Sが多い
        cout << c / 2 << endl;
    } else {
        // sが足りない
        cout << (c - 2 * s) / 4 + s << endl;

    }

}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main (String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if( a < b ){
      System.out.println("a < b");
    } else if( a > b ){
      System.out.println("a > b");
    } else {
      System.out.println("a == b");
    }
  }

}


Measured memory_bytes: 26408
using Yorukatsu046.Questions;
using Yorukatsu046.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu046.Questions
{
    /// <summary>
    /// ABC154 A
    /// </summary>
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var st = inputStream.ReadLine().Split(' ').ToArray();
            var ab = inputStream.ReadIntArray();
            var u = inputStream.ReadLine();

            if (st[0] == u)
            {
                ab[0]--;
            }
            else
            {
                ab[1]--;
            }

            yield return $"{ab[0]} {ab[1]}";
        }
    }
}


namespace Yorukatsu046
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu046.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu046.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();

		for(int i = 0; i < s.length(); i++) {
			System.out.print("x");
		}
		System.out.println();
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)


int main() {

int A,B,C,D; cin >> A >> B >> C >> D ;

bool win=false;

for(int i=0;;i++){
  if(i%2==0) C-=B;
  else A-=D;

  if(A<=0) break;
  if(C<=0){
    win=true; break;
  }
}

if(win) cout << "Yes" << endl;

else cout << "No" << endl;

return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(void){
  vector<string> s;
  string input;
  
  int n, l;
  
  cin >> n >> l;
  
  for(int i = 0 ; i < n ; i++){
    cin >> input;
    s.push_back(input);
  }
  
  sort(s.begin(), s.end());
  
  for(int i = 0 ; i < n ; i++){
    cout << s[i];
  }
  
  cout << endl;
    
  return 0;
}
  
  

Measured memory_bytes: 768
//=================================
// Created on: 2018/09/20 10:58:25
//=================================
#include <bits/stdc++.h>
int main()
{
    int N, Q;
    std::cin >> N >> Q;
    int s = 0;
    for (int q = 0; q < Q; q++) {
        int t, k;
        std::cin >> t >> k;
        if (t == 0) {
            k--;
            std::cout << ((s + k) % N) + 1 << std::endl;
        } else {
            s = (s + k) % N;
        }
    }
    return 0;
}



Measured memory_bytes: 3092
N = int(input())
a = list(map(int, input().split()))
ans = [0] * N

for i in range(N, 0, -1):
    j = 2*i - 1
    now = 0
    while j < N:
        now += ans[j]
        j += i
    if now % 2 != a[i-1]:
        ans[i-1] = 1

S = sum(ans)
print(S)
if S:
    print(*[i+1 for i in range(N) if ans[i]])



Measured memory_bytes: 98208
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu) FUNC(printe) FUNC(printe0);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    string s; cin >> s;
    cout << s.substr(0, 3) << '\n';
}


Measured memory_bytes: 3120
// Tenshi ni Fureta yo!

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef pair<int, int> pii;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define MP make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }
template<typename T> inline T sqr(const T &val) { return val * val; }

namespace fastIO
{
	const int MAX_BUFFER_SIZE = 1 << 16;

	char buffer[MAX_BUFFER_SIZE], *cur = buffer, *ed = buffer;

	inline char getc() { return *(cur == ed ? ed = buffer + fread(buffer, 1, MAX_BUFFER_SIZE, stdin), cur = buffer : cur)++; }
}
using fastIO::getc;

template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getc());
	for(; !isdigit(ch); ch = getc()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getc()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

// END tpl.

const LL INF = (LL) 1e18;

const int MAXN = (int) 5e3;

int n, A, B;

int p[MAXN + 5];

inline void input()
{
	n = read<int>(), A = read<int>(), B = read<int>();
	for(int i = 1; i <= n; ++i) p[i] = read<int>();
	p[0] = 0, p[n + 1] = n + 1;
}

inline void solve()
{
	static int g0[MAXN + 5][MAXN + 5], g1[MAXN + 5][MAXN + 5];

	for(int i = 0; i <= n + 1; ++i)
		for(int j = i + 2; j <= n + 1; ++j)
			g0[i][j] = g0[i][j - 1] + (p[j - 1] < p[i]);

	for(int i = 0; i <= n + 1; ++i)
		for(int j = i + 2; j <= n + 1; ++j)
			g1[i][j] = g1[i][j - 1] + (p[j - 1] > p[i]);

	static LL f[MAXN + 5];
	for(int i = 0; i <= n + 1; ++i) f[i] = INF;

	f[0] = 0;
	for(int i = 1; i <= n + 1; ++i)
		for(int j = i <= n ? 0 : 1; j < i; ++j) if(p[j] < p[i])
			chkmin(f[i], f[j] + (LL) B * g0[j][i] + (LL) A * g1[j][i]);

	printf("%lld\n", f[n + 1]);
}

int main()
{
#ifdef K_ON
	freopen("D.in", "r", stdin);
	freopen("D.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}




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

using namespace std;


int main() {
    int k,a,b;
    cin >> k >> a >> b;
    int r = (b / k) * k;
    if(a <= r) {
        puts("OK");
    } else {
        puts("NG");
    }
    return 0;
}

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

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)

        {
            var s = Console.ReadLine();
            var ans = string.Empty;
            if (s == "Sunny") ans = "Cloudy";
            else if (s == "Cloudy") ans = "Rainy";
            else ans = "Sunny";

            Console.WriteLine(ans);


        }

       
        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }

        static public long[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            long[] res = new long[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = long.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pii pair<int,int>
#define pll pair<lli, lli>
#define vi  vector<int>
#define vii vector<pair<int,int>>
#define vll vector<lli>
#define pb  push_back
#define mpr  make_pair
#define ss  second
#define ff  first
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define all(x) x.begin(),x.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define testcase() int tc;cin>>tc;while(tc--)
#define clean(x) memset(x,0,sizeof(x))
const lli maxn = 1e5+9;
vector<lli> catlan(int n) {
    vector<lli> dp(n + 1, 0);
    dp[0] = 1;
    dp[1] = 1;
    for (int i = 2; i <= n; i ++) {
        for (int j = 0; j < i; ++ j) {
            dp[i] += dp[j] * dp[i - j - 1];
        }
    }
    return dp;
}
lli b_ex(lli n,lli a){lli res=1;while(n){if(n%2==1)res*=a;n>>=1;a=a*a;}return res;}
lli ncr(lli n,lli k){lli ans=1;if(k>n-k)k=n-k;for(lli i=1;i<=k;i++){ans*=(n-i+1),ans=ans/i;}return ans;}
lli power(lli a , lli n){lli ans = 1;while(n){if(n % 2)ans = (ans * a) % mod;n /= 2;a = (a * a) % mod;}return ans;}
lli set_bits(lli n)
{
    int c=0;
    if(n==0)return 0;
    while(n)
    {
        if((n&1)==1)
        {
           cout<<c<<" ";
        }
        c++;
        n=n>>1;
    }
    return c;
}
lli lcm(lli a,lli b)
{
    lli ans=(a*b)/(__gcd(a,b));
    return ans;
}
///------------------ALWAYS lli-----TEMP TSF99--------------------------------------------------------------------------------------///
void solve()
{
    int n;cin>>n;
    cout<<n*800 - (n/15)*200<<endl;
}
int main()
{
    FAST;
    //int tc=1;cin>>tc;while(tc--)solve();
    solve();
}



Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <map>
#include <queue>

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

std::vector<int> In;
std::vector<int> Par;
std::vector<int> depth;
std::vector<std::vector<int>> children;


int main(void){
    // 入力
    int n; scanf("%d", &n);
    Par.resize(n); In.resize(n, 0);
    for(int i = 1; i < n ; ++i){
        int a; scanf("%d", &a); a--;
        Par[i] = a; In[a]++;
    }

    depth.resize(n, 0); children.resize(n);


    std::queue<int> Que;
    REP(i, n) if(In[i] == 0) Que.push(i);

    while(not Que.empty()){
        int v = Que.front(); Que.pop();
        int nv = Par[v];
        In[nv]--;
        children[nv].push_back(depth[v]);

        if(In[nv] == 0){
            const int m = children[nv].size();
            std::sort(children[nv].begin(), children[nv].end(), std::greater<int>());
            REP(i, m) if(depth[nv] < children[nv][i] + i) depth[nv] = children[nv][i] + i;
            depth[nv]++; 
            Que.push(Par[v]);
        }
    }
    // 出力
    printf("%d\n", depth[0]);

    return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define SpeeD ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ll long long
#define endl '\n'
//pair<int, int> *p=new pair<int, int>[n];
//std::vector<pair<int,int>> vp;
//v.push_back(make_pair(x,y))
//pair<int, int> p[1000001];
//string *s=new string [n];
//int freq[e];
//freq[a[i]-'a']++; freq[a[i]]++;
using namespace std;
ll n, t, m, c1, c2, c, x, y, sum, mn = 999999999, avg, pos, dif,k, mx, xi, yi, q;
const int MXN=1e5+7;
ll pre[MXN];
bool prime[MXN];

bool PE ( ll x )
{
    for ( ll i = 2; i * i <= x; i+=1+(i&1))
    if ( x % i == 0 )
    return false;
    return true;
}
ll dist[MXN];
void sieve()
{
    memset(prime , 1 , sizeof prime);

    for ( ll i = 2; i * i <= MXN; i+=1+(i&1))
    if (prime[i])
    {
          for (ll j = i * i; j < MXN; j +=i)
         prime[j] = false;
    }
}

bool PR ( string s )
{
    int n = s.length();
    for ( ll i = 0; i < n / 2; i++ )
    if ( s[i] != s[n - i - 1] )
    return false;
    return true;
}

int main (void){
    SpeeD;
 map <string , int>mp;
   cin >> n; 
  while (n--)
{
    string s;
    cin >> s;
   
    mp [s]++;
}
    cout <<"AC"<<" x "<< mp["AC"] << endl;
    cout <<"WA"<<" x "<< mp["WA"]<< endl;
    cout <<"TLE"<<" x "<< mp["TLE"] << endl;
    cout <<"RE"<<" x "<< mp["RE"] << endl;
}












Measured memory_bytes: 3656
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> A;
    rep (i, N) {
        ll a;
        cin >> a;
        A.pb(a);
    }
    double s = 0;
    rep (i, N) {
        s += A[i];
    }
    ll c = ceil(s / N);
    ll f = floor(s / N);
    ll ac = 0;
    ll af = 0;
    rep (i, N) {
        ac += (c - A[i]) * (c - A[i]);
        af += (f - A[i]) * (f - A[i]);
    }
    cout << min(ac, af) << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = "";
		List<String> list = new ArrayList<>();
		int a = sc.nextInt();
		int b = sc.nextInt();
		for (int i = 0; i < a; i++) {
			list.add(sc.next());
		}
		Collections.sort(list);
		for (String s : list) {
			str += s;
		}
		System.out.println(str);
	}

}


Measured memory_bytes: 24016
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() 
{
    int ans = 0;
    string S,T;
    cin >> S;
    cin >> T;

    if(S==T)
    {
        cout << ans << endl;
        return 0;
    }
    else
    {
        for(int i =0;i<S.size();++i)
        {
           if(S.at(i)!=T.at(i))
           {
               ++ans;
           }
        }

        cout << ans <<endl;
    }

    return 0;
}

Measured memory_bytes: 3920
n,k=map(int,input().split())
d=[]
A=[]

for i in range(k):
    d=d+[int(input())]
    A=A+[list(map(int,input().split()))]
ans=0


for i in range(n):
    ans+=1
    key=0
    for j in range(k):
        for l in range(d[j]):
            if i+1==A[j][l]:
                ans-=1
                key=1
            if key==1:
                break
        if key==1:
            break

print(ans)


Measured memory_bytes: 9212
#include<bits/stdc++.h>
#define ll long long
using namespace std;
 
int main()
{
    ll int n,W,val,w;
    cin >> n>>W;
    vector<ll int> dp(W+1,0);
    for(ll int i=0;i<n;i++)
    {
        cin >> w >> val;
        for(ll int j=W;j>=w;j--)
        {
            dp[j]=max(dp[j],dp[j-w]+val);
        }
    }
    ll int ans=0;
    for(ll int i=0;i<=W;i++)
    {
        ans=max(ans,dp[i]);
    }
    cout << ans;
}


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

using namespace std;
using ll = long long;

class UnionFind{
  private:
    vector<int> data; //data[i] : 頂点i
  public:

    UnionFind(int n) : data(n,-1) {}
    int root(int i) { return data[i] < 0 ? i : data[i] = root(data[i]); }
    int size(int i) { return -data[root(i)]; }
    bool same(int x, int y) {return root(x) == root(y); }
    bool connected() {return size(0) == (int)data.size(); }
    

    bool unit(int i,int j){
        i = root(i);
        j = root(j);
        if(i != j){
            data[i] += data[j];
            data[j] = i;
        }
        return i != j;
    }

};

int main()
{
    int n, m; cin >> n >> m;
    UnionFind tree(n);
    for(int i = 0; i < m; i++) {
        int x, y, z; cin >> x >> y >> z;
        tree.unit(x - 1, y - 1);
    }
    set<int> st;
    for(int i = 0; i < n; i++)st.insert(tree.root(i));
    cout << st.size() << endl;
}

Measured memory_bytes: 8240
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            String str = sc.next();
            String[] str2 = str.split("");
            str2[3] = "8";
            for(String s : str2){
              System.out.print(s);
            }
      }
}

Measured memory_bytes: 21716
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let n = v[0];
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut flag = false;
	for i in iter {
		if i == "Y" {
			flag = true;
			break;
		}
	}
	if flag {
		println!("Four");
	}else{
		println!("Three");
	}
}

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

int main(){
    int N,X;
    cin >> N >> X;
    int m[1100];
    for(int i=0;i<N;++i)cin >> m[i];

    int mn = m[0];
    for(int i=0;i<N;++i){
        if(mn > m[i])mn = m[i];
    }

    for(int i=0;i<N;++i){
        X -= m[i];
    }
    int dev = X / mn;
    cout << dev + N << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>=0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = 3.141592653589793;

int n,m;
int a[10];
string id;
ll dp[100000+5][10];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    cin >> id;
    cin >> m;
    rep(i,m) cin >> a[i];
    dp[0][0]=1;
    reverse(all(id));
    rep(i,n){
        if (id[i]=='*'){
            rep(j,10){
                rep(k,m){
                    if ((i+1)%2==0){
                        if (a[k]>=5) dp[i+1][(j+(a[k]-5)*2+1)%10]+=dp[i][j];
                        else dp[i+1][(j+2*a[k])%10]+=dp[i][j];
                    }
                    else{
                        dp[i+1][(j+a[k])%10]+=dp[i][j];
                    }
                }
            }
        }
        else{
            rep(j,10){
                if ((i+1)%2==0){
                    if ((int)(id[i]-'0')>=5) dp[i+1][(j+((int)(id[i]-'0')-5)*2+1)%10]+=dp[i][j];
                    else dp[i+1][(j+2*(int)(id[i]-'0'))%10]+=dp[i][j];
                }
                else{
                    dp[i+1][(j+(int)(id[i])-'0')%10]+=dp[i][j];
                }
            }
        }
    }
    cout << dp[n][0] << endl;
    return 0;
}

Measured memory_bytes: 11068
#include <bits/stdc++.h>
using namespace std;
typedef bool boool;
typedef long long ll;
#define vl vector<ll>
#define vb vector<boool>
#define vs vector<string>
#define vp vector<pair<ll, ll>>
#define vvl vector<vector<ll>>
#define vvp vector<vector<pair<ll, ll>>>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define rep1(i, n) for (long long i=0; i<(long long)(n); i++)
#define rep2(i, s, e) for (long long i=(s); i<(long long)(e); i++)
#define GET_MACRO(_1,_2,_3,NAME,...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

int main() {
    string str;
    cin >> str;
    if(str[str.length()-1]=='s') cout << str+"es" << endl;
    else cout << str+"s" << endl;
    return 0;
}

Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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; }

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


void solve(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    if(abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d) ) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


}



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    solve();

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n,s=0;
    cin>>n;
    vector<ll> l(n);
    for(ll i=0;i<n;i++) cin>>l[i];
    sort(all(l));
    for(ll i=0;i<n-1;i++){
        for(ll j=i+1;j<n-1;j++){
            for(ll k=j+1;k<n;k++){
                if(l[i]+l[j]<=l[k]) break;
                if(abs(l[i]-l[j])<l[k]) s++;
            }
        }
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <math.h>

int main()
{
    int n = 0;
    int a[10000];
    int i;
    int r = 0;
    int f = 0;
    std::cin >> n;
    for (i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    do {
        f = 0;
        for (i = 0; i < n; i++) {
            if (f == 0 && a[i] % 2 == 0) {
                a[i] = a[i] / 2;
                f = 1;
                r++;
                break;
            } else {
                a[i] = a[i] * 3;
            }
        }
        for (; i < n; i++) {
            a[i] = a[i] * 3;
        }
    } while (f > 0);
    std::cout << r << std::endl;
}

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

int main(){
    ll a,b,n;
    cin >>a>>b>>n;
    n=min(b-1,n);
    cout << a*n/b <<endl;
    return 0;
}

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

int main(){
	while(1){
		int n, s[100];
		int ans=0;
		
		scanf(" %d", &n);	
		if(n==0) break;
		for(int i=0; i<n; ++i) scanf(" %d", &s[i]);
		sort(s, s+n);
		
		for(int i=1; i<n-1; ++i) ans+=s[i];
		
		printf("%d\n", ans/(n-2));
	}
	return 0;
}

Measured memory_bytes: 1204
//Digit Number
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

		while (true) {

			String tmp = in.readLine();
			if (tmp == null) {
				break;
			}
			String[] ab = tmp.split(" ");

			int a = Integer.parseInt(ab[0]);
			int b = Integer.parseInt(ab[1]);

			 String out =Integer.toString(a+b);
			 System.out.println(out.length());
			


		}

		// Scanner scan = new Scanner(System.in);
		//
		// while(scan.hasNext()){
		//
		// String[] ab = scan.next().split(" ");
		//
		// int a = Integer.parseInt(ab[0]);
		// int b = Integer.parseInt(ab[1]);
		//
		//// String out =Integer.toString(a+b);
		//// System.out.println(out.length());
		////
		//
		// int i=0;
		// while(true){
		// i++;
		// if(Math.pow(10, i)>a+b){
		// break;
		// }
		// }
		// System.out.println(i);
		//
		// }
		// scan.close();
	}
}

Measured memory_bytes: 16992
def is_paindrome?(arr, len)
  len.times do |i|
    if arr[i] != arr[-(i + 1)]
      puts 'No'
      exit 0
    end
  end
end

s = gets.chomp

len = s.length
mid = len / 2

s1 = s[0..mid - 1]
s2 = s[mid + 1..-1]

is_paindrome?(s, len)
is_paindrome?(s1, s1.length)
is_paindrome?(s2, s2.length)

puts 'Yes'


Measured memory_bytes: 1788
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <numeric>
using namespace std;

#include <iostream>

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	auto result = (a + b == c
				|| a + c == b
				|| a == b + c);

	if (result)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>

using namespace std ;

int main(void){
    string S,res;

    cin >> S;
    
    if(S=="Sunny") res = "Cloudy";
    else if(S=="Cloudy") res = "Rainy";
    else if(S=="Rainy") res = "Sunny";
    
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

void funcB() {
  int a, b, c, d;
  bool takahashi;
  std::cin >> a >> b >> c >> d;
  for (takahashi = true; a > 0 && c > 0; takahashi = !takahashi) {
    if (takahashi)c -= b;
    else a -= d;
  }
  std::cout << (!takahashi ? "Yes" : "No");
}

int main(void) {
  funcB();
  return 0;
}

Measured memory_bytes: 3636
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define V vector
template <typename T> bool chmin(T &a, const T &b) {if(a > b){a = b; return true;} return false;}
template <typename T> bool chmax(T &a, const T &b) {if(a < b){a = b; return true;} return false;}
V<int> dx = {-1, 1,  0, 0, -1, -1,  1, 1};
V<int> dy = { 0, 0, -1, 1, -1,  1, -1, 1};

int main () {
    int n, x, t; cin >> n >> x >> t;
    int cnt = (n + x-1) / x;
    int ans = cnt * t;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3624
unittest
{
	assert( [ "2", ")", "(()" ].parse.expand.solve == "Yes" );
	assert( [ "2", ")(", "()" ].parse.expand.solve == "No" );
	assert( [ "4", "((()))", "((((((", "))))))", "()()()" ].parse.expand.solve == "Yes" );
	assert( [ "3", "(((", ")", ")" ].parse.expand.solve == "No" );
	
	assert( [ "4", "((", "))((((((", "))))))((", "))" ].parse.expand.solve == "Yes" );		// 追加ケース
	assert( [ "4", "((", "))((((((", ")))))", "))(" ].parse.expand.solve == "Yes" );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto ss = new dchar[][ n ];
	foreach( ref s; ss )
	{
		input.popFront;
		s = input.front.to!( dchar[] );
	}
	return tuple( ss );
}

auto solve( dchar[][] ss )
{
	// 括弧の群れを前提条件と変化量に変換
	Tuple!( long, long )[] ls;
	Tuple!( long, long )[] rs;
	foreach( s; ss )
	{
		auto m = 0L;
		auto d = 0L;
		
		// 左括弧と右括弧のどちらが多いかで分類
		if( s.length <= s.count( '(' ) * 2 )
		{
			foreach( c; s )
			{
				if( c == '(' )
				{
					d++;
				}
				else
				{
					d--;
					m = min( m, d );
				}
			}
			ls ~= tuple( -m, d );
		}
		else
		{
			foreach_reverse( c; s )
			{
				if( c == ')' )
				{
					d++;
				}
				else
				{
					d--;
					m = min( m, d );
				}
			}
			rs ~= tuple( -m, d );
		}
	}
	
	// 左括弧のやつ同士で前提条件が緩いやつから順番にくっつける
	auto lt = 0L;
	foreach( l; ls.sort() )
	{
		if( lt < l[ 0 ] ) return "No";
		lt += l[ 1 ];
	}
	
	// 右括弧のやつ同士で前提条件が緩いやつから順番にくっつける
	auto rt = 0L;
	foreach( r; rs.sort() )
	{
		if( rt < r[ 0 ] ) return "No";
		rt += r[ 1 ];
	}
	
	// 左括弧と右括弧をくっつけて対応が取れているか判定
	return ( lt == rt ) ? "Yes" : "No";
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int n, m, x;
  cin >> n >> m >> x;

  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m));
  for (int i = 0; i < n; ++i) {
    cin >> c[i];
    for (int j = 0; j < m; ++j) {
      cin >> a[i][j];
    }
  }

  int64_t ans = 92233720368547758L;
  for (int i = 0; i < (1 << n); ++i) {
    vector<int64_t> sum(m, 0);
    int64_t sumc = 0;
    for (int j = 0; j < n; ++j) {
      if (i & (1 << j)) {
        for (int k = 0; k < m; ++k) sum[k] += a[j][k];
        sumc += c[j];
      }
    }
    bool ok = true;
    for (int j = 0; j < m; ++j) {
      if (sum[j] < x) ok = false;
    }
    if (ok) ans = min(ans, sumc);
  }
  if (ans == 92233720368547758L) {
    cout << -1 << '\n';
  } else {
    cout << ans << '\n';
  }

  return 0;
}


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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);i++)
#define FOR2(i,a,b) for (int i=(a);i<(b);i++)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define ROF2(i,x,y) for(int i = (y) ; i >= (x) ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
#define FAST ios_base::sync_with_stdio(false); cin.tie(0)

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

template<class T>
ostream &operator<<(ostream &os,const vector<T> &x) {
    os << '[';
    if ( !x.empty() ) {
        std::copy (x.begin(), x.end(), std::ostream_iterator<T>(os, ","));
        os << "\b";
    }
    os << "]";
    return os;
}
template<class T>
ostream &operator<<(ostream &os,const vector<vector<T> > &x) {
    os << '[';
    if ( !x.empty() ) {
        os << x[0];
        for (int i=1;i<x.size();i++) os << endl << " " << x[i];
    } else os << "[]";
    os << "]";
    return os;
}

int main() {
    FAST;
    //freopen ("in.txt", "r", stdin);
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    int m[3];
    m[0]=abs(a[1]-a[0]);
    m[1]=abs(a[1]-a[2]);
    m[2]=abs(a[0]-a[2]);
    sort(m,m+3);
    cout << m[0]+m[1];

    return 0;
}



Measured memory_bytes: 256
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

H, W = rl()
S = []
for i in range(H):
  s = rs()
  S.append(s + '#')
S.append('#'*(W+1))

tab = [[0 for _ in range(W+1)] for _ in range(H+1)]

for i in range(H):
  k = 0
  prev = -1
  for j in range(W+1):
    if S[i][j] == '#':
      n = j-prev-1
      while k < j:
        tab[i][k] += n
        k += 1
      tab[i][k] = 0
      k += 1
      prev = j

for j in range(W):
  k = 0
  prev = -1
  for i in range(H+1):
    if S[i][j] == '#':
      n = i-prev-1
      while k < i:
        tab[k][j] += n - 1
        k += 1
      tab[k][j] = 0
      k += 1
      prev = i

ans = 0
for i in range(H):
  for j in range(W):
    ans = max(ans, tab[i][j])
print(ans)


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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; }

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

const int inf = 1e18;

int N, M, X;
int C[20];
int A[20][20];

bool check(vector<int> al) {
	rep (i, M) {
		if (al[i] < X) return false;
	}
	return true;
}

signed main() {
	cin >> N >> M >> X;
	rep (i, N) {
		cin >> C[i];
		rep (j, M) {
			cin >> A[i][j];
		}
	}

	int ans = inf;
	for (int bin = 0; bin < (1<<N); bin++) { // 組み合わせ
		int sum = 0;
		vector<int> alg(M);

		for (int dig = 0; dig < N; dig++) { // 桁ごとに見る
			if ((bin >> dig) & 1) {
				sum += C[dig];
				for (int i = 0; i < M; i++) {
					alg[i] += A[dig][i];
				}
			}
		}

		bool flg = true;
		rep (i, M) {
			if (alg[i] < X) {
				flg = false;
			}
		}
		if (flg) {
			chmin(ans, sum);
		}
	}

	cout << (ans >= inf ? -1 : ans) << endl;

	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int k, s;
  cin >> k >> s;
  int ans = 0;
  rep(i, k+1) rep(j, k+1) {
    int z = s-i-j;
    if (z >= 0 && z <= k)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int n;
    int[] nums;

    void run(){
	n = sc.nextInt();
	while(n>0){
	    n--;
	    nums = new int[10];
	    for(int i=0; i<10; i++)
		nums[i] = sc.nextInt();
	    boolean ans = solve(0, 0, 0);
	    System.out.println(ans ? "YES":"NO");
	}
    }
    boolean solve(int level, int left, int right){
	if(level==10) return true;
	
	if(left<nums[level] || right<nums[level]){
	    //System.out.println(left+" "+right);
	    if(left < nums[level])
		return solve(level+1, nums[level], right);
	    if(right < nums[level])
		return solve(level+1, left, nums[level]);
	}
	else
	    return false;
	return true;
    }
}

Measured memory_bytes: 18156
#include <iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include <queue>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
const ll MOD = 1000000007;

    ll N,ans=0,temp=0;

int main(){
    scanf("%lld",&N);
    if(N<=6){
        cout<<1;
        return 0;
    }
    if(N<=11){
        cout<<2;
        return 0;
    }
    ans=N/11*2;
    temp=N%11;

    if(temp==0){
        cout<<ans;
        return 0;
    }

    if(temp<=6){
        ans++;
    }else ans+=2;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>

using namespace std;

struct Tree
{
	int key;
	Tree *left;
	Tree *right;
	Tree *parent;
};

// Tree::Tree(int k, Tree *l, Tree *r): key(k), left(l), right(r){}

void printTreeMid(Tree *tree)
{
	// cout << "mid" << endl;
	if (tree == nullptr)
		return;
	printTreeMid(tree->left);
	printf(" %d", tree->key);
	printTreeMid(tree->right);
}

void printTreePro(Tree *tree)
{
	if (tree == nullptr)
		return;
	printf(" %d", tree->key);
	printTreePro(tree->left);
	printTreePro(tree->right);
}

void insert(Tree *tree, int key)
{
	Tree *y = nullptr;
	Tree *x = tree->right;
	while (x != nullptr)
	{
		// cout << "in while" << endl;
		y = x;
		if (x->key < key)
		{
			x = x->right;
		}
		else
		{
			x = x->left;
		}
	}
	Tree *z = (Tree *)calloc(1, sizeof(Tree));
	z->parent = y;
	z->key = key;
	z->left = nullptr;
	z->right = nullptr;
	if (z->parent == nullptr)
	{
		tree->right = z;
		return;
	}
	if (y->key < key)
	{
		y->right = z;
	}
	else
	{
		y->left = z;
	}
}

// int findNode(Tree *tree, int k) {
// 	if(tree == nullptr) {
// 		cout << "no" << endl;
// 		return 0;
// 	}
// 	if(tree->key == k) {
// 		cout << "yes" << endl;
// 		return 1;
// 	} else if(tree->key > k) {
// 		return findNode(tree->left, k);
// 	} else {
// 		return findNode(tree->right, k);
// 	}
// }

void findNode(Tree *tree, int k)
{
	while (tree != nullptr)
	{
		if (tree->key == k)
		{
			cout << "yes" << endl;
			return;
		} else if(tree->key > k) {
			tree = tree->left;
		} else {
			tree = tree->right;
		}
	}
	cout << "no" << endl;
}

//8:00
int main()
{
	int n;
	cin >> n;
	Tree *NIL = new Tree();
	NIL->right = nullptr;
	for (size_t i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		if (s == "insert")
		{
			int k;
			scanf("%d", &k);
			// if(tree != nullptr) {
			// 	cout << "root: " << tree->key;
			// }
			insert(NIL, k);
		}
		else if (s == "print")
		{
			printTreeMid(NIL->right);
			cout << endl;
			printTreePro(NIL->right);
			cout << endl;
		}
		else if (s == "find")
		{
			int k;
			scanf("%d", &k);
			findNode(NIL, k);
		}
	}
}



Measured memory_bytes: 22032
#include <bits/stdc++.h>
#define sync ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define mod 100000007
using namespace std;


int main()
{
    
    // freopen("C:\\Users\\Akarshan\\Desktop\\cp-temp\\running_on_fumes_chapter_1_input.txt","r",stdin);
    // freopen("C:\\Users\\Akarshan\\Desktop\\cp-temp\\output.txt","w",stdout);
  ll n;
  cin>>n;
  vector<char>c;
  priority_queue<ll>rh;
  priority_queue<ll,vector<ll>,greater<ll>>wh;  
  for(int i=1;i<=n;i++)
  {
      char ch;
      cin>>ch;
      c.push_back(ch);
      if(ch=='R')
        rh.push(i);
      else 
        wh.push(i);
  }
  if(rh.empty()||wh.empty())
  {
      cout<<0<<endl;
      return 0;
  }
    ll ctr=0;
    while(rh.top()>wh.top())
    {
        int x=rh.top();
        rh.pop();
        rh.push(wh.top());
        wh.pop();
        wh.push(x);
        ctr++;
    }
    cout<<ctr<<endl;
}

Measured memory_bytes: 6120
n,a,b=map(int,input().split())
s=input()
cnt=0
cntfo=0
for i in range(n):
    if s[i]=="a":
        if cnt<a+b:
            print("Yes")
            cnt+=1
        else:
            print("No")
    elif s[i]=="b":
        if cnt<a+b and cntfo<b:
            print("Yes")
            cnt+=1
            cntfo+=1
        else:
            print("No")
    else:
        print("No")


Measured memory_bytes: 4016