akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int D;
  cin>>D;
  vector<int> c(26);
  for(int &i:c)
    cin>>i;
  vector<vector<int>> s(D,vector<int>(26));
  for(vector<int> &v:s)
    for(int &i:v)
      cin>>i;
  vector<int> t(D);
  vector<int> A(26,0);
  int mzint=0;
  for(int i=0;i<D;i++){
    int mzi=mzint,mzin=0,k;
    for(int j=0;j<26;j++)
      mzi-=(i+1-A[j])*c[j];
    for(int j=0;j<26;j++){
      int l=mzi+s[i][j]-(i+1-A[j])*c[j];
      if(l>mzin){
        k=j;
        mzin=l;
      }
    }
    A[k]=i+1;
    mzint=mzin;
    t[i]=k+1;
  }
  int M=1000000,ans=mzint;
  while(M--){
    vector<pair<int,int>> AAA={make_pair(rand()%D,rand()%26),make_pair(rand()%D,rand()%26)};
    vector<int> BBB={t[AAA[0].first],t[AAA[1].first]};
    int ans2=ans;
    for(int aaa=0;aaa<2;aaa++){
    int d=AAA[aaa].first,q=AAA[aaa].second;
    ans+=s[d][q]-s[d][t[d]-1];
    int mae=-1,ato=D;
    for(int i=d-1;i>=0;i--){
      if(t[i]==t[d]){
        mae=i;
        break;
      }
    }
    for(int i=d+1;i<D;i++){
      if(t[i]==t[d]){
        ato=i;
        break;
      }
    }
    ans-=(ato-d)*(d-mae)*c[t[d]-1];
    mae=-1,ato=D;
    for(int i=d;i>=0;i--){
      if(t[i]==q+1){
        mae=i;
        break;
      }
    }
    for(int i=d;i<D;i++){
      if(t[i]==q+1){
        ato=i;
        break;
      }
    }
    ans+=(ato-d)*(d-mae)*c[q];
    t[d]=q+1;
    }
    if(ans2>ans){
      ans=ans2;
      t[AAA[0].first]=BBB[0];
      t[AAA[1].first]=BBB[1];
    }
  }
  for(int i:t)
    cout<<i<<endl;
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int bingo[3][3];
bool flag[3][3];
int cnt[2][105];
int h, w;
int choco[1010][1010];
int s[11][11];

int main() {
	int n;
	cin >> n;
	int ans = n / 500 * 1000;
	int res = n % 500;
	ans += res / 5 * 5;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_c
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}
int main() {
  constexpr double e = std::numeric_limits<double>::epsilon();
#if LOCAL&01
  std::ifstream in("./test/sample-1.in");
  //std::ifstream in("./input.txt");
  std::cin.rdbuf(in.rdbuf());
#else
  cin.tie(0);
  ios::sync_with_stdio(false);
#endif
  ll a,b,c; cin>>a>>b>>c;
  ll tmp=a+b-c;
  long double ld=(long double)tmp+2*sqrtl(a*b); 
  dump(tmp,ld);
  if(ld<0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, t; cin >> n >> t;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	int mx = a[n - 1], bg = 0;
	for(int i = n - 2; i >= 0; i--){
		bg = max(bg, max(mx - a[i], 0));
		mx = max(mx, a[i]);
	}
	mx = a[n - 1];
	int cnt = 0;
	for(int i = n - 2; i >= 0; i--){
		if(mx == a[i] + bg) cnt++;
		mx = max(mx, a[i]);
	}
	cout << cnt << endl;
	return 0;
}


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

int main(){
    //入力
    string S_a,S_b,S_c;
    cin >> S_a;
    cin >> S_b;
    cin >> S_c;

    //処理
    int num_a=0;
    int num_b=0;
    int num_c=0;
    char card=S_a.at(0);
    num_a++;

    while(true){
        if(card=='a'){
            if(num_a==S_a.size()){
                cout << 'A' << endl;
                break;
            }else{
                card=S_a.at(num_a);
                num_a++;
            }
        }else if(card=='b'){
            if(num_b==S_b.size()){
                cout << 'B' << endl;
                break;
            }else{
                card=S_b.at(num_b);
                num_b++;
            }
        }else{
            if(num_c==S_c.size()){
                cout << 'C' << endl;
                break;
            }else{
                card=S_c.at(num_c);
                num_c++;
            }
        }
    }   
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split(" ")))
a = sorted(a)[::-1]

if n % 2:
  ans = a[0] + 2 * sum(a[1:(n//2)]) + a[n//2]
else:
  ans = a[0] + 2 * sum(a[1:(n//2)])

print(ans)

Measured memory_bytes: 31552
#include<stdio.h>

int main(){
    int n,x;
    scanf("%d",&n);

    for(int i = 1; i <= n;i++){
        x = i;
        if(i%3 == 0)printf(" %d",i);
        else{
            while(x != 0){
                if(x%10 == 3){
                    printf(" %d",i);
                    break;
                }
                else x /= 10;
            }
        }
    }
    printf("\n");    
    return 0;
}



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

typedef long long ll;
int N;
ll res[2010];
ll dp[2010][2010];



int main()
{
    cin >> N;
    vector<pair<ll, int>> a(N);
    for(int i = 0; i < N; i++)
    {   
        ll A;
        cin >> A;
        a[i] = make_pair(A, i);
    }
    sort(a.begin(),a.end(), [](pair<ll, int> l, pair<ll, int> r){ return l.first > r.first;});
    memset(dp, 0, sizeof(dp));

    for(int i = 0; i < N; i++)
    {   
        for(int j = 0; j <= i; j++)
        {
            ll x = a[i].first * (a[i].second - j);
            ll y = a[i].first * (N - 1 - (i - j) - a[i].second);
            dp[j + 1][i - j] = max(dp[j + 1][i - j], dp[j][i - j] + x);
            dp[j][i - j + 1] = max(dp[j][i - j + 1], dp[j][i - j] + y);
        }
    }
    ll res = 0;
    for(int i = 0; i <= N; i++)
    {
        res = max(res, dp[N - i][i]);
    }
    cout << res << endl;
}

Measured memory_bytes: 35224
N,X=map(int,input().split())
L=sorted(map(int,input().split()),reverse=True)
mod=10**9+7

D=[[0]*(X+1) for i in range(N//2+2)]
D[1][L[0]]=1

for l in L[1:]:
    ND=[[0]*(X+1) for i in range(N//2+1)]

    for c in range(1,N//2+1):
        for s in range(X+1):
            if D[c][s]==0:
                continue
            
            k=D[c][s]

            if s+l+c<=X and c+1<=N//2:
                ND[c+1][s+l]=(ND[c+1][s+l]+k*(c+1))%mod
            ND[c][s]=(ND[c][s]+k*(s-c*(l-1)))%mod

            for i in range(1,min(X-s-c+2,l+1)):
                ND[c][s+i]=(ND[c][s+i]+k*2*c)%mod

            if c==1:
                continue

            for i in range(1,min(X-s-c+3,l+1)):
                ND[c-1][s+i]=(ND[c-1][s+i]+k*(c-1)*(l-i+1))%mod
    D=ND

print(D[1][X])

Measured memory_bytes: 63784
package main

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

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

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

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

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

func main() {
	defer stdout.Flush()
	N := readInt()
	A := make([]int, N)
	for i := range A {
		A[i] = readInt()
	}
	fa := factors(A[0])
	fb := factors(A[1])
	m := make(map[int]bool)
	for _, v := range fa {
		m[v] = true
	}
	for _, v := range fb {
		m[v] = true
	}
	fs := make([]int, 0, len(m))
	for v := range m {
		fs = append(fs, v)
	}
	sort.Sort(sort.Reverse(sort.IntSlice(fs)))

	for i := range fs {
		var count int
		for _, v := range A {
			if v%fs[i] == 0 {
				count++
			}
		}
		if N-1 <= count {
			println(fs[i])
			return
		}
	}
}

func maxfactor(A []int, fs []int) int {
	var res int
	for _, f := range fs {
		ok := true
		for i := 2; i < len(A); i++ {
			if A[i]%f != 0 {
				ok = false
				break
			}
		}
		if ok && res < f {
			res = f
		}
	}
	return res
}

func factors(x int) []int {
	res := make([]int, 0)
	for i := 1; i*i <= x; i++ {
		if x%i != 0 {
			continue
		}
		d := x / i
		res = append(res, i, d)
	}
	return res
}

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


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  string s,t;
  cin>>s>>t;
  int n=s.size();
  int m=t.size();
  vector<vecint> dp(n+1, vecint(m+1, 0));
  for(auto&& i:irange(0,n)) {
    for(auto&& j:irange(0,m)) {
      if (s[i] == t[j]) {
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1);
      }
      dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1]);
      dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j]);
    }
  }
  vector<char> v;
  int i=n, j=m;
  while(i && j) {
    if (s[i-1] == t[j-1]) {
      v.push_back(s[i-1]);
      --i;
      --j;
    } else {
      if (dp[i][j-1] >= dp[i-1][j]) {
        --j;
      } else {
        --i;
      }
    }
  }
  boost::reverse(v);
  for(auto&& c:v) cout<<c;
  cout<<endl;
  return 0;
}


Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
ll f(ll x){
    if(!x){
        return 0;
    }
    if(x%4==0){
        return x;
    }else if(x%4==1){
        return 1;
    }else if(x%4==2){
        return x^1;
    }else{
        return 0;
    }
}
int main(){
    ll a,b;
    cin>>a>>b;
    cout<<(f(b)^f(a-1))<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << '\n';}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}

const ll inf = 1e18 + 1;
const ll mod = 1e9 + 7;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

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

	
		int n, m;
		cin>>n>>m;
		ll s[m], c[m];
		vector<ll> v(n, 10);
		ll flag=0;
		for(int i=0;i<m;i++){
			cin>>s[i]>>c[i];
			if(v[s[i]-1]==10){
        	    v[s[i]-1]=c[i];
	        }
	        else if(v[s[i]-1]!=c[i]){
		        cout<<-1<<"\n";
		        return 0;
		     }
		}	
		if(v[0]==10){
	        if(n==1) v[0]=0;
	        if(n!=1) v[0]=1;
	    }
	    if(v[0]==0 && n!=1) 
	    {
	        cout<<-1<<"\n";
	        return 0;
	    }
		for(int j=0;j<n;j++){
			if(v[j]==10) cout<<0;
			else cout<<v[j];
		}
		cout<<"\n";
	
	return 0;
}


Measured memory_bytes: 256
using System;

namespace abc102_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int index = int.Parse(Console.ReadLine());
            if (index % 2 == 0)
            {
                Console.WriteLine(index);
            }
            else
            {
                Console.WriteLine(index * 2);
            }
        }
    }
}


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

#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define f(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pc __builtin_popcount // counts number of 1's in bin(num)

const double pi = 2*acos(0.0);
//__gcd(n1, n2);
//cout << fixed;
//cout << setprecision(6); //fixes # of dp



int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
    cout.tie(0);
	
    int n;
    cin >> n;
    int x[n];
    unordered_set<int> sett;
    f(i, 0, n){
        cin >> x[i];
        sett.insert(x[i]);
    }
    if(sett.size()!=n){
        cout << "NO";
    } else{
        cout << "YES";
    }
}   








Measured memory_bytes: 9288
def solve():
    n, k = map(int, input().split())
    s = list(map(int, input().split()))

    def is_ok(x):
        res = 0
        for ss in s:
            y = ss // x
            if ss % x == 0:
                y -= 1
            res += y
        return res

    ng = 0
    ok = 10 ** 10
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if is_ok(mid) <= k:
            ok = mid
        else:
            ng = mid

    print(ok)


solve()


Measured memory_bytes: 30728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N;
    cin >> N;
    vector<int> T(N);
    REP(i,N)cin >> T[i];
    int M;
    cin >> M;
    vector<pair<ll,ll>> P(M);
    REP(i,M){
        cin >> P[i].F >> P[i].S;
        P[i].F--;
    }
    ll sum = 0;
    REP(i,N){
        sum += T[i];
    }
    REP(i,M){
        cout << sum - T[P[i].F] + P[i].S << "\n";
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int[] A = new int[N - 1];
		int[] ans = new int[N];
		for(int i = 0; i < N - 1; i ++) {
			A[i] = stdIn.nextInt();
		}
		for(int i = 0; i < N; i ++) {
			ans[i] = 0;
		}
		for(int i = 0; i < A.length; i ++) {
			ans[A[i] - 1] ++;
		}
		
		for(int i = 0; i < ans.length; i ++) {
			System.out.println(ans[i]);
		}
	}
}

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

mx = 9
L = [0] * N
for i in range(N):
  x, y = xy[i]
  L[i] = x + y
  mx = max(mx, x)

L.sort()
ans = L[-1] - L[0]

for i in range(N):
  x, y = xy[i]
  L[i] = mx - x + y

L.sort()
ans = max(ans, L[-1] - L[0])

print(ans)

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> grid(H, vector<char>(W));
    for(int i = 0; i < H; i++) {
        string line;
        cin >> line;
        for(int j = 0; j < W; j++) {
            grid.at(i).at(j) = line.at(j);
        }
    }
    for(int h = grid.size() - 1; h >= 0; h--) {
        bool all_white = true;
        for(char c : grid.at(h)) {
            if(c != '.') {
                all_white = false;
                break;
            }
        }
        if(all_white) {
            grid.erase(grid.begin() + h);
        }
    }
    for(int w = grid.at(0).size() - 1; w >= 0; w--) {
        bool all_white = true;
        for(int h = 0; h < grid.size(); h++) {
            if(grid.at(h).at(w) != '.') {
                all_white = false;
            }
        }
        if(all_white) {
            for(int h=0; h<grid.size(); h++){
                vector<char> line = grid.at(h);
                line.erase(line.begin() + w);
                grid.at(h) = line;
            }
        }
    }

    for(vector<char> line : grid) {
        for(char c : line) {
            cout << c;
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
read a500
read b100
read c50
read yen
a=0
while [[ $a -le $a500 ]]; do
    b=0
    while [[ $b -le $b100 ]]; do
        c=0
        while [[ $c -le $c50 ]]; do
            [[ $(( $a * 500 + $b * 100 + $c * 50 )) -eq $yen ]] && echo $a $b $c
            c=$(( $c + 1 ))
        done
        b=$(( $b + 1 ))
    done
    a=$(( $a + 1 ))
done | sort -u | wc -l

Measured memory_bytes: 848
num_test = int(input())

difficulties = [int(s) for s in input().split(' ')]

difficulties.sort()

center = num_test // 2
must_abc = difficulties[center-1]
must_arc = difficulties[center]

if must_abc == must_arc:
    print("0")
    exit(0)

print(must_arc - must_abc)
exit(0)


Measured memory_bytes: 14428
#include<stdio.h>

int main(void)
{
  int a,b,c;
  scanf("%d %d %d", &a, &b, &c);
  if(a>b){
    if(a>c){
      printf("%d\n", a*10 + b + c);
    }else if(c>b){
      printf("%d\n", a + b + c*10);
    }
  }else{
    if(b>c){
      printf("%d\n", a + b*10 + c);
    }else{
      printf("%d\n", a + b + c*10);
    }
  }
  
  return 0;
}

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
#define mem(a,b) memset(a,b,sizeof(a))
#define shutdown ios::sync_with_stdio(false)
#define MAX 1e18+1000//1*10^18
#define INF 0x3f3f3f3f

int main()
{
    shutdown;
    LL n;
    cin>>n;
    LL a,b,c;
    for(a=1;a<=3500;a++){
        for(b=1;b<=3500;b++){
            if(4*a*b-a*n-b*n==0)
                continue;
            LL temp=a*b*n/(4*a*b-a*n-b*n);
            if(temp*(4*a*b-a*n-b*n)==a*b*n){
                if(temp<=3500&&temp>0){
                    cout<<a<<" "<<b<<" "<<temp<<endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
n, k, s = map(int, input().split())

if s==1 or s==2:
    for i in range(1, n+1):
        if i <= k:
            print('{}'.format(s), end=' ')
        else:
            print('{}'.format(s+10), end=' ')
    exit()

for i in range(1, n+1):
    if i <= k:
        print('{}'.format(s), end=' ')
    else:
        print('{}'.format(s-1), end=' ')

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

using ll = long long;
template<class T>
using V = vector<T>;

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

int main(){
    int H, W, M;
    cin >> H >> W >> M;
    V<int> h(M), w(M);
    rep(i, M){
        cin >> h.at(i);
        h.at(i)--;
        cin >> w.at(i);
        w.at(i)--;
    }
    V<int> cntH(H, 0), cntW(W, 0);
    rep(i, M){
        cntH.at(h.at(i))++;
        cntW.at(w.at(i))++;
    }
    int maxH = 0, maxW = 0;
    rep(i, H){
        if(cntH.at(i) > maxH) maxH = cntH.at(i);
    }
    rep(i, W){
        if(cntW.at(i) > maxW) maxW = cntW.at(i);
    }
    int max = maxH + maxW;
    set<int> setH, setW;
    rep(i, H){
        if(cntH.at(i) == maxH) setH.insert(i);
    }
    rep(i, W){
        if(cntW.at(i) == maxW) setW.insert(i);
    }
    ll cross = setH.size() * setW.size();
    if(cross <= M){
        int max_count = 0;
        rep(i, M){
            if(setH.find(h.at(i)) != setH.end() && setW.find(w.at(i)) != setW.end()) max_count++;
        }
        if(max_count == cross) max--;
    }
    cout << max << endl;
}

Measured memory_bytes: 35908
#include<stdio.h>
#define N 100000
 

typedef struct Card{
  char mark;
  int num;
  int index;
}Card;
 
int Partition( Card A[], int p, int r ){
  int x;
  int i,j;
  Card c;
  x = A[r].num;
  i = p - 1;
  for( j = p; j < r; j++ ){
    if( A[j].num <= x){
      i++;
      c = A[i];
      A[i] = A[j];
      A[j] = c;
    }
  }
  c = A[i+1];
  A[i+1] = A[r];
  A[r] = c;
 
  return i+1;
}
 
void QuickSort( Card A[], int p, int r ){
  int q;
  if( p < r ){
    q = Partition( A, p, r );
    QuickSort( A, p, q-1 );
    QuickSort( A, q+1, r );
  }
}
 
int isStable( Card A[], int n ){
  int i;
  for( i = 1; i < n; i++ ){
    if( A[i-1].num == A[i].num ){
      if( A[i-1].index > A[i].index ){
	return 0;
      }
    }
  }
  return 1;
}
 
int main(){
  int n, i;
  Card A[N];
 
  scanf("%d", &n);
  for( i = 0; i < n; i++ ){
    scanf(" %c %d", &A[i].mark, &A[i].num);
    A[i].index = i;
  }
 
  QuickSort( A, 0, n-1 );
 
  if( isStable(A, n) == 1 ){
    printf("Stable\n");
  }
  else{
    printf("Not stable\n");
  }
 
  for( i = 0; i < n; i++ ){
    printf("%c %d\n", A[i].mark, A[i].num);
  }
  return 0;
}

Measured memory_bytes: 1776
<?php
  $tmp = explode(" ",trim(fgets(STDIN)));
  $n = $tmp[0];
  $k = $tmp[1];
  $q = $tmp[2];
/*
  $points = [];
  for($i=0; $i<$n; $i++){
    $points[$i+1] = $k;
  }
*/
  if($k>$q){
    //全員Yes
    for($i=0; $i<$n; $i++){
      echo "Yes\n";
    }
    exit;
  }

  $points = [];
  for($i=0; $i<$n; $i++){
    $points[$i+1] = $k-$q;
  }

  for($i=0; $i<$q; $i++){
    $num = intval(fgets(STDIN));
    $points[$num]++;
  }

  for($i=0; $i<$n; $i++){
    echo $points[$i+1]>0 ? "Yes\n" : "No\n";
  }

  
  ?>

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
#define MAX_N 100000

struct UnionFind{
  vll tree;
  vll rank;
  vll size;

  UnionFind(ll n = 1){
    init(n);
  }

  void init(ll n){
    tree.resize(n);
    rank.resize(n);
    size.resize(n);
    REP(i, n){
      tree[i] = i;
      rank[i] = 0;
      size[i] = 1;
    }
  }

  ll root(ll i){
    if(tree[i] == i)
      return i;
    else{
      tree[i] = root(tree[i]);
      return tree[i];
    }
  }

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

  ll len(ll a){
    return size[root(a)];
  }

  bool merge(ll ga, ll gb){
    ll x = root(ga);
    ll y = root(gb);
    if(x == y)
      return false;

    if(rank[x] < rank[y])
      swap(x, y);
    if(rank[x] == rank[y])
      rank[x]++;
    size[x] += size[y];
    tree[y] = x;
    return true;
  }
};

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

  ll n, m;
  cin >> n >> m;

  vll a(m), b(m);
  REP(i, m){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }

  vll ans(m, 0);
  ans[m-1] = n*(n-1)/2;

  UnionFind uf(n);
  REP(i, m-1){
    ll x = a[m-1-i];
    ll y = b[m-1-i];
    if(uf.same(x, y))
      ans[m-2-i] = ans[m-1-i];
    else
      ans[m-2-i] = ans[m-1-i] - uf.len(x)*uf.len(y);

    uf.merge(x, y);
  }

  REP(i, m)
    cout << ans[i] << endl;
  
}


Measured memory_bytes: 6016
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 5121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
long long tmp[5110000];

int main(){
	int a;scanf("%d",&a);
	long long ret=pw(3,a);
	init_C(a/2+2);
	for(int i=0;i<=a/2;i++){
		tmp[i]=Comb(a/2,i)*pw(2,a/2-i)%mod;
		// printf("%d: %lld\n",i,tmp[i]);
	}
	long long ks=0;
	long long cur=0;
	int at=a/2;
	for(int i=1;i<=a/2;i++){
		cur=(cur+tmp[a/2-i+1])%mod;
		ks=(ks+cur*tmp[i])%mod;
	}

	ret=(ret+mod-ks*2%mod)%mod;
	
	printf("%lld\n",ret);
}

Measured memory_bytes: 159872
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>

using namespace std;

long long N;
long long A[100000], B[100000];
long long to_fix;
long long ans;
long long diff[100000];

int main(void) {
	scanf("%lld", &N);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &A[i]);
	}
	for (int i = 0; i < N; i++) {
		scanf("%lld", &B[i]);
	}

	ans = 0;

	/*A_i < B_iとなってる分差の和を計算*/
	to_fix = 0;
	for (int i = 0; i < N; i++) {
		if (A[i] < B[i]) {
			to_fix += B[i] - A[i];
			ans++;
		}
	}

	/*A_i > B_iとなってる分を取得*/
	for (int i = 0; i < N; i++) {
		diff[i] = A[i] - B[i];
	}
	sort(diff, diff + N, greater<long long>());
	
	if (to_fix == 0) {
		printf("0\n");
		return 0;
	}
	for (int i = 0; i < N; i++) {
		if (diff[i] <= 0) {
			printf("-1\n");
			return 0;
		}
		to_fix -= diff[i];
		if (to_fix <= 0) {
			ans += i + 1;
			break;
		}
	}
	if (to_fix > 0) {
		printf("-1\n");
		return 0;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
int main()
{
	int n;
	int i;
	scanf("%d",&n);
	int a[101];
	int sum = 0;
	for(i = 0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum += a[i];
	}
	int m,j;
	int x;
	int y,number;
	scanf("%d",&m);
	int t;
	for(j = 0;j<m;j++)
	{
		t = sum;
		scanf("%d%d",&x,&y);
		t -= a[x-1];
		t += y;
		printf("%d\n",t);
	}
	return 0 ;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		Integer N = Integer.parseInt(in.nextLine());
		in.close();
		if (N <= 111) {
			System.out.println("111");
		} else if (N <= 222) {
			System.out.println("222");
		} else if (N <= 333) {
			System.out.println("333");
		} else if (N <= 444) {
			System.out.println("444");
		} else if (N <= 555) {
			System.out.println("555");
		} else if (N <= 666) {
			System.out.println("666");
		} else if (N <= 777) {
			System.out.println("777");
		} else if (N <= 888) {
			System.out.println("888");
		} else {
			System.out.println("999");
		}
	}
}

Measured memory_bytes: 23124
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>

using namespace std;

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long


int main(){
    int n; cin >> n;
    vector<long> v, w;
    rep(i, n){
        long x; cin >> x; v.push_back(x);
    }
    w.resize(v.size()); copy(all(v), w.begin());
    sort(all(v));
    
    int l = v[n/2-1], r = v[n/2];
    rep(i, n){
        if(w[i] <= l) cout << r << endl;
        else cout << l << endl;
    }
}


Measured memory_bytes: 5488
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using vi = vector<int>;
using vl = vector<int64_t>;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64_t INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

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

  int r; cin >> r;
  cout << 3 * r * r << '\n';

  return 0;
}

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

int main() {
	int n,a[25],o;
	while (cin >> n, n) {
		o = 32;
		for (int i = 0; i < 25; i++) a[i] = 0;
		for (int i = 0; i < n; i++) cin >> a[i];
		for (int i = 0; o; i++) {
			o -= (o - 1) % 5;
			cout << o << endl;
			o -= a[i % n];
			if (o < 0) o = 0;
			cout << o << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void){
  
 unsigned long long x;
 scanf("%lld",&x);
 unsigned long long s = 100;
 int count = 0;
  
  while(s < x){
   unsigned long long temp = s;
    s = temp*1.01;
    count ++;
  }
  
  printf("%d",count);
  
  return 0;
}

Measured memory_bytes: 1736
;;; Utils (quoted from https://competitive12.blogspot.com/2020/03/common-lisp.html)


;; Read fixnum

(declaim (ftype (function * (values fixnum &optional)) read-fixnum))
(defun read-fixnum (&optional (in *standard-input*))
  (declare (inline read-byte)
           #-swank (sb-kernel:ansi-stream in))
  (macrolet ((%read-byte ()
               `(the (unsigned-byte 8)
                     #+swank (char-code (read-char in nil #\Nul))
                     #-swank (read-byte in nil 0))))
    (let* ((minus nil)
           (result (loop (let ((byte (%read-byte)))
                           (cond ((<= 48 byte 57)
                                  (return (- byte 48)))
                                 ((zerop byte) ; #\Nul
                                  (error "Read EOF or #\Nul."))
                                 ((= byte #.(char-code #\-))
                                  (setq minus t)))))))
      (declare ((integer 0 #.most-positive-fixnum) result))
      (loop
        (let* ((byte (%read-byte)))
          (if (<= 48 byte 57)
              (setq result (+ (- byte 48) (the (integer 0 #.(floor most-positive-fixnum 10)) (* result 10))))
              (return (if minus (- result) result))))))))

;; fast read-line

(defmacro buffered-read-line (&optional (buffer-size 30) (in '*standard-input*) (term-char #\Space))
  (let ((buffer (gensym))
        (character (gensym))
        (idx (gensym)))
    `(let* ((,buffer (load-time-value (make-string ,buffer-size :element-type 'base-char))))
       (declare (simple-base-string ,buffer)
                (inline read-byte))
       (loop for ,character of-type base-char =
             ,(if (member :swank *features*)
                  `(read-char ,in nil #\Newline) ; on SLIME
                `(code-char (read-byte ,in nil #.(char-code #\Newline))))
             for ,idx from 0
             until (char= ,character #\Newline)
             do (setf (schar ,buffer ,idx) ,character)
             finally (when (< ,idx ,buffer-size)
                       (setf (schar ,buffer ,idx) ,term-char))
             (return (values ,buffer ,idx))))))


;;; invoke child process

#-swank
(unless (member :child-sbcl *features*)
  (quit
    :unix-status
    (process-exit-code
      (run-program *runtime-pathname*
                   `("--control-stack-size" "128MB"
                     "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                     "--eval" "(push :child-sbcl *features*)"
                     "--script" ,(namestring *load-pathname*))
                                                                 :output t :error t :input t))))



;-------------------
; Write code here
;-------------------



(defun solve (n periods)
  (reduce #'lcm periods))


(defun main ()
  (let ((n (read))
        periods)
    (dotimes (i n)
      (push (read) periods))
    (princ (solve n periods))
    (fresh-line)))

(main)


Measured memory_bytes: 25664
#include <iostream>
#include <string>

int main()
{
	int N = 0, ans = 0;
	std::string S;

	std::cin >> N >> S;

	
	for (int i = N - 1; i > 1; i--)
	{
		std::string C(S, i -2, 3);
		if (C == "ABC") ans++;
	}
	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};



int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int h,w;
	cin>>h>>w;
	vs a(h);
	for(auto &i:a) cin>>i;
	queue<pip> q;
	vvi b(h,vi(w,inf));
	for(int i=0;i<h;i++) for(int j=0;j<w;j++){
		if(a[i][j]=='%'){
			q.push({0,{i,j}});
			b[i][j]=0;
		}
	}
	while(!q.empty()){
		pip p=q.front();q.pop();
		int x=p.second.first,y=p.second.second;
		for(int i=0;i<4;i++){
			int cx=x+dx[i],cy=y+dy[i];
			if(cx>=0&&cx<h&&cy>=0&&cy<w&&a[cx][cy]!='#'&&b[cx][cy]==inf){
				q.push({p.first+1,{cx,cy}});
				b[cx][cy]=p.first+1;
			}
		}
	}
	int mn=inf,dis;
	for(int i=0;i<h;i++) for(int j=0;j<w;j++){
		if(a[i][j]=='@') dis=b[i][j];
		if(a[i][j]=='$') mn=min(mn,b[i][j]);
	}
	cout<<(dis<mn?"Yes":"No")<<endl;
}


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

class Main{

	int a;
	int b;

	public Main(){
		Scanner scan = new Scanner(System.in);
		a = scan.nextInt();
		b = scan.nextInt();

		int x = a / b;
		int y = a % b;
		double z = (double)a / (double)b;

		System.out.printf("%d %d %.5f", x, y, z);
	}
	public static void main(String[] args){
		new Main();
	}
}

Measured memory_bytes: 26304
#include <iostream>
#include <math.h>

using namespace std;

int main(){
  string a, b, c;
  cin >> a >> b;
  c = a + b;
  int tmp;
  tmp = (int)sqrt((double)stoi(c));
  if (tmp*tmp == stoi(c)) cout << "Yes" << endl;
  else cout << "No" << 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, ll> pll;

const int MAXN = 100;
const int MAXV = 1e5;
const ll INF = 1e18;

int N, W, C[MAXN+10], V[MAXN+10];
ll dp[MAXN+10][MAXV+10];

int main()
{
    int i, j;

    scanf("%d%d", &N, &W);
    for(i=1; i<=N; i++) scanf("%d%d", &C[i], &V[i]);
    for(j=1; j<=MAXV; j++) dp[0][j]=INF;
    for(i=1; i<=N; i++)
    {
        for(j=0; j<=MAXV; j++)
        {
            dp[i][j]=dp[i-1][j];
            if(j>=V[i]) dp[i][j]=min(dp[i][j], dp[i-1][j-V[i]]+C[i]);
        }
    }
    for(j=MAXV; j>=0; j--) if(dp[N][j]<=W) return !printf("%d", j);
}


Measured memory_bytes: 80128
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
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();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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


#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;



int main(){
 
    LL N;
    cin>>N;
    vector<LL> A(N),B(N),C(N);
    REP(i,N){
        cin>>A[i];
    }
   
    REP(i,N){
        cin>>B[i];
    }
    REP(i,N){
        cin>>C[i];
    }
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());
    LL bmax=B[B.size()-1];
    LL cmax=B[C.size()-1];
    
    LL ans=0;

   REP(i,N){
       LL b=B[i];
       std::vector<LL>::iterator lowC=std::upper_bound (C.begin(), C.end(), b);
       std::vector<LL>::iterator upA=std::lower_bound (A.begin(), A.end(), b);
       LL lowernumC=C.end()-lowC;
       LL lowernumA=upA-A.begin();
    //    if(A[lowernumA]==b){lowernumA--;}
    //    if(C[lowernumC]==b){lowernumC++;}
       
       //cerr<<" num a:"<<lowernumA<<" num c:"<<(N-lowernumC)<<endl;
       ans+=(lowernumA)*(lowernumC);
       
   }

    cout<<ans<<endl;


}


Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace atcorder_BeginnerContest_117
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] line = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            long cnt = line[0];
            long maxVal = line[1];

            long[] valArr = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);

            int maxLen = 0;
            long valArrMax = valArr.Max();
            if (valArrMax < maxVal)
            {
                maxLen = Convert.ToString(maxVal, 2).ToString().Length;
            }
            else
            {
                maxLen = Convert.ToString(valArrMax, 2).ToString().Length;            
            }

            int[] digitCnt0 = new int[maxLen];
            int[] digitCnt1 = new int[maxLen]; 
            
            for (int i = 0; i < cnt; i++)
            {
                string bNumStr = Convert.ToString(valArr[i], 2).PadLeft(maxLen,'0');
                for (int j = 0; j < maxLen; j++)
                {
                    if ("0" == bNumStr.Substring(j, 1))
                    {
                        digitCnt0[j]++;
                    }
                    else
                    {
                        digitCnt1[j]++;                    
                    }
                }
            }

            string  multValStr= "";

            for (int i = 0; i < maxLen; i++)
            {
                string tmpRet = multValStr;
                bool zeroValFlg = true;
                if (digitCnt0[i] < digitCnt1[i])
                {
                    tmpRet += "0";
                }
                else
                {
                    tmpRet += "1";
                    zeroValFlg = false;
                }

                //最大値を超える場合は反転する
                if (maxVal < Convert.ToInt64(tmpRet.PadRight(maxLen, '0'), 2))
                {
                    if (zeroValFlg) multValStr += "1";
                    else multValStr += "0";
                }
                else
                {
                    multValStr = tmpRet;
                }
            }

            long multValLng = Convert.ToInt64(multValStr, 2);
            long ret = 0;
            for (int i = 0; i < cnt; i++)
            {
                ret += valArr[i] ^ multValLng;
            }

            Console.WriteLine(ret);

        }
      
    }
}


Measured memory_bytes: 29020
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fi first
#define se second
#define vi_a vector<int>a;
#define p_b push_back
#define ll long long
#define ull unsigned long long
#define ld long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define m_p make_pair
#define fast_io cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define all(x) x.begin(),x.end()
#define sqr(x) (x)*(x)
#define pw(x) (1ll << x)
#define sz(x) (int)x.size()
#define endl "\n"
using namespace std;
signed main()
{
    string a,b;
    ll f,s;
    cin>>a>>b>>f>>s;
    string u;
    cin>>u;
    if(u==a){
        f--;
    }
    else if(u==b){
        s--;
    }
    cout<<f<<" "<<s;
}


Measured memory_bytes: 256
<?php
function isPrime( $x, $primes )
{
    if( 2 == $x ) return true;
    if( 0 == $x%2 ) return false;
	if( isset( $primes[$x] ) ) return true;
    for( $i=3; $i*$i<=$x; $i++ ) {
        if( 0 == $x%$i ) { return false; }
    }
    return true;
}
	$n = trim( fgets( STDIN ) );
	$cnt = 0;
	$primes = [];
	while( $n-- ) {
		$num = trim( fgets( STDIN ) );
		if( isPrime( $num, $primes ) ) {
			$primes[$num]=true;
			$cnt++;
		}
	}
	print $cnt;
?>

Measured memory_bytes: 15432
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define INF (int)1e9+1
#define INFLL (int)1e18+1
#define sz(bb) (int)bb.size()
#define all(qq) qq.begin(), qq.end() 
#define Max(a, b, c) max(a, max(b, c))
#define Min(a, b, c) min(a, min(b, c))
const double PI=acos(-1);
// #define int unsigned long long int//used when x<2^64-1 && x>0
#define int long long//used when x<2^63-1
//bool cmp if returns true it keeps 1st as first else swaps
typedef long long  ll;

const int N=1000001;
void solve()
{
    char ch;
    cin>>ch;
    if(ch-'a'>=0)
        cout<<"a\n";
    else
        cout<<"A\n";
    
}
int32_t main()
{
    IOS;
    int t;
    // cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

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


int main(){
  string s;
  cin >> s;
  int a,b,n;
  n=s.size();
  a=(n-1)/2;
  b=(n+3)/2;

  int flag=0;

  for(int i=0;i<(n-1)/2;i++){
    if(s[i]!=s[n-1-i]){
      flag=1;
      break;
    }
  }

  if(flag==1){
    cout << "No" << endl;
    return 0;
  }
  
  for(int i=0;i<(n-1)/4;i++){
    if(s[i]!=s[a-i-1]){
      flag=1;
      break;
    }
  }

  if(flag==1){
    cout << "No" << endl;
    return 0;
  }

  for(int i=0;i<(n-1)/4;i++){
    if(s[i+b-1]!=s[a+b-i-2]){
      flag=1;
      break;
    }
  }

  if(flag==1){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }

}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n;
	scanf(" %d",&n);
	int nums[n];
	for(int i = 0; i < n;++i)
		scanf(" %d",&nums[i]);
	int min = 0;
	int pos = 1;
	for(int i = n-2; i >= 0;--i){
		if(nums[i+1] < nums[i])
			--nums[i];
	}
	for(int i = 0; i < n-1;++i){
		if(nums[i+1] < nums[i])
			pos = 0;
	}
	if(pos)
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 512