akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long A = l[0], B = l[1], K = l[2];

            if (K - A >= 0)
            {
                K -= A;
                A = 0;
            }
            else
            {
                A -= K;
                Console.WriteLine($"{A} {B}");
                return;
            }

            if (K - B >= 0)
                B = 0;
            else
                B -= K;

            Console.WriteLine($"{A} {B}");
        }
    }
}

Measured memory_bytes: 13396
#include <stdio.h>

int main(void){
  int n, m[110][2] = {0}, p[110] = {0}, dp[110][110] = {0};
  int i, j, k, l;

  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d %d", &m[i][0], &m[i][1]);
    p[i-1] = m[i][0];
    p[i] = m[i][1];
  }

  for (i = 1; i <= n; i++) {
    dp[i][i] = 0;
  }
  for (l = 2; l <= n; l++) {
    for (i = 1; i <= n - l + 1; i++) {
      j = i + l - 1;
      dp[i][j] = 999999;
      for (k = i; k <= j - 1; k++) {
        if (dp[i][j] > dp[i][k] + dp[k+1][j] + p[i-1] * p[k] * p[j]) {
          dp[i][j] = dp[i][k] + dp[k+1][j] + p[i-1] * p[k] * p[j];
        }
      }
    }
  }

  printf("%d\n", dp[1][n]);

  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
int n,k,s,t;
vector<int> a;
ll C[55][55],ways[55];
int main()
{
	scanf("%d%d%d%d",&n,&k,&s,&t);
	for(int i=0;i<n;i++)
	{
		int x;
		scanf("%d",&x);
		if(((x&s)==s)&&((x|t)==t))a.push_back(x);
	}
	if(a.empty())
	{
		printf("0\n");
		return 0;
	}
	
	C[0][0]=1;
	for(int i=1;i<55;i++)
	{
		C[i][0]=C[i][i]=1;
		for(int j=1;j<i;j++)C[i][j]=C[i-1][j]+C[i-1][j-1];
	}
	for(int i=1;i<55;i++)
	{
		for(int j=1;j<=i&&j<=k;j++)ways[i]+=C[i][j];
	}
	int free=(s^t);
	ll ans=0;
	for(int msk=0;msk<(1<<18);msk++)
	{
		if((msk&free)!=msk)continue;
		vector<int> b;
		b.clear();
		for(int i=0;i<a.size();i++)
		{
			b.push_back(a[i]&msk);
		}
		sort(b.begin(),b.end());
		ll tmp=0;
		for(int i=0,j=0;i<b.size();i=j+1)
		{
			while(j+1<b.size()&&(b[j+1]==b[i]))j++;
			tmp+=ways[j-i+1];
		}
		int bi=__builtin_popcount(msk);
		if(bi&1)ans-=tmp;
		else ans+=tmp;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3816
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
	cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	cout << head;
	if (sizeof...(tail) != 0) cout << " ";
	print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
	for (auto& a : vec) {
		cout << a;
		if (&a != &vec.back()) cout << " ";
	}
	cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
	for (auto& vec : df) {
		print(vec);
	}
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	string s;
	cin >> s;
	int ans = 0;
	if (s[0] == '1') ans++;
	if (s[1] == '1') ans++;
	if (s[2] == '1') ans++;
	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
#include <cstdio>
#include <functional>
#include <cmath>

using namespace std;

int main()
{
    long long N, S;
    scanf("%lld\n", &N);
    scanf("%lld\n", &S);

    if (N == S){
        printf("%lld", N + 1);
        return 0;
    }else if (N < S || S > (N + 1) / 2){
        puts("-1");
        return 0;
    }

    function<long long(long long, long long)> f = [&](long long b, long long n){
        if (n < b){
            return n;
        }else{
            return f(b, n / b) + (n % b);
        }
    };
    const long long sqrt_N = ceil(sqrt(N));
    for (long long b = 2; b <= sqrt_N; ++b){
        if (f(b, N) == S){
            printf("%lld\n", b);
            return 0;
        }
    }
    const long long sub = N - S;
    for (long long p = sqrt_N; p > 0; --p){
        if (sub % p) continue;
        const long long b = (sub / p) + 1;
        if (f(b, N) == S){
            printf("%lld\n", b);
            return 0;
        }
    }
    puts("-1");
}


Measured memory_bytes: 384
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;

const long long mod = 1000000007;

long long fpow(long long a, long long p)
{
	long long r = 1;
	while (p){
		if (p & 1) r = r * a % mod;
		a = a * a % mod;
		p /= 2;
	}
	return r;
}

int main()
{
	int N,K;
	scanf ("%d %d",&N,&K);

	vector<int> f;
	for (int i=1;i*i<=N;i++) if (N % i == 0){
		f.push_back(i);
		if (i * i != N) f.push_back(N/i);
	}
	sort(f.begin(),f.end());

	vector<long long> d(f.size());
	long long ans = 0;
	for (int i=0;i<f.size();i++){
		d[i] = fpow(K,(f[i]+1)/2);
		for (int j=0;j<i;j++) if (f[i] % f[j] == 0){
			d[i] = (d[i] + mod - d[j]) % mod;
		}
		long long n = d[i] * f[i] % mod;
		if (f[i] % 2 == 0) n = n * 500000004 % mod;
		ans = (ans + n) % mod;
	}

	printf ("%lld\n",ans);

	return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int H,W; cin >> H >> W;
    char S[H][W]; REP(i,H)REP(j,W) cin >> S[i][j];

    int n[H][W]; REP(i,H)REP(j,W) n[i][j] = -1;
    REP(i,H){
        int l = 0, r = 0;
        while(l<W && r<W){
            while(l<W && S[i][l] == '#') l++;
            r = l+1;
            while(r<W && S[i][r] == '.') r++;
            if(r<W+1) FOR(j,l,r) n[i][j] += r-l;
            l = r+1;
        }
    }
    REP(j,W){
        int l = 0, r = 0;
        while(l<H && r<H){
            while(l<H && S[l][j] == '#') l++;
            r = l+1;
            while(r<H && S[r][j] == '.') r++;
            if(r<H+1) FOR(i,l,r) n[i][j] += r-l;
            l = r+1;
        }
    }
    int ans = 0;
    REP(i,H)REP(j,W) chmax(ans, n[i][j]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19840
#include<stdio.h>

int main(void)
{
  int n,array[2][101],max=0,i,j,can=0,frag;
  scanf("%d",&n);
  frag = n-1;
  for(i=0;i<2;i++)
    {
      for(j=0;j<n;j++)
	{
	  scanf("%d",&array[i][j]);
	}
    }
  i=0;
  while(frag >= 0)
    {
      can = 0; i = 0;
      for(j=0;j<n;j++)
	{
	  can += array[i][j];
	  if(j == frag)
	    {
	      i++;
	      can += array[i][j];
	    }
	  //debug
	  //printf("%d\n",can);
	  if(max < can)
	    {
	      max = can;
	    }
	}
      frag--;
    }
  printf("%d\n",max);
  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    set<int> se;
    se.insert(a);
    se.insert(b);
    se.insert(c);
    cout << se.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

   bool ok=false;
   rep(i, s.size()-1) if(s[i]!=s[i+1]) ok=true;

   if(ok) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string.h>
#define ll long long
using namespace std;
int main()
{
	int N,K,S;
	cin>>N>>K>>S;
	if(S<1e9||K==N)
	{
		for(int i=1;i<=K;i++)
		{
			if(i>1)
				cout<<' ';
			cout<<S;
		}
		for(int i=K+1;i<=N;i++)
			cout<<' '<<S+1;
	}
	if(S==1e9&&K<N)
	{
		if(K>0){
		for(int i=1;i<=K-1;i++)
			cout<<S<<' ';
		for(int i=K;i<=N-1;i++)
			cout<<"1 ";
		cout<<S-(N-K);
		}
		if(K==0)
		for(int i=1;i<=N;i++)
			cout<<"1 ";
	}
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 100005 ;
const long long mod = 1.0e9+7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,i,j;
    cin>>n;
    string s[n+1];
    map<string,ll> m;
    for(i=0;i<n;i++)
    {
        cin>>s[i];
        sort(s[i].begin(),s[i].end());
        m[s[i]]++;
    }
    int sum=0,x;
    for(auto itr=m.begin();itr!=m.end();itr++)
    {
        x=itr->second;
        sum+=(x*(x-1))/2;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 16640
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <type_traits>
#include <map>
using namespace std;

int main(int argc, const char * argv[]) {
  long long n;
  cin >> n;
  if(n == 0){
    cout << 0 << endl;
  }
  string s = "";
  while(n != 0){
    if(n % -2 == -1){
      n-=2;
    }
    s = to_string(abs(n%-2)) + s;
    n /= -2;
  }
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1000000007;
signed main(){
  int N,K;
  cin>>N>>K;
  vector<int> A(N);
  for(int &i:A)
    cin>>i;
  vector<vector<int>> B(N+1,vector<int>(K+1,0));
  B[0][0]=1;
  for(int i=0;i<N;i++){
    for(int j=0;j<=K;j++){
      B[i+1][j]=(B[i+1][j]+B[i][j])%mod;
      if(j+A[i]+1<=K)
        B[i+1][j+A[i]+1]=(B[i+1][j+A[i]+1]-B[i][j]+mod)%mod;
    }
    for(int j=1;j<=K;j++)
      B[i+1][j]=(B[i+1][j]+B[i+1][j-1])%mod;
  }
  cout<<B[N][K]<<endl;
}

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

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	vector<int> l(n);
	rep(i, n) cin >> l[i];
	sort(l.begin(), l.end());

	int ans = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			int len = l[i] + l[j];
			// printf("%d %d %d\n", i, j, len);
			// l[i + 2 ~ n - 1] < len
			ans += (lower_bound(l.begin(), l.end(), len) - l.begin() - 1) - j;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {

    static int mod = (int) 1e9 + 7;

    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = in.nextInt();
        String s = in.next();
        int[][] dp = new int[n][n];
        dp[0][0] = 1;

        int[] prefixSum;

        for (int i = 1; i < n; i++) {
            boolean lastGreater = s.charAt(i - 1) == '>';

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

            for (int j = 0; j <= i; j++) {
                int L;
                int R;

                if (lastGreater) {
                    L = 0;
                    R = j;
                }

                else {
                    L = j;
                    R = n;
                }

                dp[i][j] = remove_self(prefixSum[R], prefixSum[L]);
            }
        }

        int result = 0;
        for (int i = 0; i < n; i++) {
            result = add_self(result, dp[n-1][i]);
        }

        out.println(result);
        out.close();
    }

    static int add_self(int a, int b) {
        a += b;
        if (a >= mod) a -= mod;
        return a;
    }

    static int remove_self(int a, int b) {
        a -= b;
        if (a < 0) a += mod;
        return a;
    }
}

Measured memory_bytes: 93604
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

struct node {int to, cost;};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    
    int K;
    cin >> K;
    
    vector<vector<node>> G(K);
    rep(i, K) {
        G[i].pb({(i + 1) % K, 1});
        G[i].pb({i * 10 % K, 0});
    }
    
    deque<int> dq;
    vector<int> dist(K, inf);
    dq.push_back(1);
    dist[1] = 0;
    
    while (!dq.empty()) {
        int t = dq.front();
        dq.pop_front();
        for (auto v: G[t]) {
            if (dist[v.to] > dist[t] + v.cost) {
                dist[v.to] = dist[t] + v.cost;
                if (v.cost == 0) {
                    dq.push_front(v.to);
                }
                else dq.push_back(v.to);
            }
        }
    }
    
    output(dist[0] + 1);
    
    return 0;
}


Measured memory_bytes: 6272
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() -> () {
    input!{
        n: usize,
        m: usize,
        x: i32,
        y: i32,
        xn: [i32; n],
        yn: [i32; m],
    }
    let mut xn = xn;
    let mut yn = yn;
    xn.sort();
    yn.sort();
    let xm = *xn.iter().max().unwrap();
    let ym = *yn.iter().min().unwrap();
    if xm < ym && xm < y && ym > x {
        println!("No War");
    } else {
    println!("War");
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	int n;
	cin >> n;
	if (n % 1000 == 0)cout << 0 << endl;
	else {
		int num = n / 1000;
		cout << ( num +1)* 1000 -n<< endl;
		
	}return 0;
}


Measured memory_bytes: 3632
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String ans = "Yes";
    if(s.equals("AAA")||s.equals("BBB")){
      ans = "No";
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23892
#include<stdio.h>
int main()
    {int n,a,max,sum=0;
	scanf("%d%d",&n,&a);
	max=a;
	while(n>1)
	{scanf("%d",&a);
	if(max<a){sum=sum+max;
	max=a;
	}
	else sum+=a;
	n--;
 } 
 sum+=max/2; 
	 printf("%d\n",sum);
    return 0;
 }


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(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 Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}



int main()
{
	ll n,m,a,b;
	cin >> n >> m;
	vector<bool> x(n+1,false),y(n+1,false);
	rep(i,m){
		cin >> a >> b;
		if(a==1) x[b]=true;
		if(b==n) y[a]=true;
	}
	for(ll i=2;i<n;i++){
		if(x[i] && y[i]){
			cout << "POSSIBLE\n";
			return 0;
		}
	}
	cout << "IMPOSSIBLE\n";
	return 0;
}

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

int main(){
  string s;cin >> s;
  int j= 0;
  for(int i=0;i<s.length();++i){
    cout << s[i];
    if(j == 4||j == 11){
      cout << " ";
      i += 1;
    } else if(j == 16)cout << endl;
    j += 1;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

ll add(ll x, ll y) {ll res=x+y; return(res>=MOD?res-MOD:res);}
ll mul(ll x, ll y) {ll res=x*y; return(res>=MOD?res%MOD:res);}
ll sub(ll x, ll y) {ll res=x-y; return(res<0?res+MOD:res);}
ll lcm(ll x, ll y) {ll res=(x*y)/__gcd(x,y); return res;}
ll power(ll x, ll y) {ll res=1; x%=MOD; while(y){if(y&1)res=mul(res,x); y>>=1; x=mul(x,x);} return res;}

const int MAX = 2e6 + 5;
ll fact[MAX], invf[MAX];
ll nCr(ll n, ll r){if(n<r||n<0||r<0)return 0; return mul(fact[n],mul(invf[n - r],invf[r]));}
void preprocess()
{
	fact[0] = 1;
	invf[0] = 1;
	for(ll i = 1; i < MAX; i++){
		fact[i] = mul(fact[i - 1], i);
		invf[i] = power(fact[i], MOD - 2);
	}
}
int main()
{
	boost;
	preprocess();
	int n, k, i;
	cin >> k;
	string s;
	cin >> s;
	n = s.size();
	
	ll res = 0;
	fo(i, 0, n) 
	res = add(res, mul(nCr(k + n, i), power(25, k + n - i)));
	res = sub(power(26, k + n), res);
	cout << res;
}


Measured memory_bytes: 35476
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
ll inf=1000000000000000,mod=1000000007;

int main(){
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        
        ll n;cin>>n;string s;
        cin>>s;
        ll r=0,g=0,b=0;
        for(ll i=0;i<n;i++){
            if(s[i]=='R')r++;
            if(s[i]=='G')g++;
            if(s[i]=='B')b++;
        }
        ll sum=0,num,r1=0,g1=0,b1=0;
        for(ll i=0;i<n;i++){
            if(s[i]=='R')
            num=(b1*g+g1*b),r--,r1++;
            if(s[i]=='G')
            num=(r1*b+b1*r),g--,g1++;
            if(s[i]=='B')
            num=(r1*g+g1*r),b--,b1++;
            for(ll j=1;j<n;j++){
                if(i-j<0||i+j>=n)break;
                if(s[i-j]!=s[i+j]&&s[i]!=s[i+j]&&s[i]!=s[i-j])
                num--;
            }
            sum+=num;
        }
        cout<<sum<<endl;

}


Measured memory_bytes: 3664
class Point():
    def __init__(self, x, y):
        self.x = x
        self.y = y

class Segment():
    def __init__(self, x1, y1, x2, y2):
        self.p1 = Point(x1, y1)
        self.p2 = Point(x2, y2)
        self.slope = None
        if self.p1.x == self.p2.x:
            self.slope = float('inf')
        else:
            self.slope = (self.p2.y - self.p1.y)/(self.p2.x - self.p1.x)

    def is_intersect(self, seg):
        a = (seg.p1.x - seg.p2.x) * (self.p1.y - seg.p1.y) + (seg.p1.y - seg.p2.y) * (seg.p1.x - self.p1.x)
        b = (seg.p1.x - seg.p2.x) * (self.p2.y - seg.p1.y) + (seg.p1.y - seg.p2.y) * (seg.p1.x - self.p2.x)
        c = (self.p1.x - self.p2.x) * (seg.p1.y - self.p1.y) + (self.p1.y - self.p2.y) * (self.p1.x - seg.p1.x)
        d = (self.p1.x - self.p2.x) * (seg.p2.y - self.p1.y) + (self.p1.y - self.p2.y) * (self.p1.x - seg.p2.x)
        e = (self.p1.x - seg.p1.x)*(self.p2.x - seg.p2.x)
        f = (self.p1.x - seg.p2.x)*(self.p2.x - seg.p1.x)
        g = (self.p1.y - seg.p1.y)*(self.p2.y - seg.p2.y)
        h = (self.p1.y - seg.p2.y)*(self.p2.y - seg.p1.y)
        return a*b <= 0 and c*d <= 0 and (e <= 0 or f <= 0) and (g <= 0 or h <= 0)

q = int(input())
for i in range(q):
    x0, y0, x1, y1, x2, y2, x3, y3 = list(map(int, input().split(' ')))
    line1, line2 = Segment(x0, y0, x1, y1), Segment(x2, y2, x3, y3)
    if line1.is_intersect(line2):
        print(1)
    else:
        print(0)




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

string keta(int a){
  string s=to_string(a);
  int l=s.size();
  if(l == 1){
    return "00000"+s;
  }
  if(l == 2){
    return "0000"+s;
  }
  if(l == 3){
    return "000"+s;
  }
  if(l == 4){
    return "00"+s;
  }
  if(l == 5){
    return "0"+s;
  }
  if(l == 6){
    return s;
  }
}

int main(){
  int N,M;
  cin >>N>>M;
  map<long long int,int> Z;
  for(int i=0;i<M;i++){
    long long a,b;
    cin >>a>>b;
    long long int d=a*1000000001+b;
    Z[d] = i;
  }
  vector<string> ans(M);
  int c=0;
  long long int u,uf,t;
  for(auto itr = Z.begin();itr != Z.end();itr++){
    c++;
    t=itr->first;
    u=t/1000000001;
    if(u != uf) c=1;
    ans.at(itr -> second) = keta(u)+keta(c);
    uf = u;
  }
  for(int i=0;i<M;i++){
    cout << ans.at(i)<<endl;
  }
}


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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

// repetition
//------------------------------------------
#define FOR(i, a, b) for (ll i = (a); i <= (b); ++i)
#define REP(i, n) for (ll i = 0; i < (n); ++i)

int main() {
  ll x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<ll> p(a);
  vector<ll> q(b);
  vector<ll> r(c);

  REP(i, a) {
    cin >> p[i];
  }
  REP(i, b) {
    cin >> q[i];
  }
  REP(i, c) {
    cin >> r[i];
  }

  SORT(p);
  REVERSE(p);
  SORT(q);
  REVERSE(q);
  SORT(r);
  REVERSE(r);
  ll ans = 0;
  vector<ll> nokori;

  REP(i, x) {
    nokori.push_back(p[i]);
  }
  REP(i, y) {
    nokori.push_back(q[i]);
  }

  nokori.insert(nokori.end(), r.begin(), r.end());
  SORT(nokori);
  REVERSE(nokori);

  REP(i, x + y) {
    ans += nokori[i];
  }

  ANS(ans);

  return 0;
}


Measured memory_bytes: 6896
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class abc166_a {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            if ((in.next().compareTo("ARC") == 0)) {
                out.println("ABC");
            } else {
                out.println("ARC");
            }

        }

    }
}



Measured memory_bytes: 35792
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define RAP(i, n) for(ll i=0;i<(n);i++)
#define FOR(i, a, b) for(ll i=(a);i<(b);i++)

int main(){
  ll n, r=0, g=0, b=0, ans;
  string s;
  cin >> n >> s;
  RAP(i, n){
    if(s[i] == 'R'){
      r++;
    }else if(s[i] == 'G'){
      g++;
    }else{
      b++;
    }
  }
  ans = r*g*b;
  RAP(i,n){
    RAP(j,n){
      if((j+2*i)<n){
        if(s[j] != s[j+i] && s[j] != s[j+2*i] && s[j+i] != s[j+2*i]){
          ans--;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define cmax(a,b) (a<(b)?a=(b):a)
#define cmin(a,b) (a>(b)?a=(b):a)
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
using namespace std; 

#define Pr(f,...) //printf(f,##__VA_ARGS__),fflush(stdout)

const int N=2005; 

int n,m,q,a[N][N],b[N][N],c[N][N];
char s[N][N]; 

int sum(int a[N][N],int l,int u,int r,int d){
	return a[d][r]-a[d][l-1]-a[u-1][r]+a[u-1][l-1];
}

int main(){
#ifdef CURIOUSCAT 
	freopen("dat.in","r",stdin);
#endif	
	scanf("%d%d%d",&n,&m,&q);
	rep(i,1,n){
		scanf("%s",s[i]+1);
		rep(j,1,m)a[i][j]=s[i][j]-'0'; 
	}
	rep(i,2,n)rep(j,1,m)b[i][j]=a[i][j]==a[i-1][j]&&a[i][j];
	rep(i,1,n)rep(j,2,m)c[i][j]=a[i][j]==a[i][j-1]&&a[i][j];
	
	rep(i,1,n)rep(j,2,m){
		a[i][j]+=a[i][j-1];
		b[i][j]+=b[i][j-1];
		c[i][j]+=c[i][j-1];
	}
	rep(i,2,n)rep(j,1,m){
		a[i][j]+=a[i-1][j];
		b[i][j]+=b[i-1][j];
		c[i][j]+=c[i-1][j];
	}
	while(q--){
		int l,u,r,d;
		cin>>u>>l>>d>>r;
		int ans=sum(a,l,u,r,d);
		
		ans-=sum(b,l,u+1,r,d);
		ans-=sum(c,l+1,u,r,d);
		printf("%d\n",ans);
	}

	return 0;
}



Measured memory_bytes: 52864
#include <iostream>
#include <string.h>
#include <utility>
using namespace std;

int main () {
  int n;
  cin >> n;
  int a[n];
  pair<int, int> ev[100000];
  pair<int, int> ov[100000];
  for (int i = 0; i < 100000; i++) {
    ev[i].first = 0;
    ev[i].second = i;
    ov[i].first = 0;
    ov[i].second = i;
  }
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i % 2 == 0) {
      ev[a[i] - 1].first++;  
    }  
    else {
      ov[a[i] - 1].first++;  
    }
  }
  sort(ev, ev + 100000);
  sort(ov, ov + 100000);
  if (ev[99999].second != ov[99999].second) {
    cout << n / 2 - ev[99999].first + n / 2 - ov[99999].first << endl;  
  }
  else {
    if (ev[99998].first >= ov[99998].first) {
      cout << n / 2 - ov[99999].first + n / 2 - ev[99998].first << endl;  
    } 
    else {
      cout << n / 2 - ev[99999].first + n / 2 - ov[99998].first << endl;  
    }
  }
 
}

Measured memory_bytes: 2808
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define EPS 1e-10
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

/**
 * Usage:
 * 
 * chmin(old, new);
 * chmax(old, new);
 * 
 */ 
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}




ll a, b, x;

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

  ll sho_a = a / x;
  ll ama_a = a % x;

  ll sho_b = b / x;
  //ll ama_b = b % x;

  if (ama_a == 0) {
    cout << sho_b - sho_a + 1 << "\n";
  } else {
    cout << sho_b - sho_a << "\n";
  }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}



int main(){FIN

    ll n;cin>>n;
    vector<string> v(n);
    map<char,ll> mp;
    REP(i,n) {
        cin>>v[i];
        mp[v[i][0]]++;
    }
    ll a = mp['M'];
    ll b=mp['A'];
    ll c=mp['R'];
    ll d=mp['C'];
    ll e=mp['H'];
    ll ans = 0;
    ans+=(a*b*c + a*b*d + a*b*e);
    ans+=(a*c*d + a*c*e + a*d*e);
    ans+=(b*c*d + b*c*e + b*d*e + c*d*e);
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 6364
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void){
  int n,i,x[1000],y[1000];
  double sum=0,max=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
      scanf("%d",&x[i]);
  }
  for(i=0;i<n;i++){
      scanf("%d",&y[i]);
  }
  
  for(i=0;i<n;i++){
      sum+=abs(x[i]-y[i]);
  }
  printf("%f\n",sum);
  sum=0;
  
  for(i=0;i<n;i++){
       sum+=abs(x[i]-y[i])*abs(x[i]-y[i]);
  }
  printf("%f\n",sqrt(sum));
  sum=0;
  
  for(i=0;i<n;i++){
       sum+=abs(x[i]-y[i])*abs(x[i]-y[i])*abs(x[i]-y[i]);
  }
  printf("%f\n",pow(sum,1.0/3.0));
  
  for(i=0;i<n;i++){
      if(max<abs(x[i]-y[i])) max=abs(x[i]-y[i]);
  }
  printf("%f\n",max);
  
  return 0;
}



Measured memory_bytes: 2104
import java.util.Scanner
import java.lang.Math.*

fun main(args: Array<String>) {
	val scn = Scanner(System.`in`)
	val n = scn.nextInt()
	val x = scn.nextInt()
	val y = scn.nextInt()
	val arr = IntArray(n)	//0は余分
	for (i in 1 until n){
		for (j in i+1..n){
			val d1 = j-i
			val d2 = abs(i-x)+abs(j-y)+1
			arr[min(d1, d2)]++
		}
	}
	for (k in 1 until n) println(arr[k])
}

Measured memory_bytes: 29660
#pragma GCC optimize(3)
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<bitset>
#include<deque>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define ri register int
#define il inline
#define fi first
#define se second
#define mp make_pair
#define pi pair<int,int>
#define mem0(x) memset((x),0,sizeof (x))
#define mem1(x) memset((x),0x3f,sizeof (x))
il char gc() {
	static const int BS = 1 << 22;
	static unsigned char buf[BS], *st, *ed;
	if (st == ed) ed = buf + fread(st = buf, 1, BS, stdin);
	return st == ed ? EOF : *st++;
}
#define gc getchar
template<class T>void in(T &x) {
	x = 0;
	bool f = 0;
	char c = gc();
	while (c < '0' || c > '9') {
		if (c == '-') f = 1;
		c = gc();
	}
	while ('0' <= c && c <= '9') {
		x = (x << 3) + (x << 1) + (c ^ 48);
		c = gc();
	}
	if (f) x = -x;
}
#undef gc
#define pb push_back
#define N 100010
#define M N
#define int ll
int v[M], u[M], nx[M];
int cnt, head[N];
il void add(int uu, int vv) {
	u[++cnt] = uu, v[cnt] = vv, nx[cnt] = head[uu];
	head[uu] = cnt;
}
int n, m, k;
double pos[N];
double de[N];
double ans[N];
int num[N], ys[N];
int cur;
int bel[N], rk[N];
vector<int>hv[N];
void dfs(int x, int k) {
	bel[x] = k;
	hv[k].pb(x);
	rk[x] = hv[k].size() - 1;
	for (ri i = head[x]; i; i = nx[i])
		if (!bel[v[i]]) dfs(v[i], k);
}
signed main() {
#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
#endif
	in(n);
	for (ri i = 1; i <= n; ++i) {
		scanf("%lf", &pos[i]);
		de[i] = pos[i] - pos[i - 1];
		num[i] = i;
	}
	in(m), in(k);
	for (ri i = 1, t; i <= m; ++i) {
		in(t);
		swap(num[t], num[t + 1]);
	}
	for (ri i = 1; i <= n; ++i) ys[num[i]] = i;
	for (ri i = 1; i <= n; ++i)
		add(i, ys[i]);
	for (ri i = 1; i <= n; ++i)
		if (!bel[i]) {
			++cur;
			dfs(i, cur);
		}
	for (ri i = 1, t; i <= n; ++i) {
		t = hv[bel[i]][(rk[i] + k) % hv[bel[i]].size()];
		ans[t] = de[i];
	}
	double tmp = 0.0;
	for (ri i = 1; i <= n; ++i) {
		tmp += ans[i];
		printf("%.9f\n", tmp);
	}
	return 0;
}

Measured memory_bytes: 16256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
template <typename T>
inline void read(T &x) {
	x = 0;
	char ch = 0;
	bool sign = false;
	while (ch < '0' || '9' < ch) sign |= ch == '-', ch = getchar();
	while ('0' <= ch && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	x = sign ? -x : x;
}
template <typename T>
inline void print(T x) {
	static char outp[64];
	if (!x) { putchar('0'); return; }
	if (x < 0) putchar('-'), x = -x;
	int tot = 0;
	while (x) outp[tot++] = x % 10 + '0', x /= 10;
	while (tot) putchar(outp[--tot]);
}
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef unsigned long long ull;
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rt register int
#define all(it) it.begin(), it.end()
#define rep(it, f, e) for (rt it = f; it <= e; ++it)
#define per(it, f, e) for (rt it = f; it >= e; --it)
const int MAXN = 1e3 + 10;
const int MAXW = 1e4 + 10;
struct Node {
	int w, s, v;
}	ob[MAXN];
inline bool cmp(Node a, Node b) {
	return a.w + a.s < b.w + b.s;
}
ll dp[MAXN][MAXW << 1];
#define max(a, b) (a > b ? a : b)
int main() {
	int n, m = 0;
	read(n);
	rep (i, 1, n) {
		read(ob[i].w);
		read(ob[i].s);
		read(ob[i].v);
		m = max(m, ob[i].s);
	}
	m <<= 1;
	sort(ob + 1, ob + n + 1, cmp);
	ll ans = 0 ;
	rep (i, 1, n) {
		rep (j, 1, m) {
			dp[i][j] = dp[i - 1][j];
			if (ob[i].s >= j - ob[i].w && j >= ob[i].w) {
				dp[i][j] = max(dp[i][j], dp[i - 1][j - ob[i].w] + ob[i].v);
			}
			ans = max(ans, dp[i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 157952
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>

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

    std::vector<std::tuple<int, int, char, long, std::string>> items(n);
    for (int i = 0; i < n; i++) {
        int v, w;
        char t;
        long d;
        std::string s;
        std::cin >> v >> w >> t >> d >> s;
        items[i] = std::make_tuple(v, w, t, d, s);
    }

    std::sort(items.begin(), items.end());

    for (auto it = items.begin(); it < items.end(); it++) {
        auto item = *it;
        int v = std::get<0>(item);
        int w = std::get<1>(item);
        char t = std::get<2>(item);
        long d = std::get<3>(item);
        std::string s = std::get<4>(item);
        std::cout << v << " " << w << " " << t << " " << d << " " << s << std::endl;
    }
}



Measured memory_bytes: 12132
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <cstring>

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

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    int L = inputValue();
    int R = inputValue();

    int ans = 2019;
    int LD = L / 2019;
    int RD = R / 2019;
    int LM = L % 2019;
    int RM = R % 2019;
    
    if(LD != RD){
      ans = 0;
    }else{
      repd(i,LM,RM){
        repd(j,i+1,RM+1){
          int val = i * j % 2019;
          ans = min(val,ans);
        }
      }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
from functools import reduce

# 入力
N = int(input())
p = list(map(int, input().split()))

# 先頭から順にスワップする
ans = sum(
    reduce(
        lambda acc, q:
            (
                acc[0] + acc[1],
                (not acc[1]) and q
            ),
        (i == P for i, P in enumerate(p, start=1)),
        (0, 0)
    )
)

# 出力
print(ans)


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

int main(){
   int a,b;
   cin >>a >> b;
   if(a-2*b>=0) cout << a-2*b;
   else cout << 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main ()
{
  int A, B;
  cin >> A >> B;
  
  if(A+B==3)
  {cout << 3;}
  else if(A+B==4)
  {cout << 2;}
  else if(A+B==5)
  {cout << 1;}
  
  return 0;
}

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

int N;

int main(void){
    
    cin >> N;
    
    vector<int> L(N + 1);
    vector<int> R(N + 1);
    for(int i = 0; i < N; ++i) cin >> L[i] >> R[i];
    
    sort(L.begin(), L.end());
    sort(R.begin(), R.end(), greater<int>());
    
    ll result = 0;
    for(int i = 0; i <= N; ++i){
        if(L[i] > R[i]) result += 2 * (L[i] - R[i]);
    }
    
    cout << result << endl;
    
    return 0;
}


Measured memory_bytes: 1276
import heapq

#dg = 10**7#ノード数より多く取る

n,m, S = map(int,input().split()) #n:頂点数　m:辺の数

edge = [[] for i in range(n)]
#edge[i] : iから出る道の[重み,行先]の配列


Cs=[]
Ds=[]
amax=0
for _ in range(m):
    u, v, a, b = map(int,input().split())
    edge[u-1].append([v-1,a,b])
    edge[v-1].append([u-1,a,b])#有向グラフの場合コメント
    amax=max(a,amax)

for _ in range(n):
    c, d = map(int,input().split())
    Cs.append(c)
    Ds.append(d)

dg=(n-1)*amax

def cut(S): 
    return min(S,dg)

S=cut(S)

def dijkstra(start):

    #dijkstra
    # d : minimum distance from s
    d = [[10**20]*(dg+1) for _ in range(n)]
    d[start][cut(S)] = 0
    edgelist = []

    heapq.heappush(edgelist,[Ds[0], 0, cut(S+Cs[0])])

    for e in edge[start]:
        if S-e[1]>=0:
            heapq.heappush(edgelist,[e[2],e[0],S-e[1]])

    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        t,ce,cs = minedge[0],minedge[1],minedge[2]
        #print(t,ce,cs)
        if  d[ce][cs]== 10**20:
            d[ce][cs] = t
            ns=cut(cs+Cs[ce])
            #print(ce,ns)
            if d[ce][ns]==10**20:
                #d[ce][ns]=t+Ds[ce]
                heapq.heappush(edgelist, [t+Ds[ce],ce,ns])

            for e in edge[ce]:
                if cs>=e[1]:
                    #print(e)
                    ne=e[0]
                    ns=cs-e[1]
                    if d[ne][ns]==10**20:
                        #print(ne)
                        heapq.heappush(edgelist, [t+e[2],ne,ns])
    return d

d=dijkstra(start=0)
for x in d[1:]:
    print(min(x))
#print(d)


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

int N, W;
int v, w;
pair<int, int> vw[110];
int Vic[110][10010];
int main()
{
	cin >> N >> W;
	rep(i, N)
	{
		cin >> v >> w;
		vw[i] = make_pair(v, w);
	}
	int ans;
	
	rep(c, W + 1)
	{
		rep(i, N)
		{
			if (i == 0 ) Vic[i][c] = (c / vw[i].second) * vw[0].first;
			else if (i >= 1 && c - vw[i].second < 0)	Vic[i][c] = Vic[i - 1][c];
			else Vic[i][c] = max(Vic[i][c - vw[i].second] + vw[i].first, Vic[i - 1][c]);
					//i番目の荷物を1個減らしたものはVicで表せる				
			
		}
	}
	ans = Vic[N - 1][W];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7012
import sys
import math
input = sys.stdin.readline

N,M = list(map(int,input().split()))
big = max(N,M)
small = min(N,M)
m=1000000007

if big == small:
    print(math.factorial(big)**2*2%m)
elif big == small + 1:
    print(math.factorial(big)*math.factorial(small)%m)
else:
    print(0)


Measured memory_bytes: 86268
#include<bits/stdc++.h>
using namespace std;
const int Maxn=100003;
int par[17][Maxn],root,depth[Maxn],n,T,dist[Maxn];
vector<int>G[Maxn];
vector<pair<int,int> >v[Maxn];
void dfs(int x,int p,int d){
	par[0][x]=p;
	depth[x]=d;
	for(int i=0;i<G[x].size();i++)
		if(G[x][i]!=p)
			dfs(G[x][i],x,d+1);
}
void init(){
	dfs(root,-1,0);
	for(int k=0;k<16;k++)
		for(int x=0;x<n;x++)
			if(par[k][x]<0)
				par[k+1][x]=-1;
			else
				par[k+1][x]=par[k][par[k][x]];
}
int lca(int x,int y){
	if(depth[x]>depth[y])swap(x,y);
	for(int k=0;k<17;k++)
		if((depth[y]-depth[x])>>k&1)
			y=par[k][y];
	if(x==y)return x;
	for(int k=16;k>-1;k--)
		if(par[k][x]!=par[k][y])
			x=par[k][x],
			y=par[k][y];
	return par[0][x];
} 
void DFS(int x,int dis,int p){
	dist[x]=dis;
	for(int i=0;i<G[x].size();i++)
		if(p!=G[x][i])
			DFS(G[x][i],dis+v[x][i].second,x);
}
int cnt[Maxn],sum[Maxn],ans[Maxn];
vector<pair<int,pair<int,int> > >add[Maxn],era[Maxn];
void Findans(int x,int p){
	for(int i=0;i<add[x].size();i++){
		int pos=add[x][i].first,c=add[x][i].second.first,val=add[x][i].second.second;
		ans[pos]+=dist[x];ans[pos]-=sum[c];ans[pos]+=cnt[c]*val; 
	}
	for(int i=0;i<era[x].size();i++){
		int pos=era[x][i].first,c=era[x][i].second.first,val=era[x][i].second.second;
		ans[pos]-=2*dist[x];ans[pos]+=2*sum[c];ans[pos]-=2*cnt[c]*val; 
	}
	for(int i=0;i<G[x].size();i++)
		if(G[x][i]!=p)
		{
			cnt[v[x][i].first]++;
			sum[v[x][i].first]+=v[x][i].second; 
			Findans(G[x][i],x);
			cnt[v[x][i].first]--;
			sum[v[x][i].first]-=v[x][i].second; 
		}
}
int main(){
	scanf("%d%d",&n,&T);
	for(int i=1;i<n;i++){
		int a,b,c,d;scanf("%d%d%d%d",&a,&b,&c,&d);
		a--;b--;c--;G[a].push_back(b),v[a].push_back(make_pair(c,d));
		G[b].push_back(a),v[b].push_back(make_pair(c,d));
	} 
	DFS(0,0,-1);init();
	for(int i=0;i<T;i++){
		int x,y,u,v;
		scanf("%d%d%d%d",&x,&y,&u,&v);
		x--;u--;v--;
		int w=lca(u,v);
		add[u].push_back(make_pair(i,make_pair(x,y)));
		add[v].push_back(make_pair(i,make_pair(x,y)));
		if(w!=-1)era[w].push_back(make_pair(i,make_pair(x,y)));
	}
	Findans(0,-1);
	for(int i=0;i<T;i++)cout<<ans[i]<<'\n'; 
} 

Measured memory_bytes: 36664
import java.util.Arrays;
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
      int k = sc.nextInt();
      int x = sc.nextInt();
      if(k==0){
        System.out.println("No");
        System.exit(0);
      }
      if(500*k>=x){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
      
  }
}


Measured memory_bytes: 21844