akhauriyash/Code-Regression huggingface dataset:
n = int(input())
list_A = list(map(int, input().split()))

colors = set()
other = 0
for num in list_A:
    num //= 400
    if num > 7:
        other += 1
    else:
        colors.add(num)

max_value = len(colors) + other
min_value = len(colors)

if len(colors) == 0:
    min_value = 1

print(min_value, max_value)

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"math"
)

func main(){
	var N,a,b,c,d,e float64
	fmt.Scan(&N,&a,&b,&c,&d,&e)
	var human = []float64{a,b,c,d,e}
	M := len(human) 
	Min := human[0]
	for i := 0; i < M; i++ {
		Min = float64(math.Min(float64(Min),float64(human[i])))
	}
	ans := N / Min + 4
	fmt.Println(int(math.Ceil(ans)))
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	ll A, B;
	cin >> A >> B;


	ll ans = (A * B + 1) / 2;
	if (A == 1 || B == 1)
		ans = 1;

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string str;
	cin >> str;
	for (int i = 0; i < str.size(); ++i)
	{
		if (str[i] == 'C')
			for (int j = i + 1; j < str.size(); ++j)
			{
				if (str[j] == 'F')
				{
					cout << "Yes" << endl;
					return 0;
				}
		   }
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
typedef long long ll;
const ll mod=998244353;
const int maxn=1e6;
int a[maxn+5];
int mu[maxn+5];
int prime[maxn+5];
ll inv[maxn+5];
bool valid[maxn+5];
int n;
vector<int> pre[maxn+5];
int sqr(int x)
{
    return 1LL*x*x%mod;
}
int cal(int d,int n)
{
    return sqr(pre[d][min(n,(int)pre[d].size()-1)]);
}
int f(int n,int D)
{
    int ans=0;
    for(int d=1;d<=n;++d)
    {
        ans=(ans+1LL*mu[d]*cal(d*D,n/d)%mod)%mod;
       // cout<<"ce "<<d*D<<" "<<n/d<<" "<<mu[d]*cal(d*D,n/d)<<endl;
    }
    return ans;
}
void init()
{
    inv[0]=inv[1]=1;
    for(int i=2;i<=maxn;++i) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
    int tot=0;
    mu[1]=1;
    memset(valid,true,sizeof(valid));
    for(int i=2;i<=maxn;++i){
        if(valid[i]){
            prime[++tot]=i;
            mu[i]=-1;
        }
        for(int j=1;j<=tot&&prime[j]*i<=maxn;j++){
            valid[i*prime[j]]=false;
            if(i%prime[j]==0){
                mu[i*prime[j]]=0;
                break;
            }
            else{
                mu[i*prime[j]]=-mu[i];
            }
        }
    }
    //for(int i=1;i<=10;++i) cout<<mu[i]<<" ";cout<<endl;
}
int main()
{

    init();
    scanf("%d",&n);
    ll sum=0;
    for(int i=1;i<=n;++i)
    {
        int x;
        scanf("%d",&x);
        sum=(sum+x)%mod;
        ++a[x];
    }
    n=maxn;
    for(int i=1;i<=n;++i) a[i]=1LL*a[i]*i%mod;
   // for(int i=1;i<=n;++i) cout<<a[i]<<" ";cout<<endl;
    for(int d=1;d<=n;++d)
    {
        pre[d].push_back(0);
        for(int i=d;i<=n;i+=d) pre[d].push_back(a[i]);
        int len=pre[d].size();
        for(int i=1;i<len;++i) pre[d][i]=(pre[d][i]+pre[d][i-1])%mod;
    }
   /* for(int i=1;i<=n;++i)
    {
        for(auto x:pre[i]) cout<<x<<" ";cout<<endl;
    }*/
    ll ans=0;
    for(int i=1;i<=n;++i)
    {
       // cout<<n/i<<" : "<<f(n/i,i)<<endl;
        ans=(ans+1LL*inv[i]*f(n/i,i)%mod)%mod;
    }
 //   cout<<ans<<endl;
 ans=(ans-sum)%mod;
    //for(int i=1;i<=n;++i) ans=(ans-1LL*a[i]*a[i]%mod*inv[i]%mod)%mod;
    ans=ans*inv[2]%mod;
    if(ans<0) ans+=mod;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 132844
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()


int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];
  vector<vector<ll>> v(n, vector<ll>());
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    a--; b--;
    v[a].push_back(h[b]);
    v[b].push_back(h[a]);
  }
  ll ans = 0;
  rep(i, n) {
    if (v[i].size() == 0) {
      ans++;
      continue;
    }
    sort(allr(v[i]));
    if (h[i] > v[i][0]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 13016
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for(i=0;i<n;i++)
int main() {
	int n;
	cin>>n; //number given
	if(n<=999) {
		cout<<"ABC\n";
		return 0;
	}
	else {
		cout<<"ABD\n";
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <numeric>
#include <queue>
using namespace std;
#define mod (long)(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
//#define long long long
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<long> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } long C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int main(){
    int N;
    cin >> N;
    int back = 0, ans = 0;
    for(int i = 0; i < N; i++){
        int h;
        cin >> h;
        ans += abs(h - back);
        back = h;
    }
    cout << (ans + back) / 2 << endl;
}


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

int main()
{
    while(1){
        int a, b;
        cin >> a >> b;
        if(a == 0 && b == 0) break;
        
        if(a > b) swap(a, b);
        cout << a << " " << b << endl;
    }
    return 0;
}


Measured memory_bytes: 3096
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] ans = new int[n];
    for(int i = 1; i < n; i++) {
      int a = sc.nextInt() - 1;
      ans[a]++;
    }
    for(int i = 0; i < n; i++) {
      System.out.println(ans[i]);
    }
  }
}

Measured memory_bytes: 69768
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>

using namespace std;

typedef pair<int,int> pii;
struct Situation{
public:
  pii cost;
  int node;
  int rev;
  Situation(pii cost_,int node_,int rev_){
    cost=cost_;
    node=node_;
    rev=rev_;
  }
  Situation();
  bool operator<(const Situation &s)const{
    return s.cost<this->cost;
  }
};

const int INF=1000000000;
const int MAX_V=1001;

vector<int> G[MAX_V];
vector<int> revG[MAX_V];
pii d[MAX_V][2];
int EdgeNum[MAX_V][MAX_V];
pii prevv[MAX_V][2];
void dijkstra(int s){
  priority_queue<Situation> que;
  for(int i=0;i<MAX_V;i++){
    for(int j=0;j<2;j++){
      d[i][j].first=INF;d[i][j].second=0;
      prevv[i][j].first=prevv[i][j].second=-1;
    }
  }
  d[s][0].first=0;
  que.push(Situation(pii(0,0),s,0));
  while(que.size()){
    Situation p=que.top();que.pop();
    int node=p.node;
    pii cost=p.cost;
    int rev=p.rev;
    if(d[node][rev]<cost)continue;
    for(int i=0;i<G[node].size();i++){
      int to=G[node][i];
      if(d[to][rev].first>d[node][rev].first+1){
	d[to][rev].first=d[node][rev].first+1;
	d[to][rev].second=d[node][rev].second;
	que.push(Situation(d[to][rev],to,rev));
	prevv[to][rev]=pii(node,rev);
      }
      else if(d[to][rev].first
	      ==d[node][rev].first+1){
	if(d[to][rev].second>d[node][rev].second){
	  d[to][rev].second=d[node][rev].second;
	  que.push(Situation(d[to][rev],to,rev));
	  prevv[to][rev]=pii(node,rev);
	}
      }
    }
    if(!rev){
      for(int i=0;i<revG[node].size();i++){
	int to=revG[node][i];
	if(d[to][rev^1].first>d[node][rev].first+1){
	  d[to][rev^1].first=d[node][rev].first+1;
	  d[to][rev^1].second=EdgeNum[to][node];
	  que.push(Situation(d[to][rev^1],to,rev^1));
	  prevv[to][rev^1]=pii(node,rev);
	}
	else if(d[to][rev^1].first
		==d[node][rev].first+1){
	  if(d[to][rev^1].second>EdgeNum[to][node]){
	    d[to][rev^1].second=EdgeNum[to][node];
	    que.push(Situation(d[to][rev^1],to,rev^1));
	    prevv[to][rev^1]=pii(node,rev);
	  }
	}
      }
    }
  }
}

int N,M;
int S,T;
int main(){

  while(cin>>N&&N){
    for(int i=0;i<N;i++){
      G[i].clear();
      revG[i].clear();
    }
    cin>>S>>T;
    S--;T--;
    cin>>M;
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++)
	EdgeNum[i][j]=INF;
    for(int i=0;i<M;i++){
      int a,b;
      cin>>a>>b;
      a--;b--;
      G[a].push_back(b);
      revG[b].push_back(a);
      EdgeNum[a][b]=min(EdgeNum[a][b],i+1);
      EdgeNum[b][a]=min(EdgeNum[b][a],i+1);
    }
    dijkstra(S);
    pii res=min(d[T][0],d[T][1]);
    cout<<res.first<<" "<<res.second<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 5240
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
#include <iomanip>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
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> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
//template< typename T >
//T mod_pow(T x, T n, const T &p) {
//  T ret = 1;
//  while(n > 0) {
//    if(n & 1) (ret *= x) %= p;
//    (x *= x) %= p;
//    n >>= 1;
//  }
//  return ret;
//}
/////////////////// 
//

#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
#define mp make_pair
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
//
//
//

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  int b[4];
  rep(i,4) cin >> b[i];
  sort(b,b+4);
  if(b[0]==1&&b[1]==4&&b[2]==7&&b[3]==9) pri("YES");
  else pri("NO");
  return 0;
}







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


// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3") 
// #pragma GCC optimization ("unroll-loops")
 
#define ll  long long int
#define all(v) v.begin(),v.end()
#define pb push_back
#define S second
#define F first
#define die() return 0;
 
#define MD          1000000007
#define M           1000011
#define N 			20
long long  md=MD;

int solve(){
	int n,i,j,k,m;
	cin>>n>>k;
	vector<int> v;
	set<int> a,b;
	for(i=0;i<n;++i){
		int x;
		cin>>x;v.pb(x);
	}
	int ans=(n-k+1);

	vector<int> aa(n,1),bb(n,1);
	int c=0,cp=1;
	if(cp>=k)++c;
	for(i=1;i<n;++i){
		if(v[i]>v[i-1])++cp;
		else cp=1;
		if(cp>=k)++c;
		aa[i]=c;
	}
	// cerr<<aa[n-1]<<"\n";
	ans=n-k+1-max(aa[n-1]-1,0);
	for(i=0;i<k;++i)a.insert(v[i]),b.insert(-v[i]);
	i=k;
	vector<int> in(n);
	in[0]=1;
	for(i=1;i<n;++i){
		in[i]=1;
		if(v[i]>v[i-1])in[i]=in[i-1]+1;
	}
	i=k;
	while(i<n){
		int nx=v[i];
		int mx=abs(*b.begin());
		int mn=abs(*a.begin());
		// cerr<<mx<<" "<<mn<<" "<<i<<" "<<nx<<"\n";
		if(in[i-1]-in[i-k]<k-1&&v[i-k]==mn&&nx>mx)--ans;
		b.erase(b.find(-v[i-k]));
		a.erase(a.find(v[i-k]));
		a.insert(nx);
		b.insert(-nx);
		++i;

	}
	assert(ans>=1);
	cout<<ans<<"\n";


}


int main(){

 
     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t;
    t=1;
    // cin>>t;

    while(t--){
    	solve();
    }
    die();



    

}



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


def solve(A: int, B: int):
    ans = [1, 2, 3]
    ans.remove(A)
    ans.remove(B)
    print(ans[0])
    


# 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()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  prllf("%d",x);
#define pl(x)  prllf("%lld",x);
#define pf(x)  prllf("%.10lf",x);
#define ps(x)  prllf("%s",x);
#define en() prllf("\n");
#define random_shuffle(r...)random_shuffle(r,[](int _){return rand()%_;})
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}

int main()
{

  string s,t;
  cin>>s;
  cin.ignore();
  cin>>t;
  cout<<t+s<<endl;


}


Measured memory_bytes: 256
n,m = map(int,input().split())
l = []
r = []

while True:
  try:
    tl,tr = map(int,input().split())
    l.append(tl)
    r.append(tr)
  except:
    break

R = min(r)
L = max(l)
cnt = 0
for i in range(1,n+1):
  if i>=L and i<=R:
    cnt +=1
    
print(cnt)
    

Measured memory_bytes: 10996
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  srep(i,1,10) {
    if(N % i == 0 && N / i < 10) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int x= 0;
    int y= 0;

    for (x = 1; x<=9; x++)
    {
        for (y = 1; y<=9; y++)
        cout << x << "x" << y << "=" << x*y << endl;
    }

    return 0;
}

Measured memory_bytes: 2980
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = 1001001001;
using namespace std;


int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) a[i]--;
    vector<int> s(n+1);
    rep(i, n) {
        s[i+1] = (s[i] + a[i]) % k;
    }
    map<int, int> mp;
    ll ans = 0;
    queue<int> q;
    rep(j, n+1) {
        ans += mp[s[j]];
        mp[s[j]]++;
        q.push(s[j]);
        if (q.size() == k) {
            mp[q.front()]--;
            q.pop();
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 12032
#include <algorithm>
#include <cmath>
#include <iostream>

using namespace std;

int main() {
  int A, B, C, K;
  cin >> A >> B >> C;
  cin >> K;

  const long long M = max({A, B, C});
  const long long rest = A + B + C - M;
  const long long ans = M * pow(2, K) + rest;
  cout << ans << endl;

  return 0;
}


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

int main() {
  int N,L;
  cin >> N >> L;
  vector<string> s(N);
  for(int i=0;i<N;i++) {
    cin >> s[i];
  }
  sort(s.begin(),s.end());
  string ans;
  for(int i=0;i<N;i++) {
    ans += s[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t x,y,cnt=0,count=0;
  cin >> x >> y;
  int64_t ans=x;
  while(ans<=y){
    ans*=2;
    cnt++;
  }
  ans=x;
  while(ans<=y){
    ans*=3;
    count++;
  }
  cout << max(count,cnt) << endl;
}
  

Measured memory_bytes: 3524
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i < n; i++) cin >> a[i];
    int dp[n];
    int relax[n];
    for (int i=0; i < n; i++){
        dp[i] = a[i];
        relax[i] = -1;
    }
    for (int i=0; i < n; i++){
        for (int j=i-2; j >= 0; j-=2){
            if (a[i] + dp[j] > dp[i]){
                dp[i] = a[i] + dp[j];
                relax[i] = j;
            }
        }
    }
    int an = -1e18, wh = -1;
    for (int i=0; i < n; i++){
        if (dp[i] > an){
            an = dp[i];
            wh = i;
        }
    }
    cout << an << endl;
    vector<int> val;
    int now = wh;
    while (now!=-1){
        val.push_back(now);
        now = relax[now];
    }
    int mn = 0;
    vector<int> ans;
    reverse(val.begin(), val.end());
    for (int i=0; i < val[0]; i++){
        ans.push_back(i - mn);
        mn++;
    }
    for (int i=0; i < val.size() - 1; i++){
        int A = val[i] + 1;
        int B = val[i+1] - 1;
        int pos = A+1-mn;
        while (B!=A){
            ans.push_back(pos);
            mn += 2;
            B-=2;
        }
        ans.push_back(pos-1);
        mn += 2;
    }
    for (int i=n-1; i >= val.back() + 1; i--){
        ans.push_back(i - mn);
    }
    cout << ans.size() << endl;
    for (int i=0; i < ans.size(); i++) cout << ans[i] + 1 << endl;
    return 0;
}


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

int N, F[100001];

int main(){
	int current = 0;
	long long result = 1;
	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		int val;
		scanf("%d", &val);
		F[val]++;
	}
	if(N % 2 == 0) current++;
	while(current < N){
		if((current != 0 && F[current] == 2) || (current == 0 && F[current] == 1))
			result *= F[current], result %= 1000000007, current += 2;
		else{
			printf("0\n");
			return 0;
		}
	}
	printf("%lld\n", result);
	return 0;
}


Measured memory_bytes: 768
#include<stdio.h>
int main(void)
{
	int A = 0, B = 0, C = 0, RESULT = 0, day = 0, coin = 0;

	scanf("%d%d%d", &A, &B, &C);

	while (C > coin)
	{
		RESULT++;
		day++;
		coin += A;

		if (day == 7)
		{
			day = 0;
			coin += B;
		}
	}

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

	return 0;
}


Measured memory_bytes: 2756
/* 
	Author: ankrypt
*/

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

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)

ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;


int main() {
	scanf("%lld %lld", &N, &M);
	if(M >= N) {
		printf("unsafe\n");
	}	
	else {
		printf("safe\n");
	}
	return 0;
}
/*
	Powered by Buggy Plugin
*/




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

int main() {
  int N;
  cin >> N;
  int min_count=10000;
  for(int i=0; i<N; i++){
    int64_t x;
    cin >> x;
    int count=0;
    while(x%2==0){
      count++;
      x/=2;
    }
    if(count<min_count)
      min_count=count;
  }
  cout << min_count << endl;
}


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

int main(){
    vector<int> time;
    vector<int> reminder;
    int in;
    for(int i=0;i<5;i++){
        cin>>in;
        time.push_back(in);
    }
    int min=10; int min_index=0;
    for(int i=0;i<5;i++){
        reminder.push_back(time[i]%10);
        if(reminder[i]!=0&&reminder[i]<min){
            min=reminder[i];
            min_index=i;
        }
    }
    int res=0;
    for(int i=0;i<5;i++){
        if(i==min_index)
            res+=time[i];
        else if(reminder[i]==0)
            res+=time[i];
        else res+=time[i]+10-reminder[i];
    }
    
    cout<<res<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <string.h>
int main()
{
	char a[4];
	int i;
	gets(a);
	
	if(!strcmp(a, "abc")){
		printf("Yes");
	}
	else if(!strcmp(a, "acb")){
		printf("Yes");
	}
	else if(!strcmp(a, "bac")){
		printf("Yes");
	}
	else if(!strcmp(a, "bca")){
		printf("Yes");
	}
	else if(!strcmp(a, "cab")){
		printf("Yes");
	}
	else if(!strcmp(a, "cba")){
		printf("Yes");
	}
	else{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#define ms(a) memset(a,'\0',sizeof(a))

int x,y,ans,l,p,m;
char map[105][105];
int dir[][2]={{0,1},{1,0},{0,-1},{-1,0}};

/*法1
void dfs(int xx,int yy,char c)
{
	if(xx>=0 && xx<x && yy>=0 && yy<y && map[xx][yy]==c)
	{
		map[xx][yy]='.';
	}
	else
		return ;
	dfs(xx-1,yy,c);
	dfs(xx+1,yy,c);
	dfs(xx,yy+1,c);
	dfs(xx,yy-1,c);
}
*/
//法2
void dfs(int xxx,int yyy,char c)
{
	int yy=yyy,xx=xxx;
	for(int i=0;i<4;i++)
	{
		xx=xxx+dir[i][0];
		yy=yyy+dir[i][1];
		if(xx>=0 && xx<x && yy>=0 && yy<y && map[xx][yy]==c)
		{
			map[xx][yy]='.';
			dfs(xx,yy,c);
		}
	}
}

int main()
{
	//freopen("Aizu0118.txt","r",stdin);
	scanf("%d %d",&x,&y);
	while(!(x==0&&y==0))
	{
		l=p=m=0;
		ans=0;
		getchar();
		for(int i=0;i<x;i++)
		{
			gets(map[i]);
		}
		for(int i=0;i<x;i++)
		{
			for(int j=0;j<y;j++)
			{
				if(map[i][j]!='.')
				{
					dfs(i,j,map[i][j]);
					ans++;
				}
			}
		}
		printf("%d\n",ans);
		scanf("%d %d",&x,&y);
	}
	return 0;
}

Measured memory_bytes: 1508
import itertools

N, X, Y = map(int, input().split())
lst = [0] * N
for l, r in itertools.combinations(range(1, N + 1), 2):
    lst[min(r - l, abs(r - Y) + 1 + abs(l - X))] += 1
for i in range(1, N):
    print(lst[i])


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
int x[20][20],y[20][20],a[20],check[20];
int main(){
    int n,ans = 0;
    cin>>n;
    rep(i,n){
        cin>>a[i];
        rep(j,a[i]){
            cin>>x[i][j]>>y[i][j];
        }
    }
    rep(i,pow(2,n)){
        int cnt = 0;
        bool flag = true;
        rep(j,n){
            if(i & (1 << j))check[j] = 1;
            else check[j] = 0;
        }
        rep(j,n){
            if(i & (1 << j)){
                rep(k,a[j]){
                    if(check[x[j][k]-1] != y[j][k]){
                        flag = false;
                        break;
                    }
                }
                if(!flag)break;
            }
        }
        rep(j,n)if(check[j] == 1)cnt++;
        if(flag)ans = max(ans,cnt);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;

namespace A_Garden
{
    class Program
    {
        static void Main(string[] args)
        {
            string num = Console.ReadLine();
            char separator = ' ';
            string[] splited = num.Split(separator);

            int a = int.Parse(splited[0]);
            int b = int.Parse(splited[1]);
            int ans;

            ans = a * b - a - b + 1;
            Console.WriteLine(ans);


        }
    }
}


Measured memory_bytes: 11092
import sys

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

N, K = rl()
max = (N-1) * (N-2) // 2
if K > max:
    print(-1)
    exit()
edges = []
for i in range(2, N+1):
    edges.append((1, i))
count = max - K
for i in range(2, N):
    if count == 0:
        break
    for j in range(i+1, N+1):
        if count == 0:
            break
        edges.append((i, j))
        count -= 1
print(len(edges))
for x in edges:
    print(*x)



Measured memory_bytes: 3992
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; scanf("%d", &N);
    vector<ll> A(N), B(N);
    vector< pair<ll, ll> > rec;
    for(int i=0; i<N; i++) {
        scanf("%lld%lld", &A[i], &B[i]);
        rec.emplace_back(A[i], i);
        rec.emplace_back(B[i], i);
    }
    sort(rec.begin(), rec.end());

    ll ans = LONGINF;
    chmin(ans, accumulate(A.begin(), A.end(), 0LL));
    chmin(ans, accumulate(B.begin(), B.end(), 0LL));
    ll sum = 0;
    for(int i=0; i<N; i++) sum += rec[i].first;

    vector<ll> cnt(N), dec(N);
    for(int i=0; i<N; i++) {
        cnt[ rec[i].second ]++;
        dec[ rec[i].second ] += rec[i].first;
    }

    if(*max_element(cnt.begin(), cnt.end()) >= 2) {
        chmin(ans, sum);
    }
    else {
        for(int i=0; i<N; i++) {
            int idx = rec[N].second == i ? N+1 : N;
            ll cand = sum - dec[i] + rec[idx].first;
            chmin(ans, cand);
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 8048
/*
Author : N_o_o_B
Created : April 22 2020 16:15:10 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int n;
    cin >> n;
    int x;
    cin >> x;
    vi a(n);
    fori(i,n) {
        cin >> a[i];
    }
    sort(all(a));
    int ans = 0;
    fori(i,n){
        if(x>=a[i]) {x -= a[i];ans++;}
        else x = 0;
    }
    if(x) ans--;
    cout << ans << endl;


    time_taken();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

vector<string> s;
vector< vs32 > ans;
int a = 1;

void solve(int l, int r, int b, int t)
{
    vs32 row;
    vs32 col;
    for (int i = b; i < t; ++i)
    {
        for (int j = l; j < r; ++j)
        {
            if (s[i][j] == '#')
            {
                row.push_back(i);
                break;
            }
        }
    }

    for (int j = l; j < r; ++j)
    {
        for (int i = b; i < t; ++i)
        {
            if (s[i][j] == '#')
            {
                col.push_back(j);
                break;
            }
        }
    }

    if (row.size() == 1 && col.size() == 1)
    {
        for (int i = b; i < t; ++i)
        {
            for (int j = l; j < r; ++j)
            {
                ans[i][j] = a;
            }
        }
        ++a;
        return;
    }

    if (col.size() > row.size())
    {
        int m = col[col.size() / 2];
        solve(l, m, b, t);
        solve(m, r, b, t);
    }
    else
    {
        int m = row[row.size() / 2];
        solve(l, r, b, m);
        solve(l, r, m, t);
    }
}

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

    int H, W, K;
    cin >> H >> W >> K;
    s.resize(H);
    rep (i, H)
    {
        cin >> s[i];
    }

    ans.resize(H, vs32(W));
    solve(0, W, 0, H);

    rep (i, H)
    {
        rep (j, W)
        {
            cout << ans[i][j] << " ";
        }
        cout << "\n";
    }
    return 0;
}



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

int main() {
  string S;
  cin >> S;
  
  if(S.at(0) == S.at(1))
    cout << "Bad" << endl;
    
  else if(S.at(1) == S.at(2))
    cout << "Bad" << endl;
    
  else if(S.at(2) == S.at(3))
    cout << "Bad" << endl;
  
  else
    cout << "Good" << endl;
}


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

using namespace std;

int main() {

    string s;
    cin>>s;
    
    if(s.compare("ABC") == 0) {
        cout<<"ARC";
    }
    else {
        cout<< "ABC";
    }

}



Measured memory_bytes: 3536
def num():
    return int(input())

def nums():
    return list(map(int,input().split()))

#A
"""
M1,D1 = nums()
M2,D2 = nums()
print(int(M1 != M2))
"""
#B
import math
N = num()
without_tax = N / 1.08
if int(int(without_tax) * 1.08) == N:
    print(int(without_tax))
elif int(math.ceil(without_tax) * 1.08) == N:
    print(math.ceil(without_tax))
else:
    print(":(")

Measured memory_bytes: 3060
x1,y1,x2,y2 = map(int,input().split())
x3 = x2 - (y2-y1)
y3 = y2 + (x2-x1)
x4 = x3 - (y3-y2)
y4 = y3 + (x3-x2)
print(x3, y3, x4, y4)


Measured memory_bytes: 2940
/* long long or int & the MAX_INT or MIN_INT */
/* the size of a[] & inline */
/* xx 396 */

#include<bits/stdc++.h>
using namespace std;

string S,T;
int ans=0;

signed main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>S>>T; 
	for(int i=0;i<3;i++)
		if(S[i]==T[i]) ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

    int a[3], min;

    scanf("%d%d%d",&a[0],&a[1],&a[2]);

    min = a[0] + a[1];

    for ( int i = 0; i < 2; i++ ){
        if ( min > a[i] + a[2]) min = a[i] + a[2];
    }

    printf("%d\n",min);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define int long long
using namespace std;
typedef pair<int,int> P;
template <typename T,typename E> //SegmentTree((要素数) int n_,(演算) F f,(更新) G g,(初期値) T d1)
struct SegmentTree{
  typedef function<T(T,T)> F;
  typedef function<T(T,E)> G;
  int n;
  F f;
  G g;
  T d1;
  E d0;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(int n_,F f,G g,T d1,
	      vector<T> v=vector<T>()):
    f(f),g(g),d1(d1){
    init(n_);
    if(n_==(int)v.size()) build(n_,v);
  }
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.clear();
    dat.resize(2*n-1,d1);
  }
  void build(int n_, vector<T> v){
    for(int i=0;i<n_;i++) dat[i+n-1]=v[i];
    for(int i=n-2;i>=0;i--)
      dat[i]=f(dat[i*2+1],dat[i*2+2]);
  }
  void update(int k,E a){
    k+=n-1;
    dat[k]=g(dat[k],a);
    while(k>0){
      k=(k-1)/2;
      dat[k]=f(dat[k*2+1],dat[k*2+2]);
    }
  }
  inline T query(int a,int b){
    T vl=d1,vr=d1;
    for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[(l++)-1]);
      if(r&1) vr=f(dat[(--r)-1],vr);
    }
    return f(vl,vr);
  }
  
};

signed main(){
    int N;cin>>N;
    vector<int> h(N);
    REP(i, N) cin >> h[i];
    vector<int> a(N);
    REP(i, N) cin >> a[i];
    vector<int> dp(N+1,0);
    SegmentTree<int,int> seg(N+1,[](int x,int y){return max(x,y);},[](int x,int y){return x+y;},0);
    REP(i,N){
        dp[h[i]]=max(dp[h[i]],seg.query(0,h[i])+a[i]);
        seg.update(h[i],dp[h[i]]);
    }
    int ans=0;
    REP(i,N+1) ans=max(ans,dp[i]);
    cout<<ans<<endl;
}


Measured memory_bytes: 9088
N=int(input())
ans=N
for i in range(N+1):
    cnt=0
    s=i
    while s>0:
        cnt+=s%6
        s//=6
    n=N-i
    while n>0:
        cnt+=n%9
        n//=9
    ans=min(ans,cnt)
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
vector<ll> dp(100001,10000000000);
int main(){
	int n,k;
	cin>>n>>k;
	ll a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	
	dp[0]=0;
	for(int i=1;i<n;i++){
		int j=max(0,i-k);
		while(j<i){
			dp[i]=min(dp[j]+abs(a[i]-a[j]),dp[i]);
			j++;
		}
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
typedef pair<ll,ll> P;

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

template<class T>
bool umax(T &a, const T &b){
    if (a<b) {
        a=b; return 1;
    }
    return 0;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b<a) {
        a=b; return 1;
    }
    return 0;
}

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


int dx[5]={1,0,-1,0};
int dy[5]={0,1,0,-1};
// v.front() = -BOUND;
// v.back() = BOUND;
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }
    // 素数である
    return true;
}

int d[127];
int main() {
    int N;
    int ans=0;
    int p[100005];
    cin >> N;
    for(int i=1; i<=N; i++){
        cin >> p[i];
    }

    for(int i=1; i<=N; i++){
        int temp;
        if(p[i]==i && i!=N){
            temp=p[i];
            p[i+1]=p[i];
            p[i]=temp;
            ans++;
        }else if(p[i]==i && i==N){
            ans++;
        }
    }

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


Measured memory_bytes: 640
#include <stdio.h>

int main() {

  int i,j,k,c;
  int  a[101],flag;
  int t,n,minj;

  scanf("%d",&n);

  for(i=0;i<n;i++) {

    scanf("%d",&a[i]);

  }

  c = 0;
  
  for(i=0;i<=n-1;i++) {
    minj = i;
    flag = 0;

    for(j=i; j<=n-1; j++) {
      if(a[j] < a[minj]) {
	minj = j;
	flag = 1;
	
      }
    }

    if(flag == 1) {
      t = a[i];
      a[i] = a[minj];
      a[minj] = t;
      c++;
      
    }


  }
 








  for(i = 0; i<n;i++) {

    printf("%d",a[i]);

    if(i != n-1) printf(" ");

  }

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

  return 0;



}

Measured memory_bytes: 604
from collections import deque
n, m, k = map(int, input().split())
sx, sy, gx, gy = map(int, input().split())
INF = float("inf")
d = [[INF] * m for _ in range(n)]
t = [[] for i in range(n)]
for i in range(n):
    a = list(input())
    t[i] = a
 

sx, sy, gx, gy = sx - 1, sy - 1, gx - 1, gy - 1
 
 
def bfs():
    que = deque()
    que.append((sx, sy))
    d[sx][sy] = 0
 
    while len(que):
        x, y = que.popleft()
        if x == gx and y == gy:
            break
        for dx, dy in [(0, 1), (1, 0), (-1, 0), (0, -1)]:
            for i in range(1, k + 1):
                nx, ny = x + i * dx, y + i * dy
                if not 0 <= nx < n or not 0 <= ny < m or t[nx][ny] != "." or d[nx][ny] <= d[x][y]:
                    break
                else:
                    if d[nx][ny] > d[x][y] + 1:
                        d[nx][ny] = d[x][y] + 1
                        que.append((nx, ny))
 
    return d[gx][gy]
 
 
ans = bfs()
if ans == INF:
    print(-1)
else:
    print(ans)

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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

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

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}


// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
    char c;
    cin >> c;
    char d = c + 1;
    cout << d << endl;
}
// Driver Function
int main()
{
    ll compte = 1;
    //test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define mod 1000000007
#define N 200010
using namespace std;
int ans[N], a[N], b[N];
char s[N];
int r[N][27], l[N][27];
int main()
{
    int i, j, n, t, cur, cnt, len;
    int now[27];
    scanf("%s", s + 1);
    len = strlen(s + 1);
    n = len / 2;
    for(i = 1; i <= n; ++i) swap(s[i], s[len - i + 1]);
    for(i = 1; i <= len; ++i) a[i] = s[i] - 'a' + 1;
    for(i = 1; i <= 26; ++i) now[i] = len + 1;
    for(i = len; i >= 0; --i)
    {
        for(j = 1; j <= 26; ++j)
            r[i][j] = now[j];
        now[a[i]] = i;
    }
    for(i = 1; i <= 26; ++i) now[i] = 0;
    for(i = 1; i <= len + 1; ++i)
    {
        for(j = 1; j <= 26; ++j)
            l[i][j] = now[j];
        now[a[i]] = i;
    }
    cur = cnt = 0;
    while(cur != len + 1)
    {
        b[++cnt] = cur;
        t = 0;
        for(i = 1; i <= 26; ++i)
            t = max(t, r[cur][i]);
        cur = t;
    }
    cur = len + 1;
    for(i = cnt; i >= 1; --i)
    {
        for(j = 1; j <= 26; ++j)
        {
            if(l[cur][j] <= b[i])
            {
                ans[cnt - i + 1] = j;
                cur = l[cur][j];
                break;
            }
        }
    }
    for(i = 1; i <= cnt; ++i)
        printf("%c", ans[i] + 'a' - 1);
    printf("\n");
    return 0;
}
/*
abcdefghijklmnopqrstuvwxyzab
*/


Measured memory_bytes: 44032
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define rg register
#define int long long
const int MAXN = 300010;
inline int read() {
    int s = 0; bool f = false; char c = getchar();
    while (c < '0' || c > '9') f |= (c == '-'), c = getchar();
    while (c >= '0' && c <= '9') s = (s << 3) + (s << 1) + (c ^ 48), c = getchar();
    return f ? -s : s;
}
char num[MAXN]; int bo[10], f[MAXN], g[MAXN];
int p, m, s[MAXN], s1[MAXN], gap, pos[MAXN];
struct Ask { int l, r, id; } q[MAXN];
inline bool cmp(const Ask& x, const Ask& y)
{ return pos[x.l] == pos[y.l] ? x.r < y.r : x.l < y.l; }
int ans, res[MAXN], cnt[MAXN];
inline void upt(int x, int v) {
    ans -= cnt[x] * (cnt[x] - 1) / 2;
    cnt[x] += v;
    ans += cnt[x] * (cnt[x] - 1) / 2;
}
signed main() {
    int n;
    n = read();
    p = read();
    scanf("%s", num + 1);
    n = strlen(num + 1);
    if (p != 2 && p != 5) {
        m = 1;
        for (rg int i = 1; i <= m; ++i)
            q[i].l = 1, q[i].r = n + 1, q[i].id = i;
        gap = sqrt(n * 1.0);
        pos[n + 1] = n / gap + 1;
        for (rg int c = 1, i = n; i >= 1; --i, c = c * 10 % p) {
            s1[i] = s[i] = ((num[i] ^ 48) * c % p + s[i + 1]) % p;
            pos[i] = (i - 1) / gap + 1;
        }
        std :: sort(s1 + 1, s1 + 2 + n);
        int t = std :: unique(s1 + 1, s1 + 2 + n) - s1 - 1;
        for (rg int i = 1; i <= n + 1; ++i)
            s[i] = std :: lower_bound(s1 + 1, s1 + 1 + t, s[i]) - s1;
        std :: sort(q + 1, q + 1 + m, cmp);
        for (rg int l = 1, r = 0, i = 1; i <= m; ++i) {
            while (l < q[i].l) upt(s[l++], -1);
            while (l > q[i].l) upt(s[--l], 1);
            while (r < q[i].r) upt(s[++r], 1);
            while (r > q[i].r) upt(s[r--], -1);
            res[q[i].id] = ans;
        }
        for (rg int i = 1; i <= m; ++i) printf("%lld\n", res[i]);
    } else {
        if (p == 2) bo[0] = bo[2] = bo[4] = bo[6] = bo[8] = 1;
        if (p == 5) bo[0] = bo[5] = 1;
        for (rg int i = 1; i <= n; ++i) {
            f[i] = f[i - 1] + bo[num[i] ^ 48];
            g[i] = g[i - 1] + bo[num[i] ^ 48] * i;
        }
        m = 1;
        for (rg int l, r, i = 1; i <= m; ++i) {
            l = 1, r = n;
            printf("%lld\n", g[r] - g[l - 1] - (f[r] - f[l - 1]) * (l - 1));
        }
    }
    return 0;
}

Measured memory_bytes: 14848