akhauriyash/Code-Regression huggingface dataset:
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>

#define INF 1e18
#define MOD 1000000007

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();

bool used[100010];
int main() {
    ios_base::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;

    int i = 1;
    int j = i+m;
    int cnt = m;
    while(j>i && cnt>0) {
        cout << i << " " << j << "\n";
        //assert(!used[j-i]);
        used[j-i] = true;
        i++;
        j--;
        cnt--;
    }

    i = 2+m;
    j = i+m-1;
    while(j>i && cnt>0) {
        cout << i << " " << j << "\n";
        //assert(!used[j-i]);
        used[j-i] = true;
        i++;
        j--;
        cnt--;
    }
}

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

namespace ConsoleApplication51
{
    class Program
    {
        static void Main()
        {
            int s = 0;
           for(int a = 0; a < 5; a++)
            {
                int b = int.Parse(Console.ReadLine());
                if (b < 40) s += 40;
                else s += b;
            }
            Console.WriteLine(s/5);
        }
    }
}

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

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

int main(){
  int n;
  cin >> n;
  
  vector<int> p(n);
  rep(i,n){
    cin>>p.at(i);
    p.at(i)--;
  }

  int count=0;
  rep(i,n){
    if(p.at(i)==i){
      if(i<n-1&&p.at(i+1)==i+1){count++; p.at(i+1)=i;}
      else count++;
    }
  }
  cout << count;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
char s[1000005];
int a[1000005],t[1000005];
int main()
{
	int n;
	cin>>n>>s;
	for(int i=0;s[i];i++)
	{
		if(s[i]=='o')
			t[i+1]=0;
		else
			t[i+1]=1;
	}
	t[n+1]=t[1];
	for(int i=0;i<8;i++)
	{
		a[0]=i&1;
		a[1]=(i>>1)&1;
		a[2]=(i>>2)&1;
		for(int j=2;j<=n+1;j++)
			a[j+1]=a[j-2]^t[j];
		if(a[0]^a[n]^a[1]^a[n+1]||a[1]^a[n+1]^a[2]^a[n+2])
			continue;
		for(int j=1;j<=n;j++)
		{
			if(a[j]^a[j-1])
				cout<<'W';
			else
				cout<<'S';
		}
		return 0;
	}
	cout<<"-1";

	return 0;
}

Measured memory_bytes: 6912
#include<stdio.h>
#define MAX_n 20
#define MAX_q 200
#define true 1
#define false 0

int A[MAX_n];
int M[MAX_q];
int n;
int q;

int solve(int i,int m){
  if(m==0)return true;
  if(i>=n)return false;

  if(solve(i+1,m)==false && solve(i+1,m-A[i])==false)return false;
  
  else return true;
}

int main(){
  int i;
  int res;
  
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&M[i]);
    if(solve(0,M[i])==true)printf("yes\n");
    else printf("no\n");
  }

  return 0;
}




Measured memory_bytes: 2104
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int[] mountains;
	public static void main(String[] args) {
		while(read()){
			solve();
		}
	}
	
	static boolean read(){
		if(!sc.hasNext())return false;
		mountains = new int[10];
		for(int i = 0; i < 10; i++){
			mountains[i] = sc.nextInt();
		}
		return true;
	}
	
	static void solve(){
		//Arrays.sort(mountains);
		for(int i = 0; i < 10; i++){
			for(int j = i; j < 10; j++){
				if(mountains[j] < mountains[i]){
					int swap = mountains[i];
					mountains[i] = mountains[j];
					mountains[j] = swap;
				}
			}
		}
		System.out.println(mountains[9]);
		System.out.println(mountains[8]);
		System.out.println(mountains[7]);
	}

}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define ll long long
#define F(type, i, a, b) for(type i = a; i <= b; i ++)
#define RF(type, i, a, b) for(type i = a; i >= b;i --)
#define sz(a) sizeof(a)
#define deb(a) cerr<<" ["<<#a<<"->"<<a<<"] "
#define next_line cerr<<'\n'
#define all(a) a.begin(), a.end()
#define iter(it, s) for(auto it = s.begin(); it != s.end(); it ++)

using namespace std;

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

template <typename T>
void tk_input(vector<T> &arr){
    for(T &i: arr)
        cin>>i;
}

const ll max_s = 2e3 + 1LL;
ll Fact[max_s], InvOfFact[max_s], mod = 1e9 + 7LL;

ll bin_exp(ll x, ll pw){
    ll res = 1LL;
    while(pw){
        if(pw & 1LL){
            res *= x;
            res %= mod;
        }
        x *= x;
        x %= mod;
        pw >>= 1;
    }
    return res;
}

void preprocess(){
    Fact[0] = 1LL;
    InvOfFact[0] = 1LL;
    F(ll, i, 1, max_s - 1){
        Fact[i] = (Fact[i - 1] * i) % mod;
        InvOfFact[i] = (InvOfFact[i - 1] * bin_exp(i, mod - 2LL)) % mod;
    }
}

ll ncr(ll n, ll r){
    if(n < r){
        return 0LL;
    }
    return ((Fact[n] * InvOfFact[n - r]) % mod * InvOfFact[r]) % mod; 
}

//1.Check for overflows and don't panic
//
//2.If you cannot think of a solution, try 
//  to think from backwards
void solve()
{
    int s;
    cin>>s;
    preprocess();
    int lim = (s / 3);
    ll ans = 0LL;
    F(int, i, 1, lim){
        ans += ncr((s - (3 * i)) + i - 1, (s - (3 * i)));
        ans %= mod;
    }
    cout<<ans<<'\n';
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        freopen("Debug.txt", "w", stderr);
    #else
    #endif
        solve();
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;

template<class T>bool chmax(T &a, const T &b) { if( a < b ) { a = b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) { if( b < a ) { a = b; return 1; } return 0;}

#ifdef LOCAL
	#define eprintf(...) printf(__VA_ARGS__)
#else 
	#define eprintf(...) 1
#endif

#define ROUNDUP(a, b) 		( ((a) + ((b) - 1) ) / b)
#define SET_ZERO(a)	 		( memset((a), 0, sizeof(a)))
#define SET_NUM_ARRAY(a,b)	( memset((a), b, sizeof(a)))
//#define int long long int //dont forget to change int to signed

int main() {
	char S[5];
	scanf("%s", S);

	int ans = 0;
	for (int i = 0; i < 4; i++) {
		if (S[i] == '+') ans++;
		else ans--;
	}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define range(i,l,h) for(int i=l;i<h;i++)
#define endl '\n'
#define I INT_MAX
#define L INT_MIN
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vi vector<int>
using namespace std;
using std::ios;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;

int main()
{
  fastio; 
  cout<<fixed<<setprecision(7);
  int n;
  cin>>n;
  vector<double> a(n);
  range(i,0,n)cin>>a[i];
  sort(all(a));
  double ans=0;
  ans=(a[0]+a[1])/2;
  for(int i=2;i<n;i++)
  {
    ans=(ans+a[i])/2;
  }
  cout<<ans;

}


Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll k1= a*c;
  ll k2 = a*d;
  ll k3 = b*c;
  ll k4 = b*d;
  cout<<max(k1,max(k2, max(k3,k4)))<<endl;
  return 0;
}

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

int main() {
  int N, Y, a, b, c, d, e, f; 
  cin >>N;
  f = 0;
  b = 10000;
  bool finished = false;
  for (int j=0; j<N; j++) {
    cin >>Y;
    a = 0;
     for(int i=0; i<10000; i++) {
       if (Y%2==0){
         a = a+1;
         Y = Y/2;
       }
       else {
         break;
       }
     }
    if(a<=b) {
      b = a;
    }
    else{
    continue;
    }
    }
  cout << b <<endl;
}


Measured memory_bytes: 256
line = input()
n, q = list(map(int, line.split()))
N = 1
while N < n + 1:
    N *= 2
a = [0 for _ in range(0, 2 * N - 1)]

def update(k, v):
    k += N - 1
    a[k] += v
    while k > 0:
        k = (k - 1) // 2
        a[k] = a[k * 2 + 1] + a[k * 2 + 2]

def query(x, y, k, l, r):
    if r <= x or y <= l:
        return 0
    elif x <= l and r <= y:
        return a[k]
    m = (l + r) // 2
    return query(x, y, k * 2 + 1, l, m) + query(x, y, k * 2 + 2, m, r)

for _ in range(0, q):
    line = input()
    c, x, y = list(map(int, line.split()))
    if c == 0:
        update(x, y)
    elif c == 1:
        ans = query(x, y + 1, 0, 0, N)
        print(ans)


Measured memory_bytes: 10848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	string s;
	getline(cin,s);
	int n = s.size();
	for(int i =0;i<n;i++)
	{
		if(0x41<=s[i]&&s[i]<=0x5a)s[i] += 32;
		else if(0x61<=s[i]&&s[i]<=0x7a) s[i]-=32;
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 3140
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

int main(){
    ll n,m ;cin >> n >> m;
    ll ans = n;
    if (n >= m/2){
        cout << m/2 << endl;
    }else{
        cout << n + (m - 2*n)/4 << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	long long n,sum,min,max;
	int i;
	cin>>n;
	int a[n];
	for(i=0; i<n; i++){
		cin>>a[i];
	}
	min=a[0];
	max=a[0];
	sum=a[0];
	for(i=1; i<n; i++){
		if(a[i]<min){
			min=a[i];
		}
		if(a[i]>max){
			max=a[i];
		}
		sum+=a[i];
	}
	cout<<min<<" "<<max<<" "<<sum<<"\n";
	return 0;
}


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

int main(){
	int n,k;
	int r,s,p;
	string t;
	
	cin >> n >> k;
	cin >> r >> s >> p;
	cin >> t;
	
	int res = 0;
	
	for(int i=0;i<t.size();++i){
		int point = 0;
		if(t[i] == 'r'){
			point = p;
//			cout << "pa-" <<endl;
		}
		if(t[i] == 's'){
			point = r;
//			cout << "rock-" <<endl;
		}
		if(t[i] == 'p'){
			point = s;
//			cout << "choki" <<endl;
		}
		if(i-k < 0 || t[i-k] != t[i]){
			res += point;
			//cout << i << " " << point <<endl;
		}
		if(i-k >= 0 && t[i-k] == t[i]){
			t[i] = ' ';
		}
	}
	
	cout << res <<endl;
	
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>*/
 
#define pb push_back
#define mp make_pair
#define sz(s) ((int)(s.size()))
#define all(s) s.begin(), s.end()
#define rep(i, a, n) for (int i = a; i <= n; ++i)
#define per(i, n, a) for (int i = n; i >= a; --i)
#define onlycin ios_base::sync_with_stdio(false); cin.tie(0) 
using namespace std;
// using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
/*typedef tree<
pair < int, int >,
null_type,
less< pair < int, int > >,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;*/
// find_by_order() order_of_key()
const int MAXN = (int)5e5+228;
const char nxtl = '\n';
const int mod = (int)1e9+7;
const double eps = (double)1e-7;
template<typename T> inline bool updmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
template<typename T> inline bool updmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}

int n, pref[MAXN];
inline bool prime(int x) {
	for(int i = 2; i * 1ll * i <= x; ++i)
		if(x % i == 0) return 0;
	return 1;
}

int main() {
	#ifdef accepted
		freopen(".in", "r", stdin);
		freopen(".out", "w", stdout);
	#endif
	onlycin;
	rep(i, 3, (int)1e5) pref[i] = (prime(i) && prime((i + 1) / 2)) + pref[i - 1];
	cin >> n;
	rep(i, 1, n) {
		int l, r; cin >> l >> r;
		cout << pref[r] - pref[l - 1] << nxtl;
	}
	
	return 0;
}

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

struct edge {
    int from, to;
    string w;
};

using edges = vector<edge>;

const string INF = "NO";

string solve(edges const& es, int s, int t, const int V) {
    vector<string> d(V, INF);
    d[t] = "";
    for(int i=0; i<V*7; ++i) {
        vector<string> tmp = d;
        for(auto& e : es) {
            if(tmp[e.to] != INF && (tmp[e.from] == INF || tmp[e.from] > e.w + tmp[e.to])) {
                tmp[e.from] = e.w + tmp[e.to];
                
                if(i >= V && e.from == s) {
                    return "NO";
                }
            }
        }
        d.swap(tmp);
    }
    return d[s];
}

int main() {
    int n, a, s, g;
    while(cin >> n >> a >> s >> g, n) {
        edges es(a);
        for(int i=0; i<a; ++i) {
            cin >> es[i].from >> es[i].to >> es[i].w;
        }
        cout << solve(es, s, g, n) << endl;
    }
}

Measured memory_bytes: 3888
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<cctype>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<vector>
#include<ctime>
#include<climits>

using std::cout;
using std::endl;
using std::cin;
using std::sort;
using std::queue;
using std::stack;
using std::set;
using std::vector;
using std::string;
using std::priority_queue;
using std::deque;
using std::pair;
using std::fill;
using std::lower_bound;
using std::upper_bound;




int main(int argc, char** argv)
{
	if (argc == 2 && strcmp(argv[1], "-debug") == 0)
	{
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}

	int n;
	cin >> n;
	int x, y, t;
	x = y = t = 0;
	bool ans = true;
	for (int i = 0; i < n; i++)
	{
		int t1;
		int x1, y1;
		cin >> t1 >> x1 >> y1;
		int dif = abs(x1 - x) + abs(y1 - y);
		int dift = t1-t;
		if (dif > dift || (dift - dif) % 2 != 0)
			ans = false;
		t = t1;
		x = x1;
		y = y1;
	}
	if (ans)
		cout << "Yes";
	else
		cout << "No";


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int cd=s.length();
	int c=0,f=0,flag=0,x,y;
	for(int i=0;i<cd;i++)
	{
		if(s[i]=='C')
		{
			x=i;
			for(int j=x+1;j<cd;j++)
			{
				if(s[j]=='F')
				{
					cout<<"Yes"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"

	"os"
	"io"
	"bufio"
	"bytes"

	"strings"
	"strconv"
)

//  長い入力を読む
func ReadLongLines(times int) ([]string, error) {
	result := make([]string, times)
	reader := bufio.NewReader(os.Stdin)
	buffer := bytes.NewBuffer(make([]byte, 0))
	readBytes := int64(2)
	for i := 0; i < times; i++ {
		for {
			readBuf, isPrefix, err := reader.ReadLine()
			// fmt.Printf("Reader.Read: %d\n", len(readBuf))
			readBytes += int64(len(readBuf) + 1)
			if err != nil {
				if err == io.EOF {
					fmt.Println("EOF")
					break
				} else {
					return result, err
				}
			}
			_, err = buffer.Write(readBuf)
			if err != nil {
				return result, err
			}
			// end of line
			if !isPrefix {
				result[i] = buffer.String()
				buffer.Reset()
				// reader = bufio.NewReader(os.Stdin)
				break
			}
		}
	}
	// 先読みしてしまうようなので、戻しておく
	os.Stdin.Seek(-int64(reader.Buffered()), os.SEEK_CUR)
	return result, nil
}

// 出力 for 競プロ
type Console struct {
	writer *bufio.Writer
}
func NewConsole() Console {
	return Console{ bufio.NewWriter(os.Stdout) }
}
func (this *Console) Printf(format string, a ...interface{}) {
	fmt.Fprintf(this.writer, format, a...)
}
func (this *Console) Println(s string) {
	fmt.Fprintln(this.writer, s)
}
func (this *Console) Close() {
	this.Flush()
}
func (this Console) Flush() {
	this.writer.Flush()
}

func CreateList(n int, input string) []int {
	list := make([]int, n)
	elements := strings.Split(input, " ")
	for i := 0; i < n; i++ {
		list[i], _ = strconv.Atoi(elements[i])
	}
	return list
}


func Reverse(list *[]int, begin int , end int) {
	for i := 0; i < (end - begin) / 2; i++ {
		// fmt.Printf("swap %d <-> %d\n", (*list)[begin + i], (*list)[end -1 -i])
		(*list)[begin + i], (*list)[end -1 -i] = (*list)[end -1 -i], (*list)[begin + i]
	}
	// fmt.Println(*list)
}

func main() {
	con := NewConsole()
	defer con.Flush()

	// create list
	var n int
	fmt.Scanf("%d", &n)
	lines, _ := ReadLongLines(1)
	list := CreateList(n, lines[0])

	// query
	var q int
	fmt.Scanf("%d", &q)
	lines, _ = ReadLongLines(q)
	for _, v := range lines {
		args := strings.Split(v, " ")
		begin, _ := strconv.Atoi(args[0])
		end, _ := strconv.Atoi(args[1])
		Reverse(&list, begin, end)
	}
	for i := 0; i < len(list); i++ {
		if i == 0 {
			con.Printf("%d", list[i])
		} else {
			con.Printf(" %d", list[i])
		}
	}
	con.Println("")
}


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

int main(){
  int n,tp=0,hp=0,judge;
  char taro[1000],hanako[1000];

  cin>>n;
  for(int i=0; i<n; i++){
    cin>>taro>>hanako;
    judge = strcmp(taro,hanako);
    if(judge < 0){
      hp += 3;
    }else if(judge > 0){
      tp += 3; 
    }else{
      hp ++;
      tp ++;
    }
  }
  cout<<tp<<" "<<hp<<endl;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h> 
using namespace std; 
int n;
double arr[3005] , dp[3005][3005];
bool vis[3005][3005];
double solve(int idx , int heads){
	if(idx == n){
		if(heads > n - heads)
			return 1;
		return 0;
	}
	if(vis[idx][heads])return dp[idx][heads];
	vis[idx][heads] = true;
	double rr = solve(idx + 1 , heads + 1) * arr[idx];
	rr += solve(idx + 1 , heads) * (1 - arr[idx]);
	return dp[idx][heads] = rr;
}
int main(){
	cin>>n;
	for(int i = 0; i < n ; i++)
		cin>>arr[i];
	cout<<fixed<<setprecision(10)<<solve(0,0);
	return 0;
}  


Measured memory_bytes: 79744
#include<iostream>
#include<bits/stdc++.h>
#include<climits>
#include<math.h>

#define forn(x,n,s) for(int i = x; i < n; i += s )
#define forr(x,n,s) for(int i = x; i>=n; i -= s)
#define PI 3.14159265358979323846264338327950L
#define MOD 1e9+7

using namespace std;

void go(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  #ifndef ONLINE_JUDGE
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
  #endif
} 
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}

int main(){
    go(); 

    // code here
    int k;cin>>k;
    long long ans = 0;  
    for(int i = 1;i <=k; i++){
        for(int j = 1; j <=k ;j++){
            int cal = gcd(i,j);
            for(int l = 1; l <=k ;l++){
                ans += gcd(cal,l);
            }
        }
    }
    cout<<ans;

} 



Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i, a, n) for ( i = a; i < (n); i++)
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define x first
#define y second
#define mp make_pair
#define pb push_back
using namespace std;

int main(){
	fast;
	ll i,j,k,tc,q,n,flag;	
	cin>>n>>k;
	vector<ll> a(n),dp(n+1,0);
	rep(i,0,n){
		cin>>a[i];
	}


	dp[1]=abs(a[1]-a[0]);
	rep(i,2,n){
		dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
		for(j=i-2;j>=0 && i-j-1<k ;j-- )
			dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
	}

	// for(auto i : dp)
	// 	cout<<i<<" ";
	// cout<<endl;

	cout<<dp[n-1]<<endl;


	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
using namespace std;
int main(){
  int k;
  cin>>k;
  string s,S;
  cin>>s;
  if(s.length()<=k)
    cout<<s;
  else{
    for(int i=0;i<k;i++){
    	cout<<s[i];
	}
  cout<<"...";
}
}
  

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

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

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  string s;
  cin >> s;
  s[3] = '8';
  cout << s << endl;
}






Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
    int a,sum = 0;
    rep(i,0,4){
        cin >> a;
        sum += a;
    }
    
    cout << sum/60 << endl << sum%60 << endl;
    
    
    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve(){
    ll X, Y;
    cin >> X >> Y;
    ll ans = 0;
    ll tmp = X;
    while (tmp <= Y){
        tmp = tmp * 2;
        ans++;
    }
    cout << ans << endl;
}
int main(void){
    //////////////////////////

    solve();

    //////////////////////////
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

i64 n;
i64 a;
i64 b;

int main(){
	cin >> n >> a >> b;
	if(a * b < n || a + b - 1 > n){
		cout << -1 << endl;
		return 0;
	}
	vector<int> ans;
	int cou = 0;
	n -= a;
	for(int i = 0;i < a;i++){
		if(cou + b - 1 <= n){
			for(int j = 0;j < b;j++){
				ans.push_back(cou + b - j + i);
			} cou += b - 1;
		}
		else
		{
			for(int j = 0;j <= n - cou;j++){
				ans.push_back(n - j + i + 1);
			}
			cou = n;
		}

	}
	if(ans.size() < n + a){
		 cout << -1 << endl;
	}
	else{
		for(int a : ans){
			cout << a << " ";
		}
		cout << endl;
	}
}


Measured memory_bytes: 3440
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define all(a)  (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int main(){
  int n,k; cin >> n >> k;
  vi x(n); rep(i, n) cin >> x[i];
  int ans = 1e9;
  for (int i = 0; i < n-k+1; i++) {
    chmin(ans,abs(x[i]) + x[i+k-1] - x[i]);
    chmin(ans,abs(x[i+k-1]) + x[i+k-1] - x[i]);
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define len(str) (int)(str.length())
int main() {
	int N;
	cin >> N;

	for (int a = 0; a < N; a++)
	{
		string X, Y;
		cin >> X >> Y;
		vector<vector<int> > dp(len(X) + 1, vector<int>(len(Y) + 1, 0));
		for (int a = 1; a <= len(X); a++)
		{
			for (int b = 1; b <= len(Y); b++)
			{
				if (X[a - 1] == Y[b - 1]) {
					dp[a][b] = dp[a - 1][b - 1] + 1;
				}
				else {
					dp[a][b] = max(dp[a - 1][b], dp[a][b - 1]);
				}
			}
		}
		cout << dp[len(X)][len(Y)] << endl;
	}
}


Measured memory_bytes: 6848
import math
import numpy as np
from operator import mul

# 整数Nを桁ごとのリストにする
# l = [int(x) for x in list(str(N))]

# リストliから重複を削除したリストli_uniqを作成
#li_uniq = []
#for i in li:
#    if x not in li_uniq:
#        li_uniq.append(x)

# 複数行のinput - list版
#list = [list(map(int, input().split())) for i in range(N)]
# 複数行のinput - dictionary版
# key = a, value = b
#for i in range(N):
#    a, b = map(int, input().split())
#    dict[a] = b


tmp = [list(map(int, input().split())) for i in range(3)]
C = np.array(tmp)
a = 0

div = C[0] - C[1]
if div[0] == div[1] and div[0] == div[2]:
    a += 1
    
div = C[1] - C[2]
if div[0] == div[1] and div[0] == div[2]:
    a += 1

div = C[0] - C[2]
if div[0] == div[1] and div[0] == div[2]:
    a += 1

C.T

div = C[0] - C[1]
if div[0] == div[1] and div[0] == div[2]:
    a += 1
    
div = C[1] - C[2]
if div[0] == div[1] and div[0] == div[2]:
    a += 1

div = C[0] - C[2]
if div[0] == div[1] and div[0] == div[2]:
    a += 1

if a == 6:
    print("Yes")
else:
    print("No")

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


def main():
    N = int(input())
    H = [set() for _ in range(N)]
    U = [set() for _ in range(N)]
    for i in range(N):
        m = int(input())
        for j in range(m):
            x, y = map(int, input().split())
            if y == 1:
                H[i].add(x)
            else:
                U[i].add(x)

    ans = 0
    for i in range(1 << N):
#        print('bin: {:015b}'.format(i))
        h = set()
        u = set()
        for j in range(N):
            if ((i >> j) & 1) == 1:
                h.add(j+1)
            else:
                u.add(j+1)
        b = True
        for j in range(N):
            if ((i >> j) & 1) == 1:
                if H[j] & u:
                    b = False
                    break
                else:
                    h |= H[j]
                if U[j] & h:
                    b = False
                    break
                else:
                    u |= U[j]
        if b:
            ans = max(ans, bin(i).count("1"))
    print(ans)


if __name__ == '__main__':
    main()


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

int make_c(int a, int b, int n){
    int i;
    int c = 0;
    for (i=1;i<=n;i++){
        int copy_i = i;
        int top, bottom;
        bottom = i % 10;
        if (bottom == b){
            while(copy_i>0){
                top = copy_i;
                copy_i /= 10;
            }
            if (top == a){
                c++;
            }
        }
    }
    return c;
}

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

    int i, j;
    int c[9][9];
    for (i=1;i<10;i++){
        for (j=1;j<10;j++){
            c[i-1][j-1] = make_c(i, j, n);
            // cout << c[i-1][j-1] << " ";
        }
        // cout << endl;
    }

    int count = 0;
    for (i=1;i<10;i++){
        for (j=1;j<10;j++){
            count += c[i-1][j-1] * c[j-1][i-1];
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;//例: VVI dp(10, vector<int>(10, INF);
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const int INF = 2 * pow(10, 9) + 1;//+1しないとREになるかも(out of rangeになるんかな?? )

vector<int> dx = { -1, 0, 1, 0, -1, -1, 1, 1 };
vector<int> dy = { 0, -1, 0, 1, -1, 1, -1, 1 };

ll max(ll a, ll b) { return (a > b) ? a : b; }
ll min(ll a, ll b) { return (a < b) ? a : b; }

int main(void) {
	int N, W;
	cin >> N >> W;
	vector<ll> w(N + 1), v(N + 1);
	for (int i = 1; i <= N; i++) cin >> w[i] >> v[i];

	/*for (int i = 1; i <= N; i++) {
		cout << "w[" << i << "]: " << w[i] << " v[" << i << "]: " << v[i] << endl;
	}*/

	const ll V_MAX = N * 1000;
	//dp[i][j]: 0～i番目の品物があるとき，価値jになるように入れた時の最小重さ
	vector<vector<ll>> dp(N + 1, vector<ll>(V_MAX+1, INF));
	dp[0][0] = 0;//これ入れないとdpがすべてINFになる
	/*for (int j = 0; j <= V_MAX; j++) {//これ入れたらdpはすべて0になってしまう．
		dp[0][j] = 0;
	}*/
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= V_MAX; j++) {//0からスタート!!(0からじゃないと答えは違ってくるよ)
			if (j - v[i] < 0) dp[i][j] = dp[i - 1][j];
			else dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i]);
		}
	}

	/*for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= V_MAX; j++) {
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}*/

	ll ans = 0;
	for (int j = 0; j <= V_MAX; j++) {
		if (dp[N][j] <= W) ans = j;
		//cout << "dp[" << N << "][" << j << "]: " << dp[N][j] << endl;
	}


	cout << ans << endl;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
#include <stdlib.h>
#include <numeric>
#include <math.h>
using namespace std;
int main(){
  	char a[6];
    
    int count=0, i;
    for(i=0; i<6; i++){
      cin>>a[i];
    }
    for (i = 0; i < 3; i++)
    {
      if (a[i]==a[i+3])
      {
        count++;
      }
      
    }
    
		


    cout<<count<<endl;
    
     


}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        int N, K; {int[] a = in.ii(2); N = a[0]; K = a[1];}
        int[] p = in.ii(N);
        int[] sum = new int[N + 1];
        for(int i = 0; i < N; i++){
            sum[i + 1] = sum[i] + p[i];
        }

        int ans = 0;
        for(int i = 0, M = N - K + 1; i < M; i++){
            ans = Math.max(sum[i + K] - sum[i] + K, ans);
        }
        out.println(ans / 2.0);
    }


    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        int[] ii(final int N) {
            int[] a = new int[N];
            int i = 0;
            String s = s();
            for (int j = 0; j < a.length; j++) {
                boolean minus = s.charAt(i) == '-';
                i += minus ? 1 : 0;

                int k = 0;
                while (true) {
                    try {
                        int h = s.charAt(i++) - '0';
                        if (h < 0 || 9 < h) {
                            break;
                        }
                        k = 10 * k + h;
                    } catch (Exception e) {
                        break;
                    }
                }
                a[j] = minus ? -k : k;
            }
            return a;
        }
    }
}


Measured memory_bytes: 40508
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int i,t,h[10];
	for(i=0;i<10;)cin>>t,h[i++]=-t;
	sort(h,h+10);
	for(i=0;i<3;)cout<<-h[i++]<<endl;
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
#include <algorithm>
#include <cctype>

using namespace std;

int main(){
	int n;
	cin >> n;
	int a = n%10;
	if(a == 3){
		cout << "bon" << endl;
	}else if(a == 0||a == 1||a == 6||a == 8){
		cout << "pon" << endl;
	}else{
		cout << "hon" << endl;
	}
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
int main()
{
    int N;
    std::cin >> N;
    int tmp;
    std::cin >> tmp;
    int cnt = 1;
    for (int i = 2; i <= N; i++)
    {
        int x;
        std::cin >> x;
        if (x <= tmp)
            cnt++;
        tmp = std::min(tmp, x);
    }
    std::cout << cnt <<'\n';
}

Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())

ans = 0

# まずABを買う
ab = min(A + B, C*2)
buy = min(X, Y)
ans += ab * buy

X -= buy
Y -= buy

# 残りを買う
ans += min(A, 2 * C) * X
ans += min(B, 2 * C) * Y


print(ans)


Measured memory_bytes: 3060
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	cin >> N;
	vector<int>v(N + 1);
	for (int i = 1; i <= N; i++) {
		cin >> v[i];
	}
	M = -1;
	K = -1;
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	for (int i = 0; i <= N; i++) {
		if (M==-1&&v[i] <= i) {
			M = i - 1;
		}
		if (K==-1&&M >= v[i]) {
			K = i;
		}
	}
	//cout << M << " " << K << endl;
	if ((v[M] - M) % 2 && (K - M) % 2) {
		cout << "Second\n";
	}
	else {
		cout << "First\n";
	}
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>

int main()
{
    std::string in;
    std::cin >> in;

    bool existA = false;
    bool existB = false;
    for (const auto& ch : in)
    {
        if (ch == 'A')
        {
            existA = true;
        }
        else if (ch == 'B')
        {
            existB = true;
        }
    }

    if (existA && existB)
    {
        std::cout << "Yes";
    }
    else
    {
        std::cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())
x = tx - sx
y = ty - sy
print("R" * x + "U" * y + "L" * x + "D" * (y+1) + "R" * (x + 1) + "U" * (y + 1) + "L" + "U" + "L" * (x + 1) + "D" * (y + 1) + "R")

Measured memory_bytes: 3060
n = gets.to_i
s=gets.chomp
t=gets.chomp

for i in 0..(n-1)
    ok = true
    for j in i..(n-1)
        if s[j] != t[j-i]
            ok = false
            break
        end
    end
    if ok
        p n + i
        exit 0
    end
end
p n + n


Measured memory_bytes: 1788
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using namespace std;

const long long MOD = 1000000007;

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for(int n = 1; n<=N; n+=2){
    int count = 0;
    for(int nn = 1; nn<=n; nn++){
      if (n%nn == 0) count += 1;
    }
    if (count == 8) ans += 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import scala.io.StdIn._
object Main extends App {
  val nums = readLine().split(' ').map{_.toInt}
  (nums(0), nums(1)) match {
    case  (a: Int, b: Int) if a > b => println("a > b")
    case  (a: Int, b: Int) if a < b => println("a < b")
    case  (a: Int, b: Int) if a == b => println("a == b")
  }
}

Measured memory_bytes: 43796
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	X := nextInt()
	var n int
	// 一応、値決め打ちでなくてちゃんと計算させた場合
	for i := 0; i*i*i*i*i-(i-1)*(i-1)*(i-1)*(i-1)*(i-1) < 1e9; i++ {
		n = i + 1
	}
	for i := 0; i <= n; i++ {
		for j := 0; j <= i; j++ {
			if i*i*i*i*i-j*j*j*j*j == X {
				fmt.Println(i, j)
				return
			} else if i*i*i*i*i+j*j*j*j*j == X {
				fmt.Println(i, -j)
				return
			}
		}
	}
}

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


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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

 int main(){
 
 int H, W;
 cin >> H >> W;

 vector<string>a(H);
 REP(i, H) cin >> a.at(i);


 vector<bool> h_flag(H, false), w_flag(W,false);
 REP(i, H)REP(j, W){ 
     if(a.at(i).at(j) == '#') {
         h_flag.at(i) = true;
         w_flag.at(j) = true;
    }
 }
REP(i, H){
    if(h_flag.at(i)) {
        REP(j, W){
            if(w_flag.at(j)) {
                cout << a.at(i).at(j);
            }
            if(j == W - 1) cout << endl;
    }
    }
}
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string s,v;
    cin >> s >> v;
    if(s.at(0) == v.at(2) && s.at(1) == v.at(1) && s.at(2) == v.at(0)){
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;

}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>

typedef unsigned long long int ull;
typedef long long int ll;

#define deb(x) cout << "Value - " << x << "\n"; 

using namespace std;

// Class Starts Here



// Class Ends Here

// Functions Starts Here

void prime()
{
    
}

// Functions Ends Here

int main()
{
    // *********************
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // *********************
    
    // Driver Function Starts Here

    int n;
    cin >> n;
    if (n == 1)
    cout << 0 << "\n";
    else cout << 1 << "\n";

    // Driver Function Ends Here
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef struct node
{
    char str[2];
    int id;
} point;
point __point[4005];
int dp[2005][2005];
int bl[2005][2005];
int wl[2005][2005];
int idb[2005],idw[2005];
int main(void)
{
    int n;
    cin>>n;
    for(int i = 1; i <= 2*n; i++)
        scanf("%s %d",__point[i].str,&__point[i].id);
    int t1 = 1,t2 = 1;
    for(int i = 1; i <= 2*n; i++)
    {
        if(__point[i].str[0] == 'W')
            idw[__point[i].id] = i;
        else idb[__point[i].id] = i;
    }
    memset(dp,0x3f,sizeof(dp));
    memset(bl,0,sizeof(bl));
    memset(wl,0,sizeof(wl));
    for(int i = 1; i <= n; i++)
    {   int a = 0,b = 0;
        for(int j = 1;j < i;j++)
            if(idw[i] < idw[j])a++;
        for(int j = 0; j <= n; j++)
        {
            if(idb[j] > idw[i]&&j!=0)
               b++;
            wl[i][j] = a + b;
        }
    }
    for(int j = 1; j <= n; j++)
    {   int a = 0,b = 0;
        for(int i = 1;i < j;i++)
            if(idb[i] > idb[j])a++;
        for(int i = 0; i <= n; i++)
        {
            if(idb[j] < idw[i]&&i!=0)
               b++;
            bl[i][j] = a + b;
        }
    }
    dp[0][0] = 0;
    for(int i = 0; i <= n; i++)
    {
        for(int j = 0; j <= n; j++)
        {
            if(i + 1 <= n)
            dp[i+1][j] = min(dp[i+1][j],dp[i][j] + wl[i+1][j]);
            if(j + 1 <= n)
            dp[i][j+1] = min(dp[i][j+1],dp[i][j] + bl[i][j+1]);
        }
    }
    printf("%d\n",dp[n][n]);
    return  0;
}


Measured memory_bytes: 47360
import sys
from heapq import heappop, heappush
input = sys.stdin.readline

def main():
    n = int(input())
    a = [list(map(int,input().split())) for _ in range(n)]
    g = [[] for _ in range(n)]
    for i in range(n-1):
        for j in range(i+1,n):
            g[i].append((j,a[i][j]))
            g[j].append((i,a[i][j]))
    ans = 0
    for i in range(n):
        ans += sum(a[i])
    ans //= 2
    w = []
    for i in range(n):
        que = []
        d = [10**15 for _ in range(n)]
        d[i] = 0
        heappush( que,(0,i) )
        while que:
            p =  heappop(que)
            v = p[1]
            if d[v] < p[0]:
                continue
            for k in range(len(g[v])):
                edge = g[v][k]
                if d[edge[0]] > d[v] + edge[1]:
                    d[edge[0]] = d[v] + edge[1]
                    heappush( que,(d[edge[0]] , edge[0]) )
        w.append(d)
    for i in range(n-1):
        for j in range(i+1,n):
            if w[i][j] < a[i][j]:
                print(-1)
                return
            flag = 0
            for k in range(n):
                if i == k or j == k:
                    continue
                if w[i][k] + w[k][j] == w[i][j]:
                    flag = 1
            if flag:
                ans -= w[i][j]
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 58972
import copy
n = int(input())

list1 = []
list2 = []
syokika = []
count = 0

for i in range(n):
    #list2.append(input().split())
    #list_copy=copy.deepcopy(list1)
##   list1 = copy.deepcopy(syokika)
    list1 = input().split()
    #list2.append(list1.split())
    list2.append(int(''.join(list1)))
    list1 = copy.deepcopy(syokika)

for i in range(1,len(list2)):
    if(count>=2):
        break
    if(list2[i-1]%11==0 and list2[i]%11==0):
        count += 1
    else:
        count = 0

if(count>=2):
    print('Yes')
else:
    print('No')

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

int main(int argc, char *argv[]){
  int ave = 0;
  int n;
  for (int i = 0; i < 5; i++) {
    cin >> n;
    if(n < 40)n = 40;
    ave += n;
  }
  std::cout << ave / 5 << std::endl;
  return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define MAXN 100000
const int INF=1e9;
using namespace std;
vector<int> G[MAXN+5];
int d[MAXN+5],val[MAXN+5];
int L[MAXN+5],R[MAXN+5];
bool vis[MAXN+5];
void Init()
{
	memset(vis,0,sizeof(vis));
	for(int i=0;i<=MAXN+3;i++)
		L[i]=-INF,R[i]=INF;
}
bool DFS(int u,int fa,bool typ)
{
	if(vis[u]==true&&typ!=val[u]%2)
		return false;
	for(int i=0;i<G[u].size();i++)
	{
		int v=G[u][i];
		if(v==fa)
			continue;
		if(DFS(v,u,!typ)==false)
			return false;
	}
	return true;
}
bool DFS2(int u,int fa)
{
	if(vis[u]==true)
		L[u]=R[u]=val[u];
	for(int i=0;i<G[u].size();i++)
	{
		int v=G[u][i];
		if(v==fa)
			continue;
		if(DFS2(v,u)==false)
			return false;
		L[u]=max(L[v]-1,L[u]);
		R[u]=min(R[v]+1,R[u]);
	}
	if(L[u]>R[u])
		return false;
	return true;
}
void DFS3(int u,int fa,int vn)
{
	val[u]=vn;
	for(int i=0;i<G[u].size();i++)
	{
		int v=G[u][i];
		if(v==fa)
			continue;
		if(L[v]<=vn-1&&vn-1<=R[v])
			DFS3(v,u,vn-1);
		else 
			DFS3(v,u,vn+1);
	}
}
int main()
{
	Init();
	int n,u,v;
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		scanf("%d %d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
		d[u]++,d[v]++;
	}
	int maxd=0,rt,k;
	scanf("%d",&k);
	for(int i=1;i<=k;i++)
	{
		scanf("%d %d",&u,&v);
		val[u]=v;
		vis[u]=true;
		if(d[u]>maxd)
			maxd=d[u],rt=u;
	}
	if(DFS(rt,-1,val[rt]%2)==false)
		printf("No\n");
	else if(DFS2(rt,-1)==false)
		printf("No\n");
	else
	{
		DFS3(rt,-1,val[rt]);
		printf("Yes\n");
		for(int i=1;i<=n;i++)
			printf("%d\n",val[i]);
	}
	return 0;
}
/*
5
1 2
3 1
4 3
3 5
2
2 6
5 7

*/

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
/* map_for : mapでfor文を回す */
/* gcd_lcm : 最大公倍数 & 最小公約数 */
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    int a,b,c;
    cin >> a >> b >> c;
    if(a + b + c <= 21){
        cout << "win" << endl;
    }else{
        cout << "bust" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a > b){
            System.out.println("a > b");
        }
        if(a < b){
            System.out.println("a < b");
        }
        if(a == b){
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26176
//                                               KEEP GRINDING
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp>   
using namespace std;
using namespace __gnu_pbds;
 
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
template<typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define int long long
#define ld long double
#define precise(i) fixed << setprecision(10) << i
#define f(i,a,b) for(int i=a;i<b;++i)

#define endl '\n'
#define debug cout<<"\n========================================\n";
#define err1(a) cout<<#a<<" "<<a<<endl;
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl;
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl;
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl;

#define PQ priority_queue
#define LB lower_bound  
#define UB upper_bound
#define fr first
#define sc second

#define all(a) (a).begin(),(a).end()
#define allr(a) (a).rbegin(),(a).rend()
#define show(a) {for(auto xyz:a)cout<<xyz<<" ";cout<<endl;}
#define sz(x) (int)(x).size()
const int MOD = 2019 ;
void solve(){
	string s;	cin>>s;		reverse(all(s));
	vector<int> a(sz(s)),rem(MOD,0);
	int ans=0,p=1;
	f(i,0,sz(s)){
		a[i]=( ( p*(s[i]-'0') ) + (i!=0 ? a[i-1] : 0LL) )%MOD;
		p=(p*10)%MOD;
		rem[a[i]]++;
	}
	for(auto i:rem)	ans+=(i*(i-1))/2;
	cout<<ans+rem[0]<<endl;
	
	
	
}
signed main(){
    fastio
    int t=1;
    for(;t--;solve());
}

Measured memory_bytes: 5184
#include <iostream>


using namespace std;

int main()
{
    int A , B , K ;
    cin >> A >> B ;
    if(((A + B)% 2) == 0 )
    {
        cout <<(A + B)/2 << endl;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }


    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  double w, h, x, y;
  cin >> w >> h >> x >> y;
  
  cout << w * h / 2 << " ";
  
  if((x == w / 2) && (y == h / 2))
    cout << "1" << endl;
  else
    cout << "0" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,b) for(ll i=0;i<b;i++)
ll mod=1000000007;
#define vl vector<ll>
#define pl pair<ll,ll>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define RFOR(i,a,b) for(ll i=b-1;i>=a;i--)
#define rsort(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(),(v).end()

ll n,a;
vl A;
int main() {
    cin >>a>> n;
   (a<n)?cout<<0<<endl:cout<<10<<endl;

}



Measured memory_bytes: 256