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

const int MAX_N = 1110;
int N, M;
ll x[MAX_N];
ll y[MAX_N];
ll z[MAX_N];
ll tot[MAX_N];

void solve()
{
	ll ans = 0;
	for(int i=0;i<8;++i){
		memset(tot, 0, sizeof(tot));
		for(int j=0;j<N;++j){
			if(i>>0&1) tot[j]+=x[j]; else tot[j]-=x[j];
			if(i>>1&1) tot[j]+=y[j]; else tot[j]-=y[j];
			if(i>>2&1) tot[j]+=z[j]; else tot[j]-=z[j];
		}
		sort(tot,tot+N,greater<>());
		ans=max(ans, accumulate(tot,tot+M,0LL));
	}
	cout << ans << '\n';
}

int main()
{
	cin >> N >> M;
	for(int i=0;i<N;++i){
		cin >> x[i] >> y[i] >> z[i];
	}
	solve();
	return 0;
}

Measured memory_bytes: 3596
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int main() {
    ll x;
    cin >> x;
    
    rep(a, 1000) {
        FOR(b, -1000, 1000) {
            if((a*a*a*a*a-b*b*b*b*b)==x) {
                cout << a << " " << b << endl; 
                return 0;
            }
        }
    }

    
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }


int main(){
    LL n;
    cin >> n;
    vector<LL> p(n);
    for(LL i = 0; i < n; ++i){
        cin >> p[i];
    }
    LL large = 0;
    vector<LL> seq_len(n+1, 0);
    for(LL i = 0; i < n; ++i){
        seq_len[p[i]] = seq_len[p[i]-1] + 1;
    }
    cout << n - *max_element(seq_len.begin(), seq_len.end()) << endl;
    return 0;
}



Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(){
    int N;
    long long K;
    cin >> N >> K;
    vector<long long> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    vector<long long> sum(N + 1, 0);
    for(int i = 0; i < N; i++){
        sum[i + 1] = (sum[i] + A[i]) % K;
    }
    for(int i = 0; i < N + 1; i++){
        sum[i] = (sum[i] - i % K + K) % K;
    }
    map<long long, long long> m;
    if(K > N){
        for(int i = 0; i < N + 1; i++){
            m[sum[i]]++;
        }
        long long ans = 0;
        for(auto v: m){
            ans += (v.second * (v.second - 1)) / 2;
        }
        cout << ans << endl;
        return 0;
    }
    long long ans = 0;
    for(int i = 0; i < K; i++){
        m[sum[i]]++;
    }
    for(auto v: m){
        ans += (v.second * (v.second - 1)) / 2;
    }
    for(int i = K; i < N + 1; i++){
        m[sum[i - K]]--;
        ans += m[sum[i]];
        m[sum[i]]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 18620
#include<bits/stdc++.h>
using namespace std;
#define N 200005
typedef long long ll;
ll n,a[N],X,num[N],ans,sum[N];
ll check(ll seg)
{
    ll B=n/seg,ans=n*X+X*seg;memset(sum,0,sizeof(sum));
    for(ll i=1;i<=B;i++){
        sum[i]+=seg;
    }sum[B+1]+=n%seg;
    ll tmp=n;
    for(ll i=1;i<=B+1;i++){
        while(sum[i])sum[i]--,ans+=num[i]*a[tmp--];
    }return ans;
}
int main()
{
    scanf("%lld%lld",&n,&X);ans=1000000000000000000;
    num[1]=5;for(ll i=2;i<=n+1;i++)num[i]=i*2+1;
    for(ll i=1;i<=n;i++)scanf("%lld",&a[i]);
    if(n<=0){
        for (ll i=1;i<=n;i++){
            ans=min(ans,check(i));
            // cout<<check(i)<<endl;
        }
        cout<<ans;
    }else{
        ll l=1,r=n;
        while(l<=r){
            ll mid1=l+(r-l+1)/3,mid2=l+2*(r-l+1)/3;
            ll tmp1=check(mid1),tmp2=check(mid2);
            if(tmp1<tmp2)r=mid2-1,ans=min(ans,tmp1);
            else l=mid1+1,ans=min(ans,tmp2);
        }cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 8292
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;

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

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

    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    
    vector<ll> l(n+1), r(n+1);
    rep(i, n) l[i+1] = gcd(l[i], a[i]);
    for (int i = n - 1; i >= 0; i--) r[i] = gcd(r[i+1], a[i]);

    ll ma = 0;
    rep(i, n) {
        ll v = gcd(l[i], r[i + 1]);
        ma = max(v, ma);
    }

    put(ma);
    return 0;
}

Measured memory_bytes: 5600
n = int(input())
k = int(input())
x = (list(map(int,input().split())))
xa = [2*x[j] for j in range(n)]
l = 0
xb = [2*abs(x[i]-k) for i in range(n)]

for k in range(n):
    if xa[k] >= xb[k]:
        l += xb[k]
    else:
        l += xa[k]

print(l)

Measured memory_bytes: 3064
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    ll n;cin>>n;
    string s;cin>>s;

    ll rcnt=0;
    rep(i,n)if(s[i]=='R')++rcnt;

    ll bcnt=n-rcnt;

    cout<<(rcnt>bcnt?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
s = gets.chomp
g = p = score = 0
s.chars.each do |c|
  if c == "p"
    if p < g
      p += 1
    else
      score -= 1
      g += 1
    end
  else
    if p < g
      score += 1
      p += 1
    else
      g += 1
    end
  end
end
p score


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

using namespace std;

int N;

int main()
{
	cin >> N;


	string ans = "hon";
	int n = N % 10;

	if (n == 3) {
		ans = "bon";
	}
	else if (n == 0 || n == 1 || n == 6 || n == 8) {
		ans = "pon";
	}






	cout << ans << endl;

	return 0;
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

char s[MAXN];

void solve(){
	int ans = 0;
	scanf("%s", &s[0]);
	for(int i = 1; s[i]; i++){
		if (s[i] != s[i - 1]){
			ans++;
		}
	}
	printf("%d\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 384
package main

import (
	"fmt"
	"strings"
)

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	cnt := 0

	for i := range make([]bool, h) {
		_ = i
		var a string
		fmt.Scan(&a)
		cnt += strings.Count(a, "#")
	}

	if cnt == h+w-1 {
		fmt.Println("Possible")
	} else {
		fmt.Println("Impossible")
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) int(a.size())
const int N=3e5+10;

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,a[4][N],c[N],flip[2];
ll inv[2];

void modify(int p,int v) {
	while(p<=3*n) c[p]+=v,p+=p&-p;
}

int query(int p) {
	int ret=0;
	while(p) ret+=c[p],p-=p&-p;
	return ret;
}

void No() {
	cout<<"No";exit(0);
}

int main() {
	cin>>n;
	for(int i=1;i<=3;i++)
		for(int j=1;j<=n;j++) {
			a[i][j]=gi();
			if(((i+j)&1)==(a[i][j]&1)) No();
			if((1<=a[i][j]%6&&a[i][j]%6<=3)!=(j&1)) No();
		}
	for(int i=1;i<=n;i++)
		if(a[2][i]%3!=2) No();
	for(int i=1;i<=n;i++) {
		if(a[1][i]<a[2][i]) {
			if(a[1][i]+1!=a[2][i]||a[2][i]+1!=a[3][i]) No();
		}
		else {
			if(a[3][i]+1!=a[2][i]||a[2][i]+1!=a[1][i]) No();
		}
	}
	for(int t=0;t<2;t++) {
		memset(c,0,sizeof(c));
		int cnt=0;ll inv=0;
		for(int i=n;i;i--)
			if((i&1)==t) {
				inv+=query(a[2][i]);modify(a[2][i],1);
				if(a[1][i]>a[2][i]) ++cnt;
			}
		::inv[t]=inv;flip[t]=cnt;
	}
	if((inv[0]&1)!=(flip[1]&1)) No();
	if((inv[1]&1)!=(flip[0]&1)) No();
	cout<<"Yes";
	return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = (A); I < int(B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    FOR(i,0,N) cin >> A[i];

    map<ll,ll> ma;
    FOR(i,0,N){
        ma[-A[i]]++;
    }
    vector<ll> two;
    ll t = 1;
    while(t<=4000000000LL){
        two.push_back(t);
        t *= 2LL;
    }

    int ans = 0;
    while(not ma.empty()){
        pair<ll,ll> x = *ma.begin();
        if(x.second==0){
            ma.erase(x.first);
            continue;
        }
        ma[x.first]--;
        ll ind2 = POSU(two,-x.first);
        if(ma[-two[ind2]-x.first]>0){
            ans++;
            ma[-two[ind2]-x.first]--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[120];
int main(){
    ll x,k,d;
    cin>>x>>k>>d;
    if(x<0)x=-x;
    ll t=x/d;
    if(t>k){
        cout<<x-d*k<<endl;
        return 0;
    }
    k-=t;
    x-=t*d;
    if(k&1)cout<<d-x;
    else cout<<x;
    return 0;
}


Measured memory_bytes: 3632
import sys

N, M = map(int, input().split(" "))
pen = [0 for i in range(N)]
ans = [False for i in range(N)]
num_pen = 0

for i in range(M):
    p, S = input().split(" ")
    if S == 'AC':
        if not ans[int(p) - 1]:
            num_pen += pen[int(p) - 1]
        ans[int(p) - 1] = True
    elif S == 'WA':
        pen[int(p) - 1] += 1
    else:
        sys.stderr('input error')
print(sum(ans), num_pen)


Measured memory_bytes: 4656
#include<stdio.h>

int main(){
  int N,M;
  scanf("%d%d",&N,&M);
  if(N%2==1){
    for(int i=1;i<=M;i++){
      printf("%d %d\n",i,N-i+1);
    };
  }
  else {
    int g,k;
    g=(M-1)/2+1;
    k=M/2;
    for(int i=1;i<=g;i++){     
      printf("%d %d\n",i,N-i+1);
    };   
    for(int y=g+1,i=k;i>=1;i--,y++){
      printf("%d %d\n",y,y+2*i);
    };
  };
};

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

typedef long long ll;

ll N;
typedef pair<ll, ll> Pair;
priority_queue<Pair> Asc, Desc;

bool solve() {
  ll cnt = 0;
  while (!Asc.empty()) {
    ll bot, diff;
    tie(bot, diff) = Asc.top();
    Asc.pop();
    if (bot + cnt < 0) return false;
    cnt += diff;
  }
  ll cnt2 = 0;
  while (!Desc.empty()) {
    ll bot, diff;
    tie(bot, diff) = Desc.top();
    Desc.pop();
    if (bot + cnt2 < 0) return false;
    cnt2 += diff;
  }
  return cnt == cnt2;
}
int main() {
  cin >> N;
  for (ll i = 0; i < N; ++i) {
    string s;
    cin >> s;
    ll cnt = 0, bot = 0;
    for (ll j = 0; j < s.size(); ++j) {
      if (s[j] == '(') {
        ++cnt;
      } else {
        --cnt;
        bot = min(bot, cnt);
      }
    }
    if (cnt > 0)
      Asc.push({bot, cnt});
    else
      Desc.push({bot - cnt, -cnt});
  }
  cout << (solve() ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 18856
def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

n = int(arr_data[0][0])
a = int(arr_data[0][1])
b = int(arr_data[0][2])

s = arr_data[1][0]
cnt = 0
cntb = 0

for v in s:
    
    chkflg = True
    
    if v == "c":
        
        chkflg = False
        
    elif v == "a":
                
        if cnt < a + b:
            
            cnt += 1
            
        else:
        
            chkflg = False
        
        
    elif v == "b":
        
        if cnt < a + b and cntb < b:
            
            cnt += 1
            cntb += 1
            
        else:
        
            chkflg = False
        
    print("Yes" if chkflg else "No")
        
    

Measured memory_bytes: 4016
use std::cmp;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let h: usize = sc.read();
    let w: usize = sc.read();
    let board: Vec<Vec<char>> = (0..h).map(|_| sc.chars()).collect();

    let mut ans = 0;
    for j in 1..w {
        let a = (0..h).map(|i| board[h - 1 - i][j - 1]).collect();
        let b = (0..h).map(|i| board[h - 1 - i][j]).collect();
        let cost = calc(&a, &b);
        ans += cost;
    }
    println!("{}", ans);
}

fn calc(a: &Vec<char>, b: &Vec<char>) -> u64 {
    let h = a.len();
    let mut cost = vec![vec![0; h + 1]; h + 1];
    for broken_a in 0..(h + 1) {
        let mut c = 0;
        for i in 0..h {
            if i + broken_a >= h {
                break;
            }
            if a[i + broken_a] == b[i] {
                c += 1;
            }
        }
        cost[broken_a][0] = c;
        for i in 0..h {
            if broken_a + i >= h {
                break;
            }
            cost[broken_a + i + 1][i + 1] =
                cost[broken_a + i][i] - if a[broken_a + i] == b[i] { 1 } else { 0 };
        }
    }
    for broken_b in 0..(h + 1) {
        let mut c = 0;
        for i in 0..h {
            if i + broken_b >= h {
                break;
            }
            if a[i] == b[i + broken_b] {
                c += 1;
            }
        }
        cost[0][broken_b] = c;
        for i in 0..h {
            if broken_b + i >= h {
                break;
            }
            cost[i + 1][broken_b + i + 1] =
                cost[i][broken_b + i] - if a[i] == b[broken_b + i] { 1 } else { 0 };
        }
    }

    let mut dp = vec![vec![1 << 50; h + 1]; h + 1];
    dp[0][0] = 0;
    for i in 0..(h + 1) {
        for j in 0..(h + 1) {
            if i < h {
                dp[i + 1][j] = cmp::min(dp[i + 1][j], dp[i][j] + cost[i][j]);
            }
            if j < h {
                dp[i][j + 1] = cmp::min(dp[i][j + 1], dp[i][j] + cost[i][j]);
            }
        }
    }
    dp[h][h]
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 6524
N = int(input())
rests = {}
cities = []
lst = []

for i in range(N):
    S, P = input().split()
    cities.append(S)
    lst.append((S, int(P)))
    try:
        rests[S].append(int(P))
        rests[S].sort()
    except KeyError:
        rests[S] = [int(P)]

cities.sort()
order = [(city, rests[city].pop()) for city in cities]

for rest in order:
    print(lst.index(rest) + 1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed _main(){
  int N,W; cin >> N >> W;
  v<int> value(N+1),weight(N+1);
  vv<int> dp(110,v<int>(10010,0));
  for(int i=1;i<=N;i++){
    cin >> value[i] >> weight[i];
  }
  for(int i=1;i<=N;i++) rep(w,10001){
    if(w-weight[i]<0) dp[i][w]=dp[i-1][w];
    else{
      dp[i][w]=max(dp[i-1][w],dp[i-1][w-weight[i]]+value[i]);
    }
  }
  cout << dp[N][W] << endl;
  return 0;
}



Measured memory_bytes: 11620
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    
    int N;
    cin >> N;
    vector<P> red(N), blue(N);
    rep(i,N) cin >> red[i].first >> red[i].second;
    rep(i,N) cin >> blue[i].first >> blue[i].second;

    vector<pair<int, P>> pairs;

    sort(red.begin(), red.end(), [](const P& x, const P& y) {return x.second > y.second;});
    sort(blue.begin(), blue.end(), [](const P& x, const P& y) {return x.first < y.first;});

    vector<bool> r(N, false);

    int count = 0;

    rep(i,N) {
        rep(j,N) {
            if (!r[j] && blue[i].first > red[j].first && blue[i].second > red[j].second) {
                count++;
                r[j] = true;
                break;
            }
        }
    }

    cout << count << endl;

}

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

int main(){
  int n;
  double t, a;
  cin >> n >> t >> a;
  vector<int> h(n);
  for(int i = 0; i < n; i++) cin >> h[i];
  double min = 100000;
  int min_index = 0;
  for(int i = 0; i < n; i++){
    double ans = abs((t - h[i] * 0.006) - a);
    if(min > ans){
      min = ans;
      min_index = i + 1;
    }
  }
  cout << min_index << endl;
  return 0;
}

Measured memory_bytes: 3720
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int x,y,z,n;
    cin >> n;
    if(7 == n%10 || 7 == n/10%10 || 7 == n/100){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3132
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

// Created by White Knife on 15/04/20.
// doot diddly donger cuckerino Hahahahahah

#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#pragma GCC target("popcnt")


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

// @formatter:off
#define F               first
#define S               second
#define all(x)          (x).begin(), (x).end()
#define sz(x)           (long long) (x).size()
#define sim             template<typename T
#define ris             return *this
#define dor             > debug & operator <<
#define eni(x)          sim > typename enable_if<sizeof dud<T>(0) x 1, debug&>::type operator<<(T i)
sim> struct rge { T b, e; };
sim> rge<T> rang(T i, T j) { return rge<T>{i, j}; }
sim> auto dud(T *x) -> decltype(cerr << *x, 0);
sim> char dud(...);
struct debug {
#ifdef LOCAL
  ~debug() { cerr << endl; }
  eni(!=) { cerr << boolalpha << i; ris; }
  eni(==) { ris << rang(all(i)); }
  sim, typename U dor(pair<U, T> d) { ris << "(" << d.first << ", " << d.second << ")"; }
  sim dor(rge<T> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
  sim dor(const T&) { ris; }
#endif
};
#define pr(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using li = __int128;
using uli = unsigned __int128;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vb = vector<bool>;

using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
template <typename T> using ordered_set = tree<T, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;

const ld PI = acos(-1);

template<typename T> inline T mini(T& x, T y) { return x = min(x, y); }
template<typename T> inline T maxi(T& x, T y) { return x = max(x, y); }
template <typename T> T rand(T x, T y) { return rand() % (y - x + 1) + x; }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) { return (os << p.first << " " << p.second); }
// @formatter:on


class APayment {
public:
  
  void solveOne(istream& cin, ostream& cout) {
  
  }
  
  void solve(std::istream& cin, std::ostream& cout) {
    int n;
    cin >> n;
    while (n > 0) n -= 1000;
    cout << abs(n);
  }
};

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
	APayment solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

#define LL long long
#define DD long double

#define M 1000000007
#define INF 1e18

void setIO(string s = "") { 
  cin.sync_with_stdio(0); cin.tie(0);
  if (s.size()) s += ".in", freopen(s.c_str(), "r", stdin);
}

int tt = 1;
void solve() {
  int n, c = 0, sm;
  cin >> n;
  vector<int> f (n);
  for (auto& it : f) cin >> it;
  sm = f[0];
  for (int i = 0; i < n; i++) {
    if (f[i] <= sm) c++, sm = min(f[i], sm);
  }
  cout << c << endl;
}

int main() {
  setIO();
  while (tt--) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3992
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORq(i, m, n) for(int i = m;i <= n;i++)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n);
#define DEBUG printf("%s\n","debug")
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
//////////////////////////////////////////////////////
int main() {
	int N;
	vector<int> A;
	SCD(N);
	REP(i,3*N){
		int a;
		SCD(a);
		A.PB(a);
	}
	
	sort(A.begin(),A.end(), greater<int>() );
	ll ans = 0;
	REP(i,N){
		ll x = A[(2*i+1)];
		ans += x;
	}
	
	PRINTLLD(ans);
	return 0;
} 
 

Measured memory_bytes: 2420
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

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

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

void update(int& x, int y) {
  x = min(x, y);
}

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<vector<int>> d(m + 1, vector<int>(2, INF));
  vector<vector<int>> e(m + 1, vector<int>(2, INF));
  d[0][0] = 0;
  for (int i = 0; i < n; ++i) {
    int A, B;
    scanf("%d%d", &A, &B);
    B = -B;
    e = d;
    for (int j = 0; j + 1 <= m; ++j) {
      if (d[j][0] != INF) {
        if (j + A <= m) update(e[j + A][0], d[j][0] + B);
        update(e[j + 1][1], d[j][0] + B);
      }
      if (d[j][1] != INF) {
        if (j + A <= m) update(e[j + A][1], d[j][1] + B);
      }
    }
    swap(d, e);
  }
  int best = 0;
  for (int j = 0; j <= m; ++j) {
    best = min(best, d[j][0]);
    best = min(best, d[j][1]);
  }
  printf("%d\n", -best);
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

long palindromic(long n);

int main()
{
    long a, b;
    cin >> a >> b;
    long ans = 0;
    for (long i = a; i <= b; i++) {
        ans += palindromic(i);
    }

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

long palindromic(long n) {
    long d5, d4, d3, d2, d1;
    d5 = n / 10000;
    d4 = (n / 1000) % 10;
    d3 = (n /100) % 10;
    d2 = (n / 10) % 10;
    d1 = n % 10;
    if ((d1 == d5) && (d2 == d4)) return 1;
    else return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int N; cin >> N;
	if (N == 1)cout << 1.000000000 << endl;
	else if (N % 2 == 0)cout << 0.50000000 << endl;
	else cout << (ldb)((N + 1) / 2) / (ldb)N << endl;
}


Measured memory_bytes: 3752
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	m := make(map[int]int)
	m[0]++
	s := make([]int, n+1)
	for i := 0; i < n; i++ {
		s[i+1] = a[i] + s[i]
		m[s[i+1]]++
	}

	ans := 0
	for _, c := range m {
		ans += c * (c - 1) / 2
	}
	fmt.Println(ans)
}


Measured memory_bytes: 14976
#include <bits/stdc++.h>
 
#define int long long
 
#define INF (1<<61)
 
using namespace std;
 
typedef pair<int, int> Pii;
 
int h, w, flag[1010][1010] = {0}, emblem[4];
 
bool IsEmblem(int x, int y) {
    int dx[] = {0, 1, 0, 1}, dy[] = {0, 0, 1, 1};
    for (int i = 0; i < 4; ++i)
        if (flag[x + dx[i]][y + dy[i]] != emblem[i]) return false;
 
    return true;
}
 
signed main() {
    cin >> h >> w;
 
    for (int y = 1; y <= h; ++y) {
        string temp;
        cin >> temp;
        for (int x = 1; x <= w; ++x) {
            switch (temp[x - 1]) {
                case 'J':
                    flag[x][y] = 1;
                    break;
                case 'O':
                    flag[x][y] = 2;
                    break;
                case 'I':
                    flag[x][y] = 3;
            }
        }
    }
 
    for (int y = 0; y < 2; ++y) {
        string temp;
        cin >> temp;
        for (int x = 0; x < 2; ++x) {
            int i = x + (2 * y);
            switch (temp[x]) {
                case 'J':
                    emblem[i] = 1;
                    break;
                case 'O':
                    emblem[i] = 2;
                    break;
                case 'I':
                    emblem[i] = 3;
            }
        }
    }
 
    int base = 0;
    for (int y = 1; y < h; ++y) {
        for (int x = 1; x < w; ++x) {
            if (IsEmblem(x, y)) base++;
        }
    }
 
    int max = 0, dx[] = {-1, 0, -1, 0}, dy[] = {-1, -1, 0, 0};
    for (int y = 1; y <= h; ++y) {
        for (int x = 1; x <= w; ++x) {
            for (int i = 1; i < 4; ++i) {
                int temp = flag[x][y], count = 0, countb = 0;

                for (int j = 0; j < 4; ++j) {
                    if (IsEmblem(x + dx[j], y + dy[j])) countb++;
                }

                flag[x][y] = i;
 
                for (int j = 0; j < 4; ++j) {
                    if (IsEmblem(x + dx[j], y + dy[j])) count++;
                }
 
                count -= countb;
                if (max < count) max = count;
                flag[x][y] = temp;
            }
        }
    }
 
    cout << base + max << endl;
 
    return 0;
}

Measured memory_bytes: 9104
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if(a <= b){
            System.out.println(a);
        }else{
            System.out.println(a-1);
        }
    }
}

Measured memory_bytes: 21204
#include <iostream>

using namespace std;


int main() {
	int n, k;
	char* str;

	cin >> n >> k ;
	str = new char[n];
	cin >> str;

	switch (str[k-1]){
		case 'A':
			str[k - 1] = 'a';
			break;
		case 'B':
			str[k - 1] = 'b';
			break;
		case 'C':
			str[k - 1] = 'c';
			break;
	}

	cout << str << endl;


	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

int f(int k) {
  if (k % 2 == 1)
    return 0;
  else
    return f(k/2) + 1;
  
}

int main() {
 
  int n, ans = -1000, ans2;
  scanf("%d", &n);
  
  
  for (int i = 1; i <= n; i++) {
    if (f(i) > ans) {
      ans = f(i);
      ans2 = i;
    }
  }
  printf("%d", ans2);
}

Measured memory_bytes: 256
def slove():
    import sys
    input = sys.stdin.readline
    pb = [True] * (10 ** 5 + 1)
    pb[0] = False
    pb[1] = False
    pl = [0] * (10 ** 5 + 1)
    pc = 0
    for i in range(2, len(pb)):
        if pb[i]:
            for j in range(i + i, len(pb), i):
                if pb[j]:
                    pb[j] = False
            if pb[(i + 1) // 2]:
                pc += 1
        pl[i] = pc
    n = int(input().rstrip('\n'))
    for i in range(n):
        l, r = list(map(int, input().rstrip('\n').split()))
        print(pl[r] - pl[l-1])


if __name__ == '__main__':
    slove()


Measured memory_bytes: 53592
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

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

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

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
map<ll, ll> mp;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  ll sum = 0;
  mp[0] = 1;
  REP(i, n) {
    ll tmp;
    cin >> tmp;
    sum += tmp;
    mp[sum]++;
  }

  ll ans = 0;
  for(auto x : mp) {
    if(x.second > 1) ans += x.second * (x.second - 1) / 2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 12800
#include <iostream>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
using namespace std;

int n, m, Q, l[200009], r[200009], x[509][509], c[509][509];

int main() {
    cin >> n >> m >> Q;
    for (int i = 1; i <= m; ++i) {
        cin >> l[i] >> r[i];
        x[l[i]][r[i]]++;
    }

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            c[i][j] = c[i][j - 1] + x[i][j];
        }
    }

    rep(i, Q) {
        int p, q;
        cin >> p >> q;
        int sum = 0;
        for (int j = p; j <= q; ++j) sum += c[j][q] - c[j][p - 1];
        cout << sum << endl;
    }
}

Measured memory_bytes: 4480
local function axiscomp(ary)
  local z = {}
  for i = 1, #ary do
    z[i] = ary[i]
  end
  table.sort(z)
  local ac, acinv = {}, {}
  local cur = 0
  for i = 1, #z do
    if not acinv[z[i]] then
      cur = cur + 1
      ac[cur] = z[i]
      acinv[z[i]] = cur
    end
  end
  return ac, acinv
end

local n = io.read("*n")
local ax = {}
local left, right = {}, {}
local idx = {}
for i = 1, n do
  local a, b = io.read("*n", "*n")
  left[i], right[i] = a - b, a + b
  table.insert(ax, a - b)
  table.insert(ax, a + b)
  idx[i] = i
end
local ac, acinv = axiscomp(ax)

local edge = {}
for i = 1, #ac do
  edge[i] = {}
  if i ~= #ac then
    edge[i][i + 1] = 0
  end
end
for i = 1, n do
  local l, r = acinv[left[i]], acinv[right[i]]
  edge[l][r] = 1
end

local len = {}
for i = 1, #ac do len[i] = -1 end
len[1] = 0
for src = 1, #ac - 1 do
  for dst, cost in pairs(edge[src]) do
    if len[dst] < len[src] + cost then
      len[dst] = len[src] + cost
    end
  end
end

print(len[#ac])


Measured memory_bytes: 67012
/**
*    created: 27.06.2020 19:21:56
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcountll(bit)
#define mod 1000000007
#define pi acos(-1.0)
using namespace std;
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;}

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    string s, t;
    cin >> s >> t;
    int l = s.size();
    rep(i,l) {
        string tmps = s.substr(i,l-i) + s.substr(0,i);
        if (tmps == t) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
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(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    iosetup;
    int a, b, c, d; IN(a, b, c, d);
    if(abs(a-c)<=d || (abs(a-b)<=d && abs(c-b) <= d)) puts("Yes");
    else puts("No");
    return 0;
}

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

const int M = 1000005;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> cnt(M);
  for (int x : a) {
    if (cnt[x] != 0) {
      cnt[x] = 2;
      continue;
    }
    for (int i = x; i < M; i += x) cnt[i]++;
  }
  int ans = 0;
  for (int x : a) {
    if (cnt[x] == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8012
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
signed main(){
    int n; cin >> n;
    int sum = 0;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int mx = a[0]; int mn = a[0];
    rep(i,n){
        mx = max(mx,a[i]);
        mn = min(mn,a[i]);
    }
    int ans = 1000000000;
    rep2(i, mn, mx+1){
        int cost = 0;
        rep(j,n) cost += (a[j]-i)*(a[j]-i);
        ans = min(ans,cost);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
*@Author  Chand Vachhani
*/

#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define vi          vector<int>
#define vii         vector<vector<int>>
#define pii         pair<int,int>
#define mii         map<int,int>
#define pb          push_back
#define pf          push_front
#define mp(a,b)          make_pair((a),(b))
#define vpii        vector<pair<int,int>>
#define fo(i,l,n)   for(int i{l}; i<n; i++)
#define rf(s)       for(auto &c : s)
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define PI          3.141592653589
#define sz(x)       (int)x.size()
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007  

using namespace std;

void ad(int &a, int b){
    a = a+b;
    if(a>=MOD)a-=MOD;
}
void sb(int &a, int b){
    a = a-b;
    if(a<0)a+=MOD;
}

signed main(){
    tezz
   
    int n,k,ub;
    cin >> n >> k;
    vector<int> dp(k+1,0);
    dp[0]=1;
    for(int i=0; i<n; i++){
        cin >> ub;
        vector<int> ref(k+1,0);
        for(int j=k; j>=0; j--){
            int t=dp[j];
            int l=j+1;
            int r=min(j+ub,k);
            if(l<=r){   
                ad(ref[l],t);
                if((r+1)<=k)sb(ref[r+1],t);
            }
        }
        int pre=0;
        for(int j=0; j<=k; j++){
            ad(pre,ref[j]);
            ad(dp[j],pre);
        }
        // for(auto it: ref)cout << it << " ";
        // cout << endl;
        // for(auto it: dp)cout << it << " ";
        // cout << endl << endl;
        
    }
    cout << dp[k];
    
    
    
    
    return 0;
}


Measured memory_bytes: 1792
//i ll be the king
#include<bits/stdc++.h>
#define ll long long int
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
int main()
{
	sync;
	ll n,m;
	cin>>n>>m;
	ll a[n],b[n];
	vector<pair<double,ll> >v;
	for(ll j=0;j<n;j++)
	{
		cin>>a[j];
		vmp(v,a[j],j);
		cin>>b[j];
	}
	sort(v.begin(),v.end());
	ll ans=0,cnt=0;
	for(ll i=0;i<n;i++)
	{
	//	cout<<v[i].second<<" "<<v[i].first<<endl;
		if(cnt+b[v[i].second]<=m)
		ans+=a[v[i].second]*b[v[i].second];
		else
		ans+=(m-cnt)*a[v[i].second];
		cnt+=b[v[i].second];
		if(cnt>=m)
		break;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3568
import java.util.Scanner;
//A問題
public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		int c = s.nextInt();
		if(a < c && c < b || b < c && c < a)
			System.out.print("Yes");
		else System.out.print("No");

		s.close();
		}

}

Measured memory_bytes: 22740
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main() {
    int a;
    int b;
    int c;
 
//   cin >> a >> b >> c;
  
  // cout << a << endl;
  // cout << b << endl;
  // cout << c << endl;
  
   int d = 0;
   int e = 0;
  
   int l, n=0, x[210];
 while(cin>>l){
        x[n] = l;
       
        n++;
    }
  
  
   for (int i = 0;i < 3;i++){
      
     if (x[i]==5){
       d = d + 1;
     }else{
       e = e + 1;
     }
     
   }
  

  
  if (d == 2){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
def abc099_c():
    ''' maspyさんお手本 '''
    import numpy as np
    N = int(input())

    coin = [6**n for n in range(10) if 6**n <= N]  # N以下の6の乗数
    coin += [9**n for n in range(10) if 9**n <= N]  # N以下の9の乗数

    dp = np.zeros(N+1, dtype=int)
    dp += 10**9
    dp[0] = 0

    for c in coin:
        # それぞれの額は9回以下なので
        # (6か9の倍数なので周期は最大9で、9回更新すれば十分？？)
        for _ in range(9):
            dp[c:] = np.minimum(dp[:-c]+1, dp[c:])

    ans = dp[N]
    print(ans)

abc099_c()

Measured memory_bytes: 14804
if __name__ == '__main__':

	n = int(input())
	
	A = []
	max_num = 0
	for i in range(n):
		cmd = int(input())
		max_num = max(max_num,cmd)
		A.append(cmd)

	ind = A.index(max_num)
	A[ind] = A[ind] // 2
	
	print(sum(A))


Measured memory_bytes: 9112
N=int(input())
S=input()
New=[]
for i in range(N-1):
    New.append(S[i])
    if S[i] == S[i+1]:
        New.pop()
if len(New) == 0 or S[-1] != New[-1]:
    New.append(S[-1])

print(len(New))

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define MAX 1000000

int main() {
    int A, B, C, K; cin >> A >> B >> C >> K;
    if (A < K) {
        int ans = A;
        if (K-A-B > 0) {
            for (int i = 0; i < K-A-B; i++) ans--;
            cout << ans << endl;
        } else cout << ans << endl;
    } else cout << K << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
  ll n,d; cin>>n>>d;
  ll ans=0;
  rep(i,n){
    ll x,y; cin>>x>>y;
    ll dis=x*x+y*y;
    if(dis<=d*d) ans++;
  }
  cout<<ans<<endl;
}


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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, start_index, num)  (a).begin()+(start_index),(a).begin()+(num)


int main() {
	int a;
	cin >> a;
	int res = a + a*a + a*a*a;
	pv(res)
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxn=1e6+5;
vector<ll> V;
int pre[maxn];
int main() {
    ll n;cin>>n;
    string s;
    while(n) {
    	s.push_back((n-1)%26+'a');
    	n=(n-1)/26;
    }
    for(int i=s.length()-1;i>=0;i--) cout<<s[i];
    return 0;
}

Measured memory_bytes: 3628