akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)

func read() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	v, _ := strconv.Atoi(read())
	return v
}

func main() {
	sc.Split(bufio.ScanWords)

	N := nextInt()
	M := nextInt()
	C := nextInt()

	// B := make([]int, M)
	var B [20]int
	for i := 0; i < M; i++ {
		B[i] = nextInt()
	}
	// fmt.Println(B)

	// A := make([][]int, N)
	var A [20][20]int
	for i := 0; i < N; i++ {
		// A[i] = make([]int, M)
		for j := 0; j < M; j++ {
			A[i][j] = nextInt()
		}
	}

	// fmt.Println(A)
	var sum, count int

	for i := 0; i < N; i++ {
		sum = 0
		for j := 0; j < M; j++ {
			sum += A[i][j] * B[j]
		}
		if sum+C > 0 {
			count++
		}
	}
	fmt.Println(count)

}


Measured memory_bytes: 640
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<iostream>
#include<algorithm>//next_permutation

using namespace std;
int main() {
	int N, M;
	cin >> N >> M;
	vector<int>S(M);
	vector<int>C(M);
	for (int i = 0;i < M;i++) {
		cin >> S.at(i);
		cin >> C.at(i);
	}
	bool F = false;
	int kotae = -1;
	if (N == 1) {
		for(int i = 0;i <= 9;i++){
			F = false;
			for (int k = 0;k < M;k++) {
				if (i != C.at(k)) {
					F = true;
				}
			}
			if (F == false) {
				kotae = i;
				break;
			}
		}
	}
	if (N == 2) {
		for (int i = 10;i <= 99;i++) {
			F = false;
			for (int k = 0;k < M;k++) {
				if (S.at(k) == 2) {
					if (i % 10 != C.at(k)) {
						F = true;
					}
				}
				if (S.at(k) == 1) {
					if (i / 10 != C.at(k)) {
						F = true;
					}
				}

			}
			if (F == false) {
				kotae = i;
				break;
			}
		}
	}
	if (N == 3) {
		for(int i = 100;i <= 999;i++){
			F = false;
			for (int k = 0;k < M;k++) {
				if (S.at(k) == 3) {
					if (i % 10 != C.at(k)) {
						F = true;
					}
				}
				if (S.at(k) == 2) {
					if ((i / 10) % 10 != C.at(k)) {
						F = true;
					}
				}
				if (S.at(k) == 1) {
					if (i / 100 != C.at(k)) {
						F = true;
					}
				}
			}
			if (F == false) {
				kotae = i;
				break;
			}
		}
	}
	cout << kotae << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>

int main(void){
    int N, ans=0;
    std::cin >> N;
    std::vector<std::vector<int>> A(2, std::vector<int>(N));

    for (int i=0; i<2; ++i){
        for (int j=0; j<N; ++j){
            std::cin >> A.at(i).at(j);
        }
    }

    for (int i=1; i<N; ++i){
        A.at(0).at(i) += A.at(0).at(i - 1);
        A.at(1).at(N - i - 1) += A.at(1).at(N - i);
    }

    for (int i=0; i<N; ++i){
        ans = std::max(ans, A.at(0).at(i) + A.at(1).at(i));
    }

    std::cout << ans << std::endl;

    return 0;
}


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

bool is_prime(int num){
  if(num <= 1) return false;
  if(num == 2) return true;
  if(num % 2 == 0) return false;
  int sq = sqrt(num);
  for(int i = 3; i <= sq; i = i + 2){
    if(num % i == 0) return false;
  }
  return true;
}

int main() {
  int n, num;
  vector<int> out;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> num;
    if(is_prime(num)) out.push_back(num);
  }
  cout << out.size() << endl;
  return 0;
  
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){

  ll a,b,v,w,t;
  cin >> a >> v >> b >> w >> t;
  ll k = abs(b-a);
  if(v <= w)cout << "NO" << endl;
  else {
    if((v-w)*t >= k)cout << "YES"  << endl;
    else cout << "NO" << endl;
  }

  




  return 0;
}

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

int main(){
  int n;
  int b,f,r,v;
  int A[4][3][10]; //A[b棟][f階][r番目]
  for(int i = 0; i < 4; i++){
    for(int j = 0; j < 3; j++){
      for(int k = 0; k < 10; k++){
        A[i][j][k] = 0;
      }
    }
  }
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> b >> f >> r >> v;
    A[b-1][f-1][r-1] += v;
  }
  for(int i = 0; i < 4; i++){
    for(int j = 0; j < 3; j++){
      for(int k = 0; k < 10; k++){
        cout << " " << A[i][j][k];
      }
      cout << endl;
    }
    if(i!=3)
      cout << "####################" << endl;
  }
}


Measured memory_bytes: 3104
import java .util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
	ArrayList<String> sList = new ArrayList<>();
	Scanner sc = new Scanner(System.in);
	int countAC = 0;
	int countWA = 0;
	int countTLE = 0;
	int countRE = 0;
	int inputN = sc.nextInt();

	for(int i = 0; i < inputN; i++) {
		String inputS = sc.next();
		sList.add(inputS);
	}

	for(int i = 0; i < inputN; i++) {
		if(sList.get(i).equals("AC")) {
			countAC++;
		}
		else if(sList.get(i).equals("WA")) {
			countWA++;
		}
		else if(sList.get(i).equals("TLE")) {
			countTLE++;
		}
		else{
			countRE++;
		}
	}

	System.out.println("AC x " + countAC);
	System.out.println("WA x " + countWA);
	System.out.println("TLE x " + countTLE);
	System.out.println("RE x " + countRE);
	}
}

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

const int INF = pow(2, 31) - 1;
#define ll long long
#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  REP(i, n) {
    cin >> v[i];
  }
  vector<int> odd(1e5+1, 0), even(1e5+1, 0);
  REP(i, n) {
    if(i % 2 == 0) {
      odd[v[i]]++;
    } else {
      even[v[i]]++;
    }
  }
  pair<int, int> odd_max = make_pair(0, 0);
  pair<int, int> odd_second_max = make_pair(0, 0);
  pair<int, int> even_max = make_pair(0, 0);
  pair<int, int> even_second_max = make_pair(0, 0);
  FOR(i, 1, 1e5) {
    if(odd[i] >= odd_max.second) {
      odd_second_max.first = odd_max.first;
      odd_second_max.second = odd_max.second;
      odd_max.first = i;
      odd_max.second = odd[i];
    } else if(odd[i] >= odd_second_max.second) {
      odd_second_max.first = i;
      odd_second_max.second = odd[i];
    }
    if(even[i] >= even_max.second) {
      even_second_max.first = even_max.first;
      even_second_max.second = even_max.second;
      even_max.first = i;
      even_max.second = even[i];
    } else if(even[i] >= even_second_max.second) {
      even_second_max.first = i;
      even_second_max.second = even[i];
    }
  }
  int ans;
  if(odd_max.first != even_max.first) {
    ans = n - odd_max.second - even_max.second;
  } else {
    ans = min(n - odd_max.second - even_second_max.second, n - odd_second_max.second - even_max.second);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
#!/usr/bin/env python3


def minimize(k, ps):
    qs = sorted(ps)
    return sum(qs[:k])


def main():
    n, k = (int(z) for z in input().split())
    ps = [int(p) for p in input().split()]
    res = minimize(k, ps)
    print(res)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9264
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
const int DX[8]={-1,0,1,0,-1,-1,1,1},DY[8]={0,-1,0,1,-1,1,-1,1};

int f(int x,int d){
	auto s=to_string(x);
	while(s.size()<d) s+='0';
	sort(s.begin(),s.end());
	auto t=s;
	reverse(t.begin(),t.end());
	return atoi(t.c_str())-atoi(s.c_str());
}

int main(){
	while(1){
		int x,d;
		cin>>x>>d;
		if(d==0) break;
		map<int,int> mp;
		mp[x]=0;
		int cnt=0;
		while(1){
			cnt++;
			x=f(x,d);
			if(mp.find(x)!=mp.end()){
				cout<<mp[x]<<' '<<x<<' '<<cnt-mp[x]<<endl;
				break;
			}
			mp[x]=cnt;
		}
	}
}


Measured memory_bytes: 3296
// !Start && !End 
//  0 se divide
//https: //www.youtube.com/watch?v=6Nb-prB-4P0&list=RD6Nb-prB-4P0&start_radio=1

// https: //www.youtube.com/watch?v=eYDI8b5Nn5s
// Electrify my OOOoooooOOOoooOOOOOoooooOOOooo!
#pragma optimise GCC(-O2)
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll,ll>
#define ve(x) vector<x>
#define f(a,b,c) for(int a=b;a<c;a++)
#define foto(x,v) for(auto x:v)
#define read(t) ll t; cin>>t;
#define reads(t) string t; cin>>t;
#define readarr(arr,n) ll arr[n]; f(i,0,n) cin>>arr[i];
#define forstl(i,v) for(auto &i: v)
#define ln endl
#define dbg(x) cout<<#x<<" = "<<x<<ln;
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<ln;
#define dbgstl(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    Term "<< ++c <<" = "<<it<<ln;} cout<<ln;
#define dbgstlp(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    Term "<< ++c <<" = "<<it.fi<<" , "<<it.se<<ln;} cout<<ln;
#define dbgarr(v,s,e) cout<<#v<<" = "; f(i,s,e) cout<<v[i]<<", "; cout<<ln;
#define addEdge(tr,k) f(i,0,k) { ll x,y; cin>>x>>y, tr[x].push_back(y), tr[y].push_back(x);}
#define all(v) v.begin(),v.end()

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) { uniform_int_distribution<int> uid(0, lim - 1); return uid(rang); }

//														GLOBAL VARS
ll INF =LLONG_MAX;
const ll M= 1000000007;

//														USEFUL FUNCTIONS
ll powm(ll ,ll);





// 														MAIN
int main()
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    //It gets easier day by day, but the hard part is to........
    read(r)
    double pi = 3.14159265359;
    cout<<setprecision(18)<<2*pi*r;

}










//													FUNCTIONS DECLARATIONS
ll powm(ll a, ll b) {
	ll res=1;
	while(b) {
		if(b&1)
			res=(res*a)%M;
		a=(a*a)%M;
		b>>=1;
	}
	return res;
}


Measured memory_bytes: 3804
A = []
while True:
    try:
        S = input()
        for s in S:
            if 'a' <= s <= 'z' or 'A' <= s <= 'Z':
                A.append(s.lower())
    except EOFError:
        break

D = {}
for s in A:
    if s in D:
        D[s] += 1
    else:
        D[s] = 1

Str = [chr(i) for i in range(97, 97+26)]
for s in Str:
    print(s, end=" ")
    print(":", end=" ")
    if s in D:
        print(D[s])
    else:
        print(0)



Measured memory_bytes: 5576
// https://atcoder.jp/contests/dp/tasks/dp_d

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define mod 1000000007
#define gcd __gcd
#define inf INT_MAX
#define INF LLONG_MAX
#define minf INT_MIN
#define MINF LLONG_MIN
#define pb push_back
#define all(v) v.begin(),v.end()
#define print(v) for(auto x:v) cout<<x<<" "; cout<<"\n";
#define printn(v) for(auto x:v) cout<<x<<"\n";
#define F first
#define S second
#define mp make_pair

double dp[301][301][301];

double J_sushi(int n, int x, int y, int z) {
	if (x < 0 || y < 0 || z < 0) return 0;

	if (x == 0 && y == 0 && z == 0) return 0;

	if (dp[x][y][z] > -0.9 ) return dp[x][y][z];

	return dp[x][y][z] = (n + x * J_sushi(n, x - 1, y, z) + y * J_sushi(n, x + 1, y - 1, z) + z * J_sushi(n, x, y + 1, z - 1)) / (x + y + z);
}

int32_t main() {
	fastio;
	memset(dp, -1, sizeof dp);
	int n; cin >> n;
	int one{}, two{}, three{}; //No. of dishes having 1 sushies, two sushies and three sushies .NO. of zero sushies : N-(one + two + three)
	for (int i = 1; i <= n; i++) {
		int x; cin >> x;
		if (x == 1) one++;
		if (x == 2) two++;
		if (x == 3) three++;
	}
	cout << fixed << setprecision(10);
	cout << J_sushi(n, one, two, three) << endl;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

ll gcd(ll x, ll y){ return y? gcd(y, x%y): x; }

set<ll> ff(ll x){
	set<ll> r;
	for(ll i=1; i*i<=x; i++){
		if(x%i==0){
			r.insert(i);
			r.insert(x/i);
		}
	}
	return r;
}
bool isPrime( ll x ){
	if ( x < 2 ) return false;
	else if ( x == 2 ) return true;
	if ( x % 2 == 0 ) return false;
	int limit = (int)sqrt((double)x) + 1;
	for ( ll i = 3; i <= limit; i += 2 ){
		if ( x % i == 0 ) return false;
	}

	return true;
}
int main() {
	//cin.tie(0); ios_base::sync_with_stdio(false);
	ll a,b;
	cin >> a  >>b;

	auto ka = ff(a);
	auto kb = ff(b);
	ll ans =0;
	VL vv;
	for(auto z : ka){
		if(kb.count(z)) vv.push_back(z);
	}
	//for(auto x :vv) printf("%lld, ",x); puts("");
	rep(i, sz(vv)){
		if(isPrime(vv[i])) ans++;
	}
	
	cout << ans+1 <<"\n";
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define ld long double
#define mp make_pair

void print(auto &a)
{
    for (auto s: a) cout<<s<<' ';
    cout<<endl;
}

void get(vector<auto> &a)
{
    for (int i = 0; i<a.size(); i++) cin>>a[i];
}

const int p =  856;


int mul(int a, int b) {
    return (1LL * a%p * b%p) % p;
}

int add(int a, int b) {
    ll s = (a+b);
    s = s%p;
    if (s<0) s+=p; 
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}



vector<int> Z(string s)
{
int n = s.length();
vector<int> z(n);
int L = 0, R = 0;
for (int i = 1; i < n; i++) {
  if (i > R) {
    L = R = i;
    while (R < n && s[R-L] == s[R]) R++;
    z[i] = R-L; R--;
  } else {
    int k = i-L;
    if (z[k] < R-i+1) z[i] = z[k];
    else {
      L = i;
      while (R < n && s[R-L] == s[R]) R++;
      z[i] = R-L; R--;
    }
  }
}
return z;
}

mt19937 rnd(228);


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);

    int n;
    cin>>n;
    if (n%2==0)
    {
        int m = n/2;
        cout<<2*m*(m-1)<<endl;
        for (int i = 1; i<=m; i++)
        for (int j = 1; j<=m; j++) if (i<j)
        {
            cout<<i<<' '<<j<<endl;
            cout<<n+1-i<<' '<<j<<endl;
            cout<<n+1-i<<' '<<n+1-j<<endl;
            cout<<i<<' '<<n+1-j<<endl;
        }
    }
    else
    {
        int m = n/2;
        cout<<2*m*(m-1) + 2*m<<endl;
        for (int i = 1; i<=m; i++)
        for (int j = 1; j<=m; j++) if (i<j)
        {
            cout<<i<<' '<<j<<endl;
            cout<<n-i<<' '<<j<<endl;
            cout<<n-i<<' '<<n-j<<endl;
            cout<<i<<' '<<n-j<<endl;
        } 
        for (int i = 1; i<=2*m; i++) cout<<i<<' '<<2*m+1<<endl;
    }
}

Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long double ld;
 
#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif
 
#define sz(x) ((int) (x).size())
#define TASK "text"
 
const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);
 
mt19937 mrand(random_device{} ()); 
 
int rnd(int x) {
  return mrand() % x;
}
 
void precalc() {
}
 
long long gcd(long long a, long long b) {
  return (b ? gcd(b, a % b) : a);
}
 
long long a, b, c, d;
 
int read() {
  if (scanf("%lld%lld%lld%lld", &a, &b, &c, &d) < 4) {
    return false;
  }
  return true;
}
 
void solve() {
  if (a < b || d < b) {
    printf("No\n");
    return;
  }
  long long g = gcd(b, d);
  long long k = (b - (a % b) + g - 1) / g - 1;
  long long x = (a % b) + k * g;
  if (x > c) {
    printf("No\n");
    return;
  }
  printf("Yes\n");
}
 
int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  int t;
  scanf("%d", &t);
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}

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

int main(void) 
{
	int a,b,c;
	while (cin>>a>>b)
	{
		a += b;
		c = 0;
		while (a < 0, c++, a /= 10);
		cout << c << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3096
from collections import deque

(d,), cc, *ss = [list(map(int, s.split())) for s in open(0)]

ss = deque(ss)

acc = [0]*len(cc)

while d:
    acc = [sum(x) for x in zip(acc, cc)]
    gain = [sum(x) for x in zip(acc, ss.popleft())]
    m = min(gain)
    for i, g in enumerate(gain):
        if m == g:
            cur = i
            break
    print(cur+1)
    acc[cur] = 0
    d -= 1

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

int main () {
    int N, x;
    cin >> N >> x;
    vector<int> children(N);
    int count = 0;
    for (int i = 0; i < N; i++) {
        cin >> children.at(i);
    }
    sort(children.begin(), children.end());
    for (int i = 0; i < N; i++) {
        if (x >= children.at(i)) {
            count++;
            x -= children.at(i);
            if (x == 0) {
                break;
            }
        }
    }
    if (N <= count && x != 0) {
        count--;
    }
    cout << count << endl;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	cout << (a+b == c || b+c == a || c+a == b ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
x = list(map(int, input().split()))
sx = sorted(x)

m1 = sx[len(sx) // 2 - 1]
m2 = sx[len(sx) // 2]

for xi in x:
    if xi <= m1:
        print(m2)
    else:
        print(m1)

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  ll A, B, K;

  cin >> A >> B >> K;
  ll aA, aB;

  aA = max(A - K, 0LL);

  aB = max(B - max(K - A, 0LL), 0LL);

  cout << aA << " " << aB << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	
	int a[100],b[100],n,i;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		b[n-1-i]=a[i];
	}
	for(i=0;i<n;i++){
		printf("%d",b[i]);
		if(i!=n-1){
			printf(" ");
		}
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2032
#include <iostream>
#include <vector>
#include <algorithm> 
#include <map> 
#include <math.h>
#include <string>
using namespace std;



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

		if(n <= k){
			cout << 0 << endl;
			int x[n];
			for(int j = 0; j < n; j++){
				cin >> x[j];
			}
		}else{
			int x[n];
			for(int j = 0; j < n; j++){
				cin >> x[j];
			}


			sort(x, x + n);
			reverse(x, x + n);

			int ans = x[0] - x[n - 1];

			int y[n - 1];
			for(int j = 0; j < n - 1; j++){
				y[j] = x[j] - x[j + 1];
			}
			sort(y, y + n - 1);
			reverse(y, y + n - 1);
			for(int j = 0; j < k - 1; j++){
				ans = ans - y[j];
			}
			cout << ans << endl;
		}
		
	}

	return 0;
}

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


int main () {
  int A ,B ; 
  cin >> A >> B ; 
  long K ; 
  K = 0 ; 
  
  while( abs(A-K) != abs(B-K)){
    K++ ; 
    if (K >= 1000000000){
      cout << "IMPOSSIBLE" << endl ; 
      return 0 ; 
    }
  }
  
  cout << K << endl ; 
  
  
  
  
}

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

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  
  int c[n];
  int a[n][m];
  
  rep(i, n){
    cin >> c[i];
    rep(j, m){
      cin >> a[i][j];
    }
  }
  
  int res = -1;
  
  rep(i, 1<<n){
    int b[m];
    rep(j, m) b[j] = 0;
    int sumc = 0;
    
    rep(j, n){
      if(i>>j & 1){
        rep(k, m) b[k] += a[j][k];
        sumc += c[j];
      }
    }
    
    bool ok = true;
    rep(j, m){
      if(b[j] < x){
        ok = false;
        break;
      }
    }
    
    if(ok){
      //cout << sumc << endl;
      if(res == -1){
        res = sumc;
      }else{
        res = min(res, sumc);
      }
    }
    
  }
  
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 3632
def modpow(a,n,m):
  res=1
  while n>0:
    if n&1:res=res*a%m
    a=a*a%m
    n//=2
  return res
INF=10**9+7
n,m=map(int,input().split())
print(modpow(n,m,INF))


Measured memory_bytes: 5600
#include <iostream>

int main(int argc, char **argv)
{
    int h[26];
    for (int i = 0; i < 26; i++)h[i]= 0;
    std::string s;
    std::cin >> s;
    for (int i = 0; i < 4; i++) h[s[i] - 'A']++;
    int c = 0;
    for (int i = 0; i < 26; i++) if (h[i] == 2) c++;
    std::cout << (c ==2 ? "Yes" : "No") <<std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
  int d,n,x=1;
  cin >> d >> n;
  if(n==100){
    if(d==0){
      cout << 101 << endl;
      return 0;
    }
    else if(d==1){
      cout << 10100 << endl;
      return 0;
    }else{
      cout << 1010000 << endl;
      return 0;
    }
  }
  rep(i,d){
    x*=100;
  }
  cout << n*x << endl;
}


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

int PrefixAndSuffix (string s, string t) {
	int s1 = -1 , s2 = 0;
	for (int i = 0; i < s.size(); ++i) {
		if( s[i] == t[0])
		{
			if( s.substr(i) == t.substr(0,s.size()-i))
			{
				return i + t.size();
			}
		}
	}
	return s.size() + t.size();
}

int main() {

	string x , y ;
	int n ;
	cin >> n >> x >> y;

	cout << PrefixAndSuffix(x,y);
	return 0;
}


Measured memory_bytes: 256
import numpy as np
from numba import njit


n = int(input())
arr = np.array(list(map(int, input().split())))


n = 10**6 + 1
primes = set(range(3, n+1, 2))

for i in range(3, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes.add(2)


@njit
def solve(arr, primes):
    cnt = np.bincount(arr)
    for p in primes:
        if (cnt[p::p]).sum() > 1:
            return False
    else:
        return True


if np.gcd.reduce(arr) != 1:
    print("not coprime")
elif solve(arr, primes):
    print("pairwise coprime")
else:
    print("setwise coprime")

Measured memory_bytes: 209068
#include<bits/stdc++.h>
#include<algorithm>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;
int main()
{
    fast_io
    ll t,i,j,n,kth,ans,cnt=0,x,kopi;
    cin>>n>>kth;
    vector<pair<ll,ll>>v(n);
    for(i=0; i<n; i++)
    {
        cin>>v[i].first>>v[i].second;
    }
    sort(v.begin(),v.end());
    for(i=0; i<n; i++)
    {
        cnt+=v[i].second;
        if(cnt>=kth)
            return   cout<<v[i].first<<endl,0;
    }

    return 0;
}





Measured memory_bytes: 4712
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <string>
#include <map>
#include <algorithm>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <ctime>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
  	cin >> n;
  	vector<int> a(n);
  	for (int i = 0; i < n; i++)
      	cin >> a[i];
  	ll ans = 0;
  	for (int i = 1; i < n; i++) {
    	int cur = a[i - 1] - a[i];
      	if (cur > 0) {
        	a[i] += cur;
          	ans += cur;
        }
    }
  	cout << ans;
    return 0;
}

Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n = 0, m = 0, p = 0, q = 0, tot = 0;
pair<int, int> peo[200500], mid[200500];
bool used[200500];
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for(int i = 1; i <= n; i++) {
		cin >> peo[i].first >> peo[i].second;
		peo[i].second = m + 1 - peo[i].second;
	}
	sort(peo + 1, peo + n + 1);
	for(int i = 1; i <= n; i++)
		if(peo[i].first > p) p++, used[i] = true;
	for(int i = 1; i <= n; i++)
		if(not used[i]) tot++, mid[tot] = peo[i], swap(mid[tot].first, mid[tot].second);
	sort(mid + 1, mid + tot + 1);
	for(int i = 1; i <= tot; i++)
		if(mid[i].first > q) q++;
	cout << n - min(m, p + q) << endl;
	return 0;
}

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

#define int long long

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    int n,sum=0;
    cin>>n;
    for(int x=1;x<=n;x++){
      if((x%3)>0 && (x%5)>0){
        sum+=x;
      }
    }
    cout<<sum<<'\n';
    return 0;
}
/*

*/


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long
using namespace std;
template <typename T>void read(T &x){
	x = 0; int f(1); char c = getchar();
	for(;!isdigit(c);c = getchar()) if(c == '-') f = -1;
	for(;isdigit(c);c = getchar()) x = x*10+c-'0';
	x *= f;
}
int n; ll h[200005];
map<ll,int> a;
int main(){
	read(n); ll ans = 0;
	for(int i(1);i <= n;++i)
		read(h[i]),a[h[i]-i]++;
	for(int i(1);i <= n;++i){
		a[h[i]-i]--;
		ans += a[-h[i]-i];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 27872
#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int X, N;
    cin>>X>>N;
    vector<bool> P(101, true);
    REP(i, 0, N){
        int p;
        cin >> p;
        P[p] = false;
    }
    int s = 0, d = X;
    REP(i, 0, 101){
        if(P[i] && abs(X-i) < d){
            s=i;
            d = abs(X-i);
        }
    }
    if(abs(X-101) < d){
        s = 101;
        d = abs(X-101);
    }
    cout << s << endl;
}

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

int main() {
    string s;
    cin >> s;
    if(s == "Sunny") cout << "Cloudy" << endl; 
    if(s == "Cloudy") cout << "Rainy" << endl;
    if(s == "Rainy") cout << "Sunny" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<int,int> m;
int seq[100000];
int cunt=0;
int main()
{
	int n,a,b,i,j;
	int tmp;
	int ans=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&tmp);
		if(m.count(tmp)==0)
		{
			m[tmp]=1;
			seq[cunt++]=tmp;
		}			
		else
		{
			m[tmp]++;
		}
	}
	for(i=0;i<cunt;i++)
	{
		if(m[seq[i]]>=seq[i])
		{
			ans=ans+m[seq[i]]-seq[i];	
		}
		else if(m[seq[i]]<seq[i])
		{
			ans=ans+m[seq[i]];
		}
	}
	printf("%d",ans);
	return 0;
}

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

public class Main {


    public static void main(String[] args) {
        try (CustomReader in = new CustomReader()) {
            new Main().execute(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    public void execute(CustomReader in) throws IOException {
        int[] AB = in.readLineAsIntArray();
        int A = AB[0];
        int B = AB[1];

        int total = 0;

        if(A>=B){
            total +=A;
            A--;
        }else{
            total +=B;
            B--;
        }

        if(A>=B){
            total +=A;
            A--;
        }else{
            total +=B;
            B--;
        }

        System.out.println(total);

    }

    static class CustomReader extends BufferedReader {

        private static final int DEFAULT_BUF_SIZE = 2048;
        // private static final int DEFAULT_BUF_SIZE = 4096;
        // private static final int DEFAULT_BUF_SIZE = 8192;
        //private static final int DEFAULT_BUF_SIZE = 16384;
        // private static final int DEFAULT_BUF_SIZE = 1048576;

        public CustomReader() throws IOException {
            super(new InputStreamReader(System.in), DEFAULT_BUF_SIZE);
        }

        public int[] readLineAsIntArray() throws IOException {
            String[] strArray = this.readLine().split(" ");
            int[] intArray = new int[strArray.length];
            for (int i = 0, n = strArray.length; i < n; i++) {
                intArray[i] = Integer.parseInt(strArray[i]);
            }
            return intArray;
        }

        public long[] readLineAsLongArray() throws IOException {
            String[] strArray = this.readLine().split(" ");
            long[] longArray = new long[strArray.length];
            for (int i = 0, n = strArray.length; i < n; i++) {
                longArray[i] = Long.parseLong(strArray[i]);
            }
            return longArray;
        }


        public int[][] readAsIntMatrix(int rows, int columns) throws IOException {
            int[][] matrix = new int[rows][columns];
            for (int i = 0; i < rows; i++) {
                String[] r = this.readLine().split(" ");
                for (int j = 0; j < columns; j++) {
                    matrix[i][j] = Integer.parseInt(r[j]);
                }
            }
            return matrix;
        }
    }

}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
    int n0, n1;
    cin >> n0 >> n1;
    if(n0%2 != 0 && n1%2 != 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 整数の入力
h, w = map(int, input().split())
# h * w個の文字を入力
a = [[0]*w]*h
for i in range(h):
    a[i] = list(input())

# 空行削除
a = [ai for ai in a if "".join(ai) != "."*w]

# 空列削除, atに転置させたresultを詰め込む
at = []
for aj in zip(*a):
    if "".join(aj) != "."*len(aj):
        at.append(aj)

# 結果の出力
for ai in zip(*at):
    print("".join(ai))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define MAX_N 100000
using namespace std;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n, a[MAX_N+5];
int b[2][MAX_N+5];
int main() {
	read(n);
	for (int i = 1; i <= n; i++) read(a[i]);
	for (int i = 1; i <= n; i += 2) b[0][a[i]]++, b[0][0]++;
	for (int i = 2; i <= n; i += 2) b[1][a[i]]++, b[1][0]++;
	for (int i = 1; i <= MAX_N; i++) b[0][i] = b[0][0]-b[0][i];
	for (int i = 1; i <= MAX_N; i++) b[1][i] = b[1][0]-b[1][i];
	int p01 = 1, mi01 = b[0][1], p02 = 2, mi02 = b[0][2];
	int p11 = 1, mi11 = b[1][1], p12 = 2, mi12 = b[1][2];
	if (mi01 > mi02) swap(p01, p02), swap(mi01, mi02);
	if (mi11 > mi12) swap(p11, p12), swap(mi11, mi12);
	for (int i = 3; i <= MAX_N; i++) {
		if (b[0][i] < mi02) p02 = i, mi02 = b[0][i];
		if (b[1][i] < mi12) p12 = i, mi12 = b[1][i];
		if (mi01 > mi02) swap(p01, p02), swap(mi01, mi02);
		if (mi11 > mi12) swap(p11, p12), swap(mi11, mi12);
	}
	if (p01 ^ p11) printf("%d\n", mi01+mi11);
	else printf("%d\n", min(mi01+mi12, mi02+mi11));
	return 0;
}

Measured memory_bytes: 1408
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<cstring>
#include<string>
using namespace std;
int a[5];
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	for(int i=1;i<=3;i++){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+1+3);
	printf("%d\n",a[1]+a[2]);
	return 0;
}


Measured memory_bytes: 256
def convert(t, c):
    res = 0
    while len(set(t)) > 1:
        n = len(t)
        s = list(t)[:-1]
        for i in range(n-1):
            if (t[i] == c) or (t[i+1] == c):
                s[i] = c
        res += 1
        t = "".join(s)
    return res
def solve(t):
    ans = len(t)
    for c in set(t):
        ans = min(ans, convert(t, c))
    return ans
s = input()
print(solve(s))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    double s = 0;
    for (int i = 0; i < n; ++i)
    {
        double x; string u;
        cin >> x >> u;
        if (u == "JPY")
            s += x;
        else
            s += x * 380000.;
    }
    cout << s;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>

using namespace std;

int main()
{
	int m[10];

	for(int i=0;i<10;i++) cin>>m[i];

	for(int i=0;i<3;i++){
		int max=0;
		for(int j=1;j<10;j++){
			if(m[j]>m[max]) max=j;
		}
		cout<<m[max]<<endl;
		m[max]=0; max=0;
		
	}

	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    long long cnt = 0;
    if (n == 1) cnt = a.at(0) / 2;
    
    for (int i = 0; i < n - 1; i++) {
        cnt += (a.at(i) + a.at(i + 1)) / 2;
        if (a.at(i + 1) == 0) a.at(i + 1) = 0;
        else a.at(i + 1) = (a.at(i) % 2) ^ (a.at(i + 1) % 2);
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;
use std::cmp::{min, max};
use std::rc::Rc;
use std::mem::swap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin_lock = stdin.lock();
    let s = stdin_lock
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

static DX: &'static [i32] = &[0, 0, 1, -1];
static DY: &'static [i32] = &[1, -1, 0, 0];

fn dfs(x: usize, y: usize, a: i32, b: i32, dir: usize, map: &Vec<Vec<char>>, gx: usize, gy: usize) -> bool {
    if a < 0 || b < 0 {
        return false;
    }

    if map[y][x] == '#' {
        return false;
    }

    if x == gx && y == gy && a == 0 && b == 0{
        return true;
    }

    let mut ans = false;

    if dir == 0 {
        ans |= dfs(x + 1, y, a, b, 0, &map, gx, gy);
        ans |= dfs(x, y + 1, a, b - 1, 1, &map, gx, gy);
        ans |= dfs(x, y - 1, a - 1, b, 3, &map, gx, gy);
    } else if dir == 1 {
        ans |= dfs(x, y + 1, a, b, 1, &map, gx, gy);
        ans |= dfs(x + 1, y, a - 1, b, 0, &map, gx, gy);
        ans |= dfs(x - 1, y, a, b - 1, 2, &map, gx, gy);
    } else if dir == 2 {
        ans |= dfs(x - 1, y, a, b, 2, &map, gx, gy);
        ans |= dfs(x, y + 1, a - 1, b, 1, &map, gx, gy);
        ans |= dfs(x, y - 1, a, b - 1, 3, &map, gx, gy);
    } else {
        ans |= dfs(x, y - 1, a, b, 3, &map, gx, gy);
        ans |= dfs(x + 1, y, a, b - 1, 0, &map, gx, gy);
        ans |= dfs(x - 1, y, a - 1, b, 2, &map, gx, gy);
    }

    return ans;
}

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let k: i32 = read();

    for i in a..b + 1 {
        if i < a + k || b - k < i {
            println!("{}", i);
        }
    }
}

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

#define ll long long
#define pb push_back
#define vi vector<int>
#define sz(a) (int((a).size()))
#define mp make_pair
#define f first
#define s second
#define pii pair<int, int>

using namespace std;

const int N = 111;

int n;
int a[N + N];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n + n; i++) {
		cin >> a[i];
	}
	sort(a + 1, a + n + n + 1);
	int ans = 0;
	for (int i = 1; i <= n + n; i++) {
		if (i & 1) ans += a[i];
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) throws IOException {
    Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    int n = in.nextInt();
    int k = in.nextInt();
    int[] h = new int[n];
    for (int i = 0; i < n; i++) {
      h[i] = in.nextInt();
    }
    final Solver solve = new Solver();
    System.out.println(solve.solve(h, k));
  }
}

class Solver {
  public int solve(int[] h, int k) {
    int n = h.length;
    int[] dp = new int[n + 1];
    dp[1] = 0;
    for (int i = 2; i <= n; i++) {
      dp[i] = Integer.MAX_VALUE;
      for (int j = i - 1; j >= 1 && j >= i-k; j--) {
        dp[i] = Math.min(Math.abs(h[i - 1] - h[j - 1]) + dp[j], dp[i]);
      }
    }
    return dp[n];
  }
}


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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

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

    string s;
    cin >> s;

    string ans = "No";
    if(s[2] == s[3] && s[4] == s[5]){
        ans = "Yes";
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define pi          3.14159265358979323



void solve()
{
       ll n;
       cin>>n;
       ll a[n];
       rep(i,0,n) cin>>a[i];
       sort(a, a+n);
       reverse(a, a+n);
       ll num = a[0];
       ll mid = a[0] / 2;
       ll dif=num, num2;
       for(ll i=1; i<n; i++)
       {
              ll x = abs(a[i] - mid);
              if(x < dif)
              {
                     dif = x;
                     num2 = a[i];
              }
       }
       cout<<num<<" "<<num2<<endl;
}


int main()
{
       speed_up;
       ll T=1;
       //cin>>T;
       while(T--) solve();
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.*;
 public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
      //  int[]  arr = new int[n];
        Map<Integer,Integer> map = new HashMap<Integer,Integer>();
long sum =0;
        for(int i =0;i<n;i++){
            int f = sc.nextInt();
            map.put(f,map.getOrDefault(f, 0)+1);
            sum+=f;
        }
        int q = sc.nextInt();
        for(int j=0;j<q;j++){
            int b = sc.nextInt();
            int c = sc.nextInt();
            if(map.containsKey(b)){
                int num = map.get(b);

                sum+= num*(c-b);
                map.remove(b);
                map.put(c,map.getOrDefault(c, 0)+num);
            }
            System.out.println(sum);

        }
        sc.close();
    }
}

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

int main(){
  long long n;
  cin >> n;
  long long a, b;
  long long f = floor(sqrt(n));
  long long res = 100000000000000;
  for(int i=f; i>0; i--){
    if(n%i == 0){
      a = i;
      b = n/i;
      res = min(res,a+b-2);
    }  
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>

int lcs[3001][3001] = {};
int main() {
  std::string s, t; std::cin >> s >> t;
  int s_length = static_cast<int>(s.length());
  int t_length = static_cast<int>(t.length());

  for (int i = 1; i <= s_length; ++i) {
    for (int j = 1; j <= t_length; ++j) {
      if (s[i-1] == t[j-1]) {
        lcs[i][j] = lcs[i-1][j-1] + 1;
      } else {
        lcs[i][j] = std::max(lcs[i-1][j], lcs[i][j-1]);
      }
    }
  }

  int i = s_length, j = t_length;
  std::string ans;
  while (lcs[i][j] > 0) {
    if (s[i-1] == t[j-1]) {
      ans = s[i-1] + ans;
      --i;
      --j;
    } else {
      if (lcs[i-1][j] > lcs[i][j-1]) --i;
      else                           --j;
    }
  }

  std::cout << ans << std::endl;
}


Measured memory_bytes: 38752
#include <bits/stdc++.h>
using namespace std;
const int N = 202020;
long long n, m, k, a[N], b[N];

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> m >> k;
    a[0] = b[0] = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        a[i] += a[i - 1];
    }
    for (int i = 1; i <= m; i++)
    {
        cin >> b[i];
        b[i] += b[i - 1];
    }
    int ans = 0;
    for (int i = 0; i <= n; i++)
        if (a[i] <= k)
        {
            int j = upper_bound(b + 1, b + 1 + m, k - a[i]) - b - 1;
            ans = max(ans, i + j);
            //cout << a[i] << " " << k - a[i] << " " << i << " " << j << "\n";
        }
    cout << ans;
    return 0;
}

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

#define MAXD 10
#define PII pair<int,int>

int N,M,Q,col[100010],val[100010][11]; vector<int> g[100010];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> N >> M;
	
	int x,y,i;
	for (i=1; i<=M; i++){
		cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	
	int d;
	cin >> Q;
	for (i=1; i<=Q; i++){
		cin >> x >> y >> col[i];
		val[x][y]=i;
	}
	
	for (d=10; d>0; d--){
		for (i=1; i<=N; i++){
			for (int next : g[i]){
				val[next][d-1]=max(val[next][d-1],val[i][d]);
			}
			
			val[i][0]=max(val[i][0],val[i][d]);
		}
	}
	
	
	for (i=1; i<=N; i++)
		cout << col[val[i][0]] << "\n";
	return 0;
}


Measured memory_bytes: 11256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <cstring>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define DEBUG(x) cerr<<#x<<":"<<x<<endl;
#define ALL(c) (c).begin(),(c).end()
 
template<class T> void pv(T a, T b) {
	for(T it = a; it != b; ++it)
		cerr << *it << " ";
	cerr << endl;
}
 
vector<int> boat[50];
bool bad[50];
 
int main() {
	int N, K;
	cin >> N >> K;
	REP(i,K) {
		int m; cin >> m;
		REP(j,m) {
			int t; cin >> t;
			boat[i].push_back(t);
		}
	}
#if 0
	cerr << "-----" << endl;
	REP(i,K)
		pv(ALL(boat[i]));
	cerr << "-----" << endl;
#endif
	
	int R; cin >> R;
	memset(bad, 0, sizeof bad);
	REP(i,R) {
		int p, q; cin >> p >> q;
		REP(j,K) {
			if(find(ALL(boat[j]), p) != boat[j].end() &&
					find(ALL(boat[j]), q) != boat[j].end())
				bad[p-1] = bad[q-1] = true;
		}
	}
	cout << count(bad, bad + N, true) << endl;
}

Measured memory_bytes: 1220
from collections import defaultdict

# UnionFind
class UnionFind():
    # 作りたい要素数nで初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

# solution
N,M,K=list(map(int,input().split()))
group=UnionFind(N)
friend=defaultdict(int)
for _ in range(M):
    src,dst=list(map(int,input().split()))
    group.Unite(src-1,dst-1)
    friend[src-1]+=1
    friend[dst-1]+=1

block=defaultdict(list)
for _ in range(K):
    src,dst=list(map(int,input().split()))
    block[src-1].append(dst-1)
    block[dst-1].append(src-1)

ans=[]
for i in range(N):
    total=group.Count(i)
    num=total-1-friend[i]
    #remove block
    for b in block[i]:
        if group.isSameGroup(i,b):
            num-=1
    ans.append(num)

for i in ans:
    print(i,end=" ")
print()




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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)  
#define outdeb(fir, sec, thr) cout << fir << ":" << sec << ":" << thr << endl

int main()
{
  ll n;
  cin >> n;
  map<ll, ll> values;
  ll sum = 0;

  rep(i, n)
  {
    ll tmp;
    cin >> tmp;
    values[tmp] = values[tmp] + 1;
    sum += tmp;
  }

  ll q;
  cin >> q;
  repl(i, q)
  {
    ll b,c;
    cin >> b >> c;

    if(values.find(b) != values.end())
    {
      sum += (c-b) * values[b];
      values[c] = values[c] + values[b];
      values[b] = 0;
    }
    cout << fixed << sum << endl;
  }

  return 0;
}

Measured memory_bytes: 8628