akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

//1
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){

ios::sync_with_stdio(false);
cin.tie(0);
long long int n;
cin>>n;

long long int b[n]={};
long long int a[n+1]={};

for(int i=1;i<n;i++){
cin>>b[i];
}

for(int i=1;i<n+1;i++){
if(i==1){
a[i]=b[i];
}else if(i==(n)){
a[i]=b[i-1];
}else{
a[i]=min(b[i],b[i-1]);

}

}
long long int al=0;
for(int i=0;i<n+1;i++){
al+=a[i];
}
cout<<al<<endl;

}



//cout << fixed << setprecision(5) <<(n*2)*M_PI << endl;



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  ll n, k, q;
  cin >> n >> k >> q;
  vector<ll> a(q);
  vector<ll> p(n, k);
  rep(i, q) {
    ll x;
    cin >> x;
    p[x-1]++;
  }
  rep(i, n) {
    string ans = (p[i] - q) > 0 ? "Yes" : "No";
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std ;
int main(){
  int N;
  cin >>N;
  long long ans = 0;
  for(int i = 1;i<=N;i++){
    if(i%3 != 0 && i%5 != 0){
      ans += i;
    }
  }
  cout<<ans<<endl;
}
  


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define MODB 998244353
#define INF 9223372036854775807

signed main()
{
  int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >> x>>y;
rep(i,y-x){
  z+=i;
}
std::cout << z-x << '\n';
}


Measured memory_bytes: 256
n,k = [int(i) for i in input().split()]

mod = n
qtdMin = 1/n
mid = 1
while(mod<k):
    mod<<=1
    qtdMin*=0.5
    mid<<=1
    
res = 0

for i in range(k,n):
    res += (1/n)

mod = qtdMin
res+=mod

for i in range(min(n,k)-1,0,-1):
    if(i*mid < k):
        mod*=0.5
        mid<<=1
    res+= mod
print(res)
    


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<long long> a(n+1);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    a[n] = LLONG_MAX;
    sort(a.begin(),a.end());
    int ans = 0,co = 1;
    for(int i = 0; i < n; i++)
    {
        if (a[i] == a[i+1]) {
            co++;
        }
        else
        {
            ans += co%2LL;
            co = 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define PI 2.0*acos(0.0)
#define ll              long long int
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        ((a)*(b))/gcd(a,b)
#define MOD             1000000007
#define mx              123456789
using namespace std;
int main()
{
    ll a, b, c, d, n, m, i, j, k, l;
    cin>>a>>b>>c>>d;
    int ok;
    ll res=ceil(c/(b*1.0));
    //cout<<res<<endl;
    ll res1=ceil(a/(d*1.0));
    //cout<<res1<<endl;
    if(res1>=res)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


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

using namespace std;

const int N = (int)3005;

long double arr[N];
long double dp[N][N];

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

    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
    }

    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= i; j++) {
            if (j > 0) {
                dp[i][j] += dp[i-1][j-1] * arr[i];
            }
            dp[i][j] += dp[i-1][j] * (1.00000 - arr[i]);
        }
    }

    long double ans = 0.0;

    for (int i = n/2+1; i <= n; i++) {
        ans += dp[n][i];
    }
    printf("%.15Lf",ans);
    return 0;
}




Measured memory_bytes: 139264
package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()

	for n := N; true; n++ {
		flg := false
		for k := 2; k*k <= n; k++ {
			if n%k == 0 {
				flg = true
				break
			}
		}
		if !flg {
			fmt.Println(n)
			return
		}
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include<iostream>
#include <math.h>
using namespace std;

int S(int n) {
    int s=0;
    while (n != 0) {
        s += n % 10;
        n = n / 10;
    }
    return s;
}

int main() {
    int n;

    cin >> n;

    if (n%S(n) == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


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

vector<long long> ve;
vector<long long>::iterator it,llit,lgit,rlit,rgit;
long long taml[4],tamm[4],tamr[4];
long long waru3(long long a){
	if(a%3==2) return a/3+1;
	else return a/3;
}
int main(){
	int N;
	long long hog,mns,res,S,S1_3,S2_3;
	ve.push_back(0);
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>hog;
		ve.push_back(ve[i]+hog);
	}
	S=ve[N];
	ve.pop_back();
	S1_3=waru3(S);
	S2_3=waru3(S*2);
	mns=res=0;
	for(int i=0;i<N;i++){
		hog=ve[0]+S;
		mns+=ve[1]-ve[0];
		ve.erase(ve.begin());
		ve.push_back(hog);
		lgit=lower_bound(ve.begin(),ve.end(),S1_3+mns);
		llit=lgit--;
		rgit=lower_bound(ve.begin(),ve.end(),S2_3+mns);
		rlit=rgit--;
		taml[0]=(*lgit)-mns;
		taml[1]=(*llit)-mns;
		taml[2]=(*lgit)-mns;
		taml[3]=(*llit)-mns;
		tamm[0]=(*rgit)-(*lgit);
		tamm[1]=(*rgit)-(*llit);
		tamm[2]=(*rlit)-(*lgit);
		tamm[3]=(*rlit)-(*llit);
		tamr[0]=S+mns-(*rgit);
		tamr[1]=S+mns-(*rgit);
		tamr[2]=S+mns-(*rlit);
		tamr[3]=S+mns-(*rlit);
		for(int j=0;j<4;j++){
			//cout<<i<<" "<<j<<" "<<taml[j]<<" "<<tamm[j]<<" "<<tamr[j]<<endl;
			res=max(res,min(min(taml[j],tamr[j]),tamm[j]));
		}
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 2076
n = int(input())
a = list(map(int, input().split()))

flg = True
for i in range(n):
  if a[i]%2 == 0:
    if a[i]%3 == 0 or a[i]%5 == 0:
      pass
    else:
      flg = False
if flg: print("APPROVED")
else: print("DENIED")

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

template <class T>
inline void read(T &res)
{
	res = 0; bool bo = 0; char c;
	while (((c = getchar()) < '0' || c > '9') && c != '-');
	if (c == '-') bo = 1; else res = c - 48;
	while ((c = getchar()) >= '0' && c <= '9')
		res = (res << 3) + (res << 1) + (c - 48);
	if (bo) res = ~res + 1;
}

const int N = 3005;
const double pi = acos(-1.0);

int n, l, t[N];
double ansx, ansy;

int main()
{
	read(n); read(l);
	for (int i = 1; i <= n; i++) read(t[i]);
	for (int i = 1; i <= n; i++)
		for (int j = i + 1; j <= n; j++)
		{
			double orz = pi * (t[i] + t[j]) / l;
			ansx += cos(orz) * (n - (j - i << 1));
			ansy += sin(orz) * (n - (j - i << 1));
		}
	double sum = 1.0 * n * (n - 1) * (n - 2) / 6;
	return printf("%.14lf %.14lf\n", ansx / sum, ansy / sum), 0;
}

Measured memory_bytes: 4132
#include <vector>
#include <functional>
#include <algorithm>
#include <iostream>
#include <climits>
using namespace std;

// 抽象 SegmentTree (0-indexed・一点更新・区間取得)
template <typename MonoidType>
struct SegmentTree {
    using Function = function< MonoidType(MonoidType, MonoidType) >;

    // node, identity element
    int n;
    vector<MonoidType> node;
    MonoidType E0;

    // update / combine function
    Function upd_f, cmb_f;

    void build(int m, vector<MonoidType> v = vector<MonoidType>()) {
        if(v != vector<MonoidType>()) m = v.size();
        n = 1; while(n < m) n *= 2;

        node = vector<MonoidType>(2*n-1, E0);
        if(v != vector<MonoidType>()) {
            for(int i=0; i<m; i++) {
                node[n-1+i] = v[i];
            }
            for(int i=n-2; i>=0; i--) {
                node[i] = cmb_f(node[2*i+1], node[2*i+2]);
            }
        }
    }

    // initialize
    SegmentTree() {}
    SegmentTree(int n_, MonoidType E0_,
                Function upd_f_, Function cmb_f_,
                vector<MonoidType> v = vector<MonoidType>()) :
        E0(E0_), upd_f(upd_f_), cmb_f(cmb_f_) {
        build(n_, v);
    }

    // update k-th element (applied value: x)
    void update(int k, MonoidType x) {
        k += n - 1;
        node[k] = upd_f(node[k], x);
        while(k > 0) {
            k = (k - 1) / 2;
            node[k] = cmb_f(node[2*k+1], node[2*k+2]);
        }
    }

    // range query for [a, b)
    MonoidType query(int a, int b) {
        MonoidType vl = E0, vr = E0;
        for(int l=a+n, r=b+n; l<r; l>>=1, r>>=1) {
            if(l & 1) vl = cmb_f(vl, node[(l++)-1]);
            if(r & 1) vr = cmb_f(node[(--r)-1], vr);
        }
        return cmb_f(vl, vr);
    }
};


// Range Minimum Query
// query 1: update
// query 2: range minimum
void DSL_2_A() {
    int N, Q; cin >> N >> Q;
    SegmentTree<int> seg(N, INT_MAX,
                         [](int a, int b) { return b; },
                         [](int a, int b) { return min(a, b); });

    int indexed = 0;
    for(int i=0; i<Q; i++) {
        int query_type; cin >> query_type;
        int x, y; cin >> x >> y;
        if(query_type == 0) {
            x -= indexed;
            seg.update(x, y);
        }
        if(query_type == 1) {
            x -= indexed, y -= indexed;
            y++;
            cout << seg.query(x, y) << endl;
        }
    }
}

int main() {
    DSL_2_A();
    return 0;
}



Measured memory_bytes: 3888
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, u, v;
  cin >> N >> u >> v;
  u--; v--;
  vector<vector<int>> G(N);
  F0R(i, N - 1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vector<int> vd(N);
  auto search = [&](auto search, int v, int d = 0, int p = -1)->void {
    vd[v] = d;
    for (auto c : G[v]) {
      if (c == p)continue;
      search(search, c, d + 1, v);
    }
  };
  search(search, v);
  //Print(vd);

  int result = 0;
  auto run = [&](auto run, int v, int d = 0, int p = -1)->void {
    if (vd[v] <= d) return;
    for (auto c : G[v]) {
      if (c == p) continue;
      run(run, c, d + 1, v);
    }

    if (G[v].size() == 1) {
      chmax(result, vd[v] - 1);
    }
  };
  run(run, u);
  cout << result;
}
#endif


Measured memory_bytes: 9728
l[4],r[4],i;main(){float a,b;for(;~scanf("%f%f",&a,&b);l[a<0.2?3:a<0.6?2:a<1.1?1:0]++,r[b<0.2?3:b<0.6?2:b<1.1?1:0]++);for(;i<4;printf("%d %d\n",l[i++],r[i]));exit(0);}

Measured memory_bytes: 624
N, A, B = map(int, input().split())
ans = []
 
if A+B-1<=N<=A*B:
    S = N-A
    cur = N
    ans = []
    for i in range(A+1):
        num = min(B-1, S)+1
        S -= num-1
        for j in range(num):
            ans.append(cur-num+1+j)
        cur -= num
    ans = ans[::-1][1:]
    print(*ans)
else:
    print(-1)


Measured memory_bytes: 25308
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-02-01 16:07:01
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
#define i64 long long
const i64 inf=1ll<<50;
namespace run
{
	const int N=160010;
	i64 n,e,S,T,begin[N],next[N],to[N],w[N],c[N],_n,p1,p2,p3,p4,ans;
	i64 q[10000000],l,r,d[N],pre[N],is[N];
	void add(int u,int v,i64 W,i64 C){ e++; next[e]=begin[u]; begin[u]=e; to[e]=v; w[e]=W; c[e]=C; }
	void Add(int u,int v,i64 W,i64 C){ /*printf("%d %d %d,%d\n",u,v,int(W),int(C));*/ add(u,v,W,C); add(v,u,0,-C); }
#define fo(i,a) for(int i=begin[a];i;i=next[i])
	int bfs()
	{
		fr(i,1,_n) d[i]=inf;
		d[S]=0; q[l=r=0]=S;
		while(l<=r)
		{
			int u=q[l++];
//			printf("%d\n",u);
			is[u]=0;
			fo(i,u) if(w[i]&&d[u]+c[i]<d[to[i]])
			{
				d[to[i]]=d[u]+c[i]; pre[to[i]]=i;
				if(!is[to[i]]){ is[to[i]]=1; q[++r]=to[i]; }
			}
		}
		return d[T]!=inf;
	}
	int main()
	{
		S=++_n; T=++_n; p1=++_n; p2=++_n; p3=++_n; p4=++_n; n=read(); e=1;
		fr(i,1,n)
		{
			int x=read(),y=read(),c=read(); _n++;
			Add(S,_n,c,0); Add(_n,p1,c,x+y); Add(_n,p2,c,x-y); Add(_n,p3,c,-x+y); Add(_n,p4,c,-x-y);
		}
		fr(i,1,n)
		{
			int x=read(),y=read(),c=read(); _n++;
			Add(_n,T,c,0); Add(p1,_n,c,-x-y); Add(p2,_n,c,-x+y); Add(p3,_n,c,x-y); Add(p4,_n,c,x+y);
		}
		while(bfs())
		{
//			fr(i,2,_n) printf("%d%c",int(to[pre[i]^1]),i==_n?'\n':' ');
			i64 mw=inf,t=T;
			while(t!=S){ mw=std::min(mw,w[pre[t]]); t=to[pre[t]^1]; }
			t=T;
			while(t!=S){ ans+=c[pre[t]]*mw; w[pre[t]]-=mw; w[pre[t]^1]+=mw; t=to[pre[t]^1]; }
		}
		printf("%lld\n",-ans);
		return 0;
	}
}
int main()
{
	return run::main();
}

Measured memory_bytes: 10496
import sys
input = sys.stdin.readline
def main():
    N,M = map(int,input().split())
    root = [[] for _ in range(N)]
    for _ in range(M):
        a,b = map(int,input().split())
        root[a-1].append(b-1)
        root[b-1].append(a-1)
    for i in root[0]:
        if N-1 in root[i]:
            print("POSSIBLE")
            exit()
    print("IMPOSSIBLE")

if __name__ == "__main__":
    main()

Measured memory_bytes: 38320
N, M = map(int, input().split())

shops = []
for i in range(N):
    shops.append(list(map(int, input().split())))
shops.sort(key=lambda x:x[0])

ans = 0
for a, b in shops:
    if M > b:
        M -= b
        ans += a*b
    else:
        ans += a*M
        break

print(ans)

Measured memory_bytes: 29024
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string a;
	char temp;
	int max,min,N;
	cin>>N;
	for(int i=0;i<N;i++){
		max=0;
		min=0;
		cin>>a;
		for(int k=0;k<8;k++){
			for(int j=0;j<8;j++){
				if(a[k]>a[j]){
					temp=a[j];
					a[j]=a[k];
					a[k]=temp;
				}
			}
			
		}
		for(int k=0;k<8;k++){
			max=max*10+a[7-k]-48;
			min=min*10+a[k]-48;
		}
		cout<<min-max<<endl;
	}	
	return 0;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k, q;
	cin >>n >>k >>q;
	VI sc(n, k - q);
	rep(i, q){
		int a; cin >>a; sc[a-1]++;
	}
	rep(i, n){
		cout <<(sc[i]>0? "Yes":"No") <<"\n";
	}
	return 0;
	
}


Measured memory_bytes: 1024
n = int(input())
XY = [list(map(int, input().split())) for _ in range(n)]
X_ = []
Y_ = []

for x,y in XY:
  X_.append(x-y)
  Y_.append(x+y)

print(max(max(X_)-min(X_), max(Y_)-min(Y_)))

Measured memory_bytes: 61468
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <bitset>
using namespace std;
using ll = long long int;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1;i <= (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
ll mod = 1000000007;

vector<ll> dp(100010,INF);

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i,n) cin >> h[i];
    dp[0] = 0;
    rep(i,n) {
        rep1(j,k) {
            chmin(dp[i+j],dp[i] + abs(h[i+j] - h[i]));
        }
    }
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 4792
N, M = map(int, input().split())
p = [0] * M
S = ['a'] * M
for i in range(M):
    p[i], S[i] = input().split()
    p[i] = int(p[i])

answa = 0
flg = [0] * N

for i in range(M):
    if flg[p[i]-1] == 1:
        continue
    if S[i] == 'WA':
        flg[p[i]-1] -= 1
    elif S[i] == 'AC':
        answa -= flg[p[i]-1]
        flg[p[i]-1] = 1

print(flg.count(1), answa)

Measured memory_bytes: 20516
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
vector<int> v(n);
for(int i=0;i<n;i++)
{
cin>>v[i];
}
int sum=0;
sort(v.begin(),v.end());
for(int i=0;i<k;i++)
{
sum+=v[i];
}
cout<<sum<<endl;
return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int n,m,a,b,c,d,h,w,x,y;
string str;

signed main(){
  string cod="CODEFESTIVAL2016";
  int ans = 0;
  cin >> str;
  FOR(i,str.length()){
    if(ans==0){
      if(str[i]=='C')
        ans++;
    }
    if(ans==1){
      if(str[i]=='F')
        ans++;
    }
  }
  cout << (ans==2 ? "Yes" : "No" ) fin;
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1LL<<50)
#define s second
#define f first
using namespace std;
typedef long long ll;
typedef pair<ll,ll>P;
typedef pair<ll,P> PP;
ll G[200][200][2];
int n,m,r,z[1000];

void WF(){
  for(int k=0;k<n;k++)
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++){
	G[i][j][0]=min(G[i][j][0],G[i][k][0]+G[k][j][0]);
	G[i][j][1]=min(G[i][j][1],G[i][k][1]+G[k][j][1]);
      }
}


ll dijkstra(){
  vector<vector<ll> > D(n,vector<ll>(r,INF));
  priority_queue<PP,vector<PP>,greater<PP> > Q;
  Q.push(PP(0,P(z[0],0)));
  D[z[0]][0] = 0;

  while(!Q.empty()){
    PP t=Q.top();Q.pop();
    ll cost=t.f,ship=t.s.f,idx=t.s.s,pos=z[idx];
    if(idx==r-1)return cost;
    if(D[ship][idx]<cost)continue;
    
    int npos=z[idx+1];
    ll ncost=cost+G[pos][npos][0];
    if(D[ship][idx+1]>ncost)Q.push(PP(ncost,P(ship,idx+1))),D[ship][idx+1]=ncost;

    for(int i=0;i<n;i++){
      ncost=cost+G[pos][ship][0]+G[ship][i][1]+G[i][npos][0];
      if(D[i][idx+1]>ncost)Q.push(PP(ncost,P(i,idx+1))),D[i][idx+1]=ncost;
    }
  }
  assert(0);
} 

int main(){
  while(1){
    cin>>n>>m;
    if(!n&&!m)break;
    for(int i=0;i<n;i++) 
      for(int j=0;j<n;j++) G[i][j][0]=G[i][j][1]=INF*(i!=j);
    
    for(int i=0,x,y,c,idx;i<m;i++){
      char ch;
      cin>>x>>y>>c>>ch;x--,y--;
      idx=(ch=='S');
      G[x][y][idx]=G[y][x][idx]=min(G[x][y][idx],(ll)c);
    }
    cin>>r;
    for(int i=0;i<r;i++)cin>>z[i],z[i]--;
    WF();
    cout <<dijkstra()<<endl;
  }
  return 0;
}

Measured memory_bytes: 5272
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    
    long N,M;
    cin >> N >> M;
    
    long M_left = 0;
    
    long count = 0;
    
    if( (2*N) == M ){
        count = M/(2*N);
  //      cout <<"a";
    }
    else if( (2*N) < M ){
        count = N;
        M_left = M - (2*count);
        count = count + (M_left/4);
 //       cout << "b";
    }
    else{//2N>M
        count = M/2;
  //      cout << "c";
    }
    
    cout << count;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int i,n,d,nn,b[200][2],r,l,u,dw;
	while (1) {
		r=l=u=dw=b[0][0]=b[0][1]= 0;
		scanf("%d", &n);
		if (n == 0)break;
		for (i = 1; i < n; i++) {
			scanf("%d %d", &nn,&d);
			if (d==3||d==1) {
				b[i][0] = b[nn][0];
				b[i][1] = b[nn][1] + d - 2;
				if (b[i][1] > u)u = b[i][1];
				if (b[i][1] < dw)dw = b[i][1];
			} else {
				b[i][0] = b[nn][0] + d - 1;
				b[i][1] = b[nn][1];
				if (b[i][0] > r)r = b[i][0];
				if (b[i][0] < l)l = b[i][0];
			}
		}
		printf("%d %d\n", r - l + 1, u - dw+1);
	}
	return 0;
}


Measured memory_bytes: 2664
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
#define M 400010

using namespace std;

typedef long long ll;

int n, A[M];

int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%d", &A[i]);
    sort(A + 1, A + n + 1);
    map <int, int> mp;
    for(int i = 1; i <= n; i++) mp[-A[i]]++;
    int ans = 0;
    for(map <int, int>::iterator it = mp.begin(); it != mp.end(); it++) {
        int a = -it->first, b = it->second;
        ll tmp = 1;
        while(tmp <= a) tmp *= 2;
        ll s = tmp - a;
        if(s == a) {
            ans += b / 2;
            it->second %= 2;
        } else {
        int o = min(b, mp[-s]);
        mp[-s] -= o;
        it->second -= o;
        ans += o;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 65024
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int Min(int a, int b, int c) {
	if (a <= b) { return std::min(a, c); }
	else return std::min(b, c);
}
int Max(int a, int b, int c) {
	if (a >= b) { return std::max(a, c); }
	else return std::max(b, c);
}
int main(void) {
	int n; cin >> n;
	if (n < 1200)cout << "ABC" << endl;
	else if (n < 2800)cout << "ARC" << endl;
	else cout << "AGC" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main(){
	int n, a; int x[100000];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		x[i] = a;
	}
	sort(x, x + n); int count = 0;
	for (int i = 0; i < n - 1; i++) {
		if (x[i] == x[i + 1])count++;
	}
	if (count % 2 == 1)count++;
	cout << n - count << endl;
	return 0;
}

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

int a[210000];
long long maxn=1e17;

int main()
{
    int n;
    while(scanf("%d",&n)==1)
    {
        for(int i=1; i<=n; i++)
            scanf("%d",&a[i]),a[i]-=i;
        sort(a+1,a+1+n);
        long long  ans=0;
        for(int i=1;i<=n;i++)ans+=abs(a[i]-a[n/2+1]);
        printf("%lld\n",ans);
    }
    return 0;
}


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

int main()
{
  ll n;
  cin >> n;
  vector<ll> A(n);
  for(int i=0; i<n; i++){
    cin >> A[i];
  }
  int f[n+1]={0};
  if(n<=1){
    cout << "0" << endl;
    return 0;
  }
  f[n]=INT_MAX;
  f[n-2]= abs(A[n-2]-A[n-1]);
  for(int i=n-3; i>=0; i--){
    f[i]= min(abs(A[i]-A[i+1])+f[i+1], abs(A[i]-A[i+2])+f[i+2]);
  }
  cout << f[0]<<endl;

  return 0;
}


Measured memory_bytes: 1408
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    ll n;cin>>n;
    if(n%2==0) cout<<n<<endl;
    else cout<<2*n<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
bool prime(int a)
{
	for(int i=2;i*i<=a;i++)
	{
		if(a%i==0)return 0;
	}
	return 1;
}
int main()
{
	cin>>n;
	n--;
	for(;;)
	{
		n++;
		if(prime(n))
		{
			cout<<n<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	int* x = new int[n + 1];
	for (int i = 1; i <= n; i++) {
		cin >> x[i];
	}
	int sum;
	int b = 0;
	for (int i = 1; i <= n; i++) {
		b += x[i];
	}
	int p = b / n;
	int temp = p + 1;
	int s1 = 0, s2 = 0;
	for (int i = 1; i <= n; i++) {
		s1 += (x[i] - p) * (x[i] - p);
		s2 += (x[i] - temp) * (x[i] - temp);
	}
	sum = (s1 > s2) ? s2 : s1;
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define debug(x) cerr<<#x<<' '<<x<<'\n'
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
const int maxn=1e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n,m;
    cin>>n>>m;
    if(m>n) swap(n,m);
    rep(i,1,n) cout<<m;
    cout<<'\n';
    return 0;
}



Measured memory_bytes: 256
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <math.h>
#include <string>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>

using namespace std;

#define pb push_back
#define mk make_pair
#define fr first
#define sc second

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

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

const int maxn = 200100;

int n;
ll r;
int a[maxn];

void solve(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i ++){
		scanf("%d", a + i);
	}
	if(a[1]){
		printf("-1");
		return ;
	}
	for(int i = 2; i <= n; i ++){
		if(abs(a[i]-a[i-1] > 1)){
			printf("-1");
			return ;
		}
		if(a[i] == a[i-1] + 1){
			r ++;
		} else{
			r += a[i];
		}
	}
	printf("%lld", r);
}

int main(){
	int t = 1;
	while(t --){
		solve();
	}
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(){
    int N,K,R,S,P;
    char T[100010];
    scanf("%d" "%d",&N,&K);
    scanf("%d" "%d" "%d",&R,&S,&P);
    scanf("%s",T);
    int ans=0;

    for(int i=0;i<K;i++){
        if(T[i]=='r'){
            ans+=P;
        }else if(T[i]=='s'){
            ans+=R;
        }else{
            ans+=S;
        }
    }
    for(int i=K;i<N;i++){
        if(T[i-K]==T[i]){
            ans+=0;
            T[i]='x';
        }else if(T[i]=='r'){
            ans+=P;
        }else if(T[i]=='s'){
            ans+=R;
        }else{
            ans+=S;
    }
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @author Pavel Mavrin
 */
public class Main {

    private void solve() throws IOException {
        int n = nextInt();
        long[] a = new long[n];
        long[] b = new long[n];

        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
            b[i] = nextInt();
        }

        long res = 0;
        for (int i = n - 1; i >= 0; i--) {
            long q = -(a[i] + res);
            q %= b[i];
            if (q < 0) q += b[i];
            res += q;
        }

        out.println(res);
    }

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

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st;
    PrintWriter out = new PrintWriter(System.out);

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    private void run() throws IOException {
        solve();
        out.close();
    }

}


Measured memory_bytes: 28956
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int N;
  int A = 0, B;
  int tmpA = -1, tmpB;

  cin >> N;
  REP(i, N) {
    cin >> tmpA >> tmpB;
    if (tmpA > A) {
      A = tmpA;
      B = tmpB;
    }
  }
  cout << A + B;
}

Measured memory_bytes: 3528
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a>=0&&c>=0){cout<<b*d<<endl;}
  else if(b<=0&&d<=0){cout<<a*c<<endl;}
  else if(a>=0&&d<=0){cout<<a*d<<endl;}
  else if(b<=0&&c>=0){cout<<b*c<<endl;}
  else{cout<<max(a*c,b*d)<<endl;}
}


Measured memory_bytes: 3620
my ($n,$m)=+<<get.words;
my$a=(get)xx $n;
my$b=lines;
for 0..$n-$m ->$i {
	for 0..$n-$m ->$j {
		my$f=1;
		for ^$m ->$k {
			if !$a[$i+$k].substr-eq($b[$k],$j) {
				$f=0;
				last;
			}
		}
		if $f {
			say "Yes";
			exit;
		}
	}
}
say "No";

Measured memory_bytes: 72660
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N, M; cin >> N >> M;
    vec x(M), y(M);
    REP(i, M){
        cin >> x[i] >> y[i];
        x[i]--;
        y[i]--;
    }
    vector<bool> red(N, false);
    red[0] = true;
    vec num(N, 1);

    REP(i, M){
        if(red[x[i]]) red[y[i]] = true;
        if(red[x[i]] && num[x[i]] == 1) red[x[i]] = false;
        num[x[i]]--;
        num[y[i]]++;
    }
    int ans = 0;
    REP(i, N) if(red[i]) ans++;
    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

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

int main() {

    int x, y;

    cin>>x>>y;

    int cr = 0, tu = x;

    while(cr <= x) {

        if( ((cr*2)+(tu*4)) == y) {
            cout<<"Yes\n";
            return 0;
        }
        cr++, tu--;
    }

    cout<<"No\n";
}


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

int main(){
	int n,*a,b,*c;
  	int sum = 0,bnum = -1;
  	cin >> n;
  	a = new int[n];c = new int[n-1];
  	for(int i=0;i<n;i++){cin >> a[i];}
  	for(int i=0;i<n;i++){cin >> b;sum+=b;}
  	for(int i=0;i<n-1;i++){cin >> c[i];}
  	for(int i=0;i<n;i++){
      	if(bnum+1==a[i]){
        	sum+=c[bnum-1];
        }
      	bnum = a[i];
    }
  	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

n = len(a)
a.sort()
a.append(0)
ans = 0
i = 0
while i < n:
    cnt = 1
    while a[i] == a[i+1]:
        cnt += 1
        i += 1
    if cnt >= a[i]:
        ans += cnt - a[i]
    else:
        ans += cnt
    i += 1
print(ans)


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

using namespace std;

const int mod = 998244353, N = 6030;

long long dp[N][N], C[N][N];

void add(long long & var, long long val) {
  var += val;
  if (var >= mod)
    var -= mod;
}

int main() {
  for (int i = 0; i < N; ++i) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j < i; ++j)
      C[i][j] = (C[i-1][j-1] + C[i-1][j]) % mod;
  }
  int n, x;
  scanf("%d %d", &n, &x);
  if (x == 1) {
    long long ans = 1;
    for (int i = 0; i < n; ++i)
      ans = (ans * 2) % mod;
    printf("%lld\n", ans);
    return 0;
  }
  if (x == 2) {
    printf("%d\n", n + 1);
    return 0;
  }
  dp[0][0] = 1;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < x; ++j) {
      for (int k = 0; k <= 2; ++k) {
        if (j + k >= x) continue;
        add(dp[i+1][j+k], dp[i][j]);
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < x; ++i)
    add(ans, dp[n][i]);
  for (int len = 3; len <= n; ++len) {
    for (int i = 1; i * 2 < len; ++i) {
      int tengah = len - 2 * i;
      int sisa = x-1 - 2 * i;
      if (sisa < tengah || sisa > 2 * tengah) continue;
      ans = (ans + 1LL * C[tengah][sisa-tengah] * C[n][len]) % mod;
    }
  }
  if (x & 1) {
    for (int len = (x - 1); len <= n; ++len) {
      ans = (ans + C[n][len]) % mod;
    }
  }
  ans %= mod;
  if (ans < 0) ans += mod;
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 424320
function Main (i) {
  var isWA = (
    i.charAt(0) !== 'A' ||
    i.slice(2, i.length - 2).indexOf('C') === -1 ||
    i.match(/C/g).length !== 1 ||
    !/^[a-z]+$/.test(i.replace(/[AC\s]/g, ''))
  );
  console.log('%s',isWA ? 'WA' : 'AC');
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<stdio.h>

char c;
int f;
int nextInt();

int N, H, W, A, B, ans, i;

int main(void){
	N=nextInt();
	H=nextInt();
	W=nextInt();
	for(i=0; i<N; i++){
		A=nextInt();
		B=nextInt();
		if(A>=H && B>=W){ans++;}
	}
	printf("%d\n", ans);
	return 0;
}

int nextInt(){
	f=0; c=getchar();
	while((c<'0')||('9'<c)){c=getchar();}
	while((c>='0')&&(c<='9')){f=f*10+(c-'0'); c=getchar();}
	return f;
}


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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

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

  ll a, b;

  cin >> a >> b;

  if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
    cout << "Possible"
         << "\n";
  } else {
    cout << "Impossible"
         << "\n";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
static const int INF = 2000000000;

const ll mod = 1000000007;

int main() {
  string s;
  cin >> s;
  if (s == "ABC") cout << "ARC\n";
  else cout << "ABC\n";
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
	using namespace std;
	typedef long long ll;
	#define endl "\n"
	#define space " "
	#define ll long long int
	#define vl vector<ll>
	#define vvl vector < vll >
	#define pii pair<int,int>
	#define pll pair<ll,ll>
	#define vpl vector < pll >
	#define mod 1000000007
	#define pi 3.1415926535897932384626433
	#define inf 1000000000000000001;
	#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y) 
	#define mem(a,val) memset(a,val,sizeof(a))
	#define pb push_back
	#define f first
	#define s second
	
	void solve()
	{
		int n; cin>>n;
		int a[n];
		std::map<int, int> m;
		ll s=0;
		for (int i = 0; i < n; ++i)
		{
			/* code */
			cin>>a[i];
			s+=a[i];
			m[a[i]]++;
		}
		int q; cin>>q; int b[q],c[q];
		for (int i = 0; i < q; ++i)
		{
			/* code */
			int d=0;
			cin>>b[i]>>c[i];
			if(c[i]>b[i]){
				int p=c[i]-b[i];
				int e=m[b[i]]; m[b[i]]=0; m[c[i]]+=e;
				int f=e*p;
				s+=f;
			}
			else{
				int p=b[i]-c[i];
				int e=m[b[i]]; m[b[i]]=0; m[c[i]]+=e;
				int f=e*p;
				s-=f;
			}
			cout<<s<<endl;
		}

	}

	signed main()
	{

	fast;
	#ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
     #endif

	ll T=1;
	// cin>>T;
	while(T--)
	{
		solve();
	}
	return 0;
	}


Measured memory_bytes: 9152
#include <iostream>

using namespace std;

int main(){
//////////////////////////////// INPUT
    int N;
      // マスの長さ
    int M;
      // 料金所の数
    int X;
      // 自分が最初にいるマス
    int cost_1 = 0;
      // コスト_1
    int cost_2 = 0;
      // コスト_2
    int min;
      // 最小コスト

    cin >> N >> M >> X;

    int A[M];
      // 料金所の場所

    for (int i=0; i < M; i++){
        cin >> A[i];
    }

////////////////////////////////////////

    for (int i=X; i>0; i--){
        for (int j=0; j<M; j++){
           if (i == A[j]){
               cost_1 ++;
           }
        }
    }

    for (int i=X; i<N; i++){
        for (int j=0; j<M; j++){
            if (i == A[j]){
                cost_2 ++;
            }
        }
    }

    if (cost_1 <= cost_2){
        min = cost_1;
    } else {
        min = cost_2;
    }

//////////////////////////////// OUTPUT

    cout << min << endl;

///////////////////////////////////////

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = input()
l = a.split()
for i in range(0,n):
    l[i] = int(l[i])
dp = []
dp = [1]
for i in range(0,n+1):
    dp.append(0)
m = l[0]
for i in range(1,n):
    if l[i] < m:
        m = l[i]

    if m+1 >l[i]:
        dp[i] = dp[i-1]+1
    else:
        dp[i]=dp[i-1]
print(dp[n-1])

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

int main(){
    int n;
    cin >> n;
    int a[100000];
    int count=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(a[i]%2==1)count++;
    }
    if(count%2==0)puts("YES");
    else puts("NO");
}

Measured memory_bytes: 640
import java.util.Scanner;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int cnt = b / a;
        if (cnt >= c) {
            System.out.println(c);
            return;
        }
        System.out.println(cnt);
    }
}


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

int main(){
	int n;
	cin>>n;
	int *d = new int[4*3*10];
	for(int i=0; i<4*3*10; i++){
		d[i] = 0;
	}
	while(n--){
		int b,f,r,v;
		cin>>b>>f>>r>>v;
		d[3*10*(b-1)+10*(f-1)+(r-1)] += v;
	}
	for(int a=0; a<4; a++){
		for(int b=0; b<3; b++){
			for(int c=0; c<10; c++){
				cout << " " << d[3*10*a+10*b+c];
			}
			cout << endl;
		}
		if(a!=3) cout << "####################" << endl;
	}
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 7;
int dig[N];
int dp[150][150][2], k;

int dfs(int pos, int num, bool ismax){
	if(pos == 0) return num == k;
	int &v = dp[pos][num][ismax];
	if(v != -1) return v;
	v = 0;
	int mx = ismax ? dig[pos] : 9;
	for(int i = 0; i <= mx; ++ i){
		if(i) v += dfs(pos - 1, num + 1, ismax && i == mx);
		else v += dfs(pos - 1, num, ismax && i == mx);
	}
	return v;
}

int solve(string &s){
	memset(dp, -1, sizeof dp);
	int len = 0;
	for(int i = s.size() - 1; ~i; -- i){
		dig[++ len] = s[i] - '0';
	}
	return dfs(len, 0, 1);
}

int main(){
	ios::sync_with_stdio(false); cin.tie(nullptr);
	string s; cin >> s >> k;
	cout << solve(s) << '\n';
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
void SelectionSort(int a[],int n){
    int loop,loop2,swap,min;
    int c=0;
    for(loop=0;loop<n;loop++){
        min=loop;
        for(loop2=loop;loop2<n;loop2++){
            if(a[loop2]<a[min]){
                min=loop2;
            }
        }
        if(loop!=min){
            swap=a[loop];
            a[loop]=a[min];
            a[min]=swap;
            c++;
        }
    }
    for(loop=0;loop<n;loop++){
        printf("%d",a[loop]);
        if(loop==n-1){
            printf("\n%d\n",c);
        }else{
            putchar(' ');
        }
    }
}
int main(void){
    int n,loop,a[101];
    scanf("%d",&n);
    for(loop=0;loop<n;loop++){
        scanf("%d",&a[loop]);
    }
    SelectionSort(a,n);
    return 0;
}


Measured memory_bytes: 2100
#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; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}


void solve()
{
   int k,a,b;
    cin >> k >> a >> b;
    
    if((b/k) - (a-1)/k > 0) cout <<"OK";
    else cout <<"NG";
    
    
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 3648
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int a, b;
    cin >> a >> b;

    cout << max(a + b, max(a, b) * 2 - 1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#define rep(i,n) for (int i = 0; i < (n);i++)
typedef long long ll;
using namespace std;
/*#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;*/


void Main()
{
    int n; cin >>n;
    cout << n*(n-1ll)/2ll << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

Measured memory_bytes: 256