akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void strInit(char str[]);//str[]を0で初期化
void extIntStr(char str[],int data[]);//str[]から数値(int)を抽出しdata[]に順次格納
void incsort(int data[],int len);//data[]を昇順ソート
void decsort(int data[],int len);//data[]を降順ソート
void printIntArray(int data[],int len);//data[]をprint
int* inputArray(int n);//文字列を受け取り数値を抽出、n個の数値(int)を格納した配列のポインタをreturn
int* cpyArray(int data[],int len);//配列(int)を複製した配列のポインタをreturn

//don't forget free(data);

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    int i;
    for(i=0;b>(a-1)*i+1;i++);
    printf("%d",i);
}

//temp##############################################

void strInit(char str[]){
    int len=strlen(str);
    for(int i=0;i<len;i++){
        str[i]=0;
    }
}

void extIntStr(char str[],int data[]){
    int length=strlen(str);
    str[length-1]=' ';
    char buff[12];
    int j,index;
    index=j=0;
    for(int i=0;i<length;i++){
        if(str[i]!=' '){
            buff[j++]=str[i];
        }else{
            data[index++]=atoi(buff);
            strInit(buff);
            j=0;
        }
    }
}

void incsort(int data[],int len){
    for(int i=0;i<len-1;i++){
        for(int j=i+1;j<len;j++){
            if(data[i]>data[j]){
                int tmp=data[i];
                data[i]=data[j];
                data[j]=tmp;
            }
        }
    }
}

void decsort(int data[],int len){
    for(int i=0;i<len-1;i++){
        for(int j=i+1;j<len;j++){
            if(data[i]<data[j]){
                int tmp=data[i];
                data[i]=data[j];
                data[j]=tmp;
            }
        }
    }
}

void printIntArray(int data[],int len){
    for(int i=0;i<len;i++){
        printf("%d\n",data[i]);
    }
}

int* inputArray(int n){
    int *data;
    data=(int*)malloc(sizeof(int)*n);
    char *get;
    get=(char*)malloc(sizeof(char)*11*n+1);
    fgets(get,11*n+1,stdin);
    extIntStr(get,data);
    free(get);
    return data;
}

int* cpyArray(int data[],int len){
    int *cp;
    cp=(int*)malloc(sizeof(int)*len);
    for(int i=0;i<len;i++){
        cp[i]=data[i];
    }
    return cp;
}

//temp##############################################


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

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

    int t = n % 10;
    string ans;
    switch(t){
        case 0:
        case 1:
        case 6:
        case 8:
            ans = "pon";
            break;
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            ans = "hon";
            break;
        case 3:
            ans = "bon";
            break;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] t = new int[n];
        for (int i = 0; i < n; i++) {
            t[i] = sc.nextInt();
        }
        int m = sc.nextInt();
        int[] p = new int[m];
        int[] x = new int[m];
        for (int i = 0; i < m; i++) {
            p[i] = sc.nextInt();
            x[i] = sc.nextInt();
        }

        for (int i = 0; i < m; i++) {
            int result = 0;
            for (int j = 0; j < n; j++) {
                if (p[i] == j + 1) {
                    result += x[i];
                    continue;
                }
                result += t[j];
            }
            System.out.println(result);
        }
    }

}


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

int main ()
{
	int n;
	cin>>n;
	for(int h=0;h<n;h++)
	{
		double x[4],y[4];
		for(int i=0;i<4;i++)cin>>x[i]>>y[i];
		if(x[0]==x[1]||x[2]==x[3])
		{
			if(x[0]==x[1]&&x[2]==x[3])
			{
				cout<<"YES"<<endl;
			}
			else
			{
				cout<<"NO"<<endl;
			}
		}
		else
		{
			double Z,X;
			Z=(y[1]-y[0])/(x[1]-x[0]);
			X=(y[3]-y[2])/(x[3]-x[2]);
			if(abs(Z-X)<0.0000000001)
			{
				cout<<"YES"<<endl;
			}
			else cout<<"NO"<<endl;
		
		}
	}
	
}

Measured memory_bytes: 1228
n = int(input())
a = list(map(int, input().split()))

for i in range(n):
    if a[i]-1 == i:
        continue
    a[a[i]-1], a[i] = a[i], a[a[i]-1]
    break

if a == sorted(a):
    print("YES")
else:
    print("NO")

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

int main()
{
	long W, H, x, y;
	cin >> W >> H >> x >> y;

	cout << (static_cast<double>(W * H) / 2.0) << " " << (x * 2 == W && y * 2 == H) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
class Dice{
public:
	int n1,n2,n3,n4,n5,n6;
	
	void East(){
		int t = n1;
		n1 = n4;
		n4 = n6;
		n6 = n3;
		n3 = t;
	}
	void West(){
		int t = n1;
		n1 = n3;
		n3 = n6;
		n6 = n4;
		n4 = t;
	}
	
	void South(){
		int t=n1;
		n1 = n5;
		n5 = n6;
		n6 = n2;
		n2 = t;
	}
	void North(){
		int t=n1;
		n1 = n2;
		n2 = n6;
		n6 = n5;
		n5 = t;
	}
	void Rotation(){
    	int t=n2;
		n2 = n3;
		n3 = n5;
		n5 = n4;
		n4 = t;
	}
};


int main() {
	Dice d1;
	Dice d2;
	
	cin >> d1.n1 >> d1.n2 >> d1.n3 >> d1.n4 >> d1.n5 >> d1.n6;
	cin >> d2.n1 >> d2.n2 >> d2.n3 >> d2.n4 >> d2.n5 >> d2.n6;
	
	if(d1.n3==d2.n1 || d1.n4==d2.n1){
		d1.East();
	}
	for(int i=0; i<4; i++){
		if(d2.n1==d1.n1)break;
		d1.North();
	}
	for(int i=0; i<4; i++){
		if(d2.n2==d1.n2)break;
		d1.Rotation();
	}
	
	if(d1.n1==d2.n1 && d1.n2==d2.n2 && d1.n3==d2.n3 && d1.n4==d2.n4 && d1.n5==d2.n5 && d1.n6==d2.n6){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	 return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

int main(void){
  string S;cin >> S;
  cout << 700 + 100*count(S.begin(),S.end(),'o') << endl;
  return 0;
}


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


int main()
{   
    int n, h,ans=0;
    cin>>n>>h;
    while(n--)
    {
        int a;
        cin>>a;
        if(a>=h)
        ans++;

    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    string s;
    cin >> s;
    string ex(s.length(), 'x');
    cout << ex << endl;
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc054/tasks/abc054_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int N, M;
    cin >> N >> M;
    vector<string> A(N), B(M);
    for (auto &x : A) {
        cin >> x;
    }
    for (auto &x : B) {
        cin >> x;
    }
    REP(h, N - M + 1) REP(w, N - M + 1) {
        bool ng = false;
        REP(i, M) REP(j, M) {
            if (A[h + i][w + j] != B[i][j]) {
                ng = true;
                break;
            }
        }
        if (!ng) {
            cout << "Yes\n";
            return;
        }
    }
    cout << "No\n";
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 3644
#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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
	string S, T;
	while (cin >> S >> T) {
		int res = 0;
		for (int i = 0; i < S.size(); ++i) {
			if (S[i] != T[i]) ++res;
		}
		cout << res << endl;
	}
}

















Measured memory_bytes: 3912
n=int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)

A=B=I=0
for i in a:
    if I %2:B+=i
    else:A+=i
    I+=1

print(A-B)
# other
# print(sum(a[::2]) - sum(a[1::2]))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
 int n;
 cin >> n;
 VI h(n);
 ll sum=0;
 rep(i,n){
     cin >> h.at(i);
     sum+=h.at(i);
 }
 rep(i,n-1){
     if(h.at(i)>=h.at(i+1))sum-=h.at(i+1);
     else if(h.at(i)<h.at(i+1))sum-=h.at(i);
 }
 cout << sum << endl;

}

Measured memory_bytes: 256
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))

k, s = rli()
ans = 0
for x in range(k+1):
    for y in range(k+1):
        z = -x-y+s
        if(0 <= z and z <= k):
            ans += 1
print(ans)

Measured memory_bytes: 3064
import math
x, y, now = 0, 0, 90
while 1:
    d, a = map(float, input().split(','))
    if d == 0 and a == 0:
        break
    x += d*math.cos(now * math.pi / 180)
    y += d*math.sin(now * math.pi / 180)
    now -= a

print(int(x))
print(int(y))



Measured memory_bytes: 5704
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,sse4,avx,avx2")
// #pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VL = vector<LL>;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define FILL(a, b) memset(a, b, sizeof(a))

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

mt19937 rnd(time(0));


int main()
{       
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    LL a, b, c, d;
    cin >> a >> b >> c >> d;

    LL ans = a * c;
    ans = max({ans, a * d, b * c, b * d});

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3656
import java.util.*;

public class Main {
public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();

    System.out.println(N % K == 0 ? 0 : 1);
  }
}


Measured memory_bytes: 23760
package main

import "fmt"

// 循環文字列から任意の長さの文字列を抜き出す
func get_word(ring string, idx int, lenw int) string {
	var pw string
	len_ring := len(ring)

	if idx+lenw <= len_ring {
		pw = ring[idx : idx+lenw]
	} else {
		end_len := len_ring - idx
		pw = ring[idx:] + ring[:lenw-end_len]
	}

	return pw
}

func exists_word(ring string, word string) bool {
	lens := len(ring)
	lenw := len(word)

	for i := 0; i < lens; i++ {
		if get_word(ring, i, lenw) == word {
			return true
		}
	}

	return false
}

func main() {
	var s, p string

	fmt.Scanf("%s", &s)
	fmt.Scanf("%s", &p)

	if exists_word(s, p) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>
#include<bitset>

//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;



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

	ll n;
	cin >> n;

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

	for (int i = 1; i < n; i++)
	{
		if (x[i] == x[i - 1] && y[i] == y[i - 1])
		{
			if (i == n - 1)
			{
				cout << 0 << endl;
				ret;
			}
			continue;
		}
		break;
	}

	ll ans1 = 0;

	ll tmp1 = 0;
	ll tmp2 = LINF;

	for (ll i = 0; i < n; i++)
	{
		tmp1 = max(tmp1, x[i] - y[i]);
		tmp2 = min(tmp2, x[i] - y[i]);
	}

	ans1 = abs(tmp1 - tmp2);

	ll ans2 = 0;
	tmp1 = 0;
	tmp2 = LINF;
	for (ll i = 0; i < n; i++)
	{
		tmp1 = max(tmp1, x[i] + y[i]);
		tmp2 = min(tmp2, x[i] + y[i]);
	}
	ans2 = tmp1 - tmp2;

	cout << max(ans1, ans2) << endl;

	return 0;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  int x, y;
  cin >> x >> y;
  if(n>k){
    cout << k*x + (n-k)*y << endl;
  }else{
    cout << n*x << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define Pb push_back
#define  FI first
#define  SE second
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl; 
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF =0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
LL qpow(LL a,LL b){LL s=1;while(b>0){if(b&1)s=s*a%mod;a=a*a%mod;b>>=1;}return s;}
LL gcd(LL a,LL b) {return b?gcd(b,a%b):a;}
int dr[2][4] = {1,-1,0,0,0,0,-1,1};
typedef pair<int,int> P;
const int maxn = 1e5+10;

LL A[maxn],B[maxn];

int main(void)
{
	int n;cin>>n;
	for(int i = 1;i <= n+1; ++i)
		cin>>A[i];
	for(int i = 1;i <= n; ++i)
		cin>>B[i];    
	LL ans = 0;
	for(int i = 1;i <= n+1; ++i){
		LL d= min(A[i],B[i]+B[i-1]);
		ans += d;
		d = max(0LL,d-B[i-1]);
		B[i] -= d;
	}

	cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 1792
N = int(input())
A = list(map(int, input().split()))
L = [0] * N
for i in range(N):
    L[i] = A[i] - i - 1
L.sort()
if N % 2 != 0:
    b = L[N // 2]
    ans = 0
    for i in range(N):
        ans += abs(A[i] - (b+i+1))
    print(ans)
else:
    b1 = L[N//2]
    b2 = L[N//2 + 1]
    ans1 = 0
    ans2 = 0
    for i in range(N):
        ans1 += abs(A[i] - (b1+i+1))
    for i in range(N):
        ans2 += abs(A[i] - (b2+i+1))
    print(min(ans1, ans2))


Measured memory_bytes: 88404
from sys import stdin

readline = stdin.readline


def main():
    _, *p = map(int, open(0).read().split())
    count = 0
    sp = sorted(p)
    for a, b in zip(sp, p):
        if a != b:
            count += 1
    print('YES' if count <= 2 else 'NO')


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
n,m,x = map(int, input().split())
d = {}
for i in range(n):
  c = list(map(int, input().split()))
  d[i] = c
ans_ = 1000000000
for i in range(2**n):
  f = 0
  ans = 0
  a = format(i,'b')
  a = "{:0>12}".format(a)
  b = a[12-n:]
  e = [0]*m
  for num,j in enumerate(b):
    if j == "1":
      c = d[num]
      for num_,k in enumerate(c):
        if num_ == 0:
          ans += k
        else:
          e[num_-1] += k
  for j in e:
    if j < x:
      f = 1
      break
  if f == 0:
    ans_ = min(ans_,ans)

if ans_ == 1000000000:
  print(-1)
else:
  print(ans_)

Measured memory_bytes: 9244
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;


//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
//cout << fixed << setprecision(10) << ans << endl;


map<int,int> mp[200000];
typedef pair<int, int> P;
vector <int> edge[200000];
P junban[200000];
int ans;
int f[200000];

void dfs(int k,int l){
    int now_c = 0;
    REP(i,edge[k].size()){
        int ne = edge[k][i];
        if(f[ne]==1) continue;
        now_c ++;
        if(now_c == l) now_c ++;
        f[ne] = 1;
        mp[k][ne] = now_c;
        mp[ne][k] = now_c;
        ans = max(ans,now_c);
        dfs(ne,now_c);
    }
}


signed main(){
    int n;
    cin >> n;
    REP(i,n-1){
        int a1,b1;
        cin >> a1 >> b1;
        edge[a1].pb(b1);
        edge[b1].pb(a1);
        junban[i] = P(a1,b1);
    }
    f[1] = 1;
    dfs(1,0);
    cout << ans << endl;
    REP(i,n-1){
        cout << mp[junban[i].first][junban[i].second] << endl;
    }
    return 0;
}

Measured memory_bytes: 34688
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int allnum = 0;

		Set<String> colorset = new HashSet<>();
		for(int i=0;i<N;i++) {
			int a = sc.nextInt();
			String c = color(a);

			if(c.equals("all")) {
				allnum++;
			}else{
				colorset.add(c);
			}
		}

		int min = colorset.size()==0 ? 1 : colorset.size();
		int max = colorset.size()==0 ? allnum : min + allnum;
		System.out.println(min + " " + max);
	}

	public static String color(int rate) {
		if(rate < 400) {
			return "gray";
		}else if(rate < 800) {
			return "brown";
		}else if(rate < 1200) {
			return "green";
		}else if(rate < 1600) {
			return "skyblue";
		}else if(rate < 2000) {
			return "blue";
		}else if(rate < 2400) {
			return "yellow";
		}else if(rate < 2800) {
			return "orange";
		}else if(rate < 3200) {
			return "red";
		}else {
			return "all";
		}
	}
}


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

long long h[100005],dp[100005];

int main()
{
    long long i,j,k,ans,n;
    cin>>n>>k;
    for(i=1 ; i<=n ; i++)   cin>>h[i];

    dp[n] = 0;
    for(i=n-1 ; i>=1 ; i--){
        dp[i] = 1e18;
        for(j=1 ; j<=k && i+j<=n ; j++)
            dp[i] = min(dp[i] , (long long)fabs(h[i] - h[i+j])+dp[i+j]);
    }
    cout<<dp[1]<<endl;

    return 0;
}


Measured memory_bytes: 5172
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// データの取得
		Scanner sc = new Scanner(System.in);
		ArrayList<Data> list = new ArrayList<Data>();
		// データの抽出
		String[] line_list = sc.nextLine().split(" ");
		int N = Integer.parseInt(line_list[0]);
		int M = Integer.parseInt(line_list[1]);
		for(int i=0;i<N;i++) {
			line_list = sc.nextLine().split(" ");
			list.add(new Data(Long.parseLong(line_list[0]),Integer.parseInt(line_list[1])));
		}
		
		// 単価、数量のソート
		list.sort((a,b)->a.compareTo(b));
		
		// 最小単価の取得
		long kingaku=0;
		for(int i=0;i<list.size();i++) {
			Data data = list.get(i); 
			if(M < data.getSuryou()) {
				kingaku = kingaku + M * data.getTanka();
				break;
			}
			else {
				kingaku = kingaku + data.getSuryou() * data.getTanka();
				M = M - data.getSuryou();
			}
		}
		System.out.println(kingaku);
	}
	
	public static class Data implements Comparable<Data>{
		long tanka;
		int suryou;
		
		public Data(long p_tanka,int p_suryou){
			this.tanka=p_tanka;
			this.suryou=p_suryou;
		}
		
		@Override
		public int compareTo( Data d ){
			if(this.tanka < d.tanka) return -1;
			if(this.tanka > d.tanka) return 1;
			return 0;
		}
		  
		public long getTanka() {
			return tanka;
		}

		public void setTanka(long tanka) {
			this.tanka = tanka;
		}

		public int getSuryou() {
			return suryou;
		}

		public void setSuryou(int suryou) {
			this.suryou = suryou;
		}
	}
}


Measured memory_bytes: 120152
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
// ll mod=1000000007;
 
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    ll t,i,j,k,temp,temp2,n,m,x,y,sum=0,o;
    cin >> x >> n >> y >> m >> t;
    if(n<=m) cout << "NO\n";
    else{
        if(abs(y-x)<=t*(n-m)) cout << "YES\n";
        else cout << "NO\n";
    }
}


Measured memory_bytes: 3652
/*
        Author  : Malisetti Samrat
*/

#pragma GCC optimize ("O3")

#pragma GCC optimize("Ofast")

#include   <iostream>
#include   <algorithm>
#include   <queue>
#include   <list>
#include   <map>
#include   <math.h>
#include   <numeric>
using      namespace        std;
#define    endl             '\n'
#define    FAST             ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define    ipfile           ifstream cin ("input.txt");std::cin.rdbuf(std::cin.rdbuf())
#define    pb(x)            push_back(x)
#define    int              long long int
#define    ull              unsigned long long int
#define    db               long double
#define    mod              1000000007
#define    vll              vector<int>
#define    all(v)           v.begin(),v.end()
#define    GCD(m,n)         __gcd(m,n)
#define    LCM(m,n)         m*(n/GCD(m,n))
#define    REVVEC(v)        reverse(v.begin(),v.end())
#define    REVARR(a)        reverse(a,a+n)
#define    maxc(v)          max_element(all(v))
#define    minc(v)          min_element(all(v))
#define    inputarr(a,n)    for(int xxx=0;xxx<n;++xxx) cin>>a[xxx]
#define    outputarr(a,n)   for(int xxx=0;xxx<n;xxx++) cout<<a[xxx]<<" "
#define    rep(i,m, n)      for(int i = m; i < (n); ++i)
#define    sp               setprecison(10)


void solve1()
{
    
   
    int n;
    cin>>n;
    
    if(n>=500){
        int res=(n-500*(n/500))/5;
        //cout<<res<<endl;
    cout<<(1000*(n/500)+(5*res))<<endl;}
    else
    cout<<(5*(n/5))<<endl;
    
    
}


signed main()
{
	FAST
	
//	int T; cin>>T; while( T -- ){
	    solve1();
//	}
	return 0;
}

Measured memory_bytes: 256
while line=gets
(m,f,r)=line.split().map(&:to_i)
  break if m==-1&&f==-1&&r==-1
  m=f=0 if m==-1||f==-1
  case m+f
  when 80..100; puts "A"
  when 65...80 ; puts "B"
  when 50...65 ; puts "C"
  when 30...50 ; puts r >= 50 ? "C" : "D"
  else ; puts "F"
  end
end

Measured memory_bytes: 6104
MOD = 10 ** 9 + 7

def fac(n, m)
    (n..m).inject(1) {|r, v| r * v % MOD}
end

def power(x, n)
    n == 0 ? 1 : ((n.odd? ? x : 1) * power(x ** 2 % MOD, n / 2) % MOD)
end

def com(n, m)
    m = n - m if n < 2 * m
    fac(n - m + 1, n) * power(fac(1, m), MOD - 2) % MOD
end

n, k = gets.split.map(&:to_i)
m = n - k

1.upto(k) do |i|
    puts m + 1 < i ? 0 : com(m + 1, i) * com(k - 1, i - 1) % MOD
end

Measured memory_bytes: 1788
#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
using namespace std;

int main()
{
    int n,A,B;
    char s[100000];
    scanf("%d%d%d",&n,&A,&B);
    scanf("%s",s);
    
    for(int i=0;i<n;i++){
        if(s[i]=='a'){
            if(A+B!=0){
                printf("Yes\n");
                A--;
            }else{
                printf("No\n");
            }
        }else if(s[i]=='b'){
            if(A+B!=0 && B!=0){
                printf("Yes\n");
                B--;
            }else{
                printf("No\n");
            }
        }else{
            printf("No\n");
        }
    }
    
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;

void solve(){
    int n,a,b;cin>>n>>a>>b;
    cout << min(a*n,b)<<endl;
}

int main(){
    solve();
    return 0;
}


Measured memory_bytes: 256
//Hey u r far away to know this
#include <bits/stdc++.h>
using namespace std;
#define     ff      	    	first
#define     pb 	         	push_back
#define     ss          		second
#define     ll      	    	long long
#define     MAX  	       	5000
#define     mpi         		map<int, int>
#define     mpll        		map<ll, ll>
#define     pll         		pair<ll, ll>
#define     plld        		pair<ll, double>
#define     SKILLER     		ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     vi          		std::vector<int>
#define     vll         		std::vector<ll>
#define     vs          		std::vector<string>
#define     vvi         		std::vector<std::vector<int>>
#define     vvll        		std::vector<std::vector<ll>>
#define     all(v)      		v.begin(), v.end()
#define     allr(v)      		v.rbegin(), v.rend()
#define     loop(i, a, b) 	for(int i = a; i < b; i++)
#define 	  debug(x) 		cout << x <<" " <<"\n";
#define 	  debug1(x, y) 	cout << x << " " << y  << "\n";
#define 	  debug2(x, y, z) 	cout << x << " " << y << " " << z<<"\n";
#define 	  int 			ll
const   int N = 1e6+5, Mod = 1e9 + 7;
int32_t main(){
    	SKILLER;
    
        int n; cin >> n;
        map<int, int> mp;
        int x = n;
        int i = 2;
        for(int i = 2; i*i <= x; i++){
        	while(x%i == 0){
        		mp[i]++;
        		x = x/i;
        	}
        }
        if(x > 1)
        	mp[x]++;
        int ans = 0;
        for(auto x:mp){
        	int a = x.ss;
        	a = sqrt(1 + 4 * 2 *a);
        	a = a - 1;
        	a /= 2;
        	ans += a;
        }
        cout << ans;
    	return 0;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<string.h>
#include<math.h>
#include<stdio.h>
#include<queue>
#include<utility>
#include<cstdio>
#include<cstring>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qui queue<int>
#define vit vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define prq priority_queue
#define pii pair<int,int>
#define mp make_pair
#define sz size()
#define em empty()
#define ct continue
#define ms multiset
#define all(a) (a).begin(),(a).end()
int a[202020],n;
ll ans=0;
using namespace std;
int main()
{
	cin>>n;
	fo(i,0,n){
		cin>>a[i];
		ans+=a[i]-1;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedInputStream(System.in));
        int N = scan.nextInt();
        int[] arr = new int[N+1];
        arr[0] = scan.nextInt();
        for (int i=1;i<=N;i++) arr[i] = scan.nextInt();
        Task tsk = new Task();
        System.out.println(tsk.solve(arr));
    }

    static class Task{
        public int solve(int[] arr){
            Arrays.sort(arr);
            int num = arr[1] - arr[0];
            for (int i=2;i<arr.length;i++) {
                if (arr[i] != arr[i-1]) {
                    num = gcd(num, arr[i] - arr[i-1]);
                }
            }
            return num;
        }


        private int gcd(int x, int y) {
            if (y != 0) return gcd(y, x%y);
            return x;
        }
    }
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  int n,i; cin>>n>>i;
  int j=n-i+1;
  out(j);
  

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(register int i=a;i<=b;++i)
#define rpd(i,a,b) for(register int i=a;i>=b;--i)
#define rep1(i,x) for(register int i=head[x];i;i=nxt[i])
typedef long long ll;
const int N=2e5+5;
using namespace std;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,a[N];ll ans;
int main(){
	n=read();rep(i,1,n)a[i]=read()-i;sort(a+1,a+n+1);
	rep(i,1,n)ans+=1LL*abs(a[i]-a[n-i+1]);
	printf("%lld",ans/2);
	return 0;
}

Measured memory_bytes: 1024
r,d,x2000 = map(int,input().strip().split())

x2001 = r*x2000 - d
x2002 = r*x2001 - d
x2003 = r*x2002 - d
x2004 = r*x2003 - d
x2005 = r*x2004 - d
x2006 = r*x2005 - d
x2007 = r*x2006 - d
x2008 = r*x2007 - d
x2009 = r*x2008 - d
x2010 = r*x2009 - d

print(x2001)
print(x2002)
print(x2003)
print(x2004)
print(x2005)
print(x2006)
print(x2007)
print(x2008)
print(x2009)
print(x2010)




Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

int n, k;
int a[N], cache[N];

int dp(int cur)
{
	int &ans=cache[cur];
	if(ans!=-1)
		return ans;
	ans=0;
	for(int i=1;i<=n;i++)
	{
		if(cur-a[i]<0)
			continue;
		ans|=(dp(cur-a[i])==0);
	}
	return ans;
}

int32_t main()
{
	IOS;
	memset(cache, -1, sizeof(cache));
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	if(dp(k))
		cout<<"First";
	else
		cout<<"Second";
	return 0;
}


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


int main() {

    ll x; cin >> x;
    ll sum = 0;

    for(int i = 1; i <= x; i ++){
        sum += i;
        if(sum >= x){
            sum = i;
            break;
        }
    }
    cout << sum;
    return 0;
}











Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using tii = tuple<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}
};

vl v(51);
vl p(51);
vl b(51);
ll ans = 0;

void rec(ll n, ll l) {
	if (n == 0)ans += 1;
	else if (l <= 1)return;
	else if (l >= (v[n] - 1) / 2){
		ans += p[n - 1];
		if (l >= (v[n] - 1) / 2 + 1)ans += 1;
		if (l - ((v[n] - 1) / 2 + 1) > 0) {
			rec(n - 1, l - ((v[n] - 1) / 2 + 1));
		}
	}
	else {
		rec(n - 1, l - 1);
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, k;
	cin >> n >> k;
	v[0] = 1;
	p[0] = 1;
	b[0] = 0;
	rep(i, 50) {
		v[i + 1] = v[i] * 2 + 3;
		p[i + 1] = p[i] * 2 + 1;
		b[i + 1] = b[i] * 2 + 2;
	}
	rec(n, k);
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[100010];
  int sum=0;
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
  }
  if(sum%2==0){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}


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

int main(){
  string S;
  cin >> S;
  if(S=="RRR"){
    cout << 3 << endl;
  }
  else if(S=="SSS"){
    cout << 0 << endl;
  }
  else if(S=="RRS" || S=="SRR"){
    cout << 2 << endl;
  }
  else{
    cout << 1 << endl;
  }
}

Measured memory_bytes: 3592
n=int(input());l=[0,1];a=0;b=c=1;p=998244353
for i in range(2,n):l+=[l[p%i]*(p-p//i)%p]
for i in range(n,n//2,-1):a+=b*c;b+=b%p;c=c*i*l[n+1-i]%p
print((pow(3,n,p)-2*a)%p)

Measured memory_bytes: 226464
def shouldBreak(x, y, z):
    if x == -1 and y == -1 and z == -1:
        return False
    else:
        return False

l = list(map(int, input().split()))
N = l[0]
Y = l[1]

x = -1
y = -1
z = -1

N_10000 = 0
while N_10000 <= N:
    N_5000 = 0
    while N_5000 <= N - N_10000:
        N_1000 = N - N_10000 - N_5000
        if Y == 10000 * N_10000 + 5000 * N_5000 + 1000 * N_1000:
            x = N_10000
            y = N_5000
            z = N_1000
            break
        N_5000 += 1
    if shouldBreak(x, y, z):
        break
    N_10000 += 1
print(str(x)+ " " + str(y) + " " + str(z))

Measured memory_bytes: 3064
#include<stdio.h>
int main (){
    int N;
    scanf("%d",&N);
    if (400<=N && N<=599){
        printf("8");
    }else if (600<=N && N<=799)
    {
        printf("7");
    }else if (800<=N && N<=999)
    {   printf("6");
        
    }else if (1000<=N && N<=1199)
    {   printf("5");
        
    }else if (1200<=N && N<=1399)
    {   printf("4");
        
    }else if (1400<=N && N<=1599)
    {   printf("3");
        
    }else if (1600<=N && N<=1799)
    {   printf("2");
        
    }else if (1800<=N && N<=1999)
    {   printf("1");
        
    }
    return 0;    
}

Measured memory_bytes: 1660
N = int(input())
p = list(map(int, input().split()))
cnt = 0
if p[0] == 1:
    tmp = p[1]
    p[1] = p[0]
    p[0] = tmp
    cnt += 1

for i in range(N - 1, -1, -1):
    if i + 1 == p[i]:
        tmp = p[i]
        p[i] = p[i - 1]
        p[i - 1] = tmp
        cnt += 1

print(cnt)

Measured memory_bytes: 13880
H, W = map(int, input().split())
N = int(input())
*A, = map(int, input().split())
grid = [[-1]*W for _ in range(H)]
order = []
for i in range(H):
    if i % 2 == 0:
        for j in range(W): order.append((i, j))
    else:
        for j in reversed(range(W)): order.append((i, j))
idx = 0
for i, a in enumerate(A):
    color = i + 1
    for x, y in order[idx: idx+a]: grid[x][y] = color
    idx += a
for g in grid:
    print(*g)

Measured memory_bytes: 4596
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <sstream>
using namespace std;

typedef long long LL;
#define lowbit(x) ((x)&(-x))
#define INF 0x3f3f3f3f
#define memset(a,b) memset(a,b,sizeof(a))
#define	GE() printf(">----------\n")
#define	IN() freopen("in.txt","r",stdin)
#define	OUT() freopen("out.txt","w",stdout)
const int mod=1e9+7;
const LL inf=0x3f3f3f3f3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-8;
const int maxn=100005;

/*
int n, p;
vector<int> E[maxn];
int vis[maxn];

int dfs(int u, int step){
    vis[u]=1;
    if(u==n){
        int need=step/2+1+step%2;
        if(step==need)p=u;
        else return need;
    }
    for(int i=0;i<E[u].size();i++){
        int v=E[u][i];
        if(!vis[v]){
            int val=dfs(v, step+1);
            if(val&&step==val)p=u;
        }
    }
    return 0;
}

int dfs2(int u){
    vis[u]=1;
    if(u==p)return 0;
    int add=0;
    for(int i=0;i<E[u].size();i++){
        int v=E[u][i];
        if(!vis[v]){
            add+=dfs2(v);
        }
    }
    return add+1;
}

int main() {
    while(~scanf("%d", &n)){
        int u, v;
        for(int i=1;i<=n;i++)E[i].clear();
        for(int i=0;i<n-1;i++){
            scanf("%d%d", &u, &v);
            E[u].push_back(v);
            E[v].push_back(u);
        }
        memset(vis, 0);
        dfs(1, 1);
        memset(vis, 0);
        int sum=dfs2(1);
        printf("%s\n", sum>n-sum?"Fennec":"Snuke");
    }
    return 0;
}
*/

vector<int>G[maxn];
int dep[maxn], fa[maxn], siz[maxn];
void dfs(int x, int f){
    dep[x]=dep[f]+1;
    siz[x]=1;
    for (int i=0; i<G[x].size(); ++i) {
        int v=G[x][i];
        if (v==f) continue;
        dfs(v,x); fa[v]=x; siz[x]+=siz[v];
    }
}
int main(){
    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);
    dfs(1,0);
    int x=(dep[n]-2)/2, p=n;
    for (int i=1; i<=x; ++i) p=fa[p];
    puts(n>(siz[p]<<1)?"Fennec":"Snuke");
    return 0;
}


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

using namespace std;

constexpr static int MAXN = 1e5 + 4;
int a[MAXN];
long long s1[MAXN], s2[MAXN];

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

    for (int i = 0; i < n; i++) {
        if (i > 0)
            s1[i] = s1[i - 1];
        if (a[i] > 0)
            s1[i] += a[i];

        int j = n - i - 1;
        if (j + 1 < n)
            s2[j] = s2[j + 1];
        if (a[j] > 0)
            s2[j] += a[j];
    }

    long long smid = 0;
    for (int i = 0; i < k; i++)
        smid += a[i];

    long long r = max(smid, 0LL) + s2[k];
    for (int i = 1; i + k <= n; i++) {
        smid -= a[i - 1];
        smid += a[i + k - 1];
        long long scur = s1[i - 1] + max(smid, 0LL) + s2[i + k];
        if (scur > r)
            r = scur;
    }
    cout << r << endl;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
const long long mod = 10e9 + 7;

int main(){
    int n; cin>>n;
    string s; cin>>s;
    rep (i, s.size()){
        s[i] += n;
        if (s[i] > 'Z') s[i] -= 26;
    }
  cout << s;
}

Measured memory_bytes: 3560
#include<iostream>
using namespace std;
int main(){
  double a,b;
  while(cin>>a>>b){
    if(35.5>a && 60+11>b){
      cout<<"AAA"<<endl;
    }else if(37.5>a && 60+17>b){
      cout<<"AA"<<endl;
    }else if(40>a && 60+23>b){
      cout<<"A"<<endl;
    }else if(43>a && 60+29>b){
      cout<<"B"<<endl;
    }else if(50>a && 60+45>b){
      cout<<"C"<<endl;
    }else if(55>a && 60+56>b){
      cout<<"D"<<endl;
    }else if(70>a && 120+28>b){
      cout<<"E"<<endl;
    }else{
      cout<<"NA"<<endl;
    }
  }
}

Measured memory_bytes: 1224
A,B,C,D,E,F = map(int,input().split())
waterset = set()
for i in range(F//(100*A)+1):
    for j in range(F//(100*B)+1):
        water = (A*i + B *j)*100
        if water < F:
            waterset.add(water)
waterset.remove(0)
sugarset = set()
for i in range(F//C + 1):
    for j in range(F//D + 1):
        sugar = C*i + D*j
        if sugar < F:
            sugarset.add(sugar)
best_conc = -1
best_a = -1
best_b = -1
for a in waterset:
    for b in sugarset:
        if a+b >F:
            continue
        if b * 100 > E*a:
            continue
        conc = 100*b/(a+b)
        if conc > best_conc:
            best_conc = conc
            best_a = a
            best_b = b
print(best_a+best_b,best_b)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;

int main(){
    int N,K;
    cin >> N >> K;
    LL x[N],y[N];
    vector<P> vec;
    for(int i=0;i<N;i++){
        cin >> x[i] >> y[i];
        vec.push_back(make_pair(x[i],y[i]));
    }
    sort(x,x+N);
    sort(y,y+N);
    LL ans=LINF;
    for(int i=0;i<N;i++){
        for(int j=N-1;j>=0;j--){
            if(i==j) break;
            for(int u=0;u<N;u++){
                for(int v=N-1;v>=0;v--){
                    if(u==v) break;
                    LL xl=x[i],xr=x[j],yu=y[v],yd=y[u];
                    int count=0;
                    for(int s=0;s<N;s++){
                        P p=vec[s];
                        LL nx=p.first,ny=p.second;
                        if(xl<=nx&&nx<=xr&&yd<=ny&&ny<=yu) count++;
                    }
                    if(K<=count) ans=min(ans,(xr-xl)*(yu-yd));
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

#include <algorithm>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)
int main() {
    long long k, b, c;
    cin >> k;
    long long sum = 0;
    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= k; j++) {
            for (int l = 1; l <= k; l++) {
                sum += __gcd(__gcd(i, j), __gcd(j, l));
                // cout << sum << endl;
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3652
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

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

vector<vector<ll> > table;
vector<P> roads;
vector<P> qs;

int main() {
  ll A, B, C, K;

  cin >> A >> B >> C >> K;

  ll ans = A + B + C;
  ll target = max(max(A, B), C);
  ans = ans - target + (target << K);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b) {
        cout << c << endl;
    } else if(b == c) {
        cout << a << endl;
    } else {
        cout << b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        int N = int.Parse(Console.ReadLine());
        string[] str = Console.ReadLine().Split(' ');
        long[] A = new long[N];
        for(int i=0;i<N;i++){
            A[i] = int.Parse(str[i]);
        }
        Array.Sort(A);
        long c1 = 0;
        long c2 = 0;
        for(int i=N-1;i>0;i--){
            if(A[i] == A[i-1]){
                if(c1 == 0){
                    c1 = A[i];
                    i--;
                }
                else{
                    c2 = A[i];
                    break;
                }
            }
        }
        long count = c1*c2;
        sb.Append(count+"\n");
    }
}

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


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

int main() {
    //freopen("0005.txt", "r", stdin);
    int a, b;
    while (cin >> a >> b) {
        int g = gcd(a, b);
        cout << g << " " << (a / g * b) << "\n";
    }
}

Measured memory_bytes: 2976
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  long double d;
  ll n;
  cin >> n >> d;
  ll ans=0;
  for(ll i=0;i<n;i++) {
    long double x,y;
    cin >> x >> y;
    long double dis=sqrt(x*x+y*y);
    if(dis<=d) ans++;
  }
  cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  string S; cin >> S;
  vector<int> sa(N + 1); rep(i, N + 1) sa[i] = i;
  sort(range(sa), [&](int i, int j) {
    return S.substr(i) < S.substr(j);
  });
  vector<int> isa(N + 1);
  rep(i, N + 1) isa[sa[i]] = i;
  vector<int> lcp(N + 1);
  int k = 0;
  for (int i = 0; i < N; i++) {
    int j = sa[isa[i] - 1];
    k = max(0, k - 1);
    while (i + k < N && j + k < N && S[i + k] == S[j + k]) {
      k++;
    }
    lcp[isa[i] - 1] = k;
  }

  int l = 0;
  int r = N;
  while (r - l > 1) {
    int m = (l + r) / 2;
    int i = 0;
    bool any = false;
    while (i < N) {
      int mn = sa[i];
      int mx = sa[i];
      while (i < N && lcp[i] >= m) {
        i++;
        mn = min(mn, sa[i]);
        mx = max(mx, sa[i]);
      }
      any |= mx - mn >= m;
      i++;
    }
    if (any) l = m; else r = m;
  }
  cout << l << endl;
}


Measured memory_bytes: 384
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());




int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		// reverse(a.begin(),a.end());
		cin>>n>>m;
		// n=s.length();
		// ll a[n];
		if((n+m)%2) cout<<"IMPOSSIBLE";
		else
		cout<<(n+m)/2;
		
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256