akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)

ll n, ans;
ll a[2][110], s[2][110];

int main() {
	cin >> n;
	repi(i, 0, 2) repi(j, 0, n) {
		cin >> a[i][j];
		if (j == 0) s[i][j] = a[i][j];
		else s[i][j] = s[i][j - 1] + a[i][j];
	}

	ans = s[0][0] + s[1][n - 1];

	repi(i, 1, n) ans = max(ans, s[0][i] + s[1][n - 1] - s[1][i - 1]);

	cout << ans << endl;

	return 0;
}

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

int main(){
    int a,b,k,c=0;
    cin>>a>>b>>k;
    for(int i=min(a,b);i>0;i--){
        if(a%i==0 && b%i==0) c++;
        if(c==k){
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int countfour = 0;
		int counttwo = 0;
		for (int i = 0; i < n; i++) {
			int temp = scan.nextInt();
			if (temp % 4 == 0) {
				countfour++;
			} else if (temp % 2 == 0) {
				counttwo++;
			}
		}
		if (counttwo < 2) {
			if (n / 2 <= countfour) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
			return;
		}

		int ans = n - counttwo;
		if (ans % 2 == 1) {
			ans = ans + 1;
		}

		if (countfour >= ans / 2) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 48240
n,m=map(int,input().split())
edge=[[] for _ in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  a-=1
  b-=1
  edge[a].append(b)
  edge[b].append(a)
for j in edge:
  print(len(j))

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

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

const ll INF = 1LL << 62;
#define atcoder(int)1e9+7
#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back

ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

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

int n, m;
bool p[8][8];
bool j[8] = { false };
int ans = 0;

void dfs(int v) {

	bool c = false;
	for (int i = 0; i < n; i++) {
		if (!j[i]) c = true;
	}
	if (!c)ans++;

	for (int i = 0; i < n; i++) {
		if (p[v][i] == false)continue;
		if (j[i])continue;
		j[i] = true;
		dfs(i);
		j[i] = false;
	}

}

int main() {

	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		p[a][b] = p[b][a] = true;
	}

	for (int k = 0; k < n; k++)	j[k] = false;
	j[0] = true;
	dfs(0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
	int N, Q;
	cin >> N >> Q;
	string s;
	cin >> s;
	vector<char> t(Q), d(Q);
	for (int i = 0; i < Q; i++){
		cin >> t[i] >> d[i];
	}
	int t1 = -1;
	int f1 = N;
	while (f1 - t1 > 1){
		int mid = (t1 + f1) / 2;
		int pos = mid;
		for (int i = 0; i < Q; i++){
			if (s[pos] == t[i]){
				if (d[i] == 'L'){
					pos--;
				} else {
					pos++;
				}
			}
			if (pos == -1 || pos == N){
				break;
			}
		}
		if (pos == -1){
			t1 = mid;
		} else {
			f1 = mid;
		}
	}
	int t2 = N;
	int f2 = -1;
	while (t2 - f2 > 1){
		int mid = (t2 + f2) / 2;
		int pos = mid;
		for (int i = 0; i < Q; i++){
			if (s[pos] == t[i]){
				if (d[i] == 'L'){
					pos--;
				} else {
					pos++;
				}
			}
			if (pos == -1 || pos == N){
				break;
			}
		}
		if (pos == N){
			t2 = mid;
		} else {
			f2 = mid;
		}
	}
	cout << t2 - t1 - 1 << endl;
}

Measured memory_bytes: 3932
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
void solve(){
	
	ll N;
	int c=0;
	double D;
	cin>>N>>D;
	for(int i=0;i<N;i++)
	{
		double x,y;
		cin>>x>>y;
		if(x*x + y*y <= D*D)
				c++;
	}	
	cout<<c<<"\n";
	
}
int main()
{
	solve();
	return 0;
}


Measured memory_bytes: 3772
//============================================================================
// Name        : AtcoderDPF.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MAX = 3001;
int n, m,
	dp[MAX][MAX], parx[MAX][MAX], pary[MAX][MAX];
string s, t;

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

	cin >> s >> t;
	n = s.length();
	m = t.length();

	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			if(s[i - 1] == t[j - 1]){
				parx[i][j] = i - 1;
				pary[i][j] = j - 1;
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}
			else{
				int best = -1;

				if(dp[i - 1][j] > best){
					best = dp[i - 1][j];
				}
				if(dp[i][j - 1] > best){
					best = dp[i][j - 1];
				}

				dp[i][j] = best;
			}
		}
	}

	string lcs = "";

	int x = n, y = m;
	while(x != 0 && y != 0){
		int left = dp[x - 1][y], up = dp[x][y - 1], curr = dp[x][y];

		if(curr == left) x--;
		else if(curr == up) y--;
		else{
			lcs.push_back(s[x - 1]);
			x--;
			y--;
		}
	}

	reverse(lcs.begin(), lcs.end());

	printf("%s\n", lcs.c_str());
}


Measured memory_bytes: 105856
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 60);

int main(){
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  vector<ll> p(n);
  rep(i,n) cin >> x[i] >> y[i] >> p[i];

  vector<ll> dp(n + 1, INF);

  vector<vector<ll>> xcost(1 << n, vector<ll>(n));
  vector<vector<ll>> ycost(1 << n, vector<ll>(n));

  for (int bit = 0; bit < (1 << n); bit++) {
    for (int i = 0; i < n; i++) {
      xcost[bit][i] = abs(x[i]);
      ycost[bit][i] = abs(y[i]);

      for (int j = 0; j < n; j++) {
        if (bit & (1 << j)) {
          xcost[bit][i] = min(xcost[bit][i], (ll)abs(x[i] - x[j]));
          ycost[bit][i] = min(ycost[bit][i], (ll)abs(y[i] - y[j]));
        }
      }
    }
  }

    for (int bit = 0; bit < (1 << n); bit++) {
      for (int i = 0; i < n; i++) xcost[bit][i] *= p[i], ycost[bit][i] *= p[i];
    }

    for (int bit = 0; bit < (1 << n); bit++) {
      int cnt = __builtin_popcount(bit);

      for (int i = bit; i >= 0; i--) {
        i &= bit;
        ll tmp = 0;

        for (int j = 0; j < n; j++) {
          if (!(bit & (1 << j))) tmp += min(xcost[i][j], ycost[bit - i][j]);
        }
        dp[cnt] = min(dp[cnt], tmp);
    }
  }
  

  for (int i = 0; i <= n; i++) cout << dp[i] << "\n";
  return 0;
} 


Measured memory_bytes: 12968
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using Graph = vector<vector<int>>;
using ll = long long;
using p = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);

    rep(i, n)
    {
        cin >> a[i];
    }

    vector<ll> s(n + 1, 0);
    ll amari = 0;
    for (int i = 0; i < n; ++i)
    {
        s[i + 1] = s[i] + a[i];
    }

    rep(i, n)
    {
        ll b = (s[n] - s[i + 1]) % 1000000007;
        amari += b * (a[i] % 1000000007) % 1000000007;
        amari = amari % 1000000007;
    }

    cout << amari << endl;
}

Measured memory_bytes: 6336
n,k = map(int,input().split())

def diff(n,k):
  diff = 0
  if n > k:
    diff = n-k*(n//k)
  elif n < k:
    diff = k-n
  else:
    diff = 0
  return diff

ans = [n]

for i in range(100):
  ans.append(diff(ans[i],k))

print(min(ans))



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

ll gcd (ll x, ll y) { return y ? gcd(y,x%y) : x; }
ll lcm (ll x, ll y) { return x*y / gcd(x,y); }

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  auto f = [&](ll x) {
    ll num = x - (x/c + x/d - x/lcm(c,d));
    return num;
  };
  ll ans = f(b) - f(a-1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;

int main() {
	int n, s[1010];
	double ave, sum, alpha;
	while (1) {
		ave = 0; sum = 0; alpha = 0;
		cin >> n;
		if (n == 0) break;
		for (int i = 0; i < n; i++) {
			cin >> s[i];
			sum += s[i];
		}
		ave = sum / n;

		for (int i = 0; i < n; i++) {
			alpha += (s[i] - ave)*(s[i] - ave);
		}
		alpha /= n;
		alpha = sqrt(alpha);
		cout << fixed << setprecision(6) << alpha << endl;
	}
	return 0;
}

Measured memory_bytes: 1236
n = gets.to_i
an = gets.split(' ').map{|n| n.to_i}

min = nil
an.each do | a |
  counter = 0
  while a % 2 == 0
    a = a/2
    counter += 1
  end
  min = counter unless min
  min = counter if counter < min
end
puts min

Measured memory_bytes: 1788
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    ll x;
    cin >> x;
    
    ll n = x / 11;

    ll ans;

    if(x % 11 == 0){
        ans = n * 2;
    } else if(x % 11 <= 6){
        ans = n * 2 + 1;
    } else if(x % 11 > 6){
        ans = n * 2 + 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<cctype>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    string s;
    int a,b;
    while(cin>>a>>b)
    {
        cin>>s;
        int flag=1;
        for(int i=0;s[i]!='\0';i++)
        {
            if(i==a)
                i++;
            else
                if(s[i]>'9'||s[i]<'0')
            {flag=0;break;}
        }
        if(s[a]!='-')
            flag=0;
        if(flag==0)
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;
    }
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)

int h[220000];

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

    rep(i,n) cin >> h[i];

    sort(h, h+n, greater<int>());

    if (n <= k) {
        cout << 0 << endl;
        return 0;
    }

    long long int cnt = 0;
    for (int i = k; i < n; i++) {
        cnt += h[i];
    }

    cout << cnt << endl;
    return 0;

}

Measured memory_bytes: 1024
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, K := sc.nextInt(), sc.nextInt()
	H := sc.nextIntSlice(N)
	dp := make([]int, N)
	for i, _ := range dp {
		dp[i] = 1 << 60
	}
	dp[0] = 0
	for i := 1; i < N; i++ {
		for j := 1; j <= K; j++ {
			if i >= j {
				dp[i] = min(dp[i], dp[i-j]+abs(H[i]-H[i-j]))
			} else {
				break
			}
		}
	}

	fmt.Fprintln(wtr, dp[N-1])
	wtr.Flush()
}


Measured memory_bytes: 2816
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String O = sc.next();
    String E = sc.next();
    StringBuilder ans = new StringBuilder();
    for (int i = 0; i < O.length() + E.length(); i++) {
      if (i%2 ==0) {
        ans.append(O.charAt(i/2));
      } else {
        ans.append(E.charAt(i/2));
      }
    }
    
    System.out.println(ans.toString());
  }
}

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


int main(){
    int N;
    cin >> N;
    double v[50];
    for(int i=0; i<N; i++){
        cin >> v[i];
    }

    sort(v, v+N);
    
    double answer = v[0];

    for(int k=1; k<N; k++){
        answer = (answer+v[k])/2;
    }

    cout << answer;

    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().strip().split())
sunuke=[False]*n
for i in range(k):
    d=int(input().strip())
    L = list(map(int, input().strip().split()))
    for j in L:
        sunuke[j-1]=True
ans=0
for i in sunuke:
    if not i:
        ans+=1
print(ans)

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

const int dh[]={-1,1,0,0};
const int dw[]={0,0,-1,1};
const string com="UDLR";
const int rev[]={1,0,3,2};
int h,w;

bool isRange(int hp,int wp){
    return 0<=hp && hp<h && 0<=wp && wp<w;
}
string res;
bool dfs(int hp,int wp,int dir,vector<string>& c,int cnt){
    if(cnt==0) return true;
    for(int d=0;d<4;d++){
        if(dir==rev[d]) continue;
        int thp=hp,twp=wp;
        while(isRange(thp,twp)){
            if(c[thp][twp]=='o'){
                c[thp][twp]='.';
                if(dfs(thp,twp,d,c,cnt-1)){
                    res+=com[d];
                    return true;
                }
                c[thp][twp]='o';
                break;
            }
            thp+=dh[d],twp+=dw[d];
        }
    }
    return false;
}
int main(){
    cin>>h>>w;
    vector<string> c(h);
    for(int i=0;i<h;i++) cin>>c[i];

    int cnt=0;
    int hp=-1,wp=-1,dir=-1;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(c[i][j]=='o') cnt++;
            else if(c[i][j]!='.'){
                for(int k=0;k<4;k++){
                    if(com[k]==c[i][j]){
                        hp=i,wp=j;
                        dir=k;
                        c[i][j]='.';
                        break;
                    }
                }
            }
        }
    }
    dfs(hp,wp,dir,c,cnt);
    reverse(res.begin(),res.end());
    cout<<res<<endl;    
    return 0;
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int res=7%n;
	if(res==n||res==0){
		cout<<1;
		return 0;
	}
	for(int i=2;i<=1000000;i++){
		res=(res*10+7)%n;
		if(res==n||res==0){
			cout<<i;
			return 0;
		} 
	}
	cout<<-1;
	return 0;
} 

Measured memory_bytes: 3656
#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<sstream>
#include<cctype>
#include<cassert>
#include<algorithm>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)
#define INF (1LL<<40)
#define MAX 100
using namespace std;
typedef long long ll;

map<char,map<ll,ll> > array;//array[char][index] := value
ll sizes[MAX];
bool error,found;
int phase;

ll parse(string line,int pos,int depth)
{
  if(error)return -INF;
  assert(pos < line.size());
  if('0' <= line[pos] && line[pos] <= '9')
    {
      int from = pos;
      while('0' <= line[pos] && line[pos] <= '9')pos++;
      return (atol)(line.substr(from,pos-from).c_str());
    }
  else
    {
      char c = line[pos];
      pos+=2;
      ll value = parse(line,pos,depth+1);      
      pos++;

      if(depth == 0)return value;

      if(array[c].find(value) == array[c].end())
	{
	  error = true;
	  return -INF;
	}

      if(sizes[c-'A'] <= value || sizes[c-'A'] == -INF)
	{//array index out of bounds
	  error = true;
	  return -INF;
	}
      
      return array[c][value];
      
    }
}

bool check(string line)
{
  if(line.find("=") == string::npos)//declaration
    {//verify [yes]
      char c = line[0];
      ll size = (atol)(line.substr(2,line.size()-3).c_str());
      //cout << "array's name is " << c << endl;
      //cout << "the size is " << size << endl;
      sizes[c-'A'] = size;
    }
  else//assignment
    {
      stringstream ss;
      string L,R;
      char   l,r;

      rep(i,line.size())if(line[i] == '=')
	{
	  line[i] = ' ';
	  break;
	}

      ss << line;
      ss >> L >> R;
      //cout << L << " " << R << endl;
      l = L[0], r = R[0];

      ll vL = parse(L,0,0);
      ll vR = parse(R,0,0);
      //cout << "Left informatin : " << L << " : " << l << " : " << vL << endl;
      //cout << "Right informatin: " << R << " : " << r << " : " << vR << endl;
      if(error)return error = false;
      if(sizes[l-'A'] <= vL || (!isdigit(r) && sizes[r-'A'] <= vR))
	{
	  //cout << "in check : array index out of bounds! : " << (sizes[l-'A'] <= vL?"Left":"") << (sizes[r-'A'] <= vR?" Right":"")  << endl;
	  return error = false;
	}

      if(!isdigit(r) && array[r].find(vR) == array[r].end())
	{
	  //cout << "there are no value in array[" << r << "][" << vR << "]" << endl;
	  return error = false;
	}

      //cout << "accepted! :: array["<<l<<"]["<<vL<<"] = (isdigit("<<R[0]<<")?"<<vR<<":"<<array[r][vR]<<")" << endl;
      array[l][vL] = (isdigit(R[0])?vR:array[r][vR]);

    }
  return true;
}

void init()
{
  phase = 1;
  rep(i,MAX)sizes[i] = -INF;
  array.clear();
  error = found = false;
}

int main()
{
  string line;
  init();
  while(cin >> line)
    {
      if(line == ".")
	{
	  if(phase != 1 && !found)cout << 0 << endl;
	  init();
	  continue;
	}
	
      if(!found && !check(line))
	{
	  cout << phase << endl;
	  found = true;
	}
      phase++;
    }
  return 0;
}

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

int main(){
	int n,m;
	cin>>n>>m;
	string a[50],b[50];
	for (int i = 0; i < n; i++){
		cin>>a[i];
	}
	for (int i = 0; i < m; i++){
		cin>>b[i];
	}

	for (int i = 0; i < n-m+1; i++){
		for (int j = 0; j < n-m+1; j++){
			bool flag = true;
			for (int k = 0; k < m; k++){
				for (int l = 0; l < m; l++){
					if(a[i+k][j+l]!=b[k][l])
						flag=false;
				}
			}
		if(flag){
			cout<<"Yes"<<endl;
			return 0;
			}
		}
	}

	cout<<"No"<<endl;


}

Measured memory_bytes: 256
// UTPC2010 C. RpC

#include <iostream>
#include <string>
#include <queue>
#include <string.h>

using namespace std;

char dx[] = {-1, 0, 1, 0};
char dy[] = {0, -1, 0, 1};

int main(){
	string s[12];
	bool visit[12][6], erase[12][6];
        int T; cin >> T;
	while(T--){
		for(int i=0;i<12;i++) cin >> s[i];
		int ans = 0;
		while(true){
			memset(visit, false, sizeof(visit));
			memset(erase, false, sizeof(erase));
			for(int i=0;i<12;i++){
				for(int j=0;j<6;j++){
					if(!visit[i][j]&&s[i][j]!='.'&&s[i][j]!='O'){
						queue< pair<int, int> > qu; qu.push(make_pair(i,j));
						int cnt = 0;
						while(!qu.empty()){
							pair<int, int> p = qu.front(); qu.pop();
							if(erase[p.first][p.second]) continue;
							erase[p.first][p.second] = true;
							cnt++;
							for(int k=0;k<4;k++){
								int nx = p.first + dx[k], ny = p.second + dy[k];
								if(nx < 0 || 12 <= nx || ny < 0 || 6 <= ny || s[p.first][p.second]!=s[nx][ny]) continue;
								qu.push(make_pair(nx,ny));
							}
						}
						if(cnt >= 4) memcpy(visit, erase, sizeof(visit));
						memcpy(erase, visit, sizeof(erase));
					}
				}
			}
			for(int i=0;i<12;i++){
				for(int j=0;j<6;j++){
					if(s[i][j]!='O') continue;
					for(int k=0;k<4;k++){
						int nx = i + dx[k], ny = j + dy[k];
						if(nx < 0 || 12 <= nx || ny < 0 || 6 <= ny || !erase[nx][ny] || s[nx][ny] == 'O') continue;
						erase[i][j] = true;
					}
				}
			}
			bool next = false;
			for(int i=0;i<12;i++){
				for(int j=0;j<6;j++){
					if(erase[i][j]){
						next = true;
						s[i][j] = '.';
					}
				}
			}
			for(int i=0;i<6;i++){
				vector<char> vc;
				for(int j=11;j>=0;j--){
					if(s[j][i]!='.') vc.push_back(s[j][i]);
					s[j][i] = '.';
				}
				for(int j=0;j<vc.size();j++)
					s[11-j][i] = vc[j];
			}
			if(next) ans++;
			else     break;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
#include<cstdio>
#include<map>
using namespace std;
const int MOD=1000000007;

map<long long,long long> dp;
long long DP(long long n)
{
	if(dp[n])
		return dp[n];
	dp[n]=(DP(n/2)+DP((n-1)/2)+DP((n-2)/2))%MOD;
	return dp[n];
}

int main()
{
	dp[0]=1;
	dp[1]=2;
	long long n;
	scanf("%lld",&n);
	printf("%lld\n",DP(n));
	return 0;
}


Measured memory_bytes: 256
n = int(input())

def make753(x):
    count = 0
    if int(x) > n:
        return 0
    if all(x.count(i) > 0 for i in '753'):
        count += 1
    for i in '753':
        count += make753(x + i)
    return count

print(make753('0'))

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define MOD 1000000007
//for(int i=0; i<n; ++i)
using namespace std;
#define all(c) c.begin(), c.end()

int main()
{
    int n, a;
    vector<int> v;
    double r;
    cin >> n;

    for (int i = 0; i < n; ++i)
    {
        cin >> a;
        v.push_back(a);
    }
    sort(all(v));

    r = v[0];
    for (int i = 1; i < n; ++i)
    {
        r = (r + (1.0) * v[i]) / 2.0;
    }

    printf("%0.5f\n", r);
    return 0;
}

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

using namespace std;

int n;

int main(){
    cin >> n;
    int cnt = 0;
    for(int A = 1; A <= n; A++){
        for(int B = 1; A*B <= n; B++){
            int C = n - A*B;
            if( (A*B + C) == n && C > 0){
                cnt++;
            }
        }
    }
    cout << cnt << "\n";
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
	char a;
	int ct = 0;
	cin >> a;
	while(1){
		if(a == 'Z'){
			if(ct < 26){
				cout << "A" << endl;
				return 0;
			}else{
				cout << "a" << endl;
				return 0;
			}
		}
		a++;
		ct++;
	}
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<"="<<x
#define nl cout<<"\n"
#define frn(i,n) for(int i = 0;i < n;i++)
#define fr(i,a,b) for(int i = a;i < b;i++)
#define pb push_back
#define trav(x,c) for(auto &x:c)
using namespace std;

int toint(string s)
{
    int ans = 0;
    for(char x: s)
        ans = ans*10 + (x - '0');
    return ans;
}

int sum(int x)
{
    int s = 0;
    while(x)
    {
        s += x%10;
        x /= 10;
    }
    return s;
}

bool equal(string s)
{
    for(int i = 0,j = s.size()/2; j < s.size(); i++,j++)
    {
        if(s[i] != s[j])
            return false;
    }
    return true;
}

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int f = 1;
    set<int> vis;
    set<int> :: iterator it;
    while(true)
    {
        int r = (a*f)%b;

        if(r==c)
        {
            cout<<"YES"<<endl;

            return 0;
        }
        if(vis.find(r) != vis.end())
        {
            cout<<"NO"<<endl;
            return 0;

        }
        vis.insert(r);
        f++;
        //  printf("%d \n",r);
    }
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int odd = 0;

		for (int i = 0; i < N; i++) {
			if (scan.nextInt() % 2 == 1) odd++;
		}

		System.out.println(odd % 2 == 0 ? "YES" : "NO");
	}
}

Measured memory_bytes: 48276
#include<bits/stdc++.h>
#define pb push_back
#define REP(i,j,n) for(int i=j ; i<n ; i++)
#define RREP(i,n,j) for(int i=n ; i>=j ; i--)
#define ppb pop_back()

using namespace std;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	// int q;cin>>q;
	// while(q--)
	// {
		int n;cin>>n;
		if(n%1000==0) {cout<<0;return 0;}
		cout<< 1000-n%1000;
	// }


	return 0;

}

Measured memory_bytes: 3656
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include<string>
#include <algorithm>
#include <functional>
#include <cmath>
using namespace std;
typedef vector <int> ivector;


int main(){
	double a, b, c, d, e, f;
	while (scanf("%lf%lf%lf%lf%lf%lf", &a, &b, &c, &d, &e, &f) != EOF)
	{


		double x = (c*e - b*f) / (a*e - b*d);
		double y = (c*d - a*f) / (b*d - a*e);
		if (x == 0)x = 0;
		if (y == 0)y = 0;
		printf("%.3f %.3f\n", x, y);
	}


	return 0;
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N,K;
int A[660],B[660];
int connected[660];
int f[660][660],g[660][660];
int dp[660][660];
int mod=1e9+7;
signed main() {
  cin>>N>>K;
  for(int i=0;i<K;i++){
    cin>>A[i]>>B[i];
    connected[A[i]]=connected[B[i]]=1;
  }
  for(int i=1;i<2*N;i++){
    for(int j=i+1;j<=2*N;j++){
      for(int k=i;k<=j;k++)f[i][j]+=1-connected[k];
    }
  }
  for(int i=1;i<2*N;i++){
    for(int j=i+1;j<=2*N;j++){
      g[i][j]=1;
      for(int k=1;k<f[i][j];k+=2)(g[i][j]*=k)%=mod;
    }
  }
  int ans=0;
  for(int i=1;i<2*N;i++){
    for(int j=i+1;j<=2*N;j++){
      if(f[i][j]%2==1)continue;
      bool flag=false;
      for(int k=0;k<K;k++){
        flag|=i<=A[k]&&A[k]<=j&&!(i<=B[k]&&B[k]<=j);
        flag|=i<=B[k]&&B[k]<=j&&!(i<=A[k]&&A[k]<=j);
      }
      if(flag)continue;
      dp[i][j]=g[i][j];
      for(int k=i+1;k<j;k++)dp[i][j]=(dp[i][j]-dp[i][k]*g[k+1][j]+mod)%mod;
      int outer=1;
      for(int k=1;k<f[1][2*N]-f[i][j];k+=2)(outer*=k)%=mod;
      (ans+=dp[i][j]*outer%mod)%=mod;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 10112
#include<iostream>
#include <bits/stdc++.h>
#include <string>
#include <cstring>
using namespace std;

int main() {
	
    int r,d,init ;    
    cin >> r >> d >> init ;
    int ans[11] ;
    ans[0] = init ;

    for(int i=1;i<11;i++){
      ans[i] = ans[i-1]*r - d ;
      cout << ans[i] << endl;
    } 

	return 0;
}


Measured memory_bytes: 256
L, R = map(int, input().split())
ans = 2019
for i in range(L, R+1):
  for j in range(i+1, R+1):
    ans = min(ans, i * j % 2019)
    if i * j % 2019 == 0:
      break
  else:
    continue
  break
print(ans)

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

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

    fenwick_tree<ll> fw(n);
    rep(i,n) {
        int a; cin >> a;
        fw.add(i,a);
    }

    while(Q--) {
        int type;
        cin >> type;
        if(type == 0) {
            int p,x;
            cin >> p >> x;
            fw.add(p,x);
        }
        if(type == 1) {
            int l,r;
            cin >> l >> r;
            cout << fw.sum(l,r) << endl;
        }
    }
    return 0;
}


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

int main(){	
	int k; cin >> k;
	string s; cin >> s;
	if(k < s.length()){
		for(int i = 0; i < k; i++)
			cout << s[i];
		cout << "...";
	}
	else{
		cout << s << endl;
	}	
	return 0;
}

Measured memory_bytes: 3624
//by Top1
#include <bits/stdc++.h>
          
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define cerr cout
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
      
const int inf = (1e9) + 1;
const int mod = 479001599;
const int maxn = 1e5 + 111;
        
using namespace std;          

int n, m, k, ans[maxn], b[maxn];
vector <int> g[maxn];
set <int> s[maxn];
bool was[maxn];

int dfs(int v, int cnt){
	was[v] = true;
	b[v] = cnt;
	int h = 0;
	for (int i = 0; i < sz(g[v]); i++){
		int to = g[v][i];
		if (!was[to])
			h += dfs(to, cnt);
	}
	return h + 1;
}

void solve(){ 
    cin >> n >> m >> k;

    for (int i = 1; i <= m; i++){
    	int x, y;
    	cin >> x >> y;
    	g[x].pb(y);
    	g[y].pb(x);
    }

    for (int i = 1; i <= k; i++){
    	int x, y;
    	cin >> x >> y;
    	s[x].insert(y);
    	s[y].insert(x);
    }

    int cnt = 0;

    for (int i = 1; i <= n; i++){
    	if (!was[i]){
    		cnt++;
    		b[i] = cnt;    		
    		int h = dfs(i, cnt);
    		ans[cnt] = h;
    	}
    }

    for (int i = 1; i <= n; i++){
    	int x = ans[b[i]] - sz(g[i]) - 1;
    	set <int> :: iterator it;
    	for (it = s[i].begin(); it != s[i].end(); it++)
    		if (b[i] == b[*it])
    			x--;
    	cout << x << " ";
    }                   
}                              
      
main(){
    boost;
    
    int q = 1;
 
    //cin >> q;
    
    while (q--){
        solve();
    }
}

Measured memory_bytes: 23040
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int SIZEN = 110;
bool f[SIZEN*SIZEN] = {0};
int a[SIZEN] = {0};
int N;
int main(){
	scanf("%d",&N);
	for(int i = 1;i <= N;i++)scanf("%d",&a[i]);
	f[0] = 1;
	for(int i = 1;i <= N;i++){
		for(int j = 10000;j >= a[i];j--)f[j] |= f[j-a[i]];
	}
	for(int i = 10000;i >= 0;i--){
		if(i % 10 == 0 && i)continue;
		if(!f[i])continue;
		printf("%d\n",i);
		return 0;
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int g[505][505];
int main()
{
	int k,n=500;cin>>k;
	if(k <= n)
	{
		printf("%d\n", k);
		for (int i = 1; i <= k; i ++)
			for(int j = 1; j <= k; j ++)
				printf("%d%c", i, j == k ? 10 : 32);
	}
	else
	{
		puts("500");
		for (int i = 1; i <= n; i ++)
			for (int j = 1; j <= n; j ++)
			{
				int x = j, y = (i + j - 1 - 1) % n + 1;
				if (n - i + 1 == k)
				{
					g[x][y] = k;
					if (j == n) k --;
				}
				else
				{
					g[x][y] = (j & 1) ? k : k - 1;
					if (j == n) k -= 2;
				}
			}
		for (int i = 1; i <= n; i ++)
			for (int j = 1; j <= n; j ++)
				printf("%d%c", g[i][j], j == n ? 10 : 32);
	}
}

Measured memory_bytes: 2176
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define int long long
#define lowbit(x) x&-x
using namespace std;
char s[200010];
int i,j,n,now,l,r,d[30],num,p[200010],q,t[200010],ans;
struct type
{
	int x,y;
}a[200010];
bool cmp(type x,type y)
{
	return max(n-x.x-1,x.y)>max(n-y.x-1,y.y);
}
void add(int x)
{
	for(;x<=n;x+=lowbit(x))t[x]++;
}
int get(int x)
{
	int sum=0;
	for(;x;x-=lowbit(x))sum+=t[x];
	return sum;
}
signed main()
{
	scanf("%s",s);
	n=strlen(s);
	for(i=0;i<n;i++)
		d[s[i]-'a']++;
	for(i=0;i<26;i++)
		if(d[i]&1)q++;
	if(q>(n&1))
	{
		cout<<-1<<endl;
		return 0;
	}
	for(i=0;i<26;i++)
	{
		l=0,r=n-1;
		for(j=1;j<=d[i]/2;j++)
		{
			while(s[l]!='a'+i)l++;
			while(s[r]!='a'+i)r--;
			a[++now].x=l+1;
			a[now].y=r+1;
			l++,r--;
		}
		if(d[i]&1)
		{
			for(j=l;j<r;j++)
				if(s[j]=='a'+i)break;
			p[j+1]=n/2+1;
		}
	}
	sort(a+1,a+n/2+1,cmp);
	for(i=1;i<=n/2;i++)
	{
		p[a[i].x]=i;
		p[a[i].y]=n-i+1;
	}
	for(i=1;i<=n;i++)
	{
		ans+=get(n-p[i]+1);
		add(n-p[i]+1);
	}
	cout<<ans<<endl;
}

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

int main(){
    string s;
    int ans;
    cin >> s;
    for(int i=1;i<s.size()/2;i++){
        bool a=true;
        for(int l=0;l<s.size()/2-i;l++){
            if(s.at(l)!=s.at(s.size()/2-i+l)){
                a=false;
            }
            if(a==false){break;}
        }
        if(a==true){
            ans=s.size()-2*i;
            break;
        }

    }
    cout << ans << endl;
}


Measured memory_bytes: 256
use proconio::{input, marker::Chars};

fn main() {
    input! {
        n: Chars,
    }

    let mut ans = 0;
    for i in n {
        let num: i32 = i as i32 - 48;
        ans += num;
    }

    println!("{}", if ans % 9 == 0 {"Yes"} else {"No"});
}

Measured memory_bytes: 3024
let levenshtein_distance s t =
  if s = t then 0
  else begin
    let m = String.length s in
    let n = String.length t in
    if m = 0 then n
    else if n = 0 then m
    else begin
      let v0 = Array.init (n + 1) (fun i -> i) in
      let v1 = Array.make (n + 1) 0 in
      for i = 0 to m - 1 do
        v1.(0) <- i + 1;
        for j = 0 to n - 1 do
          let c = if s.[i] = t.[j] then 0 else 1 in
          let t = if v1.(j) + 1 < v0.(j+1) + 1 then v1.(j) + 1 else v0.(j+1) + 1 in
          v1.(j+1) <- if v0.(j) + c < t then v0.(j) + c else t;
        done;
        Array.iteri (fun j e -> v0.(j) <- e) v1;
      done;
      v1.(n)
    end
  end

let () =
  let s1 = read_line () in
  let s2 = read_line () in
  Printf.printf "%d\n" (levenshtein_distance s1 s2)

Measured memory_bytes: 2364
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M, R; cin >> N >> M >> R;
    int r[R];
    rep(i, R) {cin >> r[i]; r[i]--;}
    int d[N][N]; rep(i, N) rep(j, N) d[i][j] = inf;
    rep(i, M) {
        int a, b, c; cin >> a >> b >> c; a--; b--;
        d[a][b] = c; d[b][a] = c;
    }
    rep(k, N) rep(i, N) rep(j, N) {
        if (d[i][k] + d[k][j] < d[i][j]) d[i][j] = d[i][k] + d[k][j];
    }
    //rep(i, N) {rep(j, N) cout << d[i][j] << " "; cout << endl;}
    int ans = inf;
    sort(r, r + R);
    do {
        /*
        cout << endl;
        rep(i, R) cout << r[i] << " "; cout << endl;
         */
        int tmp = 0;
        rrep(i, 1, R) {
            tmp += d[r[i - 1]][r[i]];
        }
        //cout << tmp << endl;
        ans = min(ans, tmp);
        
    } while (next_permutation(r, r + R));
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// 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 MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  string s;
  cin >> s;

  int K;
  cin >> K;

  int N = s.size();

  vector<string> v;
  REP(i, N) FOR(j, 1, K+1){
    if(i+j <= N) v.emplace_back(s.substr(i, j));
  }

  sort(ALL(v));
  v.resize(unique(ALL(v))-v.begin());

  cout << v[K-1] << "\n";

  return 0;
}

Measured memory_bytes: 1660
#set
a,b,c = gets.chomp.split(" ").map(&:to_i)
sum_ab = a + b
sum_bc = b + c
sum_ca = c + a
answer = 'No'

#main
answer = 'Yes' if sum_ab == c || sum_bc == a || sum_ca == b
print ("#{answer}\n")

Measured memory_bytes: 1788
#include <iostream>
#include <bits/stdc++.h>
#include <set>
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define vii vector<pair<int, int> >
#define si stack<int>
#define pb push_back
#define mp make_pair
#define ALL(T) (T).begin(), (T).end()
#define MODU 1000000007
typedef long long ll;
using namespace std;

ll intmax = (1LL<<32)-1;
ll llmax = (1LL<<60)-1;

const int INF = 1e9 + 5;

class fastio{
public:
	fastio(){
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
	}
} __fastio;

template <typename T>
T abs(T x){
	if(x<0)	return -x;
	else return x;
}

void DFSVisit(int u, vector<int> g[], vector<bool> &visited){ 
    visited[u] = true;
    for(int i=0; i<g[u].size(); i++){
        if(!visited[g[u][i]]){
            DFSVisit(g[u][i], g, visited); 
        }
    }
} 
  
void DFS(vector<int> adj[], int V){
    vector<bool> visited(V, false); 
    for(int u=0; u<V; u++) 
        if(!visited[u]) 
            DFSVisit(u, adj, visited);
}


void solve(){
	
}

int main(){
	int n, k;
	cin >> n >> k;
	vi a(n), dp(n, INF);
	for(int i=0; i<n; i++)
		cin >> a[i];
	dp[0] = 0;
	for(int i=0; i<n; i++){
		for(int j=1; j<=k; j++){
			if(i+j < n)
				dp[i+j] = min(dp[i+j], dp[i] + abs(a[i]-a[i+j]));
		}
	}
	cout << dp[n-1];
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef pair<long, long> P;

int main(){
    int N, M;
    long A[100000];
    P p[100000];
    cin >> N >> M;
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < M; i++){
        long B, C;
        cin >> B >> C;
        p[i] = P(C, B);
    }
    sort(A, A+N);
    sort(p, p+M, greater<P>());
    int cnt = 0;
    int l = 0;
    long ans = 0;
    vector<int> change;
    for(int i = 0; i < M; i++){
        cnt += p[i].second;
        if(cnt < N) {
            for(int j = 0; j < p[i].second; j++){
                change.push_back(p[i].first);
            }
        }
        if(cnt >= N){
            while(change.size() < N){
                change.push_back(p[i].first);
            }
            break;
        }
    }
    
    for(int i = 0; i < change.size(); i++){
        if(change[i] > A[i]) ans += change[i];
        else ans += A[i];
    }
    for(int i = change.size(); i < N; i++) ans += A[i];
    cout << ans << endl;
}

Measured memory_bytes: 3196
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  vector<long long> sum(n + 1);
  for (int i = 0; i < n; i++) {
    sum[i + 1] = sum[i] + a[i];
  }
  for (int i = n - 1; i >= 1; i--) {
    if (a[i] > sum[i] * 2) {
      cout << n - i << endl;
      return 0;
    }
  }
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 1792
N = int(input())

cnt = [[0 for _ in range(10)] for _ in range(10)]

for k in range(1, N+1):
    s = str(k)
    cnt[int(s[0])][int(s[-1])] += 1
ans = 0
for i in range(10):
    for j in range(10):
        ans += cnt[i][j] * cnt[j][i]
print(ans)


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

int main()
{
  int N,M,C,a[100],b[100],ans=0,sum;
  cin>>N>>M>>C;
  for(int i=0;i<M;i++)cin>>b[i];
  for(int j=0;j<N;j++){
    sum=0;
    for(int k=0;k<M;k++){
       cin>>a[k];
    }
    for(int i=0;i<M;i++){
      sum+=a[i]*b[i];
    }
    if(sum+C>0){
      ans++;
    }
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

#define PI 3.141592653589793238
#define INF 1050000000

using namespace std;



//cout << fixed << setprecision(15) << << endl;
//cout << << endl;

int main() {

	int A,B;
	char op;

	cin >> A >> op >> B;

	if (op == '+') {
		cout << A + B << endl;
	}
	else {
		cout << A - B << endl;
	}



	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class BJoker {
public:
    const int INF = ten(9);
    int N;
    vc<int> di = {1, 0, -1, 0}, dj = {0, 1, 0, -1};
    vvc<int> dist;
    vvc<bool> flag;

    inline bool valid(int x, int y){
        return 0 <= x and x < N and 0 <= y and y < N;
    }

    inline void bfs(int si, int sj){
        queue<pii> que;
        que.emplace(si, sj);
        while(not que.empty()){
            int ci = que.front().first, cj = que.front().second;
            int cost = dist[ci][cj] + flag[ci][cj];
            que.pop();
            REP(k, 4){
                int ni = ci + di[k], nj = cj + dj[k];
                if(valid(ni, nj) and cost<dist[ni][nj]){
                    dist[ni][nj] = cost;
                    que.emplace(ni, nj);
                }
            }
        }
    }

    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        in>>N;
        vc<int> P(N*N);
        for(auto& p : P) in>>p, p--;
        dist.resize(N, vc<int>(N, INF));
        flag.resize(N, vc<bool>(N, true));
        REP(i, N) REP(j, N){
            dist[i][j] = min(min(i, N-i-1), min(j, N-j-1));
        }
        int ans = 0;
        for(auto& p : P){
            int row = p / N, col = p % N;
            ans += dist[row][col];
            flag[row][col] = false;
            bfs(row, col);
        }
        out<<ans<<'\n';
    }
};


int main() {
	BJoker solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 5284
#include <algorithm>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long int lli;
typedef pair<lli, lli> P;
lli MOD = 1000000007;
lli sum[100005] = {}, sumb[1000005] = {};

int main()
{
    int n, k;
    cin >> n >> k;
    lli a;
    rep(i, n)
    {
        cin >> a;
        sum[i + 1] = sum[i] + a;
        sumb[i + 1] = sumb[i] + max(a, 0LL);
    }
    lli ans = -MOD * MOD;
    rep(j, n - k + 1)
    {
        ans = max(sum[j + k] - sum[j] + sumb[n] - sumb[j + k] + sumb[j], ans);
    }
    rep(j, n - k + 1)
    {
        ans = max(sumb[n] - sumb[j + k] + sumb[j], ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashMap;

fn main() {
    input!(n: usize, k: usize);
    let ans = n - k + 1;
    println!("{}", ans);
}


Measured memory_bytes: 4352
n, k = map(int, input().split())
l = list(map(int, input().split()))
 
tmp = sum(l[:k])
now = tmp
 
for i in range(n-k):
  tmp -= l[i]
  tmp += l[i+k]
  now = max(tmp, now)
  
print((now + k) / 2)

Measured memory_bytes: 25060
#include<iostream>
using namespace std;
int isPrime(int n){
  for(int i=2;i*i<=n;i++) if(n%i==0) return 0;
  return 1;
}
int main(){
  int m,a,b;
  int i,j,k;
  int memo[200001]={};
  for(i=2;i<200001;i++) memo[i]=isPrime(i);
  cin >> m >> a >> b;
  while((m+a+b)!=0){
    int p,q,o=0;
    for(i=1;i*i<=m;i++){
      
      for(j=i;j<=b*i/a;j++){
	if(j<100001){
	  if(memo[i]*memo[j]==1){
	    if(o<i*j&&i*j<=m) {
	      o=i*j;
	      p=i;q=j;
	    }
	  }
	}
      }
    }
    //cout << o << endl;
    cout << p << " " << q << endl;
    cin >> m >> a >> b;
  }
  return 0;
}

Measured memory_bytes: 1948
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int H,N;
    cin >> H >> N;
    vector<int> A(N);
    int L = H;
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);
        L = L-A[i];
    }
    if (L<=0)
    {
        cout << "Yes";
    }else{
        cout << "No";
    }
}




Measured memory_bytes: 640