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

int solve(int k, bool turn, int n, vector<int> &a, vector<vector<int>> &dp){
	if(k == 0)
		return !turn;
	if(dp[k][turn] != -1)
		return dp[k][turn];

	bool res;
	if(turn){
		res = 0;
		for(int i = 1; i <= n; ++i){
			if(k - a[i] >= 0)
				res = res | solve(k - a[i], !turn, n, a, dp);
		}
	}else{
		res = 1;
		for(int i = 1; i <= n; ++i){
			if(k - a[i] >= 0)
				res = res & solve(k - a[i], !turn, n, a, dp);
		}
	}
	return dp[k][turn] = res;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("ip.txt", "r", stdin);
    freopen("op.txt", "w", stdout);
#endif
	int n, k;
	cin >> n >> k;

	 vector<vector<int>> dp(k +1, vector<int>(2, -1));

	vector<int> a(n +1);
	for(int i = 0; i < n; ++i){
		cin >> a[i +1];
	}
	solve(k, 1, n, a, dp) ? puts("First") : puts("Second");
}

Measured memory_bytes: 17972
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int n, k;
  cin >> n >> k;
  vector<unsigned int> h(n);
  //unsigned int h[200005];
  for (int i = 0; i < n; i++)
  {
    cin >> h[i];
  }
  sort(h.begin(), h.end() );
  //reverse(h.begin(), h.end());
  /*for (int i = 0; i < k; i++){
    h[i] = 0;
  }*/
  unsigned long long int ans = 0;
  for (int i = 0; i < n - k; i++)
  {
    ans += h[i];
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 1024
def main():

    x1, x2, x3, x4, x5 = map(int, input().split())
    if (x1 == 0):
        print(1)
    elif (x2 == 0):
        print(2)
    elif (x3 == 0): 
        print(3)
    elif (x4 == 0):
        print(4)
    else:
        print(5)

main()


Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(RALL(a));
    int ans = 0;
    for(int i = 0; i < k; i++) {
        ans += a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3544
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
char findans(int k)
{
  char aaa[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  return aaa[k-1];
}
int main()
{
  long long int n; 
  cin>>n;
  string s;
  if(n<=26)
  cout<<findans(n)<<endl;
  else
  {
    while(n>0)
    {
      n--;
      char ans='a'+(char)(n%26);
      s+=ans;
    //  cout<<ans;
      n=n/26;
    }
    //if(n>0)
   // s+=findans(n);
 
    for(int i=s.length()-1;i>=0;i--)
    cout<<s[i];
    cout<<endl;
  }
}

Measured memory_bytes: 3536
/*
 * $File: p1000.cpp
 * $Author: Wayne <tletletle@163.com>
 *
 * Task:
 *   Compute A + B.
 * 
 * Solution:
 *   Straight forward.
 *   Remember to process to EOF.
 */

#include <cstdio>

int main() {
	for (int a, b; scanf("%d%d", &a, &b) != EOF; )
		printf("%d\n", a + b);
	return 0;
}

Measured memory_bytes: 1028
import java.util.*;
 
public class Main{
	public static void main(String[] args){
	    Scanner sc = new Scanner(System.in);
    	String s = sc.next();
        int a = 0;
        int z = 0;
        for(int i = 0; i < s.length(); i++){
        	if(s.charAt(i) == 'A'){
            	a = i;
                break;
            }
        }
        for(int i = 0; i < s.length(); i++){
        	if(s.charAt(i) == 'Z'){
            	z = i + 1; 
            }
        }
        System.out.println(z - a);
	}
}

Measured memory_bytes: 40404
/*..............................................*\
Author:Kishor Kumar Paroi
Dept:CSE-1703053
email.kishor.josephite@gmail.com
RUET,BANGLADESH
\*---------------------------*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <sstream>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include<bits/stdc++.h>
#include<iostream>
#include<iterator>

#define max(a,b) ((a>b)?a:b)                        //finding max
#define min(a,b) ((a<b)?a:b)                        //finding min
#define Max(a,b,c) max(a,max(b,c))                  //finding max between 3 numbers
#define Min(a,b,c) min(a,min(b,c))                  //finding min between 3 numbers
#define Pi acos(-1.0)                               //defining Pi for mathematical uses
#define Clear(a) memset(a,0,sizeof(a))              //clearing memory of an array
#define setfalse(a) memset(a,false,sizeof(a))       //setting the array into false
#define settrue(a) memset(a,true,sizeof(a))         //setting the array into true
#define clrstr(a) memset(a,'\0',sizeof(a))          //setting string array to null
#define open freopen("input.txt","r",stdin)         //opening input file
#define close freopen ("output.txt","w",stdout)     //opening output file
#define Case(a) printf("Case %d: ",a)               //printing case number
#define caseh(a) printf("Case #%d: ",a)             //printing case number having '#'
#define getcase(a) scanf("%d",&a)                   //scanning case number
#define caseloop(a,b) for(a=1;a<=b;a++)             //making case loop
#define EPS 1e-9                                    //small value for avoiding preccesion error
#define LL long long                                //long long short form
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

//const int N=100*1000;
//const int mod=1e9+7;

//# define int min3(int a,int b,int c){return min(a,min(b,c));}
//#define int max3(int a,int b,int c){return max(a,max(b,c));}
//#define int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
//#define int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
     double i,t,n,s,x,f;
     cin>>t;
     string S;
     while(t--)
     {
         cin>>x;
         cin>>S;
         if(S=="JPY")
            s+=x;
         else
         s=s+(x*380000.0);
     }
     printf("%.5lf\n",s);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sz sizes.size()
typedef pair<int, int> pii;
typedef set<pii> pqmin;
const int MAXN = 100005;
int v[MAXN];
vector<int> adj[MAXN];
bool mark[MAXN];
int cnt;
vector<int> comp[MAXN];
vector<int> val;
void dfs(int x){
    mark[x] = true;
    val.push_back(v[x]);
    cnt++;
    for(auto xt : adj[x]){
        if(!mark[xt]) dfs(xt);
    }
}
int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i = 0; i < n; i++) scanf("%d", &v[i]);
    for(int i = 0; i < m; i++){
        int u, v;
        scanf("%d %d", &u, &v);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    int comps = 0;
    for(int i = 0; i < n; i++){
        if(mark[i]) continue;
        cnt = 0;
        val.clear();
        dfs(i);
        sort(val.begin(), val.end());
        comp[comps] = val;
        comps++;
    }
    if(comps == 1) return 0 * puts("0");
    /*for(int i = 0; i < comps; i++){
        for(auto x : comp[i]) printf("%d ", x);
        printf("\n");
    }*/
    int nodes = 2 * (comps - 1);
    if(nodes > n) return 0 * puts("Impossible");
    nodes -= comps;
    vector<int> vall;
    long long ans = 0;
    for(int i = 0; i < comps; i++){
        ans += comp[i][0];
        for(int j = 1; j < comp[i].size(); j++) vall.push_back(comp[i][j]);
    }
    sort(vall.begin(), vall.end());
    for(int i = 0; i < nodes; i++) ans += vall[i];
    printf("%lld\n", ans);
    return 0;
}


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

int main(){
	long stack[100] = { 0 }, idx = 0;
	char input[1000],*elem;

	gets(input);
	elem = strtok(input, " ");
	while(elem!=NULL){
		if (elem[0] == '+'){
			stack[idx - 1] += stack[idx--];
		}
		else if (elem[0] == '-'){
			stack[idx - 1] -= stack[idx--];
		}
		else if (elem[0] == '*'){
			stack[idx - 1] *= stack[idx--];
		}else{
			stack[++idx] = atol(elem);
		}
		elem = strtok(NULL, " ");
	}
	printf("%d\n", stack[idx]);
	return 0;
}

Measured memory_bytes: 956
N = gets.to_i
B = gets.split(' ').map(&:to_i)
b = B
result = []

require 'pp'
def debug obj
  PP.pp obj, STDERR
end

debug "N: #{N}"
debug B
while(b.size > 0) do
  found = false
  b.length.times do |i|
    j = b.length - 1 - i
    if b[j] == j + 1
      found = true
      result.unshift(b.delete_at(j))
      break
    end
  end

  unless found
    puts -1
    exit
  end
end

result.each do |r|
  puts r
end

Measured memory_bytes: 2172
i = input()
i = i.split()
n=0
while str(i[1]) !="?":
    if str(i[1]) == "+":
        op = int(i[0])+int(i[2])
        print(op)
    if str(i[1]) == "-":
        op = int(i[0])-int(i[2])
        print(op)
    if str(i[1]) == "*":
        op = int(i[0]) * int(i[2])
        print(op)
    if str(i[1]) == "/" and str(i[2]) != 0:
        op = int(i[0]) / int(i[2])
        print('%d'%op)
    n=n+1
    i = input()
    i = i.split()


Measured memory_bytes: 5596
import Control.Monad
import Data.Array
main=do
 n<-readLn
 a<-replicateM n readLn
 print(f 1 n 1 (array(1,n)(zip[1..n]a)))
  where f i n s a |i>n    = -1
                  |a!s==2 = i
                  |otherwise = f (i+1) n (a!s) a

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

Measured memory_bytes: 256
while True:
    M=0
    
    A=int(input())
    
    if A==0:
        break
    
    L=list(map(int,input().split()))
    
    B=sum(L)/len(L)
    
    for i in range(A):
        if L[i]<=B:
            M+=1
            
    print(M)


Measured memory_bytes: 6612
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int m;
  cin >> m;
  int cnt = 0;
  while (b <= a) {
    b *= 2;
    ++cnt;
  }
  while (c <= b) {
    c *= 2;
    ++cnt;
  }
  if (cnt <= m) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

#define fastIO \
ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl "\n"
#define ll long long
#define MOD 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define pii pair<int,int> 

int main(){
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++)	cin >> a[i];
	int b[n];
	b[0] =1;
	for(int i=1;i<n;i++)	{
		if(a[i]<=a[i-1])	b[i] = b[i-1]+1;
		else	b[i] = 1;
	}
	int ans = 1;
	for(int i=0;i<n;i++)	ans = max(ans, b[i]);
	cout << ans-1 << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define MX 1000000000000000000LL
using ll = long long;

int main(){
  int n;
  cin>>n;
  ll ans=1;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  sort(a.begin(),a.end());
  rep(i,n){
    if(a[i]==0){
      cout<<0<<endl;
      return(0);
    }
    if(a[i]<=MX/ans){
      ans*=a[i];
    }
    else{
      cout<<-1<<endl;
      return(0);
    }
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 4020
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main{

	static PrintWriter out;
	static InputReader ir;

	static void solve(){
		int[] a=ir.nextIntArray(3);
		boolean[] f=new boolean[a[0]+a[1]];
		for(int i=a[2];;i+=60){
			int r=i%(a[0]+a[1]);
			if(f[r]){
				out.println(-1);
				break;
			}
			if(r<=a[0]){
				out.println(i);
				break;
			}
			f[r]=true;
		}
	}

	public static void main(String[] args) throws Exception{
		ir=new InputReader(System.in);
		out=new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer=new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}

		public boolean hasNextByte() {
			if(curbuf>=lenbuf){
				curbuf= 0;
				try{
					lenbuf=in.read(buffer);
				}catch(IOException e) {
					throw new InputMismatchException();
				}
				if(lenbuf<=0) return false;
			}
			return true;
		}

		private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}

		private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}

		private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}

		public boolean hasNext(){skip(); return hasNextByte();}

		public String next(){
			if(!hasNext()) throw new NoSuchElementException();
			StringBuilder sb=new StringBuilder();
			int b=readByte();
			while(!isSpaceChar(b)){
				sb.appendCodePoint(b);
				b=readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if(!hasNext()) throw new NoSuchElementException();
			int c=readByte();
			while (isSpaceChar(c)) c=readByte();
			boolean minus=false;
			if (c=='-') {
				minus=true;
				c=readByte();
			}
			int res=0;
			do{
				if(c<'0'||c>'9') throw new InputMismatchException();
				res=res*10+c-'0';
				c=readByte();
			}while(!isSpaceChar(c));
			return (minus)?-res:res;
		}

		public long nextLong() {
			if(!hasNext()) throw new NoSuchElementException();
			int c=readByte();
			while (isSpaceChar(c)) c=readByte();
			boolean minus=false;
			if (c=='-') {
				minus=true;
				c=readByte();
			}
			long res = 0;
			do{
				if(c<'0'||c>'9') throw new InputMismatchException();
				res=res*10+c-'0';
				c=readByte();
			}while(!isSpaceChar(c));
			return (minus)?-res:res;
		}

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

		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[][] nextCharMap(int n,int m){
			char[][] map=new char[n][m];
			for(int i=0;i<n;i++) map[i]=next().toCharArray();
			return map;
		}
	}
}

Measured memory_bytes: 24488
using System;
using System.Collections.Generic;

class alds14c
{
    static void Main()
    {
        int oder = int.Parse(Console.ReadLine());
        HashSet<string> dic=new HashSet<string>();
        for (int i = 0; i < oder; i++)
        {
            string[] input = Console.ReadLine().Split(' ');
            if(input[0]=="insert")
            {
                dic.Add(input[1]);
            }
            else
            {
                if(dic.Contains(input[1]))
                {
                    Console.WriteLine("yes");
                }
                else
                {
                    Console.WriteLine("no");
                }
            }

        }
    }
}

Measured memory_bytes: 51356
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import math

def input():
    return sys.stdin.readline()


def calc_coord(theta, length):
    # 第一象限
    if 0 <= theta <= 90:
        rad1 = round(math.radians(90-theta), 11)
        min_x = length * round(math.cos(rad1), 11)
        min_y = length * round(math.sin(rad1), 11)
    elif 90 < theta <= 180:
        rad1 = round( math.radians(90 - theta), 11)
        min_x = round(length * math.cos(rad1),11)
        min_y = round(length * math.sin(rad1),11)
    elif 180 < theta <= 270:
        rad2 = round(math.radians(450-theta),11)
        min_x = round(length * math.cos(rad2),11)
        min_y = round(length * math.sin(rad2),11)
    elif 270 < theta <= 360:
        rad2 = round(math.radians(450 - theta),11)
        min_x = round(length * math.cos(rad2),11)
        min_y = round(length * math.sin(rad2),11)

    return min_x, min_y


def resolve():
    a, b, h, m = map(int, input().split())

    # 時刻を角度に変換
    min_theta = 6.0 * m
    hour_theta = 30 * h + 0.5 * m

    min_x, min_y = calc_coord(min_theta, b)
    hour_x, hour_y = calc_coord(hour_theta, a)

    ans = math.sqrt((min_x - hour_x) ** 2 + (min_y - hour_y) ** 2)

    print(ans)

if __name__ == "__main__":
    resolve()



Measured memory_bytes: 62768
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        //var n = long.Parse(Console.ReadLine());
        long[] n = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var a = n[0];
        var b = n[1];
        var c = n[2];
        var ans = "NO";

        long num = 0;
        for (long i = 1; i <= b; i++)
        {
            num = a * i;
            if(num % b == c) ans = "YES";
        }

        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 28144
import java.util.*;

class Main {
	public static void main(String args[]){
		ArrayList<Integer> ar = new ArrayList<Integer>();
		int cnt = 0;
		Scanner sc = new Scanner(System.in);
		int size = sc.nextInt();
		for(int i = 0;i < size;i++){
			int num = sc.nextInt();
			if(hantei(num)){
				cnt++;
			}
		}
		System.out.println(cnt);
	}
	
	
	private static boolean hantei(int x){
		int n = (int) Math.ceil(Math.sqrt((double)x));
		if(x == 2){
			return true;
		}
		for(int j = 2;j <= n;j++){
			if(x % j == 0){
				return false;
			}
		}
		return true;	
	}
	
}

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

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

int main() {
  for (int D; cin >> D, D; ) {
      char map[128];
      REP(i, 128) map[i] = -1;
      REP(i, D) {
          char a, b; cin >> a >> b;
          map[a] = b;
      }
      cin >> D;
      REP(i, D) {
          char ch; cin >> ch;
          if (map[ch] == -1) cout << ch;
          else cout << map[ch];
      }
      cout << endl;
  }
  return 0;
}

Measured memory_bytes: 856
import java.util.*;
import java.lang.*;

public class Main {
  
    public int dp(String s1,String s2,int i1,int i2,int[][] dp,int l1,int l2) {
    	if(i1==l1 || i2==l2) {
    		return 0;
    	}
    	if(dp[i1][i2]!=-1) {
    		return dp[i1][i2];
    	}
    	if(s1.charAt(i1)==s2.charAt(i2)) {
    		dp[i1][i2]=1+this.dp(s1, s2, i1+1, i2+1, dp, l1, l2);
    	}
    	else {
    		dp[i1][i2]=Math.max(this.dp(s1, s2, i1+1, i2, dp, l1, l2),this.dp(s1, s2, i1, i2+1, dp, l1, l2));
    	}
    	return dp[i1][i2];
    }
	public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc=new Scanner(System.in);
        String s1=sc.next();
        String s2=sc.next();
        int l1=s1.length();
        int l2=s2.length();
        Main mm=new Main();
        int[][] dp=new int[l1][l2];
        for(int i=0;i<l1;i++) {
        	for(int j=0;j<l2;j++) {
        		dp[i][j]=-1;
        	}
        }
        mm.dp(s1, s2, 0, 0, dp, l1, l2);
        int i1=0;
        int i2=0;
        while(i1<l1 && i2<l2) {
        	if(s1.charAt(i1)==s2.charAt(i2)) {
        		System.out.print(s1.charAt(i1));
        		i1++;i2++;
        	}
        	else {
        		if(i1+1<l1 && i2+1<l2) {
        		if(dp[i1+1][i2]>=dp[i1][i2+1]) {
        			i1++;
        		}
        		else {
        			i2++;
        		}}
        		else if(i1+1<l1) {
        			i1++;
        		}
        		else {
        			i2++;
        		}
        		
        	}
        }
	}
}



Measured memory_bytes: 86108
N, A, B = map(int, input().split())
X = list(map(int, input().split()))

ans = 0

for i, x in enumerate(X):
    if i == N-1:
        continue
    if (X[i+1] - x) * A > B:
        ans += B
    else:
        ans += (X[i+1] - x) * A

print(ans)

Measured memory_bytes: 62704
#include <bits/stdc++.h>
    using namespace std;
    int main()
    {
      	int k,n;
      	cin>>n>>k;
      	int p[n];
      	for(int i=0;i<n;i++) cin>>p[i];
      	sort(p,p+n);
      	int s=0;
      	for(int i=0;i<k;i++) s+=p[i];
      	cout<<s<<endl;
    }

Measured memory_bytes: 3648
N = int(input())
SP = [(i+1, list(input().split())) for i in range(N)]
for i in range(N):
    SP[i][1][1] = int(SP[i][1][1])
SP.sort(key=lambda x: x[1][1], reverse=True)
SP.sort(key=lambda x: x[1][0])

for i in SP:
    print(i[0])


Measured memory_bytes: 3060
n, m = map(int, input().split())
a = []
b = []
for _ in range(n):
    a.append(input())
for _ in range(m):
    b.append(input())
flag = 0
cnt = 0
for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(m):
            if a[i+k][j:j+m] == b[k]:
                cnt += 1
        if cnt == m:
            flag = 1
        cnt = 0
if flag == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
//#####   #####   #####   #####   #####   #       #####   #   #//
//#   #   #   #   #       #       #   #   #       #   #   ## ##//
//#####   #####   #####   #       #####   #       #####   # # #//
//##      #   #       #   #       #   #   #       #   #   #   #//
//# #     #   #       #   #       #   #   #       #   #   #   #//
//#  #    #   #       #   #       #   #   #       #   #   #   #//
//#   #   #   #   #####   #####   #   #   #####   #   #   #   #//


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ppb pop_back
#define cs(n) cout<<n<<" "
#define cn(n) cout<<n<<"\n"
#define rep(i,j,k) for(int i=j;i<k;i++)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define deb(x) cout << #x << " " << x << endl;
ll bin(ll a, ll b, ll mod)
{
	if (b == 0)
		return 1;
	if (b % 2 == 0)
		return bin((a * a) % mod , b / 2 , mod) % mod;
	return ((a % mod) * (bin((a * a) % mod , b / 2 , mod) % mod)) % mod;
}
void solve()
{
	int h, w;
	cin >> h >> w;
	int m;
	cin >> m;
	vector<int>r[h + 1], c[w + 1];
	vector<int>vr, vc;
	int mr = 0, mc = 0, lr = -1, lc = -1;
	map<pair<int , int>, int>mp;
	rep(i, 0, m) {
		int a, b;
		cin >> a >> b;
		r[a].pb(b);
		c[b].pb(a);
		mp[ {a, b}] = 1;
		if (mr < r[a].size()) {
			vr.clear();
			vr.pb(a);
			mr = r[a].size();
		}
		else if (mr == r[a].size()) {
			vr.pb(a);
		}
		if (mc < c[b].size()) {
			vc.clear();
			vc.pb(b);
			mc = c[b].size();
		}
		else if (mc == c[b].size()) {
			vc.pb(b);
		}
	}
	rep(i, 0, vr.size()) {
		rep(j, 0, vc.size()) {
			if (mp[ {vr[i], vc[j]}] == 0) {
				cout << mr + mc;
				return;
			}
		}
	}
	cout << mr + mc - 1;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif
	fastio;
	int t;
	t = 1;
	//cin>>t;
	while (t--)
	{
		solve();
	}
#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
	return 0;
}

Measured memory_bytes: 57180
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef long double ld;
 
int main() {
    int A,B;
    cin >>A>>B;
    int ans=A*B;
    if((1<=A&&A<=9)&&
    (1<=B&&B<=9)
    ){
        cout<<ans<<endl;
    }
    else{
        cout<<-1<<endl;
    }

return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;



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

    int res = INT_MAX;
    for (int i = -100; i < 101; i++) {
        int sum=0;
        for (int j = 0; j < n; j++) {
            sum+=(a[j]-i)*(a[j]-i);
        }
        res=min(res,sum);
    }
    cout<<res<<endl;

    return 0;
}

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

const int N = 1000 * 1000 + 5, mod = 998244353;

long long fac[N];

int po(int x, int y) {
	if (y == 0) {
		return 1;
	}
	long long ans = po(x, y / 2);
	ans *= ans;
	ans %= mod;
	if (y % 2) {
		ans *= x;
		ans %= mod;
	}
	return ans;
}

int chs(int x, int y) {
	if (y > x) {
		return 0;
	}
	long long ans = 1ll * fac[x] * po(fac[x - y], mod - 2);
	ans %= mod;
	ans *= po(fac[y], mod - 2);
	ans %= mod;
	return ans;
}

int main() {
	fac[0] = 1;
	for (int i = 1; i < N; i++) {
		fac[i] = fac[i - 1] * i;
		fac[i] %= mod;
	}
	int n, m;
	cin >> n >> m;
	long long ans = 0;
	for (int i = 1; i <= n && i <= m; i++) {
		long long x = 1ll * chs(i * 2, i) * chs(n + m - 2 * i, n - i);
		x %= mod;
		ans += x;
	}
	ans %= mod;
	ans *= po(chs(n + m, n) * 2, mod - 2);
	ans %= mod;
	ans += max(n, m);
	ans %= mod;
	cout << ans;
	
	return 0;
}


Measured memory_bytes: 11472
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;



signed main()
{
    int R0, W0, C, R;

    while (true) {
        cin >> R0 >> W0 >> C >> R;
        if (R0 == 0 && W0 == 0 && C == 0 && R == 0) break;

        if (1.0 * R0 / W0 >= C) {
            cout << 0 << endl;
        } else {
            cout << ceil(1.0 * (W0*C - R0) / R) << endl;
        }
    }
}

Measured memory_bytes: 3184
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end();
int main() {
  string a;
  cin >> a;
  int b = a.size();
  cout << a.at(0) << b-2 << a.at(b-1);
}

Measured memory_bytes: 3600
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 1000000007
#define mxval 1e9 + 7
#define grt [](auto x,auto y){return x>y;}
#define pii pair<int,int>
/*********VARIABLE****************/
using namespace std;
int i,j,n,m,k,l,q,t,a,b,sum[3],tot[3],cnt[3];
/*********FUNCTIONS**************/
int powom(int a,int b) {
    int result = 1;
    while (b > 0) {
        if (b & 1)
            result = result * a;
        a = a * a;
        b >>= 1;
    }
    return result;
}
/***********MAIN**************/
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cin>>n;
    vector<string> s(n);
    map<string,int> mp;
    for(auto &x : s){
        cin>>x;
        sort(all(x));
        mp[x]++;
    }
    int ans = 0;
    for(auto x : mp){
        ans+=(x._2*(x._2-1)/2);
    }
    cout<<ans;
    return 0;
}
//.........

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

int main()
{
    int D, T, S;
    cin >> D >> T >> S;

    if (S * T >= D){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;
typedef pair<ll,ll> pairs;
vector<pairs> p;


ll gcd(ll A,ll B){
    if (A%B==0)return(B);
    else return(gcd(B,A%B));
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

vector<vector<ll>> combination(ll n, ll r){
    vector<vector<ll>> v(n + 1, vector<ll>(n + 1, 0));
    for(ll i=0;i<v.size();++i){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(ll i=1;i<v.size();++i){
        for(ll j=0;j<i;++j){
            v[i][j] = (v[i - 1][j - 1] + v[i - 1][j]);
        }
    }
    return v;
}

bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

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

    ll flag = 0;
    for(ll i=0;i<s.size();++i){
        if(s[i] == 'x'){
            flag++;
        }
    }
    string ans = "NO";
    if(flag <= 7){
        ans = "YES";
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

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

fn main() {
    input!{
        n: usize
    }
    println!("{}", 3 * n * n);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  for(int i = 0 ; i < N+1 ; i++){
    if((int)(i * 1.08) == N){
      cout << i << endl;
      break;
    }else if(i == N){
      cout << ":(" << endl;
    }
  }
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <unordered_map>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

typedef pair<int, int> P;

int main(int argc, char** argv) {
  string s;
  cin >> s;

  // TODO(south37) Check the length of s;

  vector<string> results;
  string prv = s.substr(0, 1);
  results.push_back(prv);
  s = s.substr(1, s.size() - 1);

  while (s.size() != 0) {
    string cur = s.substr(0, 1);

    if (prv != cur) {
      prv = cur;
      s = s.substr(1, s.size() - 1);
      results.push_back(prv);
    } else { // Match
      // Take 2
      if (s.size() > 1) {
        prv = s.substr(0, 2);
        s = s.substr(2, s.size() - 2);
        results.push_back(prv);
      } else { // s.size() == 1
        break;  //
      }
    }
  }

  cout << results.size() << endl;
}


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

using namespace std;

typedef long long ll;

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

    ll n, a, b;
    cin >> n >> a >> b;

    cout << n / (a + b) * a + min(a, n % (a + b)) << endl;

    return 0;
}


Measured memory_bytes: 256
s = list(input())
t = list(input())

s.sort()
t.sort(reverse=True)

for i in range(min(len(s), len(t))):
    if s[i] < t[i]:
        print('Yes')
        break
    elif s[i] > t[i]:
        print('No')
        break
    if i == min(len(s), len(t)) - 1:
        if len(s) == len(t):
            print('No')
        elif min(len(s), len(t)) == len(s):
            print('Yes')
        else:
            print('No')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int x=0;
  if(s[0]=='R' && s[1]=='R' && s[2]=='R') x=3;
  else if(s[0]=='S' && s[1]=='R' &&s[2]=='R') x=2;
  else if(s[0]=='R' && s[1]=='R' && s[2]=='S') x=2;
  else if(s[0]=='R' && s[1]=='s' && s[2]=='R') x=1;
  else if(s[0]=='S' && s[1]=='S' && s[2]=='S') x=0;
  else x=1;
  cout<<x;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

int main() {
    int n;
    cin >> n;
    if(n<1000){
        cout << "ABC" << endl;
    }else{
        cout << "ABD" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*
* @author:  codancer
* @createTime:  time
*/
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
typedef vector<int> VI;
typedef pair<int,int> pii;
int main(){
	int n;
	cin>>n;
	set<int> st;
	VI a(n+1);
	for(int i=1;i<=n;i++){
		 cin>>a[i];
		 st.insert(a[i]);
	}
	cout<<(st.size()==n?"YES":"NO")<<endl;
	return 0;
}

Measured memory_bytes: 10368
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	slice := make([]int, n)

	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}

	length := 0
	up := 0
	down := 0

	for i := 1; i < len(slice); i++ {
		if slice[i-1] < slice[i] {
			up = 1
		} else if slice[i-1] > slice[i] {
			down = 1
		} else {
			// i++
			continue
		}

		if up == 1 && down == 1 {
			up = 0
			down = 0

			length++
		}

	}

	length++

	fmt.Println(length)

	// for i := 0; i < len(slice); i++ {
	// 	// tmp := slice[start:len(slice)]
	// 	// fmt.Println(slice)

	// 	for j := 1; j < len(slice)-1; j++ {
	// 		// fmt.Printf("i=%d, j=%d\n", i, j)
	// 		if j+1 < n && slice[i] <= slice[j] {
	// 			continue
	// 		}

	// 		if j+1 < n && slice[i] >= slice[j] {
	// 			length++
	// 			i += j
	// 			break
	// 		}

	// 		if j+1 < n && slice[i] > slice[j] && slice[j] > slice[j+1] {
	// 			continue
	// 		}

	// 		if j+1 < n && slice[i] < slice[j] && slice[j] > slice[j+1] {
	// 			length++
	// 			i += j
	// 			break
	// 		}

	// 		if j+1 < n && slice[i] == slice[j] && slice[j] == slice[j+1] {
	// 			continue
	// 		}

	// 	}
	// fmt.Println(length)

	// }

	// fmt.Println(length)

}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)



int main(){

  int flag=0;
  int dd;
  vector<vector<int> > c(3,vector<int>(3));
  rep(i,3)rep(j,3)cin>>c[i][j];
  dd = c[0][0];
  rep(i,3)rep(j,3)c[i][j]-=dd;
  if(c[1][1]==c[0][1]+c[1][0]){
    if(c[1][2]==c[1][0]+c[0][2]){
      if(c[2][1]==c[2][0]+c[0][1]){
        if(c[2][2]==c[2][0]+c[0][2]){
          cout<<"Yes"<<endl;
          flag=1;
        }
      }
    }
  }
  if(!flag)cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 305
#define maxm maxn*maxn
using namespace std;
int n,m,Q,L;
struct data{
	int s,x; data(){}
	data(int s,int x):s(s),x(x){}
	data operator + (int w){return w<=x?data(s,x-w):data(s+1,L-w);}
	bool operator < (const data &p)const{return s==p.s?x>p.x:s<p.s;}
}f[maxn][maxn];
int fir[maxn],nxt[maxm],to[maxm],w[maxm],tot;
inline void line(int x,int y,int z){nxt[++tot]=fir[x],fir[x]=tot,to[tot]=y,w[tot]=z;}
queue<int>q; bool inq[maxn];
inline bool chkmin(data &a,const data &b){return b<a?(a=b,1):0;}
void SPFA(int S,data *dis){
	for(int i=1;i<=n;i++) dis[i]=(data){n+1,0};
	dis[S]=(data){0,L},q.push(S);
	while(!q.empty()){
		int u=q.front(); q.pop(),inq[u]=0;
		for(int i=fir[u];i;i=nxt[i])
			if(chkmin(dis[to[i]],dis[u]+w[i])&&!inq[to[i]]) inq[to[i]]=1,q.push(to[i]);
	}
}
int main()
{
	//freopen("H.out","w",stdout);
	int x,y,z;
	scanf("%d%d%d",&n,&m,&L);
	for(int i=1;i<=m;i++) {scanf("%d%d%d",&x,&y,&z);if(z<=L) line(x,y,z),line(y,x,z);}
	for(int i=1;i<=n;i++) SPFA(i,f[i]);
	scanf("%d",&Q);
	while(Q--) scanf("%d%d",&x,&y),printf("%d\n",f[x][y].s>n?-1:f[x][y].s);
}

Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = int(1e9);
typedef long long int ll;
/* -- template -- */

int main(){
    int N, K; cin >> N >> K;
    int h[N];rep(i, N)cin >> h[i];
    int dp[N + 1];//dp[i] : 足場iに行くための最小コスト
    rep(i, N + 1)dp[i] = INF;
    dp[0] = 0;
    for(int i = 0;i < N - 1;++i){
        for(int k = 1;k <= K && i + k < N;++k){
            dp[i + k] = min(dp[i + k], dp[i] + abs(h[i] - h[i + k]));
        }
    }
    cout << dp[N - 1] << endl;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <bitset>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;
// const ll mod =  998244353 ;
const ll mod =  1000000007 ;
const ll inf = 1e18;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_REV(i, n) for (ll i = (n)-1; i >= 0; --i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

using Pair = pair<ll, ll>;

signed main() {
    ios::sync_with_stdio(false);
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    ll ans = inf;
    REP(i, max(x, y) + 1) {
        ll n = x, m  = y;
        ll tmp = c * i * 2;
        n -= i;
        m -= i;
        if(n > 0) tmp += a * n;
        if(m > 0) tmp += b * m;
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


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

int data[500005];
int cnt = 0;

void merge(int left,int mid,int right)
{
  int n2 = right - mid;
  int n1 = mid - left;
  int ar1[250005];
  int ar2[250005];
  Rep(i,n1) {		    
    ar1[i] = data[left + i];
  }
  Rep(i,n2) {
    ar2[i] = data[mid + i];
  }
  int i = 0, j = 0;
  ar1[n1] = INT_MAX;
  ar2[n2] = INT_MAX;
  for(int k = left; k < right;k++) {
    cnt++;
    if(ar1[i] < ar2[j]) {
      data[k] = ar1[i++];
    }else {
      data[k] = ar2[j++];
    }
  }
  return;
}

void merge_sort(int left,int right)
{
  if(right - left > 1) {
    int mid = left + (right - left) / 2;
    merge_sort(left,mid);
    merge_sort(mid,right);
    merge(left,mid,right);
  }
  return;
}


int main()
{
  int N;
  cin >> N;
  Rep(i,N)cin >> data[i];
  merge_sort(0,N);
  Rep(i,N - 1)cout << data[i] << " ";
  cout << data[N - 1] << endl << cnt << endl;
  return 0;
}

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

int main(){
   int N;
   cin >> N;
   string S, T;
   cin >> S >> T;

   string ST = "";
   for (int i=0; i<N; i++)
      ST = ST + S.at(i) + T.at(i);

   cout << ST << endl;
}



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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

int cnt[1000];
string s[1000];
signed main(){
    int h,w;
    cin >> h >> w;
    rep(i,h) cin >> s[i];
    rep(i,w+2) cout << '#';
    cout << '\n';
    rep(i,h) cout << '#' << s[i] << '#' << '\n';
    rep(i,w+2) cout << '#';
    cout << '\n';
    return 0;
}


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

#define ll long long

using namespace std;

int main(){
	
	int N,M;
	cin >> N >> M;
	
	vector<vector<ll>> vec = vector<vector<ll>>(N, vector<ll>(3,0)) ;
	
	for(int i=0; i<N; i++){
		for(int j=0; j<3; j++){
			cin >> vec.at(i).at(j);
		}
	}
	vector<ll> inst(N);
	
	ll res=0;
	ll S;
	for(int i=0; i<8; i++){
		int a=1,b=1,c=1;
		if(i<4)a=1;
		else a=-1;
		if((i%4)<2) b=1;
		else b=-1;
		if((i%2)<1) c=1;
		else c=-1;
		
		for(int j=0; j<N; j++){
			inst.at(j)= a*vec.at(j).at(0)+b*vec.at(j).at(1)+c*vec.at(j).at(2);
		}
		
		std::sort(inst.begin(),inst.end());
		
		S=0;
		
		for(int j=N-1; j>N-M-1; j--){
			S=inst.at(j)+S;
		}
		
		
		S=std::abs(S);
		if(S>res) res=S;
	}
	cout<< res << endl;
	
	
	
}


Measured memory_bytes: 256
s = input()
S = [int(x) for x in list(str(s))]

k = len(S)
tmp = 0
ans1 = 0
ans2 = 0
for i in range(k):
    if tmp != S[i]:
        ans1 += 1
    tmp = (tmp + 1) % 2

tmp = 1
for i in range(k):
    if tmp != S[i]:
        ans2 += 1
    tmp = (tmp + 1) % 2

print(min(ans1, ans2))


Measured memory_bytes: 4724
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

N, M = list(map(int, sys.stdin.readline().split()))
UV = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]
S, T = list(map(int, sys.stdin.readline().split()))

graph = [[] for _ in range(N + 1)]
for u, v in UV:
    graph[u].append(v)

que = deque()
que.append((S, 0))
reached = np.zeros((N + 1, 3), dtype=bool)
reached[S, 0] = True

while que:
    u, step = que.popleft()
    for v in graph[u]:
        s = step + 1
        if not reached[v, s % 3]:
            reached[v, s % 3] = True
            que.append((v, s))
        if v == T and s % 3 == 0:
            print(s // 3)
            exit()
print(-1)


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

using namespace std;

#define ll long long
#define MAX 1000005
#define MOD 1000000007
ll C[MAX];

ll bigMod(ll x, ll p)
{
    if(p == 0) return 1LL;
    if(p == 1) return x;
    ll ret = bigMod(x, p/2);
    ret = (ret*ret)%MOD;
    if(p & 1LL) ret = (ret*x)%MOD;
    return ret;
}

int main()
{
    ll x, y;
    scanf("%lld %lld", &x, &y);
    if((x+y)%3 != 0){
        cout << 0 << endl;
        return 0;
    }
    ll n = (x+y)/3;
    C[0] = 1LL;
    ll lob = 1, hor = 1;
    for(ll i=1; i<=n; i++){
        lob = (lob*(n-i+1))%MOD;
        hor = (hor*i)%MOD;
        C[i] = (lob*bigMod(hor, MOD-2))%MOD;
    }
    ll cnt1 = 0, cnt2 = 0;
    for(ll i=0; i<=n; i++){
        if(i*1 + (n-i)*2 != x) continue;
        cnt1 += C[i];
    }
    for(ll i=0; i<=n; i++){
        if(i*1 + (n-i)*2 != y) continue;
        cnt2 += C[i];
    }
    ll ans = (cnt1*cnt2)%MOD;
    cout << cnt1 << endl;
}

Measured memory_bytes: 6400