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

long getBit(long n){
    long tmp = 1;
    while(n >= tmp){
        tmp *= 2;
    }
    
    tmp /= 2;
    return tmp;
}


int main(){
   int t;
   cin >> t;
   vector<int>ans(t);
   for(int tt = 0;tt<t;tt++){
       int n;
       cin >> n;
       long a[n];
       for(int i=0;i<n;i++)cin >> a[i];
       string s;
       cin >> s;
           bool chk = true;
           vector<long>zero;
           for(int i=n-1;i>=0;i--){
               if(s[i] == '0'){
                   zero.push_back(a[i]);
               }else{
                   long tmp = a[i];
                    for(int j=0;j<zero.size();j++){
                       sort(zero.begin()+j,zero.end(),greater<long>());
                       long bit = getBit(zero[j]);
                       if(bit==0)break;
                       for(int k=j+1;k<zero.size();k++){
                           if(zero[k] >= bit)zero[k]=zero[k]^zero[j];
                       }
                   }
                   for(int j=0;j<zero.size();j++){
                       if(zero[j]==0)break;
                       if(getBit(tmp) == getBit(zero[j])){
                           tmp = tmp^zero[j];
                       }
                       if(tmp==0)break;
                   }

                   if(tmp!=0){
                       chk=false;
                       break;
                   }
               }
           }
           if(chk)ans[tt]=0;
           else ans[tt]=1;
       
   }

   for(int i=0;i<t;i++){
       cout << ans[i] << endl;
   }

   return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
using namespace std;
int gcd(int a, int b){
    if( a < b ) swap(a,b);
    if(a%b == 0) return b;
    else return gcd(b,a%b);
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) cin >> a[i];
    int ans = a[0];
    for(int i = 1; i < n; ++i){
        ans = gcd(ans, a[i]);
    }
    cout << ans << endl;
    return 0;
}

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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

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

    ll N;
    std::cin >> N;
    std::vector<ll> A(N);
    REP(i, N) {
        std::cin >> A[i];
        A[i] -= (i + 1);
    }

    SORT(A);

    auto med = A[N / 2];
    REP(i, N) {
        A[i] -= med;
        A[i] = abs(A[i]);
    }

    std::cout << accumulate(ALL(A), 0LL) << std::endl;

    return 0;
}


Measured memory_bytes: 1792
import sys

n = int(input())    # ?????£?????????????????????????????°
pic_list = ['S', 'H', 'C', 'D']
card_dict = {'S':[], 'H':[], 'C':[], 'D':[]}        # ?????£?????????????????\?????????????????°
lost_card_dict = {'S':[], 'H':[], 'C':[], 'D':[]}   # ?¶??????????????????\?????????????????°

# ?????????????¨??????\???????????????
for i in range(n):
    pic, num = input().split()
    card_dict[pic].append(int(num))

# ?¶???????????????????????¨??????\????¨????
for pic in card_dict.keys():
    for j in range(1, 14):
        if not j in card_dict[pic]:
            lost_card_dict[pic].append(j)

# ?????????????????????
for pic in card_dict.keys():
    lost_card_dict[pic] = sorted(lost_card_dict[pic])

# ?¶????????????????????????????
for pic in pic_list:
    for k in range(len(lost_card_dict[pic])):
        print(pic, lost_card_dict[pic][k])

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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


int n, a[101010], b[101010];
P p[101010];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
		p[i] = P(b[i]+a[i],a[i]);
	}
	
	sort(p, p+n);
	
	ll cnt = 0;
	for(int i = 0; i < n; i++){
		if(i%2){
			cnt -= p[n-i-1].first - p[n-i-1].second;
		}
		else{
			cnt += p[n-i-1].second;
		}
	}
	
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>

using namespace std;

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

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 998244353;

int N, K, l, r;
ll dp[1<<20];
vector<pii> seg;

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);
 cin>>N>>K;
 rep(i,K) {
   cin>>l>>r;
   seg.pb({l,r});
 }
 sort(seg.begin(),seg.end());
 dp[1]=1;
 for(int i = 2;i <= N;i++) {
   for(pii x:seg) {
     l = x.F;r=x.S;
     int u = i-r;
     int v = i-l;
     if(v < 1) continue;
     u = max(1, u);
     dp[i]+=dp[v]-dp[u-1];
     dp[i]%=mod;
     dp[i]=(dp[i]+mod)%mod;
   }
   dp[i] = (dp[i]+dp[i-1])%mod;
 }
 cout<<(mod+(dp[N]-dp[N-1])%mod)%mod;


 return 0;
}


Measured memory_bytes: 5132
#include <stdio.h>

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

const int MAX = 100000;

int n,m;
int q;
int a[MAX];
bool used[MAX];
int t[MAX];
int t_i;
int rev[MAX];
int cnt[MAX+1];

int main(){
  scanf("%d%d%d",&n,&m,&q);
  REP(i,q)scanf("%d",a+i),--a[i];
  // calc target sequence
  FORR(i,0,q){
    int c = a[i];
    if(!used[c]){
      used[c] = true;
      t[t_i++] = c;
    }
  }
  REP(i,m){
    if(!used[i])t[t_i++] = i;
    rev[t[i]] = i;
  }
  // split
  cnt[0] = n;
  FORR(i,0,q){
    int c = a[i];
    int id = rev[c];
    if(cnt[id]>0){
      cnt[id]--;
      cnt[id+1]++;
    }
  }
  REP(i,m){
    if(cnt[i]>0){
      bool flag = true;
      FOR(j,i,m-1){
        flag = flag && t[j]<t[j+1];
      }
      puts(flag?"Yes":"No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}


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

// why am I so weak

int n, m;
int a[200055];
int cnt[200055];

int d[200055];

int main() {
	scanf("%d %d", &n, &m);

	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		a[i]--;
		cnt[a[i]]++;
	}

	int res = 0;

	for (int i = 0; i < n; i++) {
		for (int j = i; j >= max(0, i - cnt[i] + 1); j--) {
			d[j]++;
		}
	}

	for (int i = 0; i < n; i++) if (d[i] == 0) {
		res++;
	}

	while (m--) {
		int x, y;
		scanf("%d %d", &x, &y);
		x--, y--;

		if (a[x] - cnt[a[x]] + 1 >= 0) {
			d[a[x] - cnt[a[x]] + 1]--;

			if (d[a[x] - cnt[a[x]] + 1] == 0) {
				res++;
			}
		}

		cnt[a[x]]--;
		cnt[y]++;

		if (y - cnt[y] + 1 >= 0) {
			d[y - cnt[y] + 1]++;

			if (d[y - cnt[y] + 1] == 1) {
				res--;
			}
		}

		a[x] = y;

		printf("%d\n", res);
	}

	return 0;
}


Measured memory_bytes: 3712
#include "bits/stdc++.h"
using namespace std;
int C[16];
int x[20001];
int dp[20001][256];
const int INF = 1 << 30;
int main() {
	int N, M;
	while (cin >> N >> M, N) {
		for (int i = 0; i < M; i++) {
			cin >> C[i];
		}
		for (int i = 0; i < N; i++) {
			cin >> x[i];
		}
		for (int i = 0; i <= N; i++) {
			for (int j = 0; j < 256; j++) dp[i][j] = INF;
		}
		dp[0][128] = 0;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < 256; j++) {
				if (dp[i][j] == INF) continue;
				for (int k = 0; k < M; k++) {
					int nj = j + C[k];
					if (0 > nj) nj = 0;
					if (nj > 255) nj = 255;
					int tmp = (nj - x[i])*(nj - x[i]);
					if (dp[i][j] + tmp < dp[i+1][nj]) {
						dp[i+1][nj] = dp[i][j] + tmp;
					}
				}
			}
		}
		int ans = INF;
		for (int i = 0; i < 256; i++) {
			ans = min(ans, dp[N][i]);
		}
		cout << ans << endl;
	}
	
}

Measured memory_bytes: 23180
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(void){
  int n,a,b;
  scanf("%d",&n);
  

    a=n/500;
    
  
  n=n%500;
  b=n/5;
  printf("%d",1000*a+5*b);
return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC102.A
{
    class Program
    {
        static void Main ()
        {
            var sc = new Scanner ();
            var n = sc.Nextint ();
            var A = sc.Arrayint (n);
            Array.Sort (A);
            Console.WriteLine (A[n - 1] - A[0]);
        }
    }
    class Scanner
    {
        string[] s;
        long i;

        char[] cs = new char[] { ' ' };

        public Scanner ()
        {
            s = new string[0];
            i = 0;
        }

        public string Next ()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine ();
            while (st == "") st = Console.ReadLine ();
            s = st.Split (cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next ();
            i = 0;
            return s[i++];
        }

        public int Nextint ()
        {
            return int.Parse (Next ());
        }
        public int[] Arrayint (int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Nextint () + add;
            }
            return Array;
        }

        public long NextLong ()
        {
            return long.Parse (Next ());
        }

        public long[] ArrayLong (int N, long add = 0)
        {
            long[] Array = new long[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextLong () + add;
            }
            return Array;
        }

        public double NextDouble ()
        {
            return double.Parse (Next ());
        }

        public double[] ArrayDouble (long N, double add = 0)
        {
            double[] Array = new double[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDouble () + add;
            }
            return Array;
        }

        public decimal NextDecimal ()
        {
            return decimal.Parse (Next ());
        }

        public decimal[] ArrayDecimal (long N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDecimal ();
            }
            return Array;
        }
    }
}

Measured memory_bytes: 13268
import sys
input = sys.stdin.buffer.readline

def main():
    n, c = map(int, input().split())
    D = [list(map(int, input().split())) for _ in range(c)]
    C_ = [list(map(int, input().split())) for _ in range(n)]
    C = [0]*n
    for i, c_ in enumerate(C_):
        c_ = [x-1 for x in c_]
        C[i] = c_

    X = [[0]*c for _ in range(3)]
    for i in range(n):
        for j in range(n):
            m = (i+j)%3
            X[m][C[i][j]] += 1

    #print(C)
    import itertools
    ans = 10**18
    for p in itertools.permutations(range(c), 3):
        temp = 0
        for i in range(3):
            for j in range(c):
                temp += D[j][p[i]]*X[i][j]
        ans = min(ans, temp)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 46812
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

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;
}
///////////////////////////////////////////////

/*（๑•﹏•๑｀) */

int main() {
    int N;
    cin >> N;
    vector<int> a(N);

    int sum = 0;
    REP(i,N){
        cin >> a[i];
        sum += a[i];
    }

    int d = 10000;
    int index = -1;

    REP(i,N){
        if (chmin(d,abs(a[i] * N - sum))){
            index = i;
        }
    }

    cout << index << endl;
}


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

int main()
{
	int a, b, c;
	int r = 0;
	int l = 0;
	while (scanf("%d,%d,%d", &a, &b, &c) != EOF ) {
		if (a*a + b*b == c*c) {//??´?§?????§???¢
			r++;
		}
		else if (a == b) {//?????????????§???¢
			l++;
		}
	}
	cout << r << endl;
	cout << l << endl;
	
    return 0;
}

Measured memory_bytes: 1208
import math

n,m=map(int,input().split())

if(abs(n-m)>1):
    print(0)
    exit()

N=math.factorial(n)
M=math.factorial(m)
if(abs(n-m)==1):
    print((N*M)%(10**9+7))
else:
    print((N*M*2)%(10**9+7))


Measured memory_bytes: 5184
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int q = sc.nextInt();

		int[] pt = new int[n+1];
		for(int j=1; j<=n; j++) pt[j] = k-q;

		for(int i = 1; i <= q; i++) {
			int a = sc.nextInt();
			pt[a] ++;
		}
		for(int j=1; j<=n; j++) {
			if(pt[j]>0) System.out.println("Yes");
			else System.out.println("No");
		}
	}
}

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

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

fn main() {
    let n:usize = read();
    let a:usize = read();
    let b:usize = read();
    let s:Vec<char> = read::<String>().chars().collect();
    let mut cnt = 0;
    let mut fcnt = 0;
    for i in 0..n {
        if cnt >= a + b {
            println!("No");
            continue;
        }
        match s[i] {
            'a' => {
                println!("Yes");
                cnt += 1;
            },
            'b' => {
                if fcnt >= b {
                    println!("No");
                } else {
                    println!("Yes");
                    cnt += 1;
                    fcnt += 1;
                }
            },
            _ => println!("No")
        }
    }
}



Measured memory_bytes: 2796
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        
        String S =sc.next();
        String word[] =S.split("");
        
        String result ="";
        
        
            if(word[0].equals("A") &&word[1].equals("A")&&word[2].equals("A")){
                result ="No";
            }else if(word[0].equals("B") &&word[1].equals("B")&&word[2].equals("B")){
                result ="No";
            }else{
                result ="Yes";
            }
            
        
        System.out.println(result);
        
    }
    
    
}


Measured memory_bytes: 35608
#include<stdio.h>
#include<stdlib.h>
#define N 8
#define NOT_FREE 1
#define FREE 0
void putQueen(int);
void printBoard(void);
int M[N][N],row[N],col[N],dneg[2*N-1],dpos[2*N-1];
int main(){
  int k,i,j,r,c;
  scanf("%d",&k);
  for(i=0; i<N; i++){                            //
    col[i] = row[i] = dneg[i] = dpos[i] = FREE;  //
    for(j=0; j<N; j++){                          //
      M[i][j] = 0;                               //
    }                                            //
  }                                              //
  for(i=N; i<(N*2-1); i++){                      //
    dneg[i] = dpos[i] = FREE;                    //
  }                                              //
  for(i=0; i<k; i++){
    scanf("%d%d",&r,&c);
    M[r][c] = 1;
  }
  putQueen(0);
  return 0;
}

void putQueen(int i){
  int j;
  if(i == N){
    printBoard();
    return;
  }
  for(j=0; j<N; j++){
    if(col[j] == NOT_FREE || dpos[i+j] == NOT_FREE || dneg[i-j+N-1] == NOT_FREE) continue;
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
    putQueen(i+1);
    row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
  }
}
void printBoard(void){
  int i,j;
  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      if(M[i][j] && row[i] != j) return;
    }
  }
  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      printf((row[i] == j ? "Q" : "."));
      if(j == N-1) printf("\n");
    }
  }
}

Measured memory_bytes: 588
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
while true
  n,r = inp
  break if n == 0
  dk = (1..n).to_a.reverse
  r.times do
    p,c = inp
    pl = dk[(p-1)..(p-2+c)]
    dk.slice!(p-1,c)
    dk = pl.concat(dk)
  end
  puts dk[0]
end
=begin

=end

Measured memory_bytes: 9136
#include<iostream>
#include<cmath>
using namespace std;
typedef long long int ll;
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll a;
  cin>>a;
  cout<<a+(pow(a,2))+(pow(a,3));
  return 0;
}  

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

int main(){
  string s;
  cin >> s;
  int len= s.size();
  ll ans=0;

  for(int t=0; t<1<<(len-1); t++){
    ll num=s[0]-'0';
    for(int i=0; i<len-1; i++){
      if(t&(1<<i)){
        ans+=num;
        num=0;
      }
      num=num*10+s[i+1]-'0';
    }
    ans+=num;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    a,b,c = f()
    a = a%b
    c = c%b
    for i in range(b):
        if (a*i)%b == c:
            print('YES')
            return
    
    print('NO')

solve()


Measured memory_bytes: 2940
N, M = map(int, input().split())
A = tuple(map(int, input().split()))

M_lst = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = [-1] * (N + 10)
dp[0] = 0
for i in range(N + 1):
    if dp[i] == -1:
        continue
    for a in A:
        dp[i + M_lst[a]] = max(dp[i + M_lst[a]], dp[i] * 10 + a)
print(dp[N])


Measured memory_bytes: 14692
#include<stdio.h>

struct test{
    int mid;
    int fin;
    int re;
    char eval;
};char evaluate(int mid, int fin, int re);
int main(){
    struct test test[50];
    int i;
    int count = 0;
    for(i = 0;i < 50;i++){
        scanf("%d %d %d", &test[i].mid, &test[i].fin, &test[i].re);
        if(test[i].mid == -1 && test[i].fin == -1 && test[i].re == -1){
            break;
        }
        test[i].eval = evaluate(test[i].mid, test[i].fin, test[i].re);
        count++;
    }
    for(i = 0;i < count;i++){
        printf("%c\n", test[i].eval);
    }
    return 0;
}

char evaluate(int mid, int fin, int re){
    if(mid == -1 || fin == -1){
        return 'F';
    }
    if(mid + fin >= 80){
        return 'A';
    }
    else if(mid + fin >= 65){
        return 'B';
    }
    else if(mid + fin >= 50){
        return 'C';
    }
    else if(mid + fin >= 30){
        if(re >= 50){
            return 'C';
        }
        else{
            return 'D';
        }
    }
    else{
        return 'F';
    }
}


Measured memory_bytes: 2100
l, r = list(map(int, input().split()))
MOD = 2019
diff = r - l
ans = 0
if diff < 2019:
    l = l % MOD
    r = l + diff
    ans = 2018
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            ans = min(ans, (i % MOD * j % MOD) % MOD)

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e5 + 10;
ll a[N];
vector <int> e[N];
void dfs(int u, int fa)
{
	for (auto v : e[u])
		if (v != fa)
		{
			a[v] += a[u];
			dfs(v, u);
		}
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 1; i < n; ++i)
	{
		int u, v;
		cin >> u >> v;
		e[u].emplace_back(v);
		e[v].emplace_back(u);
	}
	while (m--)
	{
		int u, v;
		cin >> u >> v;
		a[u] += v;
	}
	dfs(1, 0);
	for (int i = 1; i <= n; ++i)
		cout << a[i] << ' ';
}

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

const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    int X, Y;
    cin >> X >> Y;
    if((X + Y) % 3){
        cout << 0 << endl;
        return 0;
    }
    COMinit();
    int totalDistance = X + Y;
    int totalMove = (X + Y) / 3;
    int maxY = (X + Y) / 3 * 2;
    int yLongMove = totalMove - (maxY - Y);
    cout << COM(totalMove, yLongMove) << endl;
    return 0;
}

Measured memory_bytes: 23808
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int max, min;
		int sum = 0;

		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			int[] score = new int[n];
			for(int i=0; i<n; i++){
				score[i] = sc.nextInt();
				sum += score[i];
			}
			max = score[0];
			min = score[0];
			for(int i=1; i<n; i++){
				if(score[i]>max){
					max = score[i];
				}
				if(score[i]<min){
					min = score[i];
				}
			}
			sum -= (max+min);
			System.out.println(sum/(n-2));
			sum = 0;
		}
	}
}

Measured memory_bytes: 28920
fn main() {
    let mut sc = Scanner::new();
    let s: Vec<char> = sc.read::<String>().chars().collect();
    let mut count = vec![0; 26];
    for &s in &s {
        count[(s as usize - 'a' as usize)] += 1;
    }

    let n = s.len();
    let mut ans = n * (n - 1) / 2;
    for &c in &count {
        if c == 0 {
            continue;
        }
        ans -= c * (c - 1) / 2;
    }
    println!("{}", ans + 1);
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


Measured memory_bytes: 4476
x, k, d = map(int, input().split())

if abs(x) // d > k:
    print(abs(x) - k * d)
else:
    tmp = abs(x) - d * (abs(x) // d)
    if (k - abs(x) // d) % 2 == 0:
        print(tmp)
    else:
        print(abs(tmp - d))


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

string line[30];
int w, h, x, y, sum;

void countup(int x, int y){
	if(line[y][x] != '#'){
		line[y][x] = '#';
		countup(x,y-1);
		countup(x,y+1);
		countup(x+1,y);
		countup(x-1,y);
		sum++;
	}
	return;
}

int main(){
	while(cin >> w >> h){
		if (!w && !h) break;
		sum = 0;
		for(int i = 1;i<=h;i++){
			cin >> line[i];
			line[i] = "#" + line[i] + "#";
			for(int j = 0;j<=w+1;j++){
				if(line[i][j] == '@'){
					x = j;
					y = i;
				}
			}
		}
		line[h + 1] = line[0] = "#####################";
		countup(x, y);
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3032
#include<bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c;
	cin>>a>>b>>c;
	if (!((a*100+b*10+c)%4)) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define mp(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

struct Type{
	char ch;
	int len;
};

void Solve(){
	string s;
	cin >> s;

	vector<Type> cmp;
	char ch=s[0];
	int cnt=1;
	rep(i,1,s.size()){
		if(s[i]!=ch){
			cmp.push_back(Type{ch,cnt});
			ch=s[i];
			cnt=1;
		}else ++cnt;
	}
	cmp.push_back(Type{ch,cnt});

	int ans=0;
	rep(i,0,(int)cmp.size()-2){
		if(cmp[i].ch=='J'&&cmp[i+1].ch=='O'&&cmp[i+2].ch=='I'&&cmp[i].len>=cmp[i+1].len&&cmp[i+1].len<=cmp[i+2].len) ans=max(ans,cmp[i+1].len);
	}

	cout << ans << endl;
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	Solve();
	return 0;
}

Measured memory_bytes: 13192
# coding: utf-8
# Your code here!
import numpy as np
N, M = (int(i) for i in input().split())
KA = [list(map(int, input().split())) for _ in range(N)]
# print(N, M)
# print(KA)
# print(list(range(1, N+1)))
count_list = [0] * M

for A in KA:
    for a in A[1:]:
        # print(a)
        count_list[a-1] += 1
print(np.sum((np.array(count_list) / N)==1))
    

Measured memory_bytes: 12424
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

class rmq {
private:
    int n;
    int sz;
public:
    vector<ll> v;
    rmq() { }
    rmq(int a){
        n = 1;
        for(; n * 2 < a;){
            n *= 2;
        }
        sz = n * 2;
        v.resize(4 * n - 1, inf);
    }
    
    void update(int i, ll x){
        i += sz - 1;
        v[i] = x;
        while(i > 0){
            i = (i - 1) / 2;
            v[i] = min(v[2 * i + 1], v[2 * i + 2]);//
        }
    }
    
    ll query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return inf;
        if(a <= l && r <= b) return v[k];
        else{
            ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return min(vl, vr);//
        }
    }
    
    ll query(int a, int b){ // closed interval
        return query(a, b, 0, 0, sz);
    }
};

typedef pair<int, pair<int, int>> pipii;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> P(N + 1);
    rep(i, N) {
        cin >> A[i];
        P[A[i]] = i;
    }
    
    vector<rmq> R(2, rmq(N));
    rep(i, N){
        R[i % 2].update(i, A[i]);
    }
    
    priority_queue<pipii, vector<pipii>, greater<pipii>> pq;
    vector<pair<int, int>> ans;
    pq.push(mp(0, mp(0, N)));
    
    while(!pq.empty()){
        auto t = pq.top();
        int p = P[t.first];
        int f = t.second.first, s = t.second.second;
        pq.pop();
        int emin = R[p % 2].query(f, s);
        int epos = P[emin];
        int omin = R[(p % 2) ^ 1].query(epos + 1, s);
        int opos = P[omin];
        ans.pb(mp(emin, omin));
//        cout << epos << "," << opos << endl;
        vector<pair<int, int>> next = {{f, epos}, {epos + 1, opos}, {opos + 1, s}};
        for(auto n: next){
            if(n.second - n.first > 1){
//                cout << R[n.first % 2].query(n.first, n.second) << "," << n.first << "," << n.second << endl;
                pq.push(mp(R[n.first % 2].query(n.first, n.second), n));
            }
        }
    }
    
    rep(i, ans.size()){
        cout << ans[i].first << " " << ans[i].second << " ";
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 14080
n=int(input())
a=list(map(int,input().split()))
x='No'
p=len(set(a))
if p==1:
  if a[0]==0:
    x='Yes'
elif p==2:
  if n%3==0:
    if a.count(0)==n//3:
      x='Yes'
elif p==3:
  if n%3==0:
    b=set(a)
    t=0
    f=1
    for i in b:
      t=t^i
      if a.count(i)!=n//3:
        f=0
    if t==0 and f:
      x='Yes'
print(x)

Measured memory_bytes: 14212
#include <stdio.h>

int clamp(int x, int mini, int maxi);

int main(void)
{
  int n, i;
  int bucket[6] = {0};

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    int height, rank;
    scanf("%d.%*d", &height);
    rank = clamp((height - 160) / 5, 0, 5);
    bucket[rank]++;
  }
  for (i = 0; i < 6; i++) {
    int j;
    printf("%d:", i + 1);
    for (j = 0; j < bucket[i]; j++) {
      printf("*");
    }
    printf("\n");
  }
  return (0);
}

int clamp(int x, int mini, int maxi)
{
  if (x <= mini) {
    return (mini);
  }
  if (maxi <= x) {
    return (maxi);
  }
  return (x);
}

Measured memory_bytes: 604
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int dp[1'001][1'001];

void solve(const string& x, const string& y)
{
    irep(i, x.size()) irep(j, y.size())
    {
        if (i == 0) {
            dp[i][j] = j;
        } else if (j == 0) {
            dp[i][j] = i;
        } else {
            dp[i][j] = min(
                min(dp[i - 1][j], dp[i][j - 1]) + 1,
                dp[i - 1][j - 1] + (x[i - 1] == y[j - 1] ? 0 : 1));
        }
    }
    cout << dp[x.size()][y.size()] << endl;
}

int main()
{
    string x, y;
    cin >> x >> y;
    solve(x, y);
    return 0;
}


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

	vector<int> array;
	for(int i=0;i<n;i++){
		int x;
		cin >> x;
		array.push_back(x);
	}
	int minSum = INT_MAX;
	for(int a=-100;a<=100;a++){
		int sum=0;
		for(auto e:array){
			sum+=(a-e)*(a-e);
		}
		minSum=min(minSum,sum);
	}
	cout<<minSum;
}

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

int main(void){
  int sec, sec3;
  int used;
  int hh,mm,ss;
  int reth,retm,rets;


  while(cin >> hh >> mm >> ss){
	if(hh == -1 && mm == -1 && ss == -1) break;
	used = hh * 3600 + mm * 60 + ss;
	sec = 7200 - used;
	sec3 = sec * 3;
	
	reth = sec / 3600;
	sec -= 3600 * reth;
	retm = sec / 60;
	sec -= 60 * retm;
	rets = sec;
	printf("%02d:%02d:%02d\n", reth, retm, rets);
	reth = sec3 / 3600;
	sec3 -= 3600 * reth;
	retm = sec3 / 60;
	sec3 -= 60 * retm;
	rets = sec3;
	printf("%02d:%02d:%02d\n", reth, retm, rets);
  }
}

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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+123;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};       ///first 4 for adjacent
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};
ll dx8[]= {+1, +1, -1, -1, +2, +2, -2, -2};    ///knights move
ll dy8[]= {+2, -2, +2, -2, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define MP make_pair
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ a%=MOD;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=MOD;--b;}a*=a;a%=MOD;b/=2;}return pr;}
ll modinverse(ll a){return powmod(a,MOD-2);}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///
bool check(ll n)
{
    ll a[]={
2
,
4
,
5
,
7
,
9};
for(auto i: a) if(i==n) return true;
return false;
}

void _case()
{
    ll a;
    cin>>a;
    if(check(a%10)) cout<<"hon" el;
    else if(a%10==3) cout<<"bon";
    else cout<<"pon" el;
}

main()
{
    fastio();
    _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


Measured memory_bytes: 3656
n = int(input())
a = [int(x) for x in input().split()]

four = sum([1 for x in a if x % 4 == 0])
two = sum([1 for x in a if x % 2 == 0 and x % 4 != 0])
others = sum([1 for x in a if x % 2 != 0])

if two == 0 and others <= four + 1:
    print("Yes")
elif others <= four:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14252
// AOJ ITP1_11_B Dice II
// 2018.4.29 bal4u
 
#include <stdio.h>
 
int rot[24][7] = {
    { 0,1,2,3,4,5,6 },{ 0,1,3,5,2,4,6 },{ 0,1,4,2,5,3,6 },{ 0,1,5,4,3,2,6 },
    { 0,2,6,3,4,1,5 },{ 0,2,3,1,6,4,5 },{ 0,2,1,4,3,6,5 },{ 0,2,4,6,1,3,5 },
    { 0,3,1,2,5,6,4 },{ 0,3,2,6,1,5,4 },{ 0,3,5,1,6,2,4 },{ 0,3,6,5,2,1,4 },
    { 0,4,1,5,2,6,3 },{ 0,4,2,1,6,5,3 },{ 0,4,5,6,1,2,3 },{ 0,4,6,2,5,1,3 },
    { 0,5,1,3,4,6,2 },{ 0,5,3,6,1,4,2 },{ 0,5,4,1,6,3,2 },{ 0,5,6,4,3,1,2 },
    { 0,6,2,4,3,5,1 },{ 0,6,3,2,5,4,1 },{ 0,6,5,3,4,2,1 },{ 0,6,4,5,2,3,1 } };
int assign[7];
 
int main()
{
    int i, j;
    int a[7], b[7], dice[7];
 
    for (i = 1; i <= 6; i++) scanf("%d", assign+i);
    for (i = 1; i <= 6; i++) scanf("%d", a+i);
    for (j = 0; j < 24; j++) {
        for (i = 1; i <= 6; i++) dice[i] = rot[j][i];
        for (i = 1; i <= 6; i++) b[i] = assign[dice[i]];
        for (i = 1; ; i++) {
            if (i > 6) { puts("Yes"); return 0; }
            if (a[i] != b[i]) break;
        }
    }
    puts("No");
    return 0;
}


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

public class Main {
    final static long MOD = 1000000007;

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = fs.nextInt();
        int k = fs.nextInt();
        long[] a = fs.nextLongArray(n);

        long[] dp = new long[n + 1];

        dp[0] = 0;

        for(int i = 1; i < n; i++) {
            long minCost = Integer.MAX_VALUE;
            for(int j = 1; j <= k && i-j >= 0; j++) {
                minCost = Math.min(dp[i - j] + Math.abs(a[i - j] - a[i]), minCost);
            }
            dp[i] = minCost;
        }

        out.println(dp[n-1]);

        out.flush();
        out.close();
    }


    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                //                br = new BufferedReader(new FileReader("testdata.out"));
                st = new StringTokenizer("");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        public String next() {
            if (st.hasMoreTokens())
                return st.nextToken();
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return st.nextToken();
        }

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

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

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

        public String nextLine() {
            String line = "";
            try {
                line = br.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return line;
        }

        public char nextChar() {
            return next().charAt(0);
        }

        public Integer[] nextIntegerArray(int n) {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }

        public char[] nextCharArray() {
            return nextLine().toCharArray();
        }
    }
}



Measured memory_bytes: 33924
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=(b);++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define pi pair<int, int>
#define mk make_pair
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N=1e2+10;
char s[N],t[N];
void solve()
{
    cin>>s+1>>t+1;
    int len=strlen(s+1);
    int flag=1;
    rep(i,1,len) if(s[i]!=t[i]) flag=0;
    if(flag) puts("Yes");
    else puts("No");
}
int main()
{
	solve();
}


Measured memory_bytes: 3624
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

//Doctor's Memorable Codes
public class Main {

	public static void main(String[] args) {
		Map<String, Character> t = new HashMap<String, Character>();
		t.put("101", ' ');
		t.put("000000", '\'');
		t.put("000011", ',');
		t.put("10010001", '-');
		t.put("010001", '.');
		t.put("000001", '?');
		t.put("100101", 'A');
		t.put("10011010", 'B');
		t.put("0101", 'C');
		t.put("0001", 'D');
		t.put("110", 'E');
		t.put("01001", 'F');
		t.put("10011011", 'G');
		t.put("010000", 'H');
		t.put("0111", 'I');
		t.put("10011000", 'J');
		t.put("0110", 'K');
		t.put("00100", 'L');
		t.put("10011001", 'M');
		t.put("10011110", 'N');
		t.put("00101", 'O');
		t.put("111", 'P');
		t.put("10011111", 'Q');
		t.put("1000", 'R');
		t.put("00110", 'S');
		t.put("00111", 'T');
		t.put("10011100", 'U');
		t.put("10011101", 'V');
		t.put("000010", 'W');
		t.put("10010010", 'X');
		t.put("10010011", 'Y');
		t.put("10010000", 'Z');
		Map<Character, String> r = new HashMap<Character, String>();
		r.put('A', "00000");
		r.put('B', "00001");
		r.put('C', "00010");
		r.put('D', "00011");
		r.put('E', "00100");
		r.put('F', "00101");
		r.put('G', "00110");
		r.put('H', "00111");
		r.put('I', "01000");
		r.put('J', "01001");
		r.put('K', "01010");
		r.put('L', "01011");
		r.put('M', "01100");
		r.put('N', "01101");
		r.put('O', "01110");
		r.put('P', "01111");
		r.put('Q', "10000");
		r.put('R', "10001");
		r.put('S', "10010");
		r.put('T', "10011");
		r.put('U', "10100");
		r.put('V', "10101");
		r.put('W', "10110");
		r.put('X', "10111");
		r.put('Y', "11000");
		r.put('Z', "11001");
		r.put(' ', "11010");
		r.put('.', "11011");
		r.put(',', "11100");
		r.put('-', "11101");
		r.put('\'', "11110");
		r.put('?', "11111");
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			char[] m = sc.nextLine().toCharArray();
			StringBuilder sb = new StringBuilder();
			for(char c:m)sb.append(r.get(c));
			String s = sb.toString();
			sb = new StringBuilder();
			int i=0;
			while(i<s.length()){
				int k;
				for(k=3;i+k<=s.length();k++){
					String sub = s.substring(i,i+k);
					boolean f = false;
					for(String v : t.keySet()){
						if(v.equals(sub)){
							f = true;
							break;
						}
					}
					if(f)break;
				}
				if(i+k>s.length())break;
				sb.append(t.get(s.substring(i,i+k)));
				i+=k;
			}
			System.out.println(sb);
		}
	}
}

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

int main(void){
	int n;

	cin>>n;
	while(n--){
		int a,b,c;

		cin>>a>>b>>c;
		a *= a;
		b *= b;
		c *= c;

		if(a+b==c || b+c==a || c+a==b){
			cout<<"YES\n";
		}
		else{
			cout<<"NO\n";
		}
	}

	return 0;
}

Measured memory_bytes: 0
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	if n%10 == 7 || (n%100)/10 == 7 || n/100 == 7 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1752
#include<stdio.h>

int main(void){
  int a;
  int b;
  int c;
  int s;

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

  if(a > b){
    s = a, a = b, b = s;
  }
    if( b > c){
      s = b, b = c, c = s;
    }
    if(a > b){
      s = a, a = b, b = s;
    }
  printf("%d %d %d\n",a,b,c);

  return 0;
}
	
    
  























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

using namespace std;

long long ans;
long long n, cnt[5];
string s;

int p[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
int q[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
int r[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};

int main(){
	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> s;
		switch(s[0]){
			case 'M': cnt[0]++; break;
			case 'A': cnt[1]++; break;
			case 'R': cnt[2]++; break;
			case 'C': cnt[3]++; break;
			case 'H': cnt[4]++; break;
		}
	}
	for(int i = 0; i < 10; ++i) ans += cnt[p[i]]*cnt[q[i]]*cnt[r[i]];
	cout << ans << endl;
}

Measured memory_bytes: 256