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

ll mod = 998244353;
class SegmentTree {
private:
    int n;
    vector<ll> node, lazy;
    vector<bool> flag_lazy;
public:
    SegmentTree(int N) {
        n = 1;
        while (n < N) n *= 2;
        node.resize(2 * n - 1, 0);
        lazy.resize(2 * n - 1, 0);
        flag_lazy.resize(2 * n - 1, false);
    }

    void update(int i, int l, int r) {
        if (!flag_lazy[i]) return;
        node[i] += lazy[i];
        node[i] %= mod;
        if (r - l > 1) {
            lazy[2 * i + 1] += lazy[i] / 2;
            lazy[2 * i + 2] += lazy[i] / 2;
            flag_lazy[2 * i + 1] = true;
            flag_lazy[2 * i + 2] = true;
        }
        flag_lazy[i] = false;
        lazy[i] = 0;
    }

    void add(int a, int b, ll x, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        update(k, l, r);
        if (b <= l || r <= a) return;
        
        if (a <= l && r <= b) {
            lazy[k] += (r - l) * x;
            flag_lazy[k] = true;
            update(k, l, r);
        } else {
            add(a, b, x, 2 * k + 1, l, (l + r) / 2);
            add(a, b, x, 2 * k + 2, (l + r) / 2, r);
            node[k] = (node[2 * k + 1] + node[2 * k + 2]) % mod;
        }
    }

    ll query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        update(k, l, r);
        if (b <= l || r <= a) return 0;        
        if (a <= l && r <= b) return node[k] % mod;

        ll sum_l = query(a, b, 2 * k + 1, l, (l + r) / 2);
        ll sum_r = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return (sum_l + sum_r) % mod;
    }

    void disp() {
        for (int i : node) {
            cout << i << " ";
        }
        cout << "\n";
    }

};

int main() {
    int N, K;
    cin >> N >> K;
    int L[K], R[K];
    for (int i = 0; i < K; i++) {
        cin >> L[i] >> R[i];
    }

    SegmentTree st(N + 1);
    st.add(1, 2, 1);
    
    for (int i = 1; i < N; i++) {
        ll x = st.query(i, i + 1);
        for (int j = 0; j < K; j++) {
            int l = i + L[j];
            int r = i + R[j] + 1;
            st.add(min(l, N + 1), min(r, N + 1), x);
        }
    }

    cout << st.query(N, N + 1) << "\n";

    return 0;
}

Measured memory_bytes: 11444
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <map>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <bitset>
#define f first
#define s second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define vi vector <int>
#define ld long double
#define pii pair<int, int>
using namespace std;    
const int N = int(3e5), mod = int(1e9)  + 7; 
string s;

int main () {
	cin >> s;
	for(int i = 0; i < 4; i++) cout << s[i];
	cout << " ";
	for(int i = 4; i < s.size() ;i++) cout << s[i];
	cout << endl; 

return 0;
}

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int a, b;
	cin >> a >> b;
	cout << (6 - a - b) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
template <typename T>
bool PN(T x){ if (x <= 1) return false; if (x == 2) return true; for (int i = 2; i < sqrt(x) + 1; i++) if (x % i == 0) return false; return true;}
const ll MOD = 1e9+7;
long long Comb(int n, int i){long long ans = 1; if(i == 0 || i == n) return 1; else {for(int j = 1; j <= i; ++j){
      ans *=(n+1-j);
      ans /= j;
      ans %= MOD;} }return ans;}

void solve()
{
  int n; cin >> n;
  vector<int> a;
  for(int i = 0; i < n; ++i) {
    int tmp; cin >> tmp;
    a.push_back(tmp);
  }

  sort(a.begin(), a.end());
  ll ans = 0;
  ans = a[n-1]-a[0];
  cout << ans << endl;
}

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


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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

constexpr ll INF = 1e18;

int main() {
    int N, D;
    cin >> N >> D;
    vector<ll> d(N);
    vector<ll> pos(N + 1);
    pos[0] = D;
    for(int i = 0; i < N; ++i) {
        cin >> d[i];
        if(d[i] / 2 < pos[i]) {
            pos[i + 1] = abs(pos[i] - d[i]);
        } else {
            pos[i + 1] = pos[i];
        }
    }

    vector<ll> v(N);
    v[N - 1] = 1;
    for(int i = N - 2; i >= 0; --i) {
        if(d[i + 1] / 2 >= v[i + 1]) {
            v[i] = v[i + 1];
        } else {
            v[i] = v[i + 1] + d[i + 1];
        }
    }

    int Q;
    cin >> Q;
    while(Q--) {
        int q;
        cin >> q;
        q--;
        if(v[q] <= pos[q]) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
}


Measured memory_bytes: 13696
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  string S;
  cin >> S;
  int N = S.size();
  rep(i,N)
  {
    if(i%2==0)
    {
      cout << S[i];
    }
    if(i==N-1)
    {
      cout << endl;
    }
  }
  return 0;
}


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

int main(){
int i, j, n, a, b;

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


Measured memory_bytes: 128
import std.stdio;
import std.string, std.conv;
import std.algorithm, std.array;
import std.typecons;


void main() {
  alias Tuple!(int, "no", real, "time") record;

  record[] rest;

  foreach(i; 0 .. 3) {
    auto t = new record[8];
    foreach(j; 0 .. 8) {
      string[] s = readln().split();
      t[j] = tuple(s[0].to!int(), s[1].to!real());
    }

    t.sort!("a.time < b.time")();

    foreach(it; t[0 .. 2])
      writefln("%d %.2f", it.no, it.time);

    rest ~= t[2 .. 8];
  }

  sort!("a.time < b.time")(rest);

  foreach(it; rest[0 .. 2])
    writefln("%d %.2f", it.no, it.time);
}

Measured memory_bytes: 1092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;

int main()
{
    ll a, b, c;
    cin >> a >> b >> c;

    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
        cout << 0 << endl;
    else
        cout << min({a * b, a * c, b * c}) << endl;
}

Measured memory_bytes: 3560
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8
from heapq import *

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


@njit((b1[:, :], i8, i8, i8, i8), cache=True)
def main(wall, Sx, Sy, Tx, Ty):
    INF = 1 << 30
    H, W = wall.shape
    S = Sx * W + Sy
    T = Tx * W + Ty
    dist = np.full(H * W, INF, np.int64)
    q = [(0, S)]
    while q:
        dv, v = heappop(q)
        if dv > dist[v]:
            continue
        vx, vy = divmod(v, W)
        # そのままあるく
        for dx, dy in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            wx, wy = vx + dx, vy + dy
            if not(0 <= wx < H):
                continue
            if not (0 <= wy < W):
                continue
            if wall[wx, wy]:
                continue
            w = wx * W + wy
            if dist[w] <= dv:
                continue
            dist[w] = dv
            heappush(q, (dv, w))
        # ワープする
        for dx in range(-2, 3):
            for dy in range(-2, 3):
                wx, wy = vx + dx, vy + dy
                if not (0 <= wx < H):
                    continue
                if not (0 <= wy < W):
                    continue
                if wall[wx, wy]:
                    continue
                w = wx * W + wy
                if dist[w] <= dv + 1:
                    continue
                dist[w] = dv + 1
                heappush(q, (dv + 1, w))
    ans = dist[T]
    if ans == INF:
        ans = -1
    return ans


H, W = map(int, readline().split())
Sx, Sy = map(lambda x: int(x) - 1, readline().split())
Tx, Ty = map(lambda x: int(x) - 1, readline().split())
wall = np.frombuffer(read(), 'S1').reshape(H, -1)[:, :W] == b'#'

print(main(wall, Sx, Sy, Tx, Ty))


Measured memory_bytes: 115580
#include<iostream>
#include<cstdio>
#include<cmath>

using namespace std;
int main(){
  int N;
  cin>>N;
  if(N%2==0){
    printf("0.5\n");
  }else{
    double res = (floor(N/2.0)+1)/(double(N));
    printf("%.6f \n", res);
  }
  return 0;
} 

Measured memory_bytes: 256
import sys

K, X=map(int,input().split())

if K==1:
  print(X)
  sys.exit()

N = K * 2 - 1
nTmp = X - (K-1)
for i in range(N):
  print(nTmp+i , end='')
  if i < N-1:
    print(' ', end='')
  else:
    print('')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
	ll n;
	cin >> n;
	int m = n/100;
	if (n <= 100*m + 10*m + m){
		cout << 100*m + 10*m + m << endl;
	} else {
		cout << 100*(m+1) + 10*(m+1) + m+1 << endl;
	}
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h> 
using namespace std;
int a,b; 
int main(){
	cin>>a>>b;
	if (b%a==0) cout<<a+b;
	else cout<<b-a;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define REV(v) reverse(v.begin(),v.end())
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
#define dout(n) cout<<# n<<" = "<<n<<endl;
#define v1out(v) FOR(j,0,v.size()){cout<<v[j]; if(j!=(ll)v.size()-1)cout<<" ";else cout<<endl; }
#define v2out(v) FOR(i,0,v.size())v1out(v[i]);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x;
    cin>>x;
    FOR(i,-500,501){
        FOR(j,-500,501){
            ll a = i*i*i*i*i;
            ll b = j*j*j*j*j;
            if(a-b==x){
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  long long a,i,sum=0,c=0;
  long long mn=1e+10;
  for(i=0;i<n;i++)
  {
    cin>>a;
    sum+=abs(a);
    if(a<0) c++;
    mn=min(mn,abs(a));
  }
  if(c%2) cout<<sum-2*mn;
  else cout<<sum;
  return 0;
}

Measured memory_bytes: 256
inputStr = input()
numList = inputStr.split(' ')
numList = [int(x) for x in numList]
numList2 = numList.copy()
numList.sort()
numSet = set(numList)

#print('numList: ',numList)
#print('numList2: ', numList2)

if numList == numList2 and len(numList)==len(numSet):
    print('Yes')
else:
    print('No')

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

using namespace std;
using ll = long long;
using P = pair<int, int>;


const ll INF64 = 1LL << 60;
const int INF32 = 1 << 30;
const int MOD = 1000000007;

int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int p, q, r;cin >> p >> q >> r;

    int tmp1 = p+q;
    int tmp2 = p+r;
    int tmp3 = r+q;

    int ans = min(tmp1, tmp2);
    ans = min(ans, tmp3);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(N):
    S=ns()
    if(S=='AC'):
        ac+=1
    elif(S=='WA'):
        wa+=1
    elif(S=='TLE'):
        tle+=1
    elif(S=='RE'):
        re+=1


print('AC x '+str(ac))
print('WA x '+str(wa))
print('TLE x '+str(tle))
print('RE x '+str(re))



Measured memory_bytes: 10476
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;

ll gcd(ll a,ll b) {
    while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
    }
    return a;
}
ll lcm(ll a, ll b){
    return a/gcd(a,b)*b;
}


int main(){
    ll N;
    cin >> N;
    ll M;
    cin >> M;
    ll ad;
    vector<ll> A(N,0);
    for(int i=0;i<N;i++){
        cin>>ad;
        A[i]=ad/2
    ;}

    ll Lcm=A[0];
    if(Lcm>M){cout<<0<<endl;return 0;}
    
    for(int i=1;i<N;i++){
        Lcm=lcm(A[i],Lcm);
        if(Lcm>M){cout<<0<<endl;return 0;}
    ;}

    int f=0;
    for(int i=0;i<N;i++){
        if((Lcm/A[i])%2==0){f=1;break;}
    ;}
    if(f){cout<<0<<endl;return 0;}

    cout<<(M/Lcm+1)/2<<endl;



return 0;
}  



Measured memory_bytes: 1024
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	for len(s) > 0 {
		switch {
		case strings.HasSuffix(s, "dreamer"):
			s = s[:len(s)-7]
		case strings.HasSuffix(s, "dream"):
			s = s[:len(s)-5]
		case strings.HasSuffix(s, "eraser"):
			s = s[:len(s)-6]
		case strings.HasSuffix(s, "erase"):
			s = s[:len(s)-5]
		default:
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}


Measured memory_bytes: 1280
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
const int inf = 1000000000; // 10^9

int main(){
   int n;scanf("%d",&n);
   long int ans[87];
   ans[0] = 2;
   ans[1] = 1;
   for(int i = 2;i <= n;i++){
      //printf("%d回目\n",i);
      ans[i] = (ans[i-1] + ans[i-2]);
   }
   printf("%ld\n",ans[n]);
   return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main()
{
  int n;
  scanf("%d",&n);
  char s[n][4];
  int i;
  int cnt[4] = {0};
  i = 0;
  while (i < n)
  {
    scanf("%s",&s[i]);
    if (s[i][0] == 'A')
      cnt[0]++;
    else if(s[i][0] == 'W')
      cnt[1]++;
    else if (s[i][0] == 'T')
      cnt[2]++;
    else if (s[i][0] == 'R')
      cnt[3]++;
    i++;
  }
  printf("AC x %d\n",cnt[0]);
  printf("WA x %d\n",cnt[1]);
  printf("TLE x %d\n",cnt[2]);
  printf("RE x %d\n",cnt[3]);
}

Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_p(x) cerr<<#x": "<<(x).first<<' '<<(x).second<<endl
#define dbg_v(x, n) {cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<(x)[_]<<' ';cerr<<endl;}
#define all(v) v.begin(), v.end()
#define fi first
#define se second
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

template<typename T1, typename T2>
ostream& operator <<(ostream &out, const pair<T1, T2> &item) {
	out << '(' << item.first << ", " << item.second << ')';
	return out;
}

template <typename T>
ostream& operator <<(ostream &out, const vector<T>& v) {
	for(const auto &item : v) out << item << ' ';
	return out;
}

string s;

void bkt(int n, char ch = 'a') {
	if(!n) { cout << s << '\n'; return; }

	for(char c = 'a'; c <= ch; ++c) {
		s += c;
		bkt(n - 1, max(char(c + 1), ch));
		s.pop_back();
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	
	int n;

	cin >> n;

	bkt(n);
	return 0;
}



Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(int argc, char** argv)
{
    ll a,b,c;
    scanf("%lld%lld%lld",&a,&b,&c);
    ll ans=0;
    if(b>c)
    {
        printf("%lld\n",b+c);
    }
    else
    {
        if(a>=c-b)
        {
            printf("%lld\n",b+c);
        }
        else
        {
            if(a<=c-b-1)
                printf("%lld\n",b*2+a+1);
            else
                printf("%lld\n",b*2+a);
        }
    }
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> X(N), Y(N);
    rep(i,N) cin >> X.at(i);
    Y = X;
    sort(X.begin(), X.end());
    int a = X.at(N/2 -1), b = X.at(N/2);
    rep(i,N){
        if(Y.at(i) <= a) cout << b << endl;
        else cout << a << endl;
    }
}   

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

int dx[4]={-1,0,0,1},dy[4]={0,-1,1,0};
unordered_map<char,int>U;
int main(){
    U['D']=3;
    U['L']=1;
    U['R']=2;
    int a;cin>>a;
    for(int b=0;b<a;b++){
	if(b)puts("");
	int c,d;cin>>c>>d;
	string f[20];
	int x=0,y=0,z=0;
	for(int e=0;e<c;e++){
	    cin>>e[f];
	    for(int g=0;g<d;g++){
		if(e[f][g]=='^'){x=e,y=g;z=0;e[f][g]='.';}
		else if(e[f][g]=='v'){x=e,y=g;z=3;e[f][g]='.';}
		else if(e[f][g]=='<'){x=e,y=g;z=1;e[f][g]='.';}
		else if(e[f][g]=='>'){x=e,y=g;z=2;e[f][g]='.';}
		}
	    }  
	int n;string S;
	cin>>n>>S;
	for(char i:S){
	    if(i=='S'){
		for(int k=1;x+dx[z]*k>=0&&x+dx[z]*k<c&&y+dy[z]*k>=0&&y+dy[z]*k<d;k++){
		    if(f[x+dx[z]*k][y+dy[z]*k]=='*'){f[x+dx[z]*k][y+dy[z]*k]='.';break;}
		    if(f[x+dx[z]*k][y+dy[z]*k]=='#')break;
		    }
		    continue;
		}
	    z=U[i];
	    if(x+dx[z]>=0&&x+dx[z]<c&&y+dy[z]>=0&&y+dy[z]<d&&f[x+dx[z]][y+dy[z]]=='.'){x+=dx[z];y+=dy[z];}
	    }
	switch(z){
	    case 0:f[x][y]='^';break;
	    case 1:f[x][y]='<';break;
	    case 2:f[x][y]='>';break;
	    case 3:f[x][y]='v';break;
	    }
	 for(int Q=0;Q<c;Q++)cout<<f[Q]<<endl;   
	}
    }

Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
    char a;

    cin >> a;
    
    if (a == 'a' || a == 'i' || a == 'u' || a == 'e' || a == 'o') {
        cout << "vowel" << endl;
    }
    else {
        cout << "consonant" << endl;
    }
}


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

using namespace std;

int main() {
  string s;
  cin >> s;
  char temp;
  for (int i  = 0; i < 4; ++i) {
    if (s[i] == temp) {
      cout << "Bad" << std::endl;
      return 0;
    }
    temp = s[i];
  }
  cout << "Good" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int a[101],i,j,k,n,x;
    int cnt=0;
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            if(a[i]>a[j]){
                x=a[i];
                a[i]=a[j];
                a[j]=x;
            }
        }
    }
    /*for(i=0;i<n;i++) printf("%d ",a[i]);
    printf("\n");*/
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            for(k=j+1;k<n;k++){
                if(a[i]!=a[j]&&a[i]!=a[k]&&a[j]!=a[k]){
                    if(a[i]+a[j]>a[k]) cnt++;
                    //printf("%d %d %d\n",i,j,k);
                }
            }
        }
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


signed main() {
  int N, K, Q, A;
  cin >> N >> K >> Q;

  vector<int> point(N);
  REP(i, Q){
    cin >> A;
    point[A-1]++;
  }

  REP(i, N){
    if(point[i] > Q-K) Yes;
    else No;
  }

  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    // 多分使わなくても行けるはずだけど...場合分けがなぁ...わからん
    unordered_map<ll, ll> used;

    for (int i = 0; i < K; ++i) {
        ll n = A + i;
        if (A <= n && n <= B) {
            cout << n << endl;
            used[n] = 1;
        }
    }

    for (int i = 0; i < K; ++i) {
        ll n = B - K + i + 1;
        if (used[n]) {
            continue;
        }

        if (A <= n && n <= B) {
            cout << n << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3252
#include <iostream>
#include <queue>
#include <stack>
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <map>
using namespace std;

typedef long long ll;

int main(){
  ll n, m; cin >> n >> m;
  ll ans=0;
  if(n==1 && m==1){
    ans=1;
  }
  else if(n==1){
    ans = max(ans, m-2);
  }
  else if(m==1){
    ans = max(ans, n-2);
  }
  else{
    ans = max(ans, n*m - 2*(n-1) - 2*(m-1));
  }

  cout << ans << endl;

  return 0;
}


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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/a.in", "r", stdin);
//  freopen("../IO/a.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}



void solve(std::istream &in, std::ostream &out) {
  string s;
  in >> s;
  out << (s[2]==s[3]&&s[4]==s[5] ? "Yes" : "No");
}


Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()

    xyz_max = int(N ** 0.5) + 1
    ans = [0] * (N + 1)
 
    for x, y, z in itertools.product(range(1, xyz_max), range(1, xyz_max), range(1, xyz_max)):
        n = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
        if n <= N:
            ans[n] += 1

    for i in range(1, N + 1):
        print(ans[i])

if __name__ == '__main__':
    resolve()


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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/*Coding Space*/

int main(){
  int n; cin >> n;
  int ans = 0;
  int temp = -1;
  rep(i,n){
    int in; cin >> in;
    if(temp == in) ans++,temp = -1;
    else temp = in;
  }
  cout << ans << endl;
}

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

def find(x):
    if par[x]<0:
        return x
    else:
        par[x]=find(par[x])
        return par[x]

def union(x,y):
    x,y=find(x),find(y)
    if x!=y:
        if x>y:
            x,y=y,x
        par[x]+=par[y]
        par[y]=x
M=[]
for i in range(m):
    x,y=map(int,input().split())
    M.append([x-1,y-1])

ans=0

for i in range(m):
    X=M[:i]+M[i+1:]
    par = [-1] * n
    for x in X:
        union(x[0],x[1])
    if [p<0 for p in par].count(1)>1:
        ans+=1
print(ans)


Measured memory_bytes: 9244
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b,m=parseMap(split(readline()))
    a=parseMap(split(readline()))
    b=parseMap(split(readline()))
    ans=minimum(a)+minimum(b)
    for i in 1:m
        x,y,c=parseMap(split(readline()))
        ans=min(ans,a[x]+b[y]-c)
    end
    println(ans)
end
main()

Measured memory_bytes: 155312
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

typedef long long ll;

bool check(int f, int v){
  for(int i = 0; i < 32; i++){
    if((f & (1 << i)) != 0 &&
      (v & (1 << i)) != 0){
      return false;
    }
  }
  return true;
}

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

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

  ll sum = 0;
  int s = 0, t = 0, f = 0;
  while(s < n){
    while(t < n && check(f, a[t])){
      f |= a[t];
      ++t;
    }
    sum += (ll)(t - s);
    f ^= a[s++];
  }

  cout << sum << endl;

  return 0;
}


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

using namespace std;

int n , d , x;

int main()
{
    cin >> n >> d >> x;
    for (int i = 1 ; i <= n ; i++)
    {
        int k;
        cin >> k;
        x++;
        int h = 1;
        while (h*k + 1 <= d)
        {
            x++;
            h++;
        }
    }
    cout << x;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
m, x, c = 0, 0, 0
j = 0
ans = 0
for i in range(n):
    m += a[i]
    x ^= a[i]
    c += 1
    if not m == x:
        while True:
            if m == x:
                break
            x ^= a[j]
            m -= a[j]
            j += 1
            c -= 1
    ans += c
print(ans)

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

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

  vector<int> p(N+1);
  // index is 1 originated.
  for (int i = 1; i < N+1; i++) {
    cin >> p[i];
  }

  int count = 0;
  int temp = 0;
  for (int i = 1; i < N; i++) {
    if (p[i] == i) {
      count++;
      temp = p[i];
      p[i] = p[i+1];
      p[i+1] = temp;
    }
  }

  if (p[N] == N) {   // 右端だけ左とスワップ
    count++;
    temp = p[N];
    p[N] = p[N-1];
    p[N-1] = temp;
  }

  cout << count << endl;

  return 0;
}


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

int main(){
  int n;
  cin >> n;
  int minn = 10000000;

  int ans = 0;
  for (int i = 0; i < n; i++)
  {
    int p;
    cin >> p;
    if(p<=minn){
      ans++;
      minn = p;
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>>v(m);
    int ans=0,c=0;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b,v[i]={--b,--a};
    }
    sort(v.begin(),v.end());
    for(auto p:v)
    {
        if(p.second>=c)
            ans++,c=p.first;
    }
    cout<<ans;
}


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

struct stu{
    int id, num;
    friend bool operator < (stu a, stu b) {return a.num < b.num;}
}a[100005];

int main()
{
    int n; scanf("%d", &n);
    for(int i = 1; i <= n; i++)
        scanf("%d", &a[i].num), a[i].id = i;
    sort(a + 1, a + n + 1);
    for(int i = 1; i <= n; i++) printf("%d ", a[i].id);
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <sstream>
#include <string>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    ll N, X, Y;
    cin >> N >> X >> Y;
    vector<ll> A(N);
    REP(n, N) cin >> A[n];
    reverse(ALL(A));

    vector<ll> mins(N);
    vector<ll> maxs(N);

    FOR(i, 2, N) {
        if (i == 2) {
            mins[i] = min(abs(A[0] - A[1]), abs(A[0] - A[2]));
            maxs[i] = max(abs(A[0] - A[1]), abs(A[0] - A[2]));
        }
        else {
            mins[i] = min(min(abs(A[0] - A[1]), abs(A[0] - A[i])), maxs[i - 1]);
            maxs[i] = max(max(abs(A[0] - A[1]), abs(A[0] - A[i])), mins[i - 1]);
        }
    }

    ll ans = -1e9;
    REP(i, N) {
        if (i == 0) {
            ans = abs(A[0] - Y);
        }
        else if (i == 1) {
            ans = max(ans, abs(A[0] - A[1]));
        }
        else {
            ans = max(ans, mins[i]);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//K-OS WITH THE OCDE

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <climits>

using namespace std;

typedef long long int ll;
typedef long double db;


#define TEST ll t; cin>>t; while(t--)
#define vell vector<ll>
#define pl pair<ll,ll>
#define all(v) v.begin(),v.end()
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define dbg(x)  cerr << #x << ": "<< x <<endl
#define dbg2(x,y) cerr<< #x <<": "<< x <<" || "<< #y << ": " << y << endl

#define endl "\n"
#define MAX 1e18
#define MIN INT_MIN
#define mod 1000000007



void solve()
{
     ll n , c = 0;
     db d;
     cin >> n >> d;

     for(ll i=0 ; i<n ; ++i) {
     	ll x ,y;
     	cin >> x >> y;

     	db f = sqrt(x*x + y*y);

     	if(f <= d)
     		c++;
     }

     cout << c;
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);cin.tie(0);   
    //TEST
     solve();
}



Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
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;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b; cin >> a >> b;
  cout << (b-1+a-1-1)/(a-1) << endk;
  return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<cctype>
using namespace std;

const int ch_MAX = 1200;
char ch[ch_MAX],CH[ch_MAX];

int input(){
	int length = 0;
	for (;; length++){
		scanf("%c",&ch[length]);
		if (ch[length] == '\n')break;
	}
	return length;
}

void changeCH(int length){
	for (int i = 0; i < length; i++){
		bool flag = islower(ch[i]);
		if (flag==true)CH[i] = toupper(ch[i]);
		else CH[i] = tolower(ch[i]);
		cout << CH[i];
	}
	cout << endl;
}

int main(){
	int length;
	
	length = input();

	changeCH(length);

	return 0;
}


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

int main(){
  int nu=0,ma=0;
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]>='A'&&s[i]<='Z'){
      ma++;
    }
  }
  for(int i=2;i<=s.size()-2;i++){
    if(s[i]=='C'){
      nu++;
    }
  }
  if(s[0]=='A'&&nu==1&&ma==2){
    cout<<"AC"<<endl;
  }
  else{
    cout<<"WA"<<endl;
  }
}
    
  
  



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

typedef long long int ll;

int main()
{
    ll n;
    cin >> n;
    if(n % 2 == 0){
        cout << n / 2 * n / 2;
    }
    else{
        cout << n / 2 * (n / 2 + 1);
    }

    return 0;
}

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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  bool unko=1;
  while(unko){
    C-=B;
    if (C<=0) {cout << "Yes" << endl; return 0;}
    A-=D;
    if (A<=0) {cout << "No" << endl; return 0;}
  }
}

Measured memory_bytes: 3580
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define maxn 200005
#include <bits/stdc++.h>
using namespace std;

ll A[maxn], frq[maxn];
ll cal(ll n){
    if(n <= 1) return 0;
    ll res = n * (n-1);
    res /= 2;
    return res;
}




int main() {
    ll n, sum = 0;
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> A[i];
        frq[A[i]] ++;
    }
    for(int i=1;i<=n;i++){
        sum += cal(frq[i]);
    }
    for(int i=1;i<=n;i++){
        ll res = sum - (frq[A[i]] - 1);
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 4736
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>

using namespace std;

int main()
{
    int p, q, r;
    cin >> p >> q >> r;

    vector<int> sums = { p + q, q + r, r + p };
    cout <<
        accumulate(sums.begin(), sums.end(), INT_MAX,
                   [](auto a,auto b) { return min(a,b); })
         << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for (auto &e : a) std::cin >> e;
    int ret = 0;
    for (int i = 1; i < n - 1; i++) {
        if ((a[i] - a[i - 1]) * (a[i] - a[i + 1]) < 0) ret++;
    }
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using namespace boost::multiprecision;

#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)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define ALL(x) (x).begin(),(x).end()

int main () {
  int n, a, b;
  string s;

  cin >> n >> a >> b >> s;
  int qualifying = 0;
  int foreign = 0;
  REP(i, n) {
    if(s[i] == 'a' && ((a + b) > qualifying)) {
      cout << "Yes" << endl;
      qualifying++;
    }
    else if(s[i] == 'b' && ((a + b) > qualifying) && (b > foreign)) {
      cout << "Yes" << endl;
      qualifying++;
      foreign++;
    }
    else {
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 896
n = int(input())
a = list(map(int,input().split()))
b = [0] * n
for i in range(n):
    if (a[i]%2 == 0) and (a[i]%3 != 0) and (a[i]%5 !=0):
        b[i] = 1
        print('DENIED')
        exit()
if sum(b) == 0:
    print('APPROVED')


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

using namespace std;

using i32 = int32_t;
using u32 = uint32_t;
using f32 = float;
using f64 = double;
using i64 = int64_t; 
using u64 = uint64_t; 

#define SELECTER(_1, _2, _3, _4, _5, _6, _7, _8, SELECT, ...) SELECT

#define _FC1(func, type, _1)      func(type, _1) 
#define _FC2(func, type, _1, ...) func(type, _1); _FC1(func, type, __VA_ARGS__)
#define _FC3(func, type, _1, ...) func(type, _1); _FC2(func, type, __VA_ARGS__) 
#define _FC4(func, type, _1, ...) func(type, _1); _FC3(func, type, __VA_ARGS__)
#define _FC5(func, type, _1, ...) func(type, _1); _FC4(func, type, __VA_ARGS__)
#define _FC6(func, type, _1, ...) func(type, _1); _FC5(func, type, __VA_ARGS__)
#define _FC7(func, type, _1, ...) func(type, _1); _FC6(func, type, __VA_ARGS__)
#define _FC8(func, type, _1, ...) func(type, _1); _FC7(func, type, __VA_ARGS__)

#define _FCN(func, type, ...) SELECTER(__VA_ARGS__, _FC8, _FC7, _FC6, _FC5, _FC4, _FC3, _FC2, _FC1)(func, type, __VA_ARGS__)

constexpr const char *type2fmt(const char *fmt) {
  if(strcmp(fmt, "i32") == 0) return "%d";
  if(strcmp(fmt, "u32") == 0) return "%u";
  if(strcmp(fmt, "f32") == 0) return "%f";
  if(strcmp(fmt, "f64") == 0) return "%lf";
  if(strcmp(fmt, "i64") == 0) return "%lld";
  if(strcmp(fmt, "u64") == 0) return "%llu";
  return "";
}

#define _R(type, _1) type _1; { type _t; scanf(type2fmt(#type), &_t); _1 = _t; }
#define _P(type, _1) { const type _t = (_1); printf(type2fmt(#type), _t); putchar('\n'); }

#define RI(...)   _FCN(_R, i32, __VA_ARGS__)
#define RUI(...)  _FCN(_R, u32, __VA_ARGS__)
#define RF(...)   _FCN(_R, f32, __VA_ARGS__)
#define RD(...)   _FCN(_R, f64, __VA_ARGS__)
#define RLL(...)  _FCN(_R, i64, __VA_ARGS__)
#define RULL(...) _FCN(_R, u64, __VA_ARGS__)

#define PI(...)   _FCN(_P, i32, __VA_ARGS__)
#define PUI(...)  _FCN(_P, u32, __VA_ARGS__)
#define PF(...)   _FCN(_P, f32, __VA_ARGS__)
#define PD(...)   _FCN(_P, f64, __VA_ARGS__)
#define PLL(...)  _FCN(_P, i64, __VA_ARGS__)
#define PULL(...) _FCN(_P, u64, __VA_ARGS__)

#define REP(n) for (int _i = 0; _i < n; _i++)

const u64 mod = 1000000007;

u64 f(u64 n) {
  return ((n + 1) / 2 % 2) ^ (n % 2 ? 0 : n);
}

int main() {
  RULL(A, B);
  
  PULL(f(B) ^ f(A) ^ A);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

const int mod = 1e9 + 7;

vector<long long int> fac;

long long int mypow(long long int a, long long int b) {
    if (b == 0) return 1;
    if (b == 1) return a;
    long long int res = mypow(a, b / 2);
    res = res * res % mod;
    if (b % 2 == 1) res *= a;
    return res % mod;
}

long long int myc(long long int a, long long int b) {
    return fac[a] * mypow(fac[b] * fac[a - b] % mod, mod - 2) % mod;
}

long long int mya(long long int a, long long int b) {
    return fac[a] * mypow(fac[a - b], mod - 2) % mod;
}

int main() {
    long long int n, m;
    cin >> n >> m;
    fac.push_back(1);
    for (long long int i = 1; i <= m; i++) {
        fac.push_back(fac.back() * i % mod);
    }
    long long int res = 0;
    for (long long int i = 0; i <= n; i++) {
        res += (i % 2 == 1 ? -1 : 1) * mya(m - i, n - i) % mod * mya(m - i, n - i) % mod * mya(m, i) % mod * myc(n, i) % mod;
        res %= mod;
    }
    res = (res + mod) % mod;
    cout << res << endl;
}


Measured memory_bytes: 7368
var i: longint;
n,sum,sum1: string;
begin

read(n);  
for i:=1 to length(n) do
if n[i]<>' ' then sum:=sum+n[i] else break;
for i:=i to length(n) do
if n[i]<>' ' then sum1:=sum1+n[i];
write(sum1,sum);


end.

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int a[100000], n;
vector<int>vec;
int main() {
	cin >> n; for (int i = 0; i < n; i++)cin >> a[i];
	if (n == 1) { cout << "1" << endl; return 0; }
	int cnt = 1;
	for (int i = 1; i < n; i++) {
		if (a[i - 1] == a[i]) { vec.push_back(cnt); cnt = 1; }
		else { cnt++; }
	}
	vec.push_back(cnt);
	int maxn = 0;
	for (int i = 0; i < vec.size(); i++) {
		int p1 = vec[i];
		int p2 = 0; if (i >= 1)p2 = vec[i - 1];
		int p3 = 0; if (i < vec.size() - 1)p3 = vec[i + 1];
		maxn = max(maxn, p1 + p2 + p3);
	}
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 3532
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	ll r,d, x; cin>>r>>d>>x;
	ll cur = x;
	for(int i = 0 ; i<10; i++)
	{
		cur = r*cur - d;
		cout<<cur<<"\n";
	}
}

Measured memory_bytes: 256
X, Y = list(map(int, input().split()))
 
if (4 * X - Y) % 2 == 1:
    print("No")
    exit()
 
if (-2 * X + Y) % 2 == 1:
    print("No")
    exit()
 
turu = (4 * X - Y) // 2
kame = (-2 * X + Y) // 2
if turu < 0 or kame < 0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 61892
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N, M = sc.nextInt()
    val A = Array.fill(N)(sc.nextLong() / 2)

    // aの要素は全て偶数, pが整数であることから,
    // Xは奇数である必要がある. (偶数の場合, pが整数でなくなる.)
    // とにかく, 任意のa_kである数Xを割った数のあまりが a_k / 2 の場合,
    // pが存在すると考えられる.
    // X = (a_k / 2)(2p + 1)
    // なので, 常に 2p + 1は奇数である必要があり,
    // a_k / 2 を2で割れる回数は全て一致している必要がある.
    def div2count(n: Long): Long = {
      def loop(n: Long, count: Long): Long =
        if (n % 2 == 0) loop(n / 2, count + 1)
        else count
      loop(n, 0)
    }

    def gcd(a: Long, b: Long): Long =
      if (a % b == 0) b
      else gcd(b, a % b)

    def lcm(a: Long, b: Long): Long =
      a * b / gcd(a, b)

    val res =
      if (A.map(div2count).forall(_ == div2count(A(0)))) {
        val l = A.reduce(lcm)
        (1L to (M / l) by 2).size
      } else 0

    println(res)
  }

}


Measured memory_bytes: 52604
#include <bits/stdc++.h>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int H,W;
char a[1010][1010];

// dp[i][j]: マス(i,j)に移動するまでの経路数
int dp[1010][1010];  // 0に初期化

int main()
{
  cin >> H >> W;
  REP(i,0,H) REP(j,0,W) cin >> a[i][j];

  // Init:
  // REP(i,0,H) dp[i][0] = 1;
  // REP(j,0,W) dp[0][j] = 1;
  dp[0][0] = 1;

  // Update:
  REP(i,0,H) REP(j,0,W) {
    // (i,j)への経路数 (貰う)
    // 下 (i-1,j) -> (i,j)
    if (i >= 1 && a[i-1][j] == '.') {
      dp[i][j] += dp[i-1][j];
      dp[i][j] %= MOD;
    }
    // 右 (i,j-1) -> (i,j)
    if (j >= 1 && a[i][j-1] == '.') {
      dp[i][j] += dp[i][j-1];
      dp[i][j] %= MOD;
    }
  }

  cout << dp[H-1][W-1] << endl;

  return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

int t[12][12];

int main(){
  int n;

  while(cin >> n, n){
    //ツ配ツ療アツづー0ツづ?渉可甘コツ可サツつオツづ?つィツつュ
    memset(t, 0, sizeof(t));

    //ツ禿シツ療債つキツづゥツづつつ「ツづ?づ? ツ債?計ツづ可堕ォツつオツつアツづ敖づ?行ツつ、
    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
        cin >> t[i][j];

        t[i][n] += t[i][j];
        t[n][j] += t[i][j];
        t[n][n] += t[i][j];
      }
    }

    //ツ出ツ療?
    for(int i = 0; i <= n; i++){
      for(int j = 0; j <= n; j++){
        printf("%5d", t[i][j]);
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 1192
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
using namespace std ;
using ll = long long;

/*
int main(){
    ll N;
    ll cost = 0;
    ll h[20000];
    cin >> N;
    for(int i=0; i<=N; i++){
        cin >> h[i];
    }
    for(int i=0; i != N; i++){
        if(abs(h[i]-h[i+1])>=abs(h[i]-h[i+2])){
            // h[i] = h[i+2];
            cost = cost + abs(h[i]-h[i+1]);
        }else{
            // h[i] = h[i+1];
            cost = cost + abs(h[i]-h[i+2]);
            i = i+1;
        }
    }
    cout << cost << endl;
    return 0 ;
}
*/

int main(){
    ll n, k;
    cin >> n >> k;

    //hの初期化
    vector<ll> h;
    for(ll i=0; i<n; i++){
        ll t;
        cin >> t;
        h.push_back(t);
    }

    //コストの初期化
    vector<ll> dp(2000000);
    for(ll i=0; i<n; i++){
        dp[i] = 10000000000;
    }
    dp[0]=0;

    //dpの更新
    for(ll i=0; i<n; i++){
        for(ll j=1; j<=k; j++){
            dp[i+j] = min(dp[i+j],dp[i] + abs(h[i]-h[i+j]));
        }
    }

    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 16756
// A - Restaurant

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

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

	int x = 800 * N;
	int y = (N / 15) * 200;

	int ans = x - y;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = ll(1e9) + 7LL;

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    if (v.size() > 0) {
        os << v[v.size() - 1] << endl;
    }
    return os;
}

ll extgcd(ll a, ll b, ll &x, ll &y) {  // extended Euclidean algorithm, used for
                                       // modular multiplicative inverse
    ll d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;  // return gcd(a,b)
}

ll mod_inv(ll a, ll m = MOD) {  // return inv(a) mod m, ax+my=gcd(a,m)=1, m is
                                // prime int, ax-1=mq equiv. ax-mq=1
    ll x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m;  // From (possibly) negative x to positive x
}

vector<ll> fact, invfact;
void calc_fact(int n, ll m = MOD) {  // Calculate factorial up to n
    fact.resize(n + 1);
    invfact.resize(n + 1);
    fact[0] = invfact[0] = 1;
    REP(i, n) {
        fact[i + 1] = fact[i] * (i + 1) % m;
        invfact[i + 1] = invfact[i] * mod_inv(i + 1) % m;
    }
}
ll perm(int n, int k, ll m = MOD) {
    if (n < 0 || k < 0 || k > n) return 0;
    return fact[n] * invfact[n - k] % m;
}
ll comb(int n, int k, ll m = MOD) {
    if (n < 0 || k < 0 || k > n) return 0;
    return (fact[n] * invfact[n - k] % m) * invfact[k] % m;
}

int main() {
    ll n;
    cin>>n;
    vll l(n), r(n);
    vector<pll> p(n);
    REP(i, n) {
        ll a, b;
        cin >> a >> b;
        p[i].second = a - b;
        p[i].first = a + b;
    }
    sort(p.begin(), p.end());
    ll now = LLONG_MIN, ans = 0;
    REP(i,n){
        if (p[i].second >= now){
            now = p[i].first;
            ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 6256