akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <valarray>
#include <utility>
#include <cctype>
#include <numeric>
#include <memory>
#include <functional>
#if __cplusplus >= 201103L
#include <cwchar>
#include <cwctype>
#include <array>
#include <forward_list>
#include <unordered_map>
#include <unordered_set>
#include <ratio>
#endif
using namespace std;
#define Debug(x) cerr << #x << " = " << x << endl
#define Debug22(x,y) cerr<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<endl;
#define Debug2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define Debug3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<")\n";
#define Debug_arr(v,n) for(int i=0;i<n;++i) cerr<<#v<<"["<<i<<"]"<<" = "<<v[i]<<endl;
#define SET(p,v) fill((__typeof(**p)*)p,(__typeof(**p)*)p+sizeof(p),v);
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define prl cerr << "called: " << __LINE__ << endl
#define mod 1000000007
#define int long long
using namespace std;
int a[114514];
int cnt[114514];
int kaijo[114514];
int kinv[114514];
int modpow(int x, int n, int md) {
	if (n == 0)return 1;
	int res = modpow(x*x%mod, n / 2, mod);
	if (n & 1)res = res*x%mod;
	return res%mod;
}
 
int comb( int n, int r){
	if (n < r)return 0;
	int ans = kaijo[n] * kinv[r];
	ans %= mod;
	return ans*kinv[n - r] % mod;
}
signed main() {
	int n;
	cin >> n;
	for (int i = 0; i <= n; i++)cin >> a[i];
 
	for (int i = 0; i <= n; i++)cnt[a[i]]++;
	int kas;
	for (int i = 0; i <= n; i++) {
		if (cnt[i] == 2)kas = i;
	}
	int l, r;
	for (int i = 0; i <= n; i++) {
		if (a[i] == kas) {
			l = i;
			break;
		}
	}
	for (int i = l + 1; i <= n; i++) {
		if (a[i] == kas)r = i;
	}
 
	kaijo[0] = 1;
	for (int i = 1; i <= 114514; i++) {
		kaijo[i] = kaijo[i - 1] * i;
		kaijo[i] %= mod;
	}
 
	for (int i = 0; i <= 114514; i++) {
		kinv[i] = modpow(kaijo[i], mod - 2, mod);
	}
 
	for (int i = 1; i <= n + 1; i++) {
		int x = l + n - r;
		int y = i - 1;
		int ans = comb(x, y);
		int cmb = comb(n + 1, i);
		cout << (cmb - ans+mod) % mod << endl;
	}
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N=10000;

int main()
{
    int a,b,d;
    while(cin >>a >>b >>d,a)
    {
        int x=50001,y=50001;
        for(int i=-N; i<=N; ++i)
        {
            int v = d-a*i;
            if(v%b==0)
            {
                int j = v/b;
                int X = abs(i), Y = abs(j);
                if(x+y>X+Y || (x+y==X+Y && a*x+b*y>a*X+b*Y))
                {
                    x=X;
                    y=Y;
                }
            }
        }
        printf("%d %d\n", x,y);
    }
    return 0;
}

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

#define int long long

int w, h, n;
int x[200010];
int y[200010];
char d[200010];

map<int, int> zip;
vector<pair<int, int> > member[200010];

int id[200010];

signed main(){
    cin >> w >> h >> n;
    vector<int> vec;

    {
        for(int i = 0;i < n;i++){
            cin >> x[i] >> y[i] >> d[i];
            vec.push_back(y[i]+x[i]);
        }

        sort(vec.begin(), vec.end());
        vec.erase(unique(vec.begin(), vec.end()), vec.end());

        for(int i = 0;i < vec.size();i++){
            zip[vec[i]] = i;
        }
    }

    for(int i = 0;i < n;i++){
        member[zip[y[i]+x[i]]].push_back(make_pair(x[i], i));
    }

    for(int i = 0;i < vec.size();i++){
        sort(member[i].begin(), member[i].end(), greater<pair<int, int> >());

        queue<int> que1;
        queue<int> que2;

        queue<int> ans;

        for(int j = 0;j < member[i].size();j++){
            int idx = member[i][j].second;
            if(d[idx] == 'S'){
                if(x[idx] % 2 == 0){
                    que1.push(idx);
                }else{
                    que2.push(idx);
                }
            }else{
                if((y[idx]+x[idx])%2 == 0){
                    if(x[idx]%2 == 0){
                        que1.push(idx);
                        ans.push(que1.front());
                        que1.pop();
                    }else{
                        que2.push(idx);
                        ans.push(que2.front());
                        que2.pop();
                    }
                }else{
                    if(x[idx]%2 == 1){
                        que1.push(idx);
                        ans.push(que1.front());
                        que1.pop();
                    }else{
                        que2.push(idx);
                        ans.push(que2.front());
                        que2.pop();
                    }
                }
            }
        }

        for(int j = 0;j < member[i].size();j++){
            int idx = member[i][j].second;
            if(d[idx] == 'S'){
                if(x[idx] % 2 == 0){
                    id[idx] = que1.front();
                    que1.pop();
                }else{
                    id[idx] = que2.front();
                    que2.pop();
                }
            }else{
                id[idx] = ans.front();
                ans.pop();
            }
        }
    }

    priority_queue<pair<int, int> > ans;

    for(int i = 0;i < n;i++){
        if(d[i] == 'S'){
            ans.push(make_pair(-(h-y[i]), -id[i]));
        }else{
            ans.push(make_pair(-(w-x[i]), -id[i]));
        }
    }

    while(!ans.empty()){
        cout << -ans.top().second+1 << endl;
        ans.pop();
    }

    return 0;
}



Measured memory_bytes: 36912
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<set>
using namespace std;
class uft {//union-find tree
public:
    int parent[100000];
    int size[100000];
    int root(int x);
    bool same(int x,int y);
    void unite(int x,int y);
};
int uft::root(int x){
    if(parent[x]==x){
        return x;
    }
    return parent[x] = root(parent[x]);
}
bool uft::same(int x,int y){
    if(root(x)==root(y)){
        return true;
    }else{
        return false;
    }
}
void uft::unite(int x,int y){
    x=root(x);
    y=root(y);
    if(x == y) return;
    parent[x] = y;
    size[y] = size[y]+size[x];
}

int main(){
    int N,M;
    vector<int> v[100001];
    cin>>N>>M;
    for(int i=0;i<N;i++){
        int K;
        cin>>K;
        for(int j=0;j<K;j++){
            int x;
            cin>>x;
            v[x].push_back(i);
        }
    }
    uft u;
    for(int i=0;i<N;i++){
        u.parent[i]=i;
        u.size[i]=1;
    }
    for(int j=1;j<=M;j++){
        if(v[j].size() > 1){
            for(int i=1;i<v[j].size();i++){
                u.unite(v[j][0],v[j][i]);
                //cout<<v[j][0]<<' '<<v[j][i]<<endl;
            }
        }
    }
    for(int j=1;j<=M;j++){
        if(v[j].size() > 1){
            for(int i=1;i<v[j].size();i++){
                u.unite(v[j][0],v[j][i]);
                //cout<<v[j][0]<<' '<<v[j][i]<<endl;
            }
        }
    }
    //cout<<u.size[u.root(0)]<<endl;
    bool flag=true;
    for(int i=1;i<N;i++){
        if(!u.same(0,i)){
            flag=false;
            break;
        }
    }
    if(flag){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    
    
    
    return 0;
}


Measured memory_bytes: 5500
#include <stdio.h>

int main()
{
	int a,b,k,ret;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&k);

	for (ret=100;ret>=1;ret--) {
		if (a%ret!=0) continue;
		if (b%ret!=0) continue;

		k--;
		if (k==0) break;
	}

	


	printf("%d\n",ret);
	return 0;
}


Measured memory_bytes: 128
n, k = map(int,input().split())
A = list(map(int,input().split()))

ans = float('inf')
for i in range(n-k+1):
    left = A[i]
    right = A[i+(k-1)]
    if right <= 0:
        ans = min(ans, abs(left))
    elif 0 <= left:
        ans = min(ans, right)
    else:
        tmp1 = 2*abs(left)+right
        tmp2 = 2*right+abs(left)
        ans = min(ans, min(tmp1, tmp2))
print(ans)

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

int main() {
  int n;
  //string s;
  cin >> n;
  vector<int> d(n);
  for(int i = 0; i < n; i++) {
    cin >> d.at(i);
  }
  //cout << p.at(0) << endl;
  sort(d.begin(), d.end());
  
  int ans = 0;
  ans = d.at(n/2) - d.at(n/2-1);
  cout << ans << endl;
  /*
  for(int i = 0; i < n; i++) {
    cout << d.at(i) << endl;
  }*/

  /*
  int count = 0;
  for(int i = 0; i < n-2; i++) {
    if(p.at(i+1) > p.at(i) && p.at(i+1) < p.at(i+2))
      count++;
    else if(p.at(i+1) < p.at(i) && p.at(i+1) > p.at(i+2))
      count++;
  }

    cout << count << endl;
  //else
    //cout << "No" << endl;
    */
}


Measured memory_bytes: 768
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var ST = ReadSplit();
            Println($"{ST[1]}{ST[0]}");
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static void YESOrNO(bool e) => Println(e ? "YES" : "NO");

        static void YesOrNo(bool e) => Println(e ? "Yes" : "No");

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());
        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}

Measured memory_bytes: 11220
#include<iostream>
using namespace std;
int main(){
    int a,b,c;
    cin >> a;
    cin >> b;
    cin >> c;

    if(a<b && a<c){
        if(b<c){
            cout << a<<" "<<b<<" "<<c <<"\n";
        }
        if(b>c){
            cout << a<<" "<<c<<" "<<b <<"\n";
        }
    }
    if(b<a && b<c){
        if(a<c){
            cout << b<<" "<<a<<" "<<c <<"\n";
        }
        if(a>c){
            cout << b<<" "<<c<<" "<<a <<"\n";
        }
    }
    if(c<a && c<b){
        if(a<b){
            cout << c<<" "<<a<<" "<<b <<"\n";
        }
        if(a>b){
            cout << c<<" "<<b<<" "<<a <<"\n";
        }
    }
    if(a == b){
        if(a<c){
            cout << a<<" "<<b<<" "<<c <<"\n";
        }
        if(a>c){
            cout << c<<" "<<a<<" "<<b <<"\n";
        }
    }
    if(b == c){
        if(a<b){
            cout << a<<" "<<b<<" "<<c <<"\n";
        }
        if(a>b){
            cout << b<<" "<<c<<" "<<a <<"\n";
        }
    }
    if(a == c){
        if(a<b){
            cout << a<<" "<<c<<" "<<b <<"\n";
        }
        if(a>b){
            cout << b<<" "<<a<<" "<<c <<"\n";
        }
    }
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <vector>
#include <iostream>
typedef long long ll;
typedef int64_t in;
using namespace std;
#define INF 1000000007


int main() {
	int n[5];
    int r[5];
    int minr = 10;

    int sum=0;
    for(int i=0; i<5; i++){
        cin >> n[i];
        r[i] = n[i] % 10;
        if(r[i] != 0) minr = min(r[i], minr);
        if(r[i] != 0) sum += n[i] + 10 - r[i];
        else sum += n[i];
    }

    if(minr != 10) sum += minr - 10;

    cout << sum << endl; 
}

Measured memory_bytes: 256
# https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/all/ALDS1_3_A
# 逆オペランド表記の理解とスタックの練習

# INPUT = [int(x) if x.isdigit() else x for x in input().split()]
INPUT = list(input().split())
stack = []  # listを用いてスタックを実装する

for x in INPUT:
    if x.isdigit():
        stack.append(x)
    else:
        second_item = stack.pop()
        first_item = stack.pop()
        tmp = eval(first_item + x + second_item)
        stack.append(str(tmp))

print(int(stack.pop()))



Measured memory_bytes: 5600
import sys
sys.setrecursionlimit(10**6)
if sys.platform in ['ios', 'win32', 'darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(x) for x in input().split()]

def main():
	N = INT()
	A = MAP()

	R = sum(A)
	# print(R)

	def solve(i):
		if i<N-1:
			if M[i] != -1:
				mi = M[i]
			else:
				mi = 2*A[i]-solve(i+1)
				M[i] = mi
		else:
			mi = 2*A[i]-solve(0)
			M[i] = mi
		return mi

	# print(M)
	M = [-1] * N
	M[0] = 0
	s = 0
	for i in range(1, N):
		s += solve(i)
	# print(s)

	M = [-1] * N
	M[0] = (R-s)

	ans = [solve(i) for i in range(N)]
	print(' '.join(map(str, ans)))

if __name__ == "__main__":
	main()

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

int main()
{
    int  n;
    cin>>n;
    bool flag=false;
    for(int i=1;i<=9;i++)
    {
        for(int j=1;j<=9;j++)
        {
            if(i*j==n)
            {
                flag=true;
                break;
            }
        }
    }
    cout<<(flag?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    
    int a, b;
    scanf("%d %d", &a, &b);
    
    if(a < b){
        printf("a < b\n");
    }else if(a > b){
        printf("a > b\n");
    }else{
        printf("a == b\n");
    }
    
return 0;

}



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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)

const LL mod=(1e9)+7;
int main()
{
    string s;
    cin>>s;
    REP(i,s.size())
    cout<<'x';
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

void f(int n,int m){
  int a[100],b[100];
  int suma=0,sumb=0;
  rep(i,n){
    cin>>a[i];
    suma+=a[i];
  }
  rep(i,m){
    cin>>b[i];
    sumb+=b[i];
  }
  sort(a,a+n);
  sort(b,b+m);

  rep(i,n){
    rep(j,m){
      if(suma-a[i]+b[j]==sumb-b[j]+a[i]){
        cout<<a[i]<<' '<<b[j]<<endl;
        return;
      }
    }
  }

  cout<<-1<<endl;
}


int main(){
  while(1){
    int n,m;
    cin>>n>>m;
    if(n==0) break;
    f(n,m);
  }

  return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  int a, b;
  cin >> a >> b;
  cout << (a-1)*(b-1) << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  string a, b;
  cin >> a >> b;
  int n = stoi(a + b);
  for (int i = 1; i * i <= 100100; i++)
  {
    if (n == i * i)
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 384
#include"bits/stdc++.h"
using namespace std;

int main(){
  vector<int> ans,b;
  int n,s;
  bool check;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> s;
    b.push_back(s);
  }
  while(true){
    check = false;
    for(int i = b.size()-1; i >= 0; i--){
      if(i+1 == b[i]){
        check = true;
        ans.push_back(i+1);
        b.erase(b.begin() + i);
        break;
      }
    }
    if(check == false){
      cout << -1 << endl;
      break;
    }
    if(b.size() == 0){
      for(int i = ans.size()-1; i >= 0; i--){
        cout << ans[i] << endl;
      }
      break;
    }
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>

#define NIL -1
#define MAX 100000

// void Calc::decompositPrime(int n, int A[])
// {
// 	A[0] = 1;
// 	int a = 2, i=1;
// 	while(n >= a*a){
// 		if(n%a == 0){
// 			n /= a;
// 			A[i] = a;
// 			i++
// 		}
// 		else a++;
// 	}
// 	A[i+1] = a;
// }


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

void multipleGcd(int A[], int i, int A0, int *ans)
{
	if(A[i+1] == NIL){
		*ans = A0;
		return;
	}
	A0 = gcd(A0, A[i+1]);
	multipleGcd(A, i+1, A0, ans);
}

int main()
{
	int N, X, num[MAX], ans;
	scanf("%d %d", &N, &X);
	for(int i=0; i<N; i++){
		scanf("%d", &num[i]);
		num[i] = abs(num[i]-X);
	}
	num[N] = NIL;
	multipleGcd(num, 0, num[0], &ans);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 512
#include <string>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;


int main() {
  int n;
  cin >> n;
  if(n<=104){
    cout << "0" << endl;
  }
 else if(135>n&&n>104){
    cout << "1" << endl;
  }
 else if(165>n&&n>=135){
    cout << "2" << endl;
  }
 else if(175>n&&n>=165){
    cout << "3" << endl;
  }
 else if(189>n&&n>=175){
    cout << "3" << endl;
  }
 else if(195>n&&n>=189){
    cout << "4" << endl;
  }
 else if(n>=195){
    cout << "5" << endl;
  }
}


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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;

const ll MOD = 1000000007;

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

	int l = s.length();
	REP(i,l) {
		int t = s[i] - 'A';
		cout << (char)('A'+(t+n)%26);
	}
	cout << endl;

}



Measured memory_bytes: 256
class Main{public static void main(String[]z)throws Exception{for(byte[]b=new byte[11];System.in.read(b)>0;System.out.println(b[0]%=10)){int i,l;for(i=l=10;i-->0;)b[i]-=48;for(;l-->0;)for(i=0;i<l;)b[i]+=b[++i]%10;}}}

Measured memory_bytes: 9340
import sys
input = sys.stdin.readline

N, D, a = [int(x) for x in input().split()]
XH = []
for _ in range(N):
    XH.append([int(x) for x in input().split()])
XH.sort()

#####segfunc######
def segfunc(x,y):
    return x + y

def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]    
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 

def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])

def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

#入力
n = N
A = [0] * N

#####単位元######
ide_ele = 0

#num:n以上の最小の2のべき乗
num =2**(n-1).bit_length()
seg=[ide_ele]*2*num

#init
init(A)

import bisect

X = []
H = []
for i in XH:
    X.append(i[0])
    H.append(i[1])
ans = 0
for i in range(N):
    x, h = X[i], H[i]
    idx_left = bisect.bisect_left(X, x - 2 * D)
    idx_right = bisect.bisect_right(X, x + 2 * D)
    tmp = query(idx_left, idx_right)
    if tmp < h:
        h -= tmp
        cnt = h // a + int(h % a != 0)
        ans += cnt
        update(i, a * cnt)
print(ans)
        


Measured memory_bytes: 107356
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		Long X = sc.nextLong();
      Long Y = sc.nextLong();
      ArrayList<Long> list = new ArrayList<Long>();
      list.add(X);
      while(true){
        if(list.size() == 1){
          if(X * 2 > Y){
            System.out.println(list.size());
            return;
          }else{
            list.add(X * 2);
          }
        }else{
          if(list.get(list.size() - 1) * 2 > Y){
            System.out.println(list.size());
            return;
          }else{
            list.add(list.get(list.size() - 1) * 2);
          }
        }
      }
	}
}


Measured memory_bytes: 22608
#include <iostream>
#include <algorithm>

using namespace std;

static const int MAX = 200000;

int main() {
    int n, R;
    int maxv = -1000000000;
    int minv;

    cin >> n;
    cin >> minv;
    for(int i = 1; i < n; i++) {
        cin >> R;
        maxv = max(maxv, R-minv);
        minv = min(minv, R);
    }

    cout << maxv << endl;


    return 0;
    
}


Measured memory_bytes: 3092
n = int(input())
li = [1,6,6**2,6**3,6**4,6**5,6**6,9,9**2,9**3,9**4,9**5]
dp = [100000]*100001
dp[0] = 0
for i in range(100001):
  for s in li:
    if i+s <= 100000:
      dp[i+s] = min(dp[i]+1,dp[i+s])
print(dp[n])

Measured memory_bytes: 3956
#include <iostream>
#include <cmath>
#include <vector>
#include <cstring>
using namespace std;

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define ms(arr, val) memset(arr, val, sizeof(arr))
#define incl(i, a, b) for(int i = a; i <= b; i++)
#define decl(i, a, b) for(int i = a; i >= b; i--)

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

    int n, d;
    cin >> n >> d;
    cout << ceil(1.0f * n / ((2 * d) + 1)) << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = []
cnt = 0
for i in range(n):
    b.append(abs(a[i]))
    if a[i] < 0:
        cnt += 1
if cnt%2 == 1:
    print(sum(b)-2*min(b))
else:
    print(sum(b))


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <functional>
 
using namespace std;
 
int main(void) {
    unsigned long int A = 0, B = 0, K = 0;
    cin >> A >> B >> K;
 
    if(A > K){
        A -= K;
    }else{
        K -= A;
        A = 0;
        if(B > K){
            B -= K;
        }else{
            B = 0;
        }
    }
    cout << A << " " << B << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){

    int n, a, b;
    cin >> n >> a >> b;
    
    if(a*n>b) {
        cout << b  << endl;
    }
    else {
        cout << a*n << endl;
    }

    return 0;    
}


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

bl = []

min_a = float("inf")
for a in al:
   min_a = min(a, min_a)
   bl.append(min_a)

cl = []

for a,b in zip(al, bl):
   cl.append(a-b)

cl = sorted(cl)

print(cl.count(cl[-1]))

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

int main(){
  int N, K;
  cin>>N>>K;
  int a[N];
  
  for(int i = 0; i < N; i++)cin>>a[i];
  
  sort(a, a + N, greater<int>());
  
  int sum = 0;
  
  for(int i=0; i<K; i++){
    sum += a[i];
  }
  
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,t,a,i;
    cin>>n;
    cin>>t>>a;
    int h[n],o[n];
    for(i=0;i<n;i++)
    {
        cin>>h[i];
    }
    for(i=0;i<n;i++)
    {
        o[i]=a*1000-(t*1000-6*h[i]);
        if(o[i]<0)
        {
            o[i]=-o[i];
        }
    }
    int ans=0,mini=o[0];
    for(i=1;i<n;i++)
    {
        if(o[i]<mini)
        {
            mini=o[i];
            ans=i;
        }
    }
    cout<<(ans+1)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

main()
{
 
int a,b;

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

int x,y,z;

x=a+b;y=a-b;z=a*b;

if (x>=y && x>=z) printf("%d",x);
else if(y>=x && y>=z) printf("%d",y);
else if(z>=x && z>=y) printf("%d",z);

return 0;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
long long k,a,b,nn;
void solve(){
    nn=k;
    while(true) {
        if(a<=nn&&nn<=b) {
            cout<<"OK"<<endl;
            break;
        }else if(b<nn) {
            cout<<"NG"<<endl;
            break;
        }
        nn+=k;
    }
}

int main(){
    cin>>k>>a>>b;

    solve();
    return 0;
}


Measured memory_bytes: 3592
s = list(map(str, input()))

k = 0
l = list()
for i in range(0, 3):
    for j in range(i, 3):
        if s[i] == s[j+1]:
            k += 1
    if k == 1:
        l.append(1)
    k = 0

if sum(l) == 2:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
import java.io.*;
import java.util.*;
public class Main implements Runnable {
    public void solve() throws Exception {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        long n = sc.nextLong();
        long m = sc.nextLong();
        long sum = 0;
        while (m>0){
            long a = sc.nextLong();
            sum+=a;
            m--;
        }
        if (n>=sum){
            out.println(n-sum);
        }else {
            out.println(-1);
        }
    }

    //main function//
    public static PrintWriter out;
    public static void main(String[] args) throws Exception {
        new Thread(null, new Main(), "", 1 << 26).start();
    }
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
    public void run() {
        try {
           solve();
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        } finally {
            out.close();
        }
    }
}


Measured memory_bytes: 34204
/*************************************************************************
  >         File: C.cc
  >       Author: lyyllyyl
  >         Mail: riho.yoshioka@yandex.com
  > Created Time: Sat 24 Sep 2016 08:07:18 PM CST
*************************************************************************/
#include <bits/stdc++.h>

inline int GetDis(char a, char b) {
  if (a == b) return 0;
  return b - 'a' + 'z' - a + 1;
}

char Get(char a, int step) {
  a += step;
  if (a > 'z') a = a - 'z' + 'a' - 1;
  return a;
}

int main() {
  std::ios::sync_with_stdio(0);
  std::string s;
  std::cin >> s;
  int k;
  std::cin >> k;
  for (int i = 0; i < (int) s.size(); ++i) {
    if (s[i] != 'a') {
      int dis = GetDis(s[i], 'a');
      if (dis > k) {
        continue;
      }
      else {
        k -= dis;
        s[i] = 'a';
      }
    }
  }
  if (k > 0) {
    char &c = s.back();
    k %= 26;
    c = Get(c, k);
  }
  std::cout << s << std::endl;
  return 0;
}


Measured memory_bytes: 592
# -*- coding: utf-8 -*-
import sys

def get_num():
    return int(input())


def get_nums(n):
    res = [0 for _ in range(n)]
    for i in range(n):
        res[i] = int(input())
    return res


def get_numbers():
    return map(int, input().split())


a, b = get_numbers()


if (a - b) % 2 == 1:
    print('IMPOSSIBLE')
else:
    print((a + b) // 2)

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

#define int long long



typedef long long ll;
typedef long double ld;








signed main(){
	ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int N,M;
    cin>>N>>M;
    vector<int> vis(N+1,0);
    int ans = N;
    vector<int> high(N+1);
    for(int i = 0;i < N;i++) cin>>high[i+1];
    for(int i = 0;i < M;i++){
    	int a ,b;
    	cin>>a>>b;
    	if(high[a] > high[b]){
    		if(vis[b] == 0){
    			vis[b] = 1;
    			ans--;
			}
		}
		else{
			if(high[a] < high[b]){
				if(vis[a] == 0){
					vis[a] = 1;
					ans--;
				}
			}
			else{
				if(vis[a] == 0){
					vis[a] = 1;
					ans--;
				}
				if(vis[b] == 0){
					vis[b] = 1;
					ans--;
				}
			}
		}
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4784
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC144B_81
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            bool flag1 = false;
            bool flag2 = false;

            for(int i = 1; i <= 9; i++)
            {
                for(int j = 1; j <= 9; j++)
                {
                    if (i * j == n)
                    {
                        flag1 = true;
                        break;
                    }
                }
                if (flag1)
                {
                    flag2 = true;
                    break;
                }
            }

            if (flag2)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> A(N);

    for (auto &x : A)
    {
        cin >> x;
    }
    int compa = (accumulate(A.begin(), A.end(), 0) + (4 * M)-1) / (4 * M);

    int ans = 0;
    for (auto &x : A)
    {
        if (compa <= x)
        {
            ans++;
        }
    }
    if (ans>=M)
    {
        cout << "Yes";
    }else
    {
        cout << "No";
    }
    cout << endl;
}

Measured memory_bytes: 3616
"use strict";
(function (){
    var s = require("fs").readFileSync("/dev/stdin", "utf8");
    var ary=s.split('\n').map(Number);
    for (var i=0; i<ary.length; i++){
	if (ary[i]===0){
	    break;
	}
	console.log("Case %d: %d",i+1, ary[i]);
    }
})();


Measured memory_bytes: 23244
#include<cstdio>

int main() {
    int a,b;
    std::scanf("%d %d",&a,&b);
        if(a < b) {
        std::printf("a < b");
    }
    else if(a > b ) {
        std::printf("a > b");
    }
    else if(a == b){
        std::printf("a == b");
    }
    std::printf("\n");
    return 0;
    }


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct Data {
    ll prev = -1;
    ll nxt = -1;
    ll value = INF;
};

Data D[500005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll Q;
    cin >> Q;
    ll index = 1;
    ll cursor = 0;
    REP(_, Q) {
        ll q;
        cin >> q;
        if (q == 0) {
            ll x;
            cin >> x;
            ll p = D[cursor].prev;
            D[cursor].prev = index;
            D[index].nxt = cursor;
            D[index].value = x;
            D[index].prev = p;
            if (p >= 0)
                D[p].nxt = index;
            cursor = index;
            index++;
        }
        else if (q == 1) {
            ll d;
            cin >> d;
            if (d > 0) {
                REP(i, abs(d)) {
                    cursor = D[cursor].nxt;
                }
            }
            else {
                REP(i, abs(d)) {
                    cursor = D[cursor].prev;
                }
            }
        }
        else {
            if (D[cursor].nxt >= 0)
                D[D[cursor].nxt].prev = D[cursor].prev;
            if (D[cursor].prev >= 0)
                D[D[cursor].prev].nxt = D[cursor].nxt;
            cursor = D[cursor].nxt;
        }

#if false
        vector<ll> v;
        ll tmp = 0;
        while (D[tmp].prev != -1) {
            ll p = D[tmp].prev;
            v.push_back(D[p].value);
            tmp = p;
        }
        reverse(v.begin(), v.end());
        REP(i, v.size()) {
            cout << v[i] << " ";
        }
        cout << endl;
#endif
    }

    vector<ll> v;
    cursor = 0;
    while (D[cursor].prev != -1) {
        ll p = D[cursor].prev;
        v.push_back(D[p].value);
        cursor = p;
    }
    reverse(v.begin(), v.end());
    REP(i, v.size()) {
        cout << v[i] << endl;
    }
    return 0;
}


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

int main() {
  int have;
  cin >> have;
  int happy = 0;
 
  while (true) {
    if(have >= 500) {
      have -= 500;
      happy += 1000;
    }
    else if (have >= 5) {
      have -= 5;
      happy += 5;
    }
    else {
      break;
    }
  }
  cout << happy << endl;
}

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

using ll = long long;
#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 1e9

int main(){
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A), b(B), x(M), y(M), c(M);
  int mina = INF, minb = INF;
  REP(i, A){
    cin >>a[i];
    mina = min(mina, a[i]);
  }
  REP(i, B){
    cin >> b[i];
    minb = min(minb, b[i]);
  }
  int ans = mina + minb;
  REP(i, M){
    cin >> x[i] >> y[i] >> c[i];
    x[i]--, y[i]--;
    ans = min(ans, a[x[i]] + b[y[i]] - c[i]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

//最小公倍数
ll lcm(ll x, ll y){
	ll g = gcd(x,y);
	return x/g*y;
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

int main() {
	int n, k;
	int ans = 0;
	cin >> n >> k;
	string s;
	cin >> s;
	int rl, lr;
	rl = lr = 0;
	rep(i,n-1){
		if(s[i]=='R' && s[i+1]=='L')
		{
			rl++;
			continue;
		}
		if (s[i] == 'L' && s[i + 1] == 'R')
		{
			lr++;
			continue;
		}
		ans++;
	}

	if(k >= max(rl,lr)){
		ans += min(rl, lr) * 2;
		if(rl!=lr){
			ans += 1;
		}
	}
	else
	{
		ans += k * 2;
	}
	cout << ans << endl;
}


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

int main()
{
    vector<int> vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n;
    cin >> n;
    cout << vec.at(n-1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
#define INF 1000000
#define LLINF 10000000000000000ll
#define MOD 998244353LL

bool dbgflag = false;

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

  int n, s;
  cin >> n >> s;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];

  vector<vector<ll>>dp(n+1, vector<ll>(s+1));
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= s; j++) {
      dp[i][j] = dp[i-1][j] * 2; //元の部分列にi個目を入れても入れなくてもいいが、i個目は和に使わない
      if (j - a[i-1] >= 0) {
        dp[i][j] += dp[i-1][j-a[i-1]];
      }
      dp[i][j] %= MOD;
    }
  }
  cout << dp[n][s] << endl;
}

Measured memory_bytes: 73688
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define forn(i,n) for(int i = 0; i < (int) n; i++)
#define ios ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;

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

  vector<int> v(n);
  forn(i,n) cin >> v[i];
  sort(all(v));

  int ans = 0;
  forn(i,k) ans += v[i];
  cout << ans << "\n";
}


Measured memory_bytes: 3628
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

fn main() {
  let n = read::<i32>();
  let mut a = vec![];

  for _ in 0..n {
    let a_i = read::<u32>();
    a.push(a_i);
  }

  let mut answer = a[0];

  for i in a {
    answer = gcd(answer, i)
  }

  println!("{}", answer);

}

fn gcd(a: u32, b: u32) -> u32 {
  if b == 0 {
    a
  } else {
    gcd(b, a % b)
  }
}



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

int main(){
    vector <int> a(3, 0);
    int ans = 0;

    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end());
    
    ans += abs(a[1] - a[0]);
    ans += abs(a[2] - a[1]);

    cout << ans << endl;

    return 0;
}


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

//#define int                long long int
#define jaldichal          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb                 push_back
#define mk                 make_pair
#define R                  return
#define line               "\n"
#define space              " "
#define all(x)             x.begin(),x.end()
#define w(x)               int x;cin>>x;for(int i=1;i<=x;i++)
#define vi                 vector<int>
#define setbits(x)         __builtin_popcountll(x)
#define ll                 long long 

int n,m;

ll int recursion(int a[],int K, int i, int previous_taken, ll int* dp){

     if(i >= n){
        return 0;
    }


    if(dp[i]!=-1){
        return dp[i];
    }

    // cout<<"?";
    ll int res = INT_MAX;
    for(int j =i+1;j<=i+K && j<n;j++){
        res = min(res,abs(previous_taken - a[j]) + recursion(a,K,j,a[j],dp));
    }
    if(res == INT_MAX)
        res =0;
      dp[i] = res;
return  res;
}


void solve()
{
    cin>>n;
    int a[n];
    int K;cin>>K;
    ll int dp[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        dp[i]= -1;
    }

    ll int ans = recursion(a,K,0,a[0],dp);
    cout<<ans<<line;
}

signed main()
{    
    jaldichal
    solve();

    return 0;
}



Measured memory_bytes: 12492
#include<iostream>
using namespace std;
int main(){
long n,d[10],i,j,a,b[8]={0,1,2,3,5,7,8,9};
while(cin>>n){
if(n==0)break;
for(i=0;;i++){
a=n/8;
d[i]=n%8;
n=a;
if(n==0)break;
}
for(j=i;j>=0;j--)cout<<b[d[j]];cout<<endl;
}
return 0;
}

Measured memory_bytes: 1156
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}


use input::*;
use std::collections::VecDeque;

fn main() {
    let s = input_line_str();
    let mut v = VecDeque::new();

    for z in s.chars() {
        if z == '0' {
            v.push_back("0");
        } else if z == '1' {
            v.push_back("1");
        } else {
            v.pop_back();
        }
    }
    for z in v {
        print!("{}", z);
    }
    println!("");
}


Measured memory_bytes: 4352
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
typedef long long int Int;

int main() {
  int N;
  while(cin >>N && N){
    vector<Int> v(N);
    REP(i, N) cin >>v[i];
    SORT(v);
    Int ans = 0;
    REP(i, N - 1) ans += v[i] * (N - i - 1);
    cout <<ans <<endl;
  }
  return 0;
}

Measured memory_bytes: 1296
#include <iostream>
using namespace std;
 int main(){
 int n,a,b,c,d,x=0,y=0;
 cin>>n>>a>>b>>c>>d;
 if(n%a==0)x=n/a*b;
 else x=(n/a+1)*b;
 if(n%c==0)y=n/c*d;
 else y=(n/c+1)*d;
 if(x<y)cout<<x<<endl;
 else cout<<y<<endl;
 return 0;
 }


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

int main() {
  int n;
  while ( cin >> n ) {
    vector<vector<int>> data(n, vector<int>(3)), dp = data;
    for ( int i = 0; i < n; ++i ) {
      cin >> data[i][0] >> data[i][1] >> data[i][2];
    }
    dp[0] = data[0];

    for ( int i = 1; i < n; ++i ) {
      for ( int j = 0; j < 3; ++j ) {
        dp[i][j] = max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]) + data[i][j];
      }
    }
    cout << *max_element(dp[n - 1].begin(), dp[n - 1].end()) << endl;
  }
  return 0;
}

Measured memory_bytes: 11136
#include <stdio.h>
#include <math.h>

int main(void)
{
    int N, D;
    int count = 0;
    long double tmp;
    long long X[200001],Y[200001];

    scanf("%d %d",&N, &D);
    for(int i=0; i<N; i++){
        scanf("%lld %lld",&X[i],&Y[i]);
    }

    for(int i=0; i<N; i++){
        tmp = X[i]*X[i] + Y[i]*Y[i];
        tmp = sqrt(tmp);
        if(tmp <= D) {
            //printf("i = %d\n",i);
            count++;
        }
    }

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

    return 0;
}

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

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
 
typedef long long ll;
using namespace std;
 
int main(){
  int r,g,b,ans;
  cin >> r >> g >> b;

  ans = (r*100 + g*10 + b)%4;

  if(ans == 0){
    printf("YES\n");
  }
  else printf("NO\n");
  return 0;
}

Measured memory_bytes: 256