akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC043A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;       //人数
            int s;       //必要な個数
            int i;


            n = int.Parse(Console.ReadLine());

            s = 0;       //合計を０に初期化

            for (i = 1; i <= n; i++)　　　　//1→nの繰り返し
            {
                s = s + i;    //s+=iでも良い
            }

            Console.WriteLine(s);

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
S = input()
a = True
for i in range(len(S)):
    if len(S) % 2 != 0:
        a = False 
        break
    else:
        if i %2==0 and (S[i] != 'h' or S[i+1] != 'i'):
            a = False

if a: 
    print('Yes')
else: 
    print('No')
        
        

Measured memory_bytes: 2940
X,K,D = map(int,input().split())
k1 = abs(X) // D
ans = 0
if k1 >= K:
  ans = abs(X) - K * D
else:
  k2 = K - k1
  if k2 % 2 == 0:
    ans = abs(X) - k1 * D
  else:
    ans = abs(abs(X) - (k1 + 1) * D)
print(ans)

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

int main(){
    int H,W; cin >> H >> W;
    char a[H][W];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> a[i][j];
        }
    }
    bool check=true;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if((i+1)<H&&(j-1)>=0){
                if(a[i+1][j-1]=='#'&&a[i][j]=='#') check=false;
            }
        }
    }
    if(check) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    
}

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

int main(){
  string s;
  cin >> s;
  string tmp;
  string a = s.substr(0,(s.size()-1)/2);
  string b = s.substr((s.size()+3)/2-1,s.size()-(s.size()+3)/2+1);
  int ans = 1;
  tmp = a;
  reverse(a.begin(), a.end());
  if(tmp != a){
    ans = 0;
  }
  tmp = b;
  reverse(b.begin(), b.end());
  if(tmp != b){
    ans = 0;
  }
  tmp = s;
  reverse(s.begin(), s.end());
  if(tmp != s){
    ans = 0;
  }
  
  if(ans == 1){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl; 
  }
}

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

int main() {
  int A, B;
  cin >> A >> B;
  
  int n = 1;
  int ans = 0;
  
  while (n < B) {
    ans++;
    n += A -1;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int ret = INF;
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int x = 0; x <= 100; x++) {
        int tmp = 0;
        for (int i = 0; i < N; i++) {
            tmp += (A[i] - x) * (A[i] - x);
        }
        ret = min(ret, tmp);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int H, W;
    cin >> H >> W;
    vec<string> s(H);
    rep(i, H) cin >> s[i];

    rep(i, H) rep(j,W){
        if(s[i][j] == '#'){
            bool flag = false;
            if(i != 0 && s[i-1][j] == '#') flag = true;
            if(i != H-1 && s[i+1][j] == '#') flag = true;
            if(j != 0 && s[i][j-1] == '#') flag = true;
            if(j != W-1 && s[i][j+1] == '#') flag = true;

            if(!flag){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<cstdio>
int n,k,ans=0x3f3f3f3f;
void search(int x,int val)
{
	if(x==n)
	{
		if(val<ans) ans=val;
		return;
	}
	search(x+1,val+k);
	search(x+1,val*2);
}
int main()
{
	scanf("%d%d",&n,&k);
	search(0,1);
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll N, K;
    cin >> N >> K;
    vector<int> A(N);
    vector<bool> seen(N+1);
    for (size_t i = 0; i < N; i++)
    {
        cin >> A[i];
        A[i]--; //添え字が0から始まるのでそれに合わせる
    }
    int beforeLoop = 0; //ループが始まるまでの長さ
    int now = 0; //最初
    while(!seen[now])
    {
        seen[now] = true;
        now = A[now];
        beforeLoop++;
    } 
    int loopStart = now; //ループが始まる場所
    int loopLength = 0; //ループの長さ(周期)
    do
    {
        seen[now] = true;
        now = A[now];
        loopLength++;
    } while (loopLength <= N and now != loopStart);
    if(K<beforeLoop) //ループが始まるまでに終わるとき
    {
        int ans = 0;
        for (int i = 0; i < K; i++)
        {
            ans = A[ans];
        }
        cout<<ans+1;
        return 0;
    }
    K -= beforeLoop;
    K %= loopLength;
    int pos = loopStart;
    for (int i = 0; i < K; i++)
    {
        pos = A[pos];
    }
    cout << pos + 1;
    return 0;
}

Measured memory_bytes: 4068
#include<iostream>
using namespace std;
int main(){
    int a[6],b[6];
    for(int i=0; i<6; i++)  cin>>a[i];
    for(int i=0; i<6; i++)  cin>>b[i];
    bool flag=false;
    if(a[0]==b[0] && a[5]==b[5]){
        if((a[1]==b[1] && a[2]==b[2]) || (a[1]==b[2] && a[2]==b[4]) || (a[1]==b[4] && a[2]==b[3]) || (a[1]==b[3] && a[2]==b[1]))  flag=true;
    }
    else if(a[0]==b[1] && a[5]==b[4]){
        if((a[1]==b[2] && a[2]==b[0]) || (a[1]==b[0] && a[2]==b[3]) || (a[1]==b[3] && a[2]==b[5]) || (a[1]==b[5] && a[2]==b[2]))  flag=true;
    }
    else if(a[0]==b[2] && a[5]==b[3]){
        if((a[1]==b[1] && a[2]==b[5]) || (a[1]==b[5] && a[2]==b[4]) || (a[1]==b[4] && a[2]==b[0]) || (a[1]==b[0] && a[2]==b[1]))  flag=true;
    }
    else if(a[0]==b[3] && a[5]==b[2]){
        if((a[1]==b[1] && a[2]==b[0]) || (a[1]==b[0] && a[2]==b[4]) || (a[1]==b[4] && a[2]==b[5]) || (a[1]==b[5] && a[2]==b[1]))  flag=true;
    }
    else if(a[0]==b[4] && a[5]==b[1]){
        if((a[1]==b[0] && a[2]==b[2]) || (a[1]==b[2] && a[2]==b[5]) || (a[1]==b[5] && a[2]==b[3]) || (a[1]==b[3] && a[2]==b[0]))  flag=true;
    }
    else if(a[0]==b[5] && a[5]==b[0]){
        if((a[1]==b[1] && a[2]==b[3]) || (a[1]==b[3] && a[2]==b[4]) || (a[1]==b[4] && a[2]==b[2]) || (a[1]==b[2] && a[2]==b[1]))  flag=true;
    }
    if(flag)    cout<<"Yes"<<endl;
    else    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3108
#include<stdio.h>
 
int main()
{
	char n[5];
	scanf("%s",n);
	if(((n[0]==n[1])&&(n[1]==n[2]))||((n[1]==n[2])&&(n[2]==n[3])))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

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

using lint = long long;

lint layers[51];
lint putties[51];

lint P(int N, lint X){
    if(N == 0) return 1;
    if(X == 0 || X == 1) return 0;
    if(layers[N-1] + 1 >= X){
        return P(N-1, X-1);
    }
    else if(layers[N-1] + 2 == X) return putties[N-1] + 1;
    else if(layers[N-1]*2 + 2 >= X){
        return P(N-1, X - layers[N-1] - 2) + putties[N-1] + 1;
    }
    else if(layers[N-1]*2 + 3 == X){
        return putties[N-1]*2 + 1;
    }
    else{
        return 99999999999999999999999999999999999999;
    }
}

int main(){
    int N;
    lint X;

    cin >> N >> X;
    layers[0] = 1;
    putties[0] = 1;
    for(int i=1;i<=N;i++){
        layers[i] = layers[i-1]*2 + 3;
        putties[i] = putties[i-1]*2 + 1;
    }
    cout << P(N, X) << endl;
    return 0;
}

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

int main(){
    string s;
    string t;
    cin >> s >> t;
    int i,ga;
    ga=0;
    for(i=0;i<3;i++){
        if(s.at(i)==t.at(i)){
            ga++;
        }
    }
    cout << ga << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char s[26];
int i,j,x,f[26];
int main()
{	
	scanf("%s",&s);
	for(i=0;i<strlen(s);i++){
		f[s[i]-97]++;
	}
	for(i=0;i<26;i++){
		if(f[i]>=2){
			x=1;
			break;
		}
		//printf("%c=%d ",i+97,f[i]);
	}
	if(x==1){
		puts("no");
	}else{
		puts("yes");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n;
    cin >> n;
    vector<int> ue(n);
    vector<int> sita(n);
    rep(i,n) cin >> ue[i];
    rep(i,n) cin >> sita[i];
    ll ans=0;

    rep(i,n){
        ll ame=0;
        for(int j=i; j<n; j++){
            ame += sita.at(j);
        }
        for(int k=0; k<=i; k++){
            ame += ue.at(k);
        }
        ans = max(ans,ame);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int A, B, K;
    cin >> A >> B >> K;

    int cnt = 0;
    int X = min(A, B) + 1;
    while (cnt < K) {
        X--;
        if (A % X == 0 && B % X == 0) cnt++;
    }

    cout << X << endl;
}

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n; cin>>n;
    vector<string> s(n);
    set<string> st;
    rep(i,n){
        cin>>s[i];
        st.insert(s[i]);
    }
    bool ok=true;
    if(st.size()!=n) ok=false;
    for(int i=1;i<n;i++){
        if(s[i].front()!=s[i-1].back()) ok=false;
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N,A;
    cin >> N >> A;
    int S = N % 500;
    if (S <= A) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

int main(void){
    int tx,ty;
    string s;
    cin>>s>>tx>>ty;
    assert((int)s.size()<=8000);
    s += "T";
    int init = s.find("T",0);
    tx -= init;
    s = string(s.begin()+init, s.end());
    bitset<M*2> dp[2];
    dp[0][M] = dp[1][M] = 1;
    int cnt = 0, mode = 0;
    for(char c : s){
        if(c=='F') cnt++;
        else{
            dp[mode] = (dp[mode]<<cnt) | (dp[mode]>>cnt);
            cnt = 0;
            mode = !mode;
        }
    }
    cout<<((dp[0][M+tx] && dp[1][M+ty]) ? "Yes" : "No")<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a%3==0||b%3==0||(a+b)%3==0){
		printf("Possible");
		return 0;
	}
	printf("Impossible");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200100;
int a[maxn];
int main(){
  int n;
  scanf("%d", &n);
  for(int e = 0; e < n; e++) scanf("%d", a + e);
  sort(a, a + n);
  set<pair<int, int> > b;
  for(int e = 0; e < n; e++) b.insert({a[e], e});
  int ans = 0;
  for(int e = n - 1; e >= 0; e--){
    auto me = b.lower_bound({a[e], e});
    if(me != b.end() && me->first == a[e] && me->second == e){
      long long lg = 1;
      while(a[e] >= lg) lg *= 2;
      int diff = (int)(lg - a[e]);
      auto nme = b.lower_bound({diff, -1});
      if(nme != b.end() && nme->first == diff && nme->second != e){
        b.erase(b.lower_bound({a[e], e}));
        b.erase(b.lower_bound({diff, -1}));
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 10368
import sys
input = sys.stdin.readline
RS = input
RI = lambda x=int: x(RS())
RA = lambda x=int: map(x, RS().split())
RSS = lambda: RS().split()


def solve():
    mi = 1
    ma = 1
    man = [0]*(n+1)
    for i in range(n+1):
        man[i] = ma
        mi -= a[i]
        ma -= a[i]

        if ma < 0:
            print(-1)
            return
        ma*= 2
    if not mi<=0<=ma:
        print(-1)
        return
    d = n-1
    c = a[n]
    ans = c
    while d>=0:
        c = min(man[d], c+a[d])
        ans += c
        d -= 1
    print(ans)
    return

def ceild(a):
    return a//2 + a%2



n = RI()
a = list(RA())
solve()

Measured memory_bytes: 700940
S = input()
 
chars = "abcdefghijklmnopqrstuvwxyz"
char_set = set(chars)
 
if len(S) == 26:
    for i in range(len(S)-1, -1, -1):
        x = chars.index(S[i])
        y = sorted(set(chars[x+1:])-set(S[:i]))
        # print(i, y)
        if len(y):
            print(S[:i]+y[0])
            exit()
else:
    t = sorted(set(chars)-set(S))[0]
    print(S+t)
    exit()
print(-1)

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

int main() {
  long long N,n;
  cin>>N;
  for(int i=0;i<=sqrt(N);i++){
    n=i;
  }
  
  for(int i=n;i>0;i--){
    if(N%i==0){
      cout<<i+N/i-2;
      break;
    }
  }
  
}

Measured memory_bytes: 256
#!/usr/bin/env ruby
@ans = []

def k(sum, ary)
  return 0 if ary.count.zero?

  tmp = ary.pop
  @ans << (sum + tmp + k(sum + tmp, ary.dup))
  @ans << (sum + k(sum, ary.dup))

  0
end

gets
a = gets.split.map(&:to_i)
gets
m = gets.split.map(&:to_i)

k(0, a)

@ans.uniq!.sort!

m.each do |k|
  puts (@ans.include?(k)) ? 'yes' : 'no'
end


# @todo 高速化できそう



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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void answer1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void answer2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void answer3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void answer(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i, j;
  ll n;
  cin >> n;
  //ll h,w;
  //cin >> h >> w;
  //string s; cin >> s;
  ll result = 0;
  bool judge = true;
  vector<ll> a;
  for(i=2;a.size()<n;i++){
    if((i-2)%5==0){
      judge = true;
      for(j=2;j<i&&judge;j++){
        if(i%j==0){
          judge = false;
        }
      }
      if(judge){
        a.push_back(i);
      }
    }
  }
  cout << a[0];
  for(i=1;i<n;i++){
    cout << " " << a[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
int main(){
	ll ans = 0;
    ll r, g, b, n; cin >> r >> g >> b >> n;
	for(ll i = 0; i <= 3000; ++i){
		for(ll j = 0; j <= 3000; ++j){
			if(((n - i * r - j * g) % b == 0 && n - i * r - j * g > 0) || n - i * r - j * g == 0){
				ans++;
			}
		}
	}
	cout << ans;
    return 0;
}


Measured memory_bytes: 3580
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.HashMap;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Atg017A solver = new Atg017A();
        solver.solve(1, in, out);
        out.close();
    }

    static class Atg017A {
        int a[];
        int p;
        int n;
        HashMap<String, Long> cache = new HashMap<String, Long>();

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            n = in.nextInt();
            p = in.nextInt();
            a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            if (p != 0 && p != 1) {
                out.println("0");
                return;
            }
            long result = calc(0, false);
            out.println(result);
        }

        long calc(int index, boolean isOdd) {
            String key = index + "-" + (isOdd ? 1 : 0);
            Long result = cache.get(key);
            if (result != null) {
                return result;
            }
            if (index == n) {
                return ((p == 0 && !isOdd) || (p == 1 && isOdd)) ? 1 : 0;
            }
            boolean isOdd2;
            if ((a[index] % 2) == 1) {
                isOdd2 = !isOdd;
            } else {
                isOdd2 = isOdd;
            }
            long total = calc(index + 1, isOdd) + calc(index + 1, isOdd2);
            cache.put(key, total);
            return total;
        }

    }
}



Measured memory_bytes: 21076
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>

using ll = long long;
using namespace std;
const int maxn = 2e5 + 1e3;
vector<int> edges[maxn];
array<int, maxn> dis1, dis2;

void dfs(int current, int father, int dist, array<int, maxn> &cur) {
    cur[current] = dist;
    for (auto to:edges[current]) {
        if (to != father) {
            dfs(to, current, dist + 1, cur);
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        cin >> u >> v;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    dfs(1, 0, 0, dis1);
    dfs(n, 0, 0, dis2);
    int balance = 0;
    for (int i = 1; i <= n; ++i) {
        balance += -1 + (dis1[i] <= dis2[i]) * 2;
    }
    if (balance > 0) {
        cout << "Fennec" << endl;
    } else {
        cout << "Snuke" << endl;
    }
}


Measured memory_bytes: 15104
/*######################################################
#########~~~~~####~~~~###~~##~~##~~##~~##~~##~~#########
#########~~##~~##~~##~~##~~~#~~##~~~#~~##~~##~~#########
#~~~~~~##~~~~~###~~~~~~##~~#~~~##~~#~~~##~~##~~##~~~~~~#
#########~~######~~##~~##~~##~~##~~##~~##~~##~~#########
#########~~######~~##~~##~~##~~##~~##~~###~~~~##########
######################################################*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("O3")
#define rtn return
#define endl '\n'
#define F first
#define S second
#define mt make_tuple
#define pb push_back
#define int long long
#define value_at find_by_order
#define index_of order_of_key
#define fill(a, v) memset(a,v,sizeof(a))
#define copy(a, b) memcpy(b,a,sizeof(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i, n) for(int i=0;i<(int)n;++i)
#define per(i, n) for(int i=(int)n-1;i>=0;--i)
#define rep1(i, n) for(int i=1;i<=(int)n;++i)
#define per1(i, n) for(int i=(int)n;i>=1;--i)
#define loop(i, begin, end) for(int i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " = " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " = " << arg1 << " |";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef string str;
typedef long double db;
typedef long long ll;
typedef pair<int, int> pll;
typedef vector<int> vll;
typedef vector<pll> vpll;
typedef vector<db> vdb;

template<class T, class V> void remin(T &a, V b) { a > b ? a = b : a = a; }
template<class T, class V> void remax(T &a, V b) { a < b ? a = b : a = a; }
template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int INF = 1e18;
const db EPS = 1e-15;
const int MOD = 1e9 + 7;
const int N = 1e5 + 7;

int h[N];
int dp[N];
int n, k;

int32_t main() {
  FAST_IO;
  cin >> n >> k;
  rep1(i, n)
    cin >> h[i];
  h[0] = INF;
  loop(i, 2, n + 1) {
    dp[i] = INF;
    for (int j = i - 1; j >= i - k && j >= 1; j--)
      dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
  }
  cout << dp[n] << '\n';
  rtn 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,t,m;
    vl<ll> arr;
    arr.pb(0);
    cin>>n>>m;
    ll sum=0;
    for(i=0;i<n;i++)
    {
        cin>>a;
        sum+=a;
        arr.pb(sum);
    }
    ll count=0;
    for(i=0;i<n+1;i++)
    {
        if(arr[i]<=m) count++;
        else break;
    }
    cout<<count;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin>>n;
  vector<int> b(n-1);
  
  for(int i=0;i<n-1;i++){
    cin>>b[i];
  }
  int ans=0;
  ans+=b[0];
  ans+=b[n-2];
  for(int i=0;i<n-2;i++){
    ans+=min(b[i],b[i+1]);
  }
  cout<<ans<<endl;
}
  

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		if(i%3!=0&&i%5!=0)
		{
			ans+=i;
		}
	}
	printf("%lld\n",ans);
	return 0;
} 


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_H = (int)(5e1 + 5);
const int MAX_W = (int)(5e1 + 5);

int h, w;
char s[MAX_H][MAX_W];

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

ll path[MAX_H][MAX_W];

void calc_path() {
  queue<pair<int, int>> que;

  que.push(make_pair(0, 0));
  path[0][0] = 0LL;

  while (!que.empty()) {
    auto cur = que.front();
    que.pop();

    ll cur_cost = path[cur.first][cur.second];

    for (int i = 0; i < 4; ++i) {
      int nx = cur.first + dx[i];
      int ny = cur.second + dy[i];

      if (!(0 <= nx && nx < h && 0 <= ny && ny < w)) continue;
      if (s[nx][ny] == '#') continue;
      if (path[nx][ny] < INF) continue;

      path[nx][ny] = cur_cost + 1LL;

      que.push(make_pair(nx, ny));
    }
  }
}

int main(void) {
  // Here your code !
  scanf("%d %d", &h, &w);

  for (int i = 0; i < h; ++i) {
    scanf("%s", s[i]);
  }

  for (int i = 0; i < h; ++i)
    for (int j = 0; j < w; ++j) {
      path[i][j] = INF;
    }

  calc_path();

  if (path[h - 1][w - 1] == INF) {
    printf("-1\n");
    return 0;
  }

  int cnt = 0;

  for (int i = 0; i < h; ++i)
    for (int j = 0; j < w; ++j) {
      if (s[i][j] == '.') cnt += 1;
    }

  int ans = cnt - (int)(path[h - 1][w - 1] + 1LL);

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

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main {

	private static void updateDistances(List<Integer> []adjList, int []dp, boolean []visited, int src) {
		
		visited[src] = true;

		for(int target: adjList[src]) {
			if (!visited[target])
				updateDistances(adjList, dp, visited, target);

			dp[src] = Math.max(dp[src], 1 + dp[target]);
		}
	}

	public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String []s = br.readLine().split(" ");

		int N = Integer.parseInt(s[0]);
		int M = Integer.parseInt(s[1]);

		List<Integer> []adjList = new ArrayList[N];

		for(int i=0; i < N; ++i)
			adjList[i] = new ArrayList<>();


		boolean []visited = new boolean[N];

		int []dp = new int[N];
		Arrays.fill(dp, 0);

		for(int i=0; i < M; ++i) {
			s = br.readLine().split(" ");

			int u = Integer.parseInt(s[0]) - 1;
			int v = Integer.parseInt(s[1]) - 1;

			adjList[u].add(v);
		}

		for(int i=0; i < N; ++i)
			if (!visited[i])
				updateDistances(adjList, dp, visited, i);

		int result = 0;
		for(int i=0; i < N; ++i)
			result = Math.max(result, dp[i]);

		System.out.println(result);
    }
}

Measured memory_bytes: 55764
import numpy as np

N = int(input())
A = np.fromiter(map(int, input().split()), np.int64)

result = 0
for b in range(60):
  bs = int(((A >> b) & 1).sum())
  result = (result + bs * (N - bs) * (1 << b)) % 1000000007
print(result)


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

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

    if (A < 10 and B < 10) {
        cout << A*B << endl;
    }
    else {
        cout << -1 << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi=vector<int>;
using vii=vector<vi>;
using vl=vector<ll>;
using vll=vector<vl>;

int main() {
    int N, K;
    cin >> N >> K;
    vi H(N);
    for (auto i = 0; i < N; i++) {
        int hi;
        cin >> hi;
        H.at(i) = hi;
    }

    vi dp(N);
    dp.at(0) = 0;
    dp.at(1) = abs(H.at(0) - H.at(1));
    for (auto i = 2; i < N; i++) {
        auto m = dp.at(i - 1) + abs(H.at(i) - H.at(i - 1));
        for (auto j = 2; j <= K; j++) {
            if (i >= j) {
                m = min(m, dp.at(i - j) + abs(H.at(i) - H.at(i - j)));
            }
        }
        dp.at(i) = m;
    }

    cout << dp.at(N - 1) << endl;
    return 0;
}


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




int distance(const string &s, const string &t) {
    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
        ans += s[i] != t[i];
    }
    return ans;
}



int main () {
    string s, t;
    cin >> s >> t;

    int ans = t.size();
    for (int i = 0; i+t.size() <= s.size(); i++) {
        ans = min(ans, distance(s.substr(i, t.size()), t));
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3628
#include <stdio.h>

int main(){
  int i,j,k;
  long l,m,n;
  while(scanf("%ld",&l),l!=0){
    for(i=j=0;i<12;i++){
      scanf("%ld %ld",&m,&n);
      l-=(m-n);
      if(j==0 && l<=0){ k=i+1; j=1;}
    }
    if(j==1) printf("%d\n",k); else printf("NA\n");
  }
  return 0;
}

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

int main() {
    int n; cin >> n;
    string c; cin >> c;
    string t = c;

    int ans;
    //赤か白どちらか一色の場合
    int cnt = 0;
    for(int i=0; i<n; i++){
        if(c[i] == 'R') cnt++;
    }
    ans = min(cnt,n-cnt);

    sort(t.begin(),t.end());

    cnt = 0;
    for(int i=0; i<n; i++){
        if(t[i] != c[i]) cnt++;
    }
    cnt /= 2;
    ans = min(cnt,ans);
    cout << ans << endl;
}

Measured memory_bytes: 3920
#include<bits/stdc++.h>
#define maxn 120
#define maxk 120000
using namespace std;
typedef long long LL;
const int mod = 1000000007;
LL s[maxk];
LL f[maxk];
LL a[maxn];
int main(){
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	for(int i = 1; i <= N; i += 1) cin >> a[i];
	f[0] = 1;
	for(int i = 1; i <= N; i += 1){
		for(int j = 0; j <= K; j += 1) s[j] = j ? (s[j - 1] + f[j]) % mod : f[j];
		for(int j = 0; j <= K; j += 1){
			int L = max(0LL, j - a[i]);
			f[j] = (s[j] - (L ? s[L - 1] : 0) + mod) % mod;
		}
	}
	cout << f[K];
}

Measured memory_bytes: 1792
A = int(input())
B = int(input())

if A == 1:
    if B == 2:
        print(3)
    elif B == 3:
        print(2)
elif A == 2:
    if B == 1:
        print(3)
    elif B == 3:
        print(1)
elif A == 3:
    if B == 1:
        print(2)
    elif B == 2:
        print(1)

Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    XY=[tuple(map(int,input().split())) for _ in range(n)]
    parity=[0]*2
    for x,y in XY:
        parity[(x+y)%2]=1

    # それぞれのパリティの点が存在すると不可能
    if(parity[0] and parity[1]):
        print(-1)
        return

    m=31
    D=[pow(2,i) for i in range(m)]
    # 偶数の場合は奇数に帰着させる
    if(parity[0]):
        XY=[(x-1,y) for x,y in XY]
        D=[1]+D

    U=[x-y for x,y in XY]
    V=[x+y for x,y in XY]

    W=[0]*n
    for j in range(n):
        res=[0]*m
        u=(U[j]+pow(2,m)-1)//2
        v=(V[j]+pow(2,m)-1)//2
        for i in range(m):
            ub=u&1; vb=v&1
            if(ub and vb):
                res[i]='R'
            elif(ub and (not vb)):
                res[i]='D'
            elif((not ub) and vb):
                res[i]='U'
            else:
                res[i]='L'
            u>>=1; v>>=1
        ans=''.join(res)
        W[j]=ans

    m=m+parity[0]
    print(m)
    print(*D)
    for j in range(n):
        ans=W[j] if(parity[1]) else 'R'+W[j]
        print(ans)
resolve()

Measured memory_bytes: 42480
#include<stdio.h>
#include<stdlib.h>

struct Node{
  int key;
  struct Node *p;
  struct Node *l;
  struct Node *r;
};
typedef struct Node * Nodepointer;

Nodepointer root,nil;

void insert(int i){
  Nodepointer x = root;
  Nodepointer y = nil; /*parent*/
  Nodepointer z;

  z = (struct Node *)malloc(sizeof(struct Node));
  z->key = i;
  z->l = nil;
  z->r = nil;

  while(x != nil){
    y = x;
    if(x->key > z->key) x = x->l;
    else x = x->r;
  }

  z->p = y;

  if(y == nil) root = z;
  else{
    if(y->key > z->key) y->l = z;
    else y->r = z;
  }

}

void inorder(Nodepointer x){
    if(x == nil) return;
    inorder(x->l);
    printf(" %d",x->key);
    inorder(x->r);
}

void preorder(Nodepointer x){
    if(x == nil) return;
    printf(" %d",x->key);
    preorder(x->l);
    preorder(x->r);
}

Nodepointer find(Nodepointer x,int i){
  while(x != nil && i != x->key){
    if(x->key > i) x = x->l;
    else x = x->r;
  }
  return x;
}

Nodepointer getMinimum(Nodepointer x){
  while(x->l != nil) x = x->l;
  return x;
}

Nodepointer getSuccessor(Nodepointer x){
  Nodepointer y;

  if(x->r != nil) return getMinimum(x->r);

  y = x->p;
  while(y != nil && x == y->r){
    x = y;
    y = y->p;
  }
  return y;
}

void delete(Nodepointer z){
  Nodepointer x,y;
  if(z->l == nil || z->r == nil) y = z;
  else y = getSuccessor(z);

  if(y->l != nil) x = y->l;
  else x = y->r;

  if(x != nil) x->p = y->p;

  if(y->p == nil) root = x;
  else if(y == y->p->l) y->p->l = x;
  else y->p->r = x;

  if(y != z) z->key = y->key;
}

int main(){
  int n,i,num;
  char c[20];

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    scanf("%s",&c);
    if(c[0] == 'i'){
      scanf("%d",&num);
      insert(num);
    }
    else if(c[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(c[0] == 'f'){
      scanf("%d",&num);
      if(find(root,num) != nil) printf("yes\n");
      else printf("no\n");
    }
    else if(c[0] == 'd'){
      scanf("%d",&num);
      delete(find(root,num));
    }
  }
  return 0;
}



Measured memory_bytes: 20456
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>

using namespace std;

#define MOD 1000000007
#define INT_MAX

int main()
{
	int n, m;
	cin >> n;
	vector<int> t(n+1);

	int sum = 0;
	for (int i = 1; i <= n; i++) {
		cin >> t[i];
		sum += t[i];
	}
	cin >> m;

	for (int i = 0; i < m; i++) {
		int p, x;
		cin >> p >> x;
		int res = sum - (t[p] - x);
		cout << res << endl;
	}

	

	return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;

int main(){
	int N;
	cin>>N;
	bool f=false;
	deque<int> deq;
	REP(i,N){
		int a;
		cin>>a;
		if (!f){
			deq.push_back(a);
		}else{
			deq.push_front(a);
		}
		f=!f;
	}
	REP(i,N){
		int v;
		if (!f){
			v=deq.front();
			deq.pop_front();
		}else{
			v=deq.back();
			deq.pop_back();
		}
		if (i){
			cout<<" ";
		}
		cout<<v;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 2944
import java.util.Scanner;
public class Main{
    int high;
    int low;
    int sa;
    
    public void solve(){
        Scanner sc = new Scanner(System.in);
        for(int i=0;i<7;i++){
            high=sc.nextInt();
            low=sc.nextInt();
            sa=high-low;
            System.out.println(sa);
        }
    }
    
    public static void main(String[] args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17332
#include<stdio.h>
int main(void){
    int S,h,m,s;
    scanf("%d",&S);
    h = S / 3600;
    m = (S % 3600) / 60;
    s = (S % 3600) % 60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2128
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

int n;
int dist[2][100005];
vector<int> v[100005];
queue<int> que;
bool visit[100005];

void bfs(int id,int s){
    for (int i = 0; i < n; i++) visit[i] = false;
    que.push(s);
    visit[s] = true;
    dist[id][s] = 0;
    while (que.size() != 0){
        int now = que.front(); que.pop();
        for (int i = 0; i < v[now].size(); i++){
            int next = v[now][i];
            if (!visit[next]){
                dist[id][next] = dist[id][now] + 1;
                visit[next] = true;
                que.push(next);
            }
        }
    }
}
int main(void){
    cin >> n;
    for (int i = 0; i < n - 1; i++){
        int s, t;
        cin >> s >> t;
        s--; t--;
        v[s].push_back(t); v[t].push_back(s);
    }

    bfs(0, 0);
    bfs(1, n - 1);

    int fe, sn;
    fe = sn = 0;
    for (int i = 0; i < n; i++){
        if (dist[0][i]>dist[1][i]) fe++;
        else sn++;
    }

    if (fe < sn) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
    
}

Measured memory_bytes: 6784
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9;
const int ZERO = 0;
const int MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

signed main() {
    double N;
    cin >> N;
    int ret = (N + 1.07) / 1.08;
    int cnt = ret * 1.08;
    if(cnt != N) {
        cout << ":(" << endl;
    }
    else {
        cout << ret << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	if (abs(n - m) == 0) {
		int ans = 1;
		for (int i = n; i >= 1; i--) {
			ans *= i; ans %= MOD;
		}
		cout << (ans*ans) % MOD * 2 % MOD << endl;
	}
	else if (abs(n - m) == 1) {
		int ans1 = 1;
		for (int i = n; i >= 1; i--) {
			ans1 *= i; ans1 %= MOD;
		}
		int ans2 = 1;
		for (int i = m; i >= 1; i--) {
			ans2 *= i; ans2 %= MOD;
		}
		cout << ans1 * ans2%MOD << endl;
	}
	else {
		cout << 0 << endl; return 0;
	}
	return 0;
}


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

int main() {
 int N,K;
  string S;
  cin >> N >> K;
  K-=1;
  cin >> S;
  if(S.at(K)=='A'){
   S.at(K)='a'; 
  }
  else if(S.at(K)=='B'){
   S.at(K)='b'; 
  }
  else{
   S.at(K)='c'; 
  }
  cout << S << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    ll n,q,k,d;
    cin>>n>>q>>k>>d;
    --k;--d;
    ll res=d;
    rep(i,q)res=(res*2)%n;
    ll ret=(k-res+2*n)%n;
    if(q<62&&ret>=(1LL<<q)){
        cout<<-1<<endl;
        return 0;
    }
    vector<int> tmp(q);
    rep(i,60){
        if((1LL<<i)&ret)tmp[i]=1;
    }
    vector<ll> ans(q);
    ll cur=d;
    for(int i=q-1;i>=0;--i){
        if(cur<n/2)ans[i]=tmp[i];
        else ans[i]=1-tmp[i];
        cur=(2*cur+tmp[i])%n;
    }
    rep(i,q){
        cout<<ans[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 13536
#include <stdio.h>
#include <string.h>
int main(void){
    // Your code here!
    int i,a,b,c,count;
    scanf("%d %d %d",&a,&b,&c);
    
    for(i=a;i<=b;i++){
        if(c%i==0)
        count++;
    }
    printf("%d\n",count);
    return 0;
}



Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie();
    int n, m;
    cin>>n>>m;
    if(n == 0 || m == 0){
        cout<<"0 0";
        return 0;
    }    
    bool accepted[n];
    unordered_map<int, int> ma;
    for(int i = 0; i < n; i++){
        accepted[i] = false;
    }
    for(int i = 0; i < m; i++){
        int p; string s;
        cin>>p>>s;
        p-=1;
        if(s == "AC"){
            accepted[p] = true;
        }else{
            if(!accepted[p]){
                if(ma.find(p) == ma.end()){
                    ma[p] = 1;
                }else
                {
                    ma[p]++;
                }
                
            }
        }
    }                 
    int correct = 0, penalties = 0;
    for(int i = 0; i < n; i++){
        if(accepted[i]){
            correct++;
            penalties += ma[i];
        }
    }                         
    cout<<correct<<" "<<penalties;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
    return 0;
}

Measured memory_bytes: 7396
#include<stdio.h>
char str[131072];
int c[10];
int dp[8][10];
int main(){
	int a;
	scanf("%d%s",&a,str);
	int b;
	int s;
	scanf("%d",&b);
	for(int i=0;i<b;i++){
		scanf("%d",&s);c[s]=1;
	//	scanf("%d",c+i);
	}
	int d=0;
	int e=0;
	int v=0;
	for(int i=0;i<a;i++){
		if(str[i]=='*'){
			if((a-i)%2==1)d++;
			else e++;
		}else{
			int p=str[i]-'0';
			if((a-i)%2==0)p*=2;
			if(p>=10)p-=9;
			v+=p;
		}
	}
	dp[0][v%10]=1;
	for(int i=0;i<d+e;i++){
		for(int j=0;j<10;j++){
			if(i<d){
				for(int k=0;k<10;k++){
					if(!c[k])continue;
					dp[i+1][(j+k)%10]+=dp[i][j];
				}
			}else{
				for(int k=0;k<10;k++){
					if(!c[k])continue;
					int p=k*2;
					if(p>=10)p-=9;
					dp[i+1][(j+p)%10]+=dp[i][j];
				}
			}
		}
	}
	printf("%d\n",dp[d+e][0]);
}

Measured memory_bytes: 1132
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int H, W, A, B;

int main() {
	cin >> H >> W >> A >> B;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cout << ((i < B) ^ (j < A));
		}
		cout << endl;
	}
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>

typedef long long ll;
using namespace std;

int main()
{
    int n;
    string a[100];
    int tmp1, tmp2;

    cin >> n;

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

    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            if(a[i] == a[j]){
                cout << "No" << endl;
                return 0;
                //cout << i << j << endl;
            }
        }
    }

    for(int i=0; i<n-1; i++){
        tmp1 = a[i].length();
        if(a[i][tmp1-1] != a[i+1][0]){
            cout << "No" << endl;
            //cout << i << endl;
            return 0;
        }
    }

    cout <<  "Yes"<< endl;
    return 0;
}

Measured memory_bytes: 256
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(__,v.size()){rep(_,v[__].size())cout<<" "<<v[__][_];cout<<endl;}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
signed main(){
	string s;
	cin>>s;
	if(s.size()==2)cout<<s<<endl;
	else cout<<s[2]<<s[1]<<s[0]<<endl;
	
}















Measured memory_bytes: 256
N=int(input())
L=list(map(int,input().split()))
tmp=0
ans=0
for i in range(len(L)-1):
	if L[i]>=L[i+1]:
		tmp+=1
	else:	
		ans=max(ans,tmp)
		tmp=0
else:
	ans=max(ans,tmp)
print(ans)

Measured memory_bytes: 63984
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  ll s;
  scan(s);
  int m = 1000000000;
  int rest = s % m;
  int x3 = 0;
  int y2 = 0;
  if (rest > 0) {
    x3 = 1;
    y2 = m - rest;
  }
  ll sum = s + y2;
  int x2 = m;
  int y3 = sum / x2;
  printf("0 0 %d %d %d %d\n", x2, y2, x3, y3);

  return 0;
}


Measured memory_bytes: 888