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

using namespace std;

void rwFile() {
    freopen("INP.inp", "r", stdin);
    freopen("OUT.out", "w", stdout);
}

void solveA() {
    char x; cin >> x;
    cout << char(x + 1);
}

void solveB() {
    int n, k, m;
    cin >> n >> k >> m;
    int S = 0;
    for (int i = 0; i < n - 1; i++) {
        int x; cin >> x;
        S += x;
    }
    if (m * n - S > k) cout << -1;
    else {
        if (m * n - S < 0) cout << 0;
        else cout << m * n - S;
    }
}

void solveC() {
    int n, m;
    cin >> n >> m;
    int arr[n + 1], check[n + 1];
    memset(arr, 0, sizeof(arr));
    memset(check, 0, sizeof(check));
    for (int i = 0; i < m; i++) {
        int p; cin >> p;
        string s; cin >> s;
        if (s == "AC") check[p] = 1;
        else {
            if (check[p] != 1) arr[p]++;
        }
    }
    int cor = 0, pen = 0;
    for (int i = 1; i <= n; i++) {
        if (check[i] == 1) {
            cor++;
            pen += arr[i];
        }
    }
    cout << cor << ' ' << pen;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    //rwFile();
    solveC();
}


Measured memory_bytes: 1024
/************************************/
/* NoobM							*/
/* File Name : at.cpp				*/
/* Date : 21.06.2020 18:00:49 +06	*/
/************************************/

#include <bits/stdc++.h>

#define rr(i, b)    for (int i = 0; i < int(b); i++)
#define vi(n, a) vector <int> a(n); rr(i, n) cin >> a[i]
#define pvec(a) rr(i, a.size()) cout << a[i] << " "; cout << endl
#define bug(x) cout << #x << " " << x << endl
#define ll long long
#define vii vector <int>

using namespace std;

void solve() {
	int n, k;
	cin >> n >> k;

	vi(n, a);
	
	sort(a.begin(), a.end());
	
	ll sum = 0;
	
	rr(i, k) {
		sum += a[i];
	}
	
	cout << sum << endl;
}
 
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
	
	int t = 1;
	//cin >> t;
	
	while (t--) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 3648
N,K=map(int,input().split())
X=[(b,a*b)for a,b in zip(sorted(list(map(int,input().split()))),sorted(list(map(int,input().split())))[::-1])]
m,M,i=0,2**40,1
exec("i,M,m=((i+m)//2,i,m) if -sum(min(0,i-c)//b for b, c in X)<=K else((i+M)//2,M,i);"*50)
print(M)

Measured memory_bytes: 123384
n = int(input())
a = [int(x) for x in input().split()]

colors = ["gray","brown","green","water","blue","yellow","orange","red","other"]
d = {x: 0 for x in colors}

for x in a:
    rate = x // 400
    if rate == 0:
        d["gray"] += 1
    elif rate == 1:
        d["brown"] += 1 
    elif rate == 2:
        d["green"] += 1 
    elif rate == 3:
        d["water"] += 1 
    elif rate == 4:
        d["blue"] += 1 
    elif rate == 5:
        d["yellow"] += 1 
    elif rate == 6:
        d["orange"] += 1 
    elif rate == 7:
        d["red"] += 1 
    elif rate > 7:
        d["other"] += 1 

num = 0
for x in d:
    if d[x] > 0 and x != "other":
        num += 1

if num == 0:
    print("1" + " " + str(d["other"]))
else:
    print(num, num+d["other"])

Measured memory_bytes: 3064
N=int(input())
L=[11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381][0:N]
print(' '.join(map(str, L)))

Measured memory_bytes: 3064
IDENTIFICATION DIVISION.
        PROGRAM-ID. AtCoder.
      
        ENVIRONMENT DIVISION.
      
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01 INP PIC X(100).
        01 A PIC 9(15).
        01 B PIC 9(15).
        01 C PIC 9(15).
      	01 D PIC 9(15).
      	01 E PIC ZZZZZZZZZZZZ.
	    01 temp1 PIC 9(15).
        01 temp2 PIC 9(15).
        01 N PIC 9(15).
      
        PROCEDURE DIVISION.
      	MAIN.
			ACCEPT INP.
        	PERFORM VARYING temp1 FROM 1 BY 1
            UNTIL INP(temp1:1) = SPACE
        	END-PERFORM.
        	SUBTRACT 1 FROM temp1.
        	MOVE INP(1:temp1) TO A.
        	ADD 2 TO temp1.
        	PERFORM VARYING temp2 FROM temp1 BY 1
            UNTIL INP(temp2:1) = SPACE
        	END-PERFORM.
        	COMPUTE N = temp2 - temp1.
        	MOVE INP(temp1:N) TO B.
      		IF A > B THEN
      			COMPUTE C = A - B
      		ELSE 
      			COMPUTE C = B - A
      		END-IF.
      		COMPUTE D = C / 2.
      		COMPUTE D = D * 2.
			IF C = D THEN
      			COMPUTE E = (A + B) / 2
				DISPLAY E
			ELSE 
				DISPLAY "IMPOSSIBLE"
			END-IF.
		STOP RUN.

Measured memory_bytes: 384
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
const int MOD = 1000000007;


typedef long long int ll; 
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

void floatOutPutSetup(){
    cout << fixed;
    cout << setprecision(10);
}

int main(){
    string s;
    cin >> s;
    if(s=="ABC"){
        cout << "ARC";
        return 0;
    }
    cout << "ABC";
    return 0;
}

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

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    set<char>s;
    string str;
    cin>>str;
    for(int i=0;i<str.size();i++)
    {
        s.insert(str[i]);
    }
    if(s.size()==str.size())
    {
        cout<<"yes"<<endl;
    }
    else
    {
        cout<<"no"<<endl;
    }
    return 0;
}


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

ll f(ll n){
  ll res=0;
  while(n){
    res+=(n%10);
    n/=10;
  }
  return res;  
}

ll calc(ll N,ll base){
  if(N<base)return 0;
  ll fi=N/base;
  return f(fi-1)+f(base-1);
}

int main(){
  ll N;
  cin>>N;
  ll ans=f(N);
  ll base=1;
  for(int i=0;i<17;i++){
    base*=10LL;
    ans=max(ans, calc(N,base) );
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, Q: int, a: "List[int]", b: "List[int]", c: "List[int]", d: "List[int]"):
    res = 0

    def rec(A):
        nonlocal res
        if len(A) == N:
            ans = 0
            for i in range(Q):
                if A[b[i]-1] - A[a[i]-1] == c[i]:
                    ans += d[i]
            res = max(res, ans)
            return

        last_max = 1 if len(A) == 0 else A[-1]

        for i in range(last_max, M+1):
            rec(A + [i])

    rec([])
    print(res)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    a = [int()] * (Q)  # type: "List[int]"
    b = [int()] * (Q)  # type: "List[int]"
    c = [int()] * (Q)  # type: "List[int]"
    d = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
        c[i] = int(next(tokens))
        d[i] = int(next(tokens))
    solve(N, M, Q, a, b, c, d)


if __name__ == '__main__':
    main()


Measured memory_bytes: 73980
#pragma GCC optimize ("-O3","unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<cmath>
#include<cstdio>
#include<algorithm>
#include<bitset>
#include<complex>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<typeinfo>
#include<typeindex>
#include<type_traits>
#include<utility>
#include<valarray>
#include<vector>
#include<array>
#include<forward_list>
#include<random>
#include<ratio>
#include<tuple>
#include<unordered_map>
#include<unordered_set>
#include<cstring>

using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef pair<Int,Int> Pl;
constexpr int mod = 1e9+7;
constexpr int INF32 = numeric_limits<int>::max();
constexpr Int INF64 = numeric_limits<Int>::max();
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rep(i,n) for(int(i)=0; i<n; ++i)
#define rer(i,l,r) for(int i=l; i<=r; ++i)
#define gnr(i,l,r) for(int i=r; i>=l; --i)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(i,n-1)cout<<a[i]<<' '; if(n)cout<<a[n-1]<<'\n';}
#define prip(p) cout<<p.fi<<' '<<p.se<<'\n'
#define var(type) valarray<type>
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

Int n,m,_,x,y,q,key;
string s,sb;
bool ok;

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

	cin>>n>>m; Int a[n],b[n]; rep(i,n)cin>>a[i]; rep(i,n)cin>>b[i];
	sort(a,a+n); sort(b,b+n); reverse(b,b+n); Int ma=0; rep(i,n)cmax(ma,a[i]*b[i]);
	Int ok=-1,ng=ma,cnt;
	while(ng-ok>1){
		cnt=0;
		Int mid=(ng+ok)/2;
		rep(i,n){
			if(a[i]*b[i]>mid){
				cnt+=(a[i]*b[i]-mid)/b[i]+(((a[i]*b[i]-mid)%b[i])?1:0);
			}
		}
		if(cnt>m)ok=mid;
		else ng=mid;
	}
	pri1(ng);
}

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

struct edge {
    edge(int t, ll c) : to(t), cost(c) {}
    int to;
    ll cost;
};

void dijkstra(int s, vector<ll> &d, vector<vector<edge>> &G) {
    priority_queue<pll, vector<pll>, greater<pll>> que;
    fill(All(d), LINF);
    d[s] = 0;
    que.push(make_pair(0, s));

    while(!que.empty()) {
        pll p = que.top();
        que.pop();
        int v = p.second;
        if(d[v] < p.first)
            continue;
        for(auto e : G[v]) {
            if(d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(make_pair(d[e.to], e.to));
            }
        }
    }
}

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    vector<vector<edge>> G(N + 1, vector<edge>());
    vector<pair<pii, int>> edges(M);
    rep(i, M) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        G[a].push_back(edge(b, c));
        G[b].push_back(edge(a, c));
        edges[i] = MP(MP(a, b), c);
    }

    rep(i, K) {
        int k;
        cin >> k;
        k--;
        G[N].push_back(edge(k, 0));
    }
    vector<ll> dist(N + 1);
    dijkstra(N, dist, G);
    ll res = 0;
    rep(i, N) { res = max(res, dist[i]); }
    rep(i, M) {
        int a = edges[i].first.first;
        int b = edges[i].first.second;
        ll c = edges[i].second;
        res = max(res, (dist[a] + dist[b] + c + 1) / 2);
    }
    cout << res << endl;
    return 0;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;

  map<i64, i64> cnt;
  rep(i, n) {
    i64 d;
    cin >> d;
    cnt[d]++;
  }

  int m;
  cin >> m;

  vector<i64> t(m+10);
  map<i64, i64> cnt2;
  rep(i, m) {
    cin >> t[i];
    cnt2[t[i]]++;
  }

  bool yes = true;
  rep(i, m) {
    if (cnt[t[i]] < cnt2[t[i]]) yes = false;
  }

  cout << (yes ? "YES" : "NO") << "\n";

  return 0;
}

Measured memory_bytes: 26880
A,B,C,D =map(int, input().split())
import fractions
lcm = C * D // fractions.gcd(C, D)
E = B - (B // C + B // D - B // lcm)
F = (A-1) - ((A-1) // C + (A-1) // D - (A-1) // lcm)
result = E-F
print(result)

Measured memory_bytes: 5048
input = gets.split(' ').map(&:to_i)
t = input[0]
a = input[1]
b = input[2]
sums = []

t.times do |i|
  i = i + 1

  sum = i.to_s.chars.map(&:to_i).inject(:+)
  if a <= sum && sum <= b
    sums << i
  end
end

puts sums.inject(:+)

Measured memory_bytes: 1916
#include <stdio.h>

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

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

    int i, count = 0;
    for(i = a; i <= b; ++i)
    {
        count += (c % i == 0);
    }

    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 596
n, k = gets.to_s.split.map{|e|e.to_i}
a = [0] + gets.to_s.split.map{|e|e.to_i}
 
t = Array.new(n+1){ -1 } 
used = Array.new(n+1){ false }

t[1] = i = 0
s = 1
used[1] = true
loop do
  
  s = a[s]
  i +=1
  # if i == k
  #   puts s
  #   exit
  # end
  
  used[s] ? break : used[s] = true
  t[s] = i
end

dist = t[s]
cycle = i - dist

if dist >= k
  puts t.index(k)
else
  idx = (k - dist) % cycle + dist
  puts t.index(idx)
end

Measured memory_bytes: 32108
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    cout << (n-1)/2 << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#include <conio.h>
using namespace std;

int main() {
	int goal = 0;
	int position = 0;
	int count = 0;
	cin >> goal;
	int command(int count, int goal, int position);
	count = command(count, goal, position);
	cout << count;
	//_getch();
}
int command(int count, int goal, int position) {
	count++;
	if (position + count >= goal) return count;
	if (position + count < goal) {
		command(count, goal, position + count);
	}
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    Set<Integer> set = new HashSet<>();
    for(int i=0; i<N; i++){
      int A = sc.nextInt();
      if(set.contains(A)){
        set.remove(A);
      }else{
        set.add(A);
      }
    }
    System.out.println(set.size());  
  }
}
      

Measured memory_bytes: 62216
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

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

    int n; cin >> n; string s; cin >> s;
    int count = 0;
    FOR(i, 1, n) if (s.at(i) == 'E') count++;
    int best = count;
    FOR(i, 1, n) {
        if (s.at(i-1) == 'W') count++;
        if (s.at(i) == 'E') count--;
        best = min(count, best);
    }
    cout << best << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 720
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

lli n;
vst a;
vst b;
vst c;

void output(vst a){
    cout << a[0];
    for(lli i = 1;i < n;i++){
        cout << " " << a[i];
    }
    cout << endl;
}

int main(){
    cin >> n;
    a = vst(n);
    for(lli i = 0;i < n;i++) cin >> a[i];
    b = a;
    for(lli i = n-1;i >= 0;i--){
        for(lli j = n-1;j > 0;j--){
            if(b[j][1] < b[j-1][1]) swap(b[j],b[j-1]);
        }
    }
    output(b);
    cout << "Stable" << endl;
    for(auto itr = a.begin();itr < a.end();itr++){
        auto jtr = min_element(itr,a.end(),[](string a,string b){
            return a[1] < b[1];
        });
        if(itr == jtr) continue;
        swap(*itr,*jtr);
    }
    output(a);
    for(lli i = 0;i < n;i++){
        if(a[i] != b[i]){
            cout << "Not stable" << endl;
            return 0;
        }
    }
    cout << "Stable" << endl;
    return 0;

    

}

Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n,q;
    cin>>n>>q;
    vector<pair<int,pair<int,int>>> v(2*n+q);
    for(int i=0;i<n;i++){
        int s,t,x;
        cin>>s>>t>>x;
        v[2*i]={s-x,{1,x}};
        v[2*i+1]={t-x,{-1,x}};
    }
    for(int i=0;i<q;i++){
        int d;
        cin>>d;
        v[2*n+i]={d,{2,i}};
    }
    sort(v.begin(),v.end());
    int ans[q];
    memset(ans,-1,sizeof(ans));
    multiset<int> eve;
    for(int i=0;i<2*n+q;i++){
        int id=v[i].second.first;
        int t=v[i].second.second;
        if(id==1){
            eve.insert(t);
        }
        else if(id==-1){
            eve.erase(eve.lower_bound(t));
        }
        else if(eve.size()){
            ans[t]=*eve.begin();
        }
    }
    for(int i=0;i<q;i++){
        cout<<ans[i]<<endl;
    }
}


Measured memory_bytes: 18432
def main():
    sx,sy,tx,ty = map(int,input().split())
    subx = tx-sx
    suby = ty-sy
    if subx>=0:
        ls1 = "R"*subx
        ls3 = "L"*subx
    else:
        ls1 = "L"*(-subx)
        ls3 = "R"*(-subx)
    if suby>=0:
        ls2 = "U"*suby
        ls4 = "D"*suby
    else:
        ls2 = "D"*(-suby)
        ls4 = "U"*(-suby)
    first = ls1 + ls2 + ls3 + ls4
    second = ls4[0] + (ls1 + ls1[0]) + (ls2 + ls2[0]) + ls3[0] + ls2[0] + (ls3 + ls3[0]) + (ls4 + ls4[0]) + ls1[0]
    ans = first + second
    print("".join(ans))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 38384
n, m = map(int, input().split())
dp = ['.' for _ in range(n + 1)]
dp[0] = 1
dp[1] = 1
for i in range(m):
    mm = int(input())
    dp[mm] = 0

for i in range(2, n + 1):
    if dp[i] != 0:
        dp[i] = dp[i - 1] + dp[i - 2]

print(dp[n] % 1000000007)


Measured memory_bytes: 460056
def gcd(a,b):
    while b > 0:
        a, b = b, a%b
    return a

N, M = map( int, input().split())
g = gcd(N,M)
S = input()
T = input()
c = M//g
t = N//g
ans = M*N//g
for i in range(N):
    if c*i%t == 0:
        if S[i] != T[c*i//t]:
            ans = -1
print(ans)


Measured memory_bytes: 3316
#!/usr/bin/env python3
(w, h, n), *q = [[*map(int, i.split())] for i in open(0)]
r = {1: 0, 2: w, 3: 0, 4: h}
for i in q:
    if i[2] == 1:
        r[i[2]] = max(i[0], r[i[2]])
    elif i[2] == 2:
        r[i[2]] = min(i[0], r[i[2]])
    elif i[2] == 3:
        r[i[2]] = max(i[1], r[i[2]])
    elif i[2] == 4:
        r[i[2]] = min(i[1], r[i[2]])
print(
    (r[2] - r[1] if r[2] > r[1] else 0) * (r[4] - r[3] if r[4] > r[3] else 0))


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

/*
ll gcds(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    ll r=a%b;
    if(r==0){
        return b;
    }
    while(r>0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}


ll lcms(ll a,ll b){
    ll mmr=gcds(a,b);
    a=a/mmr;
    b=b/mmr;
    return a*b*mmr;
}
*/

int main(){
    ll H,N;
    cin>>H>>N;
    vector<ll> A(N);
    for(ll i=0;i<N;i++){
        cin>>A.at(i);
    }
    ll tasu=0;
    for(ll i=0;i<N;i++){
        tasu+=A.at(i);
    }
    if(tasu>=H){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<vector<ll>> matrix;//matrix A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
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;}
#define MOD 998244353 //1000000007


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

    // solution comes here

    ll X;
    cin >> X;
    for(ll a=0; a*5<100; a++) {
        for(ll b=0; a*5+b*4<100; b++) {
            for(ll c=0; a*5+b*4+c*3<100; c++) {
                for(ll d=0; a*5+b*4+c*3+d*2<100; d++) {
                    for(ll e=0; a*5+b*4+c*3+d*2+e<100; e++) {
                        if(a*5+b*4+c*3+d*2+e == (X%100) && (a+b+c+d+e)<=X/100){
                            cout << 1 << nl;
                            return 0;
                        }
                    }
                }
            }
        }
    }

    cout << 0 << nl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

ll a[110000];
int main(){
    ll n,m,ans=0;
    cin>>n;
    bool f=true;
    rep(i,0,n)cin>>a[i];
    sort(a,a+n);
    rep(i,0,n)if(a[i]==a[0])ans++;
    ll y=a[n-1]-a[0];
    if(y>1)cout<<"No"<<endl;
    if(y==0){
        if(n==a[0]+1||n>=a[0]*2)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    if(y==1){
        if(ans==a[0])cout<<"Yes"<<endl;
        else if((n-ans)/2+ans==a[n-1]&&(n-ans)%2==0)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    
}


Measured memory_bytes: 1024
n,A,B,C=map(int,input().split())
l=[int(input()) for _ in range(n)]
t=10**9
def dfs(level,a,b,c):
  if level==n:
    return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else t
  k1=dfs(level+1,a,b,c)
  k2=dfs(level+1,a+l[level],b,c)+10
  k3=dfs(level+1,a,b+l[level],c)+10
  k4=dfs(level+1,a,b,c+l[level])+10
  return min(k1,k2,k3,k4)
print(dfs(0,0,0,0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;


const ll modo=998244353;
const ll inf=1e16;
const ll ms=(2e5) +5;


int main()
{
    idfc;


    ll n;
    cin>>n;
    ll tt=(n/500)*1000;
    n=n%500;
    tt+=((n/5)*5);
    cout<<tt;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 3005
#define ll long long
ll dp[N][N], n, arr[N];

int main()
{
    //memset(dp, -1, sizeof(dp));
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> arr[i];

    for(int i = n; i >= 1; i--)
    {
        for(int j = i; j <= n; j++)
        {
            dp[i][j] = max(arr[i] - dp[i + 1][j], arr[j] - dp[i][j - 1]);
        }
    }
    cout << dp[1][n] << endl;
    //cout << -cal(1, n) << endl;
}


Measured memory_bytes: 70016
#include <bits/stdc++.h> 
using namespace std; 
  
// Function to traverse the DAG 
// and apply Dynamic Programming 
// to find the longest path 
void dfs(int node, vector<int> adj[], int dp[], bool vis[]) 
{ 
    // Mark as visited 
    vis[node] = true; 
  
    // Traverse for all its children 
    for (int i = 0; i < adj[node].size(); i++) { 
  
        // If not visited 
        if (!vis[adj[node][i]]) 
            dfs(adj[node][i], adj, dp, vis); 
  
        // Store the max of the paths 
        dp[node] = max(dp[node], 1 + dp[adj[node][i]]); 
    } 
} 
  
// Function to add an edge 
void addEdge(vector<int> adj[], int u, int v) 
{ 
    adj[u].push_back(v); 
} 
  
// Function that returns the longest path 
int findLongestPath(vector<int> adj[], int n) 
{ 
    // Dp array 
    int dp[n + 1]; 
    memset(dp, 0, sizeof dp); 
  
    // Visited array to know if the node 
    // has been visited previously or not 
    bool vis[n + 1]; 
    memset(vis, false, sizeof vis); 
  
    // Call DFS for every unvisited vertex 
    for (int i = 1; i <= n; i++) { 
        if (!vis[i]) 
            dfs(i, adj, dp, vis); 
    } 
  
    int ans = 0; 
  
    // Traverse and find the maximum of all dp[i] 
    for (int i = 1; i <= n; i++) { 
        ans = max(ans, dp[i]); 
    } 
    return ans; 
} 
  
int main() 
{ 
    int n, m;
    cin>>n>>m; 
    vector<int> adj[n + 1]; 
  
    while(m--){
    	int a, b;
    	cin>>a>>b;
    	addEdge(adj, a, b); 
    }
    
    
  
    cout << findLongestPath(adj, n); 
    return 0; 
}

Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		String s = sc.next();

		sc.close();

		if(n % 2 != 0) {
			System.out.println("No");
			return;
		}

		int e = n / 2;

		if(s.subSequence(0, e).equals(s.substring(e, s.length()))) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 22100
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,k = li()
h = [ni() for _ in range(n)]

h.sort()

ans = 10**18
for st in range(n-k+1):
    ans = min(ans, h[st+k-1] - h[st])
    
print(ans)

Measured memory_bytes: 7512
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
/*
～biginer 148 E～
・N <= 10^18 だから階乗をまともに計算すると間に合わない
・割る回数にだけ注目
*/
ll N;

ll g1(ll n, int p) {
	if (n == 0) return 0;
	return n / p + g1(n / p, p);
}

ll g2(ll n,int p) /* n!! を p で何回わることができるか*/
{
	ll res = 0;
	if (n % 2 == 1) {
		return g1(n, p) - g2(n - 1, p);
	}
	else {
		res = g1(n / 2, p);
	}
	if (p == 2) res = res + (n / 2);

	return res;
}

int main() {
	cin >> N;
	ll ans = min(g2(N, 2), g2(N, 5)); /* "10で何回割れるか" は、"2で何回割れるか"と"5で何回割れるか"の min を求めることと同値*/
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string S, T;
    cin >> S >> T;
    REP(i, S.size()) {
        if(S[i] != T[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3656
function main(input){
    inputArray=input.split('\n');
    leng=inputArray[1].length;
  out = '';
  copy=inputArray[1];
  out='';

    k = parseInt(inputArray[0]);

    if(leng>k){
		for(i=0;i<k;i++){
          out=out+copy[i];
        }
      out=out+'...';
    }
    else{
        out=inputArray[1];
    }

    console.log(out);
}
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29608
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
 
class SegmentTree {
    private:
        int *tree;
        string arr;
        int treeSize;
        int arrSize;
 
        void __buildTree(int low, int high, int pos) {
            if (low == high) {
                tree[pos] = 1 << (arr[low] - 'a');
            } else {
                int mid = (low + high) / 2, left = 2 * pos + 1, right = 2 * pos + 2;
                if (left == -1) return;
                __buildTree(low, mid, left);
                __buildTree(mid + 1, high, right);
 
                tree[pos] = tree[left] | tree[right];
            }
        }
 
        int __query(int qLow, int qHigh, int low, int high, int pos) {
 
            if (qLow <= low and qHigh >= high)
                return tree[pos];
 
            else if (qLow > high or qHigh < low)
                return 0;
 
            else {
                int mid = (high + low) / 2;
 
                if (qLow > mid)
                    return __query(qLow, qHigh, mid + 1, high, 2 * pos + 2);
                if (qHigh <= mid)
                    return __query(qLow, qHigh, low, mid, 2 * pos + 1);
 
                int left = __query(qLow, qHigh, low, mid, 2 * pos + 1);
                int right = __query(qLow, qHigh, mid + 1, high, 2 * pos + 2);
 
                return left | right;
            }
        }
 
        void __update(int loc, char value, int low, int high, int pos) {
            if (loc == low and loc == high) {
                tree[pos] = 1 << (value - 'a');
            }
 
            else if (loc > high or loc < low)
                return;
 
            else {
                int mid = (low + high) / 2, left = 2 * pos + 1, right = 2 * pos + 2;
 
                __update(loc, value, low, mid, left);
                __update(loc, value, mid + 1, high, right);
 
                tree[pos] = tree[left] | tree[right];
            }
        }
 
    public:
        SegmentTree(string array, int n) {
            arr = array;
            arrSize = n;
            treeSize = 2 * (1 << int(ceil(log2(n)))) - 1;
 
            tree = new int[treeSize];
            __buildTree(0, arrSize - 1, 0);
        }
 
        int _query(int qLow, int qHigh) {
            return __builtin_popcount(__query(qLow, qHigh, 0, arrSize - 1, 0));
        }
 
        void _update(int loc, int value) {
            __update(loc, value, 0, arrSize - 1, 0);
        }
};
 
int main() {
    
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    int n; cin >> n;
    string s; cin >> s;
    int q; cin >> q;
 
    SegmentTree seg(s, s.length());
    while (q--) {
        int s; cin >> s;
        if (s == 1) {
            int loc; char val;
            cin >> loc >> val;
            seg._update(--loc, val);
        } else {
            int low, high;
            cin >> low >> high;
            cout << seg._query(--low, --high) << endl;
        }
    }
 
    return 0;
}

Measured memory_bytes: 5532
//#include "stdc++.h"
#include <bits/stdc++.h>
#define int long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;



int32_t main()
{
    int n,m;
    cin>>n>>m;
    if(n==m)cout<<"Yes\n";
    else
    {
        cout<<"No\n";
    }
    
}

Measured memory_bytes: 256
n, w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]

v_total = sum([x[1] for x in wv])
dp = [0] + [float("inf")]*v_total

for i in range(n):
    for j in range(v_total, wv[i][1]-1, -1):
        dp[j] = min(dp[j], dp[j-wv[i][1]]+wv[i][0])

ans = 0
for i in range(v_total+1):
    if dp[i] <= w:
        ans = i
print(ans)

Measured memory_bytes: 92364
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

ll a,b,c,d;

int main()
{

  cin >> a >> b >> c >> d;

  cout << max(max(a*c, a*d), max(b*c, b*d)) << endl;
  return 0;
}


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

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

using namespace std;

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

	int arb=0;
	bool color[8]={};
	rep(i,n){
		int a; cin>>a;
		if     (a< 400) color[0]=true;
		else if(a< 800) color[1]=true;
		else if(a<1200) color[2]=true;
		else if(a<1600) color[3]=true;
		else if(a<2000) color[4]=true;
		else if(a<2400) color[5]=true;
		else if(a<2800) color[6]=true;
		else if(a<3200) color[7]=true;
		else arb++;
	}

	int c=count(color,color+8,true);
	cout<<max(c,1)<<' '<<c+arb<<endl;

	return 0;
}


Measured memory_bytes: 256
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

s=input()
print("2018"+s[4:])

Measured memory_bytes: 68984
import sys
import bisect

input = sys.stdin.readline


def main():
    N = int(input())
    L = [int(i) for i in input().split()]

    L.sort()
    ans = 0

    for i in range(N):
        for j in range(i):
            # a = bisect.bisect_right(L, L[i]+L[j])
            b = bisect.bisect_left(L, L[i]+L[j])
            # print(a, b)
            ans += max(0, b-i-1)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 44588
#include <algorithm>
#include <iostream>
#include <string>
int main() {
    using std::cin;
    using std::string;

    int n;
    cin >> n;
    string s;
    cin >> s;

    int ans = 0;
    for (int i = 1; i < n - 1; ++i) {
        string f = s.substr(0UL, i);
        string r = s.substr(i);

        // 各々の重複を削除
        std::sort(f.begin(), f.end());  // Θ(n * n log n)
        std::sort(r.begin(), r.end());
        f.erase(std::unique(f.begin(), f.end()), f.end());
        r.erase(std::unique(r.begin(), r.end()), r.end());

        int duplications = 0;
        for (char fc : f) {  // 𝑶(n * n/2 * n/2)
            if (r.find(fc) != string::npos) duplications++;
        }
        ans = std::max(ans, duplications);
    }

    std::cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const LL INF=1e18;
const int MAXN=60;
const double eps=1e-10;
LL a[MAXN];

int main()
{
    LL n;
    while(scanf("%lld",&n)!=EOF)
    {
        for(int i=1;i<=n;++i)
            scanf("%lld",&a[i]);
        LL* p;
        LL ans=0;
        while(*(p=max_element(a+1,a+n+1))>=n)
        {
            for(int i=1;i<=n;i++)
                if(a+i!=p)
                a[i]+=(*p)/n;
            ans+=(*p)/n;
            (*p)%=n;
        }
        printf("%lld\n",ans);
    }
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


ll f(ll b, ll n){
  if(n<b) return n;
  return f(b,n/b)+n%b;
}


signed main(){
  int n; cin>>n;
  vector<pair<ll, ll> > p(n);
  rep(i,n){
    int x,l; cin>>x>>l;
    pair<ll,ll> q = MP(x,l); p[i]=q;
  }
  sort(ALL(p));
  // rep(i,n) cerr << p[i].first SP p[i].second << endl;

  ll l = p[0].first-p[0].second;
  ll r = p[0].first+p[0].second;
  int ans = n;
  reps(i,n-1){
    ll n_l = p[i].first-p[i].second;
    ll n_r = p[i].first+p[i].second;
    if(r<=n_l) r=n_r;
    else{
      ans--;
      r = min(r,n_r);
    }
  }
  cout << ans << endl;



  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using P = pair<ll,int>;
using G = vector<vector<int>>;
const long long INF = 1LL << 60;

int main(){
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  int ans = 0;
 if(a+b >= c*2){
   if(y >= x){
     if(b > c*2){
       ans = c*2*y;
     }else{
       ans = (2*c) * x + b * (y-x); 
     }
   }else{
     if(a > c*2){
       ans = c*2*x;
     }else{
       ans = (2*c) * y + a * (x-y); 
     }
   }
 }else{
   ans = a*x + b*y;
 } 
 cout << ans <<  endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<ctype.h>
#include<string>
#include<cmath>
#include<string.h>
#include<sstream>
#include<limits.h>
#include<regex>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;

//最大公約数
int gcd(int a,int b){
    return b ? gcd(b,a%b):a;
}

//最小公倍数
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}

//素数判定
bool isPrime(int x){
    if(x<2)return 0;
    else if(x==2)return 1;
    if(x%2==0)return 0;
    for(int i=3;i*i<=x;i+=2){
        if(x%i==0)return 0;
    }
    return 1;
}

//桁ごとの足し算
int digsum(int n){
    int res=0;
    while(n>0){
        res+=n%10;
        n/=10;
    }
    return res;
}

//約数列挙
vector<int> enum_div(int n){
    vector<int> ret;
    for(int i=1;i*i<=n;++i){
        if(n%i==0){
            ret.push_back(i);
            if(i*i !=n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

//累乗の計算とあまり,0で累乗そのまま出力
long long modpow(long long a,long long n,long long mod){
    if(mod==0)mod=__LONG_LONG_MAX__;
    long long res=1;
    while(n>0){
        if(n & 1)res=res*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}

string S,T;
int main(){
    cin>>S>>T;
    int ans=T.size();
    for(int i=0;i<S.size()-T.size()+1;++i){
        string temp=S.substr(i,T.size());
        int count=T.size();
        for(int j=0;j<temp.size();++j){
            if(T[j]==temp[j])count--;
        }
        if(ans>count)ans=count;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define deb(x) cout<<#x<<" "<<x<<endl;
#define print(arr,n) for(int i=0;i<n;++i) { cout<<arr[i]<<" "; } cout<<endl;
#define ub(x,el) upper_bound(x.begin(),x.end(),el) - x.begin()
#define lb(x,el) lower_bound(x.begin(),x.end(),el) - x.begin();
#define bs(x,el) binary_search(x.begin(),x.end(),el)
#define MOD 1000000007
#define finish return 0
using namespace std;
using namespace __gnu_pbds; 
typedef long long int ll;
typedef tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
template<int D, typename T> struct Vec : public vector<Vec<D - 1, T>> { static_assert(D >= 1, "Vector dimension must be greater than zero!"); template<typename... Args> Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) { }}; template<typename T> struct Vec<1, T> : public vector<T> { Vec(int n = 0, T val = T()) : vector<T>(n, val) { } };
inline ll mod(ll x) { return (x%MOD + MOD)%MOD; }
ll power(ll x,ll y, ll p) { ll res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res*x) % p; y = y>>1; x = (x*x) % p;   } return res; } 
ll power(ll x,ll y) { ll res = 1; while (y > 0) { if (y & 1) res = (res*x); y = y>>1; x = (x*x);   } return res; } 
ll mod(ll num, ll den){ return mod(mod(num) * power(den,MOD-2,MOD)); }
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n,m;
	cin>>n>>m;
	ll sum = 0;
	for(ll i=0;i<m;++i) 
	{
		ll x;
		cin>>x;
		sum+=x;
	}
	ll ans = -1;
	ans = max(ans, n-sum);
	cout<<ans<<endl;
}

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

using namespace std;

const int N = 100000 + 5;
int p[N], n;

int main ()
{
	scanf ("%d", &n);
	for (int i = 1; i <= n; ++i)
	{
		int tmp;
		scanf ("%d", &tmp);
		p[tmp] = i;
	}
	for (int i = 1; i <= n; ++i)
		printf ("%d ", p[i]);
	return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>

int A[100000];
#pragma warning( disable:4996 )

int partition(int p, int r)
{
	int i = p - 1;
	int j = 0;
	int x = A[r];
	int temp;

	for (j = 0; j < r; j++)
	{
		if (A[j] <= x)
		{
			i++;
			temp = A[i];
			A[i] = A[j];
			A[j] = temp;
		}
	}
	temp = A[i+1];
	A[i+1] = A[r];
	A[r] = temp;
	return i+1;
}

int main()
{
	int i, n;
	int p;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	p = partition(0, n-1);
	for (i = 0; i < n; i++) {
		if (i) printf(" ");
		if (i == p) {
			printf("[%d]", A[i]);
		}
		else
		{
			printf("%d", A[i]);
		}
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 3108
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#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++)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> v(N);
    rep(i, N) cin >> v[i];

    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    int ans = 0;
    rep(i, K)
    {
        ans += v[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
 
int main(){
  int a, b, n;
  int c, d;
  int dp[17][17];
 
  while(1) {
    cin >> a >> b;
    if(a == 0 && b == 0) break;
 
    for(int i = 0; i < 17; i++)
      for(int j = 0; j < 17; j++)
    dp[i][j] = 0;
 
    cin >> n;
    for(int i = 0; i < n; i++) {
      cin >> c >> d;
      dp[d][c] = -1;
    }
 
    dp[1][1] = 1;
    for(int i = 1; i <= b; i++) {
      for(int j = 1; j <= a; j++) {
    if(i == j && i == 1) continue;
     
    if(dp[i][j] == -1) {
      dp[i][j] = 0;
      continue;
    }
 
    dp[i][j] = dp[i][j-1] + dp[i-1][j];
      }
    }
 
 
    cout << dp[b][a] << endl;
  }
   
  return 0;
}

Measured memory_bytes: 1160
#include <functional>
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <cctype>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <stdio.h>
#include <stack>
#include <ctime>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define TR(i,x) for(__typeof(x.begin()) i=x.begin();i!=x.end();i++)
#define ALL(x) x.begin(),x.end()
#define SORT(x) sort(ALL(x))
#define CLEAR(x) memset(x,0,sizeof(x))
#define FILL(x,c) memset(x,c,sizeof(x))
#define PB push_back
#define MP make_pair

using namespace std;

const double eps = 1e-8;

typedef map<int,int> MII;
typedef map<string,int> MSI;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long double> VD;
typedef pair<int,int> PII;
typedef long long int64;
typedef long long LL;
typedef unsigned int UI;
typedef long double LD;

int main() {
    int n, cnt = 0;
    cin >> n;
    vector<int> nums(n, 0);
    for (int i = 0; i < n; ++i) cin >> nums[i];
    for (int i = 1; i < n - 1; ++i) {
        if (nums[i] > nums[i - 1] && nums[i] < nums[i + 1]) ++cnt;
        if (nums[i] < nums[i - 1] && nums[i] > nums[i + 1]) ++cnt;
    }
    cout<<cnt<<endl;
    return 0;
}


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

#define st first
#define nd second
#define all(x) (x).begin(), (x).end()

using namespace std;
using namespace placeholders;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <class T> void mini(T &l, T r){l = min(l, r);}
template <class T> void maxi(T &l, T r){l = max(l, r);}

template <class TH> void _dbg(const char *sdbg, TH h){cerr << sdbg << "=" << h << "\n";}
template <class TH, class ...TA> void _dbg(const char *sdbg, TH h, TA... a){
	while (*sdbg != ',') cerr << *sdbg++; cerr << "=" << h << ","; _dbg(sdbg + 1, a...);
}
template <class T> ostream &operator <<(ostream &os, vector<T> V){
	os << "["; for (auto vv: V) os << vv << ","; return os << "]";
}
template <class L, class R> ostream &operator <<(ostream &os, pair<L, R> P){
	return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef SFIC
	#define eput(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
	#define eput(...) 218
#endif

const int N = 2E5 + 10;

int n;
int a[N], loc[N];

int main(){
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i){
		scanf("%d", a + i);
		loc[a[i]] = i;
	}
	int ans = 0;
	for (int j, i = 1; i <= n; i = j + 1){
		j = i;
		for (; j < n && loc[j] < loc[j + 1]; ++j);
		ans = max(ans, j - i + 1);
	}
	printf("%d\n", n - ans);
	return 0;
}


Measured memory_bytes: 1792