akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        long x = sc.nextLong();
        long y = sc.nextLong();

        long ans = 0;
        if (a + b <= c * 2) {
            ans = a * x + b * y;
        } else {
            long cnt = Math.min(x, y);
            if (cnt % 2 == 1)
                cnt--;

            ans = c * cnt * 2;
            x -= cnt;
            y -= cnt;

            cnt = Math.min(x, y);
            if (a * cnt + b * cnt <= c * cnt * 2) {
                ans += a * cnt + b * cnt;
            } else {
                ans += c * cnt * 2;
            }
            x -= cnt;
            y -= cnt;

            if (a * x + b * y <= c * Math.max(x, y) * 2) {
                ans += a * x + b * y;
            } else {
                ans += c * Math.max(x, y) * 2;
            }
        }

        System.out.println(ans);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

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

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

Measured memory_bytes: 21332
fn main() {
    let n: usize = read();
    println!("{}", n.pow(3));
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

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

// =========



Measured memory_bytes: 5028
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	scan(N);
	ll MOD=1e+9+7;
	map<string,ll> dp;
	vector<string> moji;
	map<string,int> ban;
	char ch[4]={'A','G','C','T'};
	string ihan[6]={"AGC","GAC","ACG","AGTC","ATGC","AGGC"};
	if(N==3){
		prin("61"); return 0;
	}
	rep(i,4){
		rep(j,4){
			rep(k,4){
				string str="";
				str+=ch[i]; str+=ch[j]; str+=ch[k];
				moji.push_back(str);
				ban[str]=i*16+j*4+k;
			}
		}
	}
	rep(i,64) dp[moji[i]]=1;
	rep(l,3) dp[ihan[l]]=0;
	for(int i=3;i<N;i++){
		map<string,ll> newdp;
		rep(j,64){
			ll old=dp[moji[j]];
			rep(k,4){
				string newstr="";
				newstr+=moji[j][1]; newstr+=moji[j][2]; newstr+=ch[k];
				string chekku=moji[j]+ch[k];
				int flag=1;
				rep(l,6) if(chekku==ihan[l]||newstr==ihan[l]) flag=0;
				//printf("str: %s  flag: %d\n",chekku.c_str(),flag);
				if(flag){
					newdp[newstr]+=old;
					newdp[newstr]%=MOD;
				}
			}
		}
		dp=newdp;
	}
	ll ans=0;
	for(auto x:dp){
		ans+=x.second;
		ans%=MOD;
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int A[1000006];
int main()
{
    int n,x;
    cin>>n>>x;
    if(x==1 || x== 2*n-1)
    {
        cout<<"No";
        return 0;
    }
    cout<<"Yes\n";
    A[n-1] = x;
    A[n-2] = 1;
    A[n] = 2*n-1;
    int pre = 2;
    for(int i = 0;i<2*n-1;i++)
    {
        if(pre==x)
            pre++;
        if(abs(n-1-i)>1)
            A[i] = pre,pre++;;
        printf("%d\n",A[i]);
    } 

}

Measured memory_bytes: 2304
// abc134_c.cpp
#include <iostream>
#include <vector>

using namespace std;
int A[200000];
int N;
int main() {
	cin >> N;
	for (int i =0; i<N; i++){
		int a;
		cin >> a;
		A[i] = a;
	}

	int firstMax, fMV, firstMin, secondMax;

	firstMax = 0;

	firstMin = 0;
	
	for ( int i = 1; i< N; i++){
		if (A[firstMax] < A[i]){
			firstMax = i;
		}
		if (A[firstMin] > A[i]){
			firstMin = i;
		}
	}
	
	fMV=A[firstMax];
	A[firstMax] = A[firstMin];
	
	secondMax = 0;
	for ( int i = 1; i< N; i++){
		if (A[secondMax] < A[i]){
			secondMax = i;
		}
	}
	for(int i =0 ; i<N; i++){
		if(i != firstMax){
			cout << fMV << endl;
		}
		else{
			cout << A[secondMax] << endl;
		}
	}

	return 0;
}

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

#define REP(i, s, e) for(int i = (int)s; i < (int) e; i++)
#define rep(i, n) REP(i, 0 ,n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define fi first
#define se second
#define pb push_back
#define mp nake_pair

typedef long long ll;

typedef vector<int> vi;

int calc(int m, const vi& d){
    int ret = m;
    rep(i, 3) if(m > d[i]) return -1e9;
    rep(i, 3) ret += (d[i]-m)/3;
    return ret;
}

int main(){
    vi v(6);
    while(1){
        rep(i, 6) cin>>v[i];
        if(v[0]==0 && v[1] == 0 && v[2] == 0 && v[3] == 0 && v[4] == 0 && v[5] == 0) break;
        vi d(3);
        rep(i, 6) d[i%3] += v[i];
        double l = 0, r = 1e9;
        rep(i, 1000){
            double m1 = l + (r - l) / 3.0, m2 = l + (r - l) * 2.0/ 3.0;
            int f1 = calc(m1, d), f2 = calc(m2, d);
            if(f1 < f2) l = m1;
            else r = m2;
        }
        cout<<calc(r, d)<<endl;
    }
}

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

char input;
//turn it into as ascii digit; +1; convert back to char
int main(){
  cin >> input;
  if (input == 'z'){
    cout << 'z';
  }
  else{
    cout << char(int(input)+1);
  }
  
  return 0;
}

Measured memory_bytes: 256
/*
*          Name : chaitanya
*
*     Institute : ANITS,Visakhapatnam
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define infy  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll mod = 1000000007;
#pragma GCC optimization ("O3")
const int N = 1000010;
using namespace std;
int main()
{
 
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n,j=1;
  cin >> n;
  vector <int>v;
  for (int i = 0; i < n; ++i)
  {
    int a;
    cin >> a;
    if(a == j)
    {
      v.pb(a);
      j++;
    }
  }
  if(v.size() == 0)
    cout << -1;
  else
    cout << n-v.size();
  return 0;
} 


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

int main(){
    int N, ABC[3], L[8];
    cin >> N;
    for(int i=0; i<3; i++) cin >> ABC[i];
    for(int i=0; i<N; i++) cin >> L[i];

    int ans = 1e9;
    for(int b=0; b<(1<<(2*N)); b++){
        int bits = b;
        vector<int> l[3];
        for(int i=0; i<N; i++){
            if(bits%4 < 3) l[bits%4].push_back(L[i]);
            bits /= 4;
        }
        int cost = 0;
        for(int i=0; i<3; i++){
            if(l[i].size() == 0) cost = 1e9;
            cost += (l[i].size() - 1) * 10;
            int sum = accumulate(l[i].begin(), l[i].end(), 0);
            cost += abs(ABC[i] - sum);
        }
        ans = min(ans, cost);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <cstdlib>
#include<algorithm>
#include<string>
#define ll long long int
using namespace std;
 
int main()
{
  int n;
  cin>>n;
  vector <int> arr;
  for(int i=0;i<n;i++)
  {
  int temp;
  cin>>temp;
  arr.push_back(temp);
 
  }
 
  vector <int> ans(n,0);
  ans[0]=0;
  ans[1]=abs(arr[1]-arr[0]);
  for(int i=2;i<n;i++)
  {
  int temp=abs(arr[i]-arr[i-1]);
  int temp2=abs(arr[i]-arr[i-2]);
  ans[i]=min(ans[i-1]+temp,ans[i-2]+temp2);
  
  }
//  for(int i=0;i<n;i++)
 // cout<<ans[i]<<" ";
// cout<<endl;
  cout<<ans[n-1];
 // cin>>n;
  return 0;
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	int arr[n];
	vector<int> dp(n,INT_MAX);
	int c=0;
	for(int i=0;i<n;i++) {
		cin>>arr[i];
	}
	dp[0]=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<i+3;j++)
		{
			if(j<n)
			{
				dp[j]=min(abs(arr[i]-arr[j])+dp[i],dp[j]);
			}
		}
	}
	cout<<dp[n-1]<<endl;

return 0;
}

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

int main() {
  	int n; cin >> n;
  	int a[n];
  for (int i=0; i<n; i++) cin >> a[i];
  sort(a, a+n);
  int ok = 1;
  for (int i=0; i<n-1 && ok; i++) {
  	if (a[i] == a[i+1]) ok = 0;
  }
  if (ok) cout << "YES\n"; else cout << "NO\n";
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n;
  scanf("%d",&n);
  deque<int> Q;
  REP(i,n){
    int a;
    scanf("%d",&a);
    if(i%2==0){
      Q.push_back(a);
    }else{
      Q.push_front(a);
    }
  }
  if(n%2==0){
    REP(i,n)printf("%d%c",Q[i],i==n-1?'\n':' ');
  }else{
    REP(i,n)printf("%d%c",Q[n-1-i],i==n-1?'\n':' ');
  }
  return 0;
}


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

int main() {
  string S;
  int count =0;
  for(int i=0; i<4; i++) {
    cin >> S;
    if(S[i]=='+') count++;
    if(S[i]=='-') count--;
  }
  cout << count << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	string s; cin >> s;
	s[5] = s[13] = ' ';
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var sol = new Solve();
        sol.Exec();
    }
}

class Solve
{
    public void Exec()
    {
        var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int N = l[0], K = l[1];

        var ans = "";
        while (N > 0)
        {
            var rem = N % K;
            N /= K;
            ans += rem;
        }

        Console.WriteLine(ans.Length);
    }
}


Measured memory_bytes: 13268
// inputに入力データ全体が入る
function Main(input) {
  input = input.split('\n');
  var answer = 0;

  var red = []; 
  var blue = []; 
  var switched = false;

  function Point(x, y) {
    this.x = parseInt(x, 10);
    this.y = parseInt(y, 10);
  }

  for (var i = 1; i < input.length; i++) {
    if (i === parseInt(input[0]) + 1) {
      switched = true;
    }

    if (switched) {
      blue.push(new Point(...input[i].split(' ')));
    } else {
      red.push(new Point(...input[i].split(' ')));
    }
  }

  function isFriendly(red, blue) {
    return red.x < blue.x && red.y < blue.y;
  }


  function getBlueWithSmallestX() {
    var smallest;
    blue.forEach((thisBlue) => {
      if (!smallest || thisBlue.x < smallest.x) {
	smallest = thisBlue;
      }
    })
    blue.splice(blue.indexOf(smallest), 1);
    return smallest;
  }

  function getMatchWithBiggestY(bluePoint) {
    var bestMatch;
    red.forEach((thisRed) => {
      if (isFriendly(thisRed, bluePoint)) {
	if (!bestMatch || thisRed.y > bestMatch.y) {
	  bestMatch = thisRed;
	}
      }
    })
    return bestMatch;
  }


  while (blue.length > 0) {
    var thisBlue = getBlueWithSmallestX();
    var bestMatch = getMatchWithBiggestY(thisBlue);

    if (bestMatch) {
      answer++;
      red.splice(red.indexOf(bestMatch), 1);
    }
  }



  // 出力
  console.log(answer);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));



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

using namespace std;
typedef long long ll;
ll p[20];
int main()
{
    ll a,b,c,d,e,f,g;
   for(ll i=0;i<5;i++)
    cin>>p[i];
      for(ll i=0;i<5;i++)
        if(p[i]==0)
        cout<<i+1<<endl;
    return 0;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n, m) for (int i = n; i < m; i++)
#define ll long long int

using namespace std;

int main()
{
  int n, x;
  cin >> n >> x;
  int l[100];
  REP(i, n)
  {
    cin >> l[i];
  }

  int result = 1;
  int d = 0;
  REP(i, n)
  {
    d += l[i];
    if (d <= x)
    {
      result++;
    }
  }
  cout << result << endl;
}


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

#define ll long long

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll k;
    cin >> k;
    if(k<=10) cout << k << "\n";
    else{
        queue<ll> q;
        for(int i=1; i<=9; i++){
            q.push(i);
        }
        k=k-9;
        while(k)
        {
            ll p = q.front();
            q.pop();
            if(p%10!=0){
                q.push(10*p+(p%10)-1);
                k--;
            }
            if(k==0) break;
            q.push(10*p+(p%10));
            k--;
            if(k==0) break;
            if(p%10!=9){
                q.push(10*p+(p%10)+1);
                k--;
            }
        }
        cout << q.back() << "\n";
    }

    return 0;
}

Measured memory_bytes: 768
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]
graph = [[] for i in range(n)]
for a,b in ab:
  a -= 1
  b -= 1
  graph[a].append(b)
  graph[b].append(a)
q = int(input())
query = [list(map(int,input().split())) for i in range(q)]
query = query[::-1]
depth = [-1 for i in range(n)]
color = [0 for i in range(n)]
stack = []
for v,d,c in query:
  v -= 1
  if depth[v] < d:
    stack.append((v,d))
  while stack:
    x,dep = stack.pop()
    if color[x] == 0:
      color[x] = c
    for y in graph[x]:
      if depth[y] < dep-1:
        stack.append((y,dep-1))
        depth[y] = dep-1
print(*color,sep="\n")

Measured memory_bytes: 104796
#include<stdio.h>
#include<string.h>
#define N 20000
typedef struct Data{
  int area,posi;
}Data;
 
Data t[N];
int u[N],n,i,T,U,ans,A;
char str1[N+1];
 
Data X,Y;
 
void Dpush(Data data)
{
  t[T++]=data;
}
Data Dpop()
{
  return t[--T];
}
void push(int x)
{
  u[U++]=x;
}
int pop()
{
  return u[--U];
}
void init()
{
  ans=U=T=0;
}
 
Data mkData(int x,int y)
{
  Data res;
  res.area=x;
  res.posi=y;
 
  return res;
}
 
int main(){
  init();
  scanf("%s",str1);
  n=strlen(str1);
 
  for(i=0;i<n;i++){
 
    if(str1[i]=='/'){
      if(U==0)
    continue;
    A=pop();
    X=mkData(i-A,A);
    ans+=i-A;
    while(T>0){
      Y=Dpop();
      if(Y.posi<A){
        Dpush(Y);
        break;
      }
      X.area+=Y.area;
      if(Y.posi<X.posi)
        X.posi=Y.posi;
    }
    Dpush(X);
    }
    else if(str1[i]=='\\'){
      push(i);
    }
  }
  printf("%d\n%d",ans,T);
  for(i=0;i<T;i++){
    printf(" ");
    printf("%d",t[i].area);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 1856
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[100010];
int B[100010];
int C[100010];

signed main(){
	cin>>N;
	REP(i,N)cin>>A[i];
	REP(i,N)cin>>B[i];
	REP(i,N)cin>>C[i];
	sort(A,A+N);sort(B,B+N);sort(C,C+N);
	int ans=0;
	REP(i,N){
		if(A[0]>=B[i])continue;
		int ok=0,ng=N;
		while(abs(ok-ng)>1){
			int mid=(ok+ng)/2;
			if(A[mid]<B[i]){
				ok=mid;
			}
			else{
				ng=mid;
			}
		}
		int X=ok+1;
		if(C[N-1]<=B[i])continue;
		ok=N-1,ng=-1;
		while(abs(ok-ng)>1){
			int mid=(ok+ng)/2;
			if(C[mid]>B[i]){
				ok=mid;
			}
			else{
				ng=mid;
			}
		}
		int Y=(N-1)-ok+1;
		ans+=X*Y;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;

int main(){
  int A,B,C;
  string S;
  int N;
  cin >> A >> B;
  if(A%B==0){
    //ない
    cout << -1 << endl;
  }
  else{
    cout << A << endl;
  }
}


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

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


    int n,k;
    cin >> n >> k;
    vector<int> h(n+1, 0);
    rep(i,n) cin >> h[i+1];
    
    vector<int> dp(n+1, INF);
    dp[0] = dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);
    
    for(int i=3; i<=n; i++){
        for(int j=1; j<=k && i-j>=1; j++){
            dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]));
        }
    }
    
    cout << dp[n] << endl;

    return 0;
}

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

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

    double time = m * 1900 + (n - m) * 100;
    double p = double(1) - double(1) / double(1 << m);
    double pp = p;

    double ex = 0;

    for(int i = 1; i <= 10000; i++)
    {
        ex += double(i) * time * pp;
        pp *= p;
    }

    double ip = double(1) - p;

    ex *= ip;

    ex += time;

    cout << llround(ex) << endl;
    return 0;
}

Measured memory_bytes: 256
/*{{{*/
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    LL N;
    R(N);
    VL p;
    for(LL i=1;i*i<=N;i++){
        if(N%i==0)p.PB(i),p.PB(N/i);
    }
    SORT_UNIQUE(p);
    int an=0;
    for(LL x: p){
        if(x==1)continue;
        LL now=N;
        while(now%x==0)now/=x;
        if(now%x==1)an++;
    }
    N--;
    p.clear();
    for(LL i=1;i*i<=N;i++){
        if(N%i==0)p.PB(i),p.PB(N/i);
    }
    SORT_UNIQUE(p);
    for(LL x: p){
        if(x>1)an++;
    }
    W(an);
    return 0;
}


Measured memory_bytes: 384
fun main(args:Array<String>):Unit {
    while (true) {
        val n = readLine()!!.trim().toInt()
        if (n == 0) return
        val judges = Array(n) { readLine()!!.toInt() }
        with(judges) {
            println((sum() - max()!! - min()!!) / (n - 2))
        }
    }
}


Measured memory_bytes: 29088
s = input()
l = len(s)

for i in range(l-2):
    if s[i] == s[i+1]:
        print(i+1, i+3)
        exit(0)
    elif s[i] == s[i+2]:
        print(i+1, i+3)
        exit(0)
if s[-1] == s[-2]:
    print(l-2 if l > 2 else l - 1, l)
else:
    print(-1, -1)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int h, a; scanf("%d%d", &h, &a);
	
	printf("%d\n", (h + a - 1) / a);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

// https://qiita.com/keymoon/items/11fac5627672a6d6a9f6
class rollinghash
{
public:
  const ll MOD = (1LL << 61) - 1;
  const ll MASK61 = MOD;
  const ll MASK31 = (1LL << 31) - 1;
  const ll MASK30 = (1LL << 30) - 1;
  const ll Base = rand() % 1024 + 256;
  const ll POSITIVISER = MOD * 3;

  ll mul(ll a, ll b)
  {
    ll au = a >> 31; // (a / MASK31)
    ll ad = a & MASK31; // (a % MASK31)
    ll bu = b >> 31;
    ll bd = b & MASK31;
    ll m = au * bd + ad * bu;
    ll mu = m >> 30;
    ll md = m & MASK30;

    return au * bu * 2 + mu + (md << 31) + ad * bd;
  }

  ll calcmod(ll x)
  {
    ll xu = x >> 61;
    ll xd = x & MASK61;

    ll ret = xu + xd;
    if (ret >= MOD)
      ret -= MOD;

    return ret;
  }

  vector<ll> powmem;
  vector<ll> hash;

  rollinghash(string S)
  {
    ll N = S.size();

    powmem.resize(N + 1);
    powmem.at(0) = 1;
    for (ll i = 0; i < N; i++)
    {
      powmem.at(i + 1) = calcmod(mul(powmem.at(i), Base));
    }
    
    hash.resize(N + 1);
    hash.at(0) = 1;
    for (ll i = 0; i < N; i++)
    {
      hash.at(i + 1) = calcmod(mul(hash.at(i), Base) + S.at(i));
    }
  }

  ll sub(ll pos, ll len)
  {
    return calcmod(hash.at(pos + len) + POSITIVISER - mul(hash.at(pos), powmem.at(len)));
  }
};

int main()
{
  string T, P;
  cin >> T >> P;
  ll N = T.size(), M = P.size();

  rollinghash rol(T + P);
  for (ll i = 0; i <= N - M; i++)
  {
    if (rol.sub(i, M) == rol.sub(N, M))
      cout << i << '\n';
  }
}


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

typedef long long ll;
int n, c[500233];
pair<int, int> a[1000233];

int main() {
  scanf("%d", &n);
  ll s1 = 0, s2 = 0;
  for (int i = 1, x, y; i <= n; i++) {
    scanf("%d%d", &x, &y);
    a[i] = make_pair(x, i);
    a[i + n] = make_pair(y, i);
    s1 += x;
    s2 += y;
  }
  sort(a + 1, a + 1 + n * 2, greater<pair<int, int>>());
  ll ans = max(s1, s2), cur = 0;
  int ok = 0;
  for (int i = 1; i <= n; i++) {
    if (c[a[i].second]) ok = 1;
    c[a[i].second] = 1;
    cur += a[i].first;
  }
  if (ok) {
    ans = max(ans, cur);
  } else {
    for (int i = n + 1; i <= n * 2; i++) {
      if (a[i].second != a[n].second) {
        ans = max(ans, cur + a[i].first - a[n].first);
      } else {
        ans = max(ans, cur + a[i].first - a[n - 1].first);
      }
    }
  }
  printf("%lld\n", s1 + s2 - ans);
}


Measured memory_bytes: 3840
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#include<bits/stdc++.h>
using ll = int;
using pii = std::pair<int,int>;
using namespace std;
template<class T>T chmin(T a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T b,T a){if(a<b){a^=b;b^=a;a^=b;return 1;}return 0;}

string str;
void input(){
    cin>>str;
}
void src(){
    
    int n=str.size();
    bool flg=false;
    int cR=0;
    int cL=0;
    int Rbegin=0;
    int Rend=0;
    int Lbegin=0;
    int Lend=0;
    vector<int> child(n+1,0);
    str.push_back('R');
    rep(i,n){
        if(str[i]=='R') cR++;
        if(str[i]=='L') cL++;
        if(str[i]!=str[i+1]){
            if(str[i]=='R'){
                Rend=i;
                Lbegin=i+1;

            }else{
                Lend=i;
                child[Rend  ]=(Rend-Rbegin+1+1)/2+(Lend-Lbegin+1)/2;
                child[Lbegin]=(Lend-Rbegin+1-child[Rend]);
                Rbegin=i+1;
            }
        }
    }
    rep(i,n) cout<<child[i]<<" ";
    return;
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 1104
#include <bits/stdc++.h>
#define endl '\n'
#define all(a) (a).begin(), (a).end()
#define len(a) (int) (a).size()
#define forn(i, n) for (int (i) = 0; (i) < (n); ++(i))
#define int long long
using namespace std;
void solve();
mt19937 rnd(2007);
signed main(){
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    swap(rng, rnd);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    solve();
} // Code


const int mod = 998244353;
void solve() {
    int n; cin >> n; vector<int> a(n); forn (i, n) cin >> a[i];
    if (a[0] != 0){
        cout << 0 << endl;
        return;
    }
    if (count(all(a), 0) != 1){
        cout << 0 << endl;
        return;;
    }
    sort(all(a));
    forn (i, n - 1){
        if (a[i + 1] > a[i] + 1){
            cout << 0 << endl;
            return;
        }
    }
    map<int, int> cnt;
    int ans = 1;
    for (auto i : a){
        if (i != 0){
            ans *= cnt[i - 1];
            ans %= mod;
        }
        cnt[i]++;
    }
    cout << ans << endl;
}




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

int main()
{
	int A;
	int B;
	cin >> A >> B;
	
	// 入力された九九の結果
	int result = A * B;
	
	if (A > 9 || B > 9)
	{
		result = -1;
	}
	
	// 出力
	cout << result << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.lang.Exception

var nodeList = arrayListOf<Treee>()

fun main(args: Array<String>) {

    val count = readLine()!!.toLong()
    for (i in 1..count) {
        val order = readLine()!!
        when {
            order.contains("insert") -> {
                insert(order.split(" ")[1].toInt())
            }
            order.contains("print") -> {
                printByInorder(nodeList[0])
                println()
                printByPreorder(nodeList[0])
                println()
            }
        }
    }
}

fun insert(addedKey: Int) {
    val addedNode = Treee(nodeList.count(), key = addedKey)

    if (nodeList.count() == 0) {
        nodeList.add(addedNode)
        return
    }

    // ルートノーのから開始
    var x = nodeList[0]
    while (true) {
        if (x.key < addedKey) {

            // 右に配置
            if (x.right == null) {
                x.right = addedNode
                break

            } else {
                x = x.right!!
            }
        } else if (x.key > addedKey) {

            // 左に配置
            if (x.left == null) {
                x.left = addedNode
                break;

            } else {
                x = x.left!!
            }

        } else {
            throw Exception("key is duplicated!!!")
        }
    }

    nodeList.add(addedNode)
}

fun printByPreorder(node: Treee) {

    print(" ${node.key}")

    if (node.left != null) {
        printByPreorder(node.left!!)
    }

    if (node.right != null) {
        printByPreorder(node.right!!)
    }
}


fun printByInorder(node: Treee) {

    if (node.left != null) {
        printByInorder(node.left!!)
    }

    print(" ${node.key}")

    if (node.right != null) {
        printByInorder(node.right!!)
    }
}

data class Treee(
    var id: Int,
    var parent: Int = -1,
    var left: Treee? = null,
    var right: Treee? = null,
    var key: Int
)


Measured memory_bytes: 192184
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;
const int N=1e6+5;
int fact[N];

void pre(){
	fact[0]=1;
	for(int i=1;i<N;i++){
		fact[i]=(fact[i-1]*i)%M;
	}
}

int power(int a,int x){
	if(x==0) return(1);
	int p=power(a,x/2);
	p=(p*p)%M;
	if(x%2==0) return(p);
	return((p*a)%M);
}

int32_t main(){
    IOS;
    pre();
    int x,y;
    cin>>x>>y;
    if(x>y) swap(x,y);
    int X=(y-x);
    x-=X;
    y-=2*X;
    if(x==y&&x>=0){
    	if(x%3==0){	
    		int ans=fact[(x/3)*2+X];
    		ans=(ans*power(fact[x/3+X],M-2))%M;
    		ans=(ans*power(fact[x/3],M-2))%M;
    		cout<<ans<<endl;
    	}
    	else cout<<0<<endl;
    }	
    else cout<<0<<endl;
}

Measured memory_bytes: 8064
a, b, c, k = map(int, input().split())

max_num = 0

if k <= a:
    max_num = k
    print(max_num)

else:
    max_num = a
    k -= a
    if k < b:
        print(max_num)
    else:
        k -= b
        max_num -= k
        print(max_num)


Measured memory_bytes: 9180
S = list(input())
N = len(S)
M = ["A","G" ,"C" ,"T"]

cnt = 0
Ans = 0
for i in range(N):
    if S[i] in M:
        cnt += 1
        Ans = max(Ans, cnt)
    else:
        Ans = max(Ans, cnt)
        cnt = 0
print(Ans)

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

int solve(int a, int b){
    //Escolhe o maior dentre os 3 cenários possíveis
    return max({2*a-1, 2*b-1, a+b});
}
int main(){
    int a,b;
    cin>>a>>b;
    cout<<solve(a,b)<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define rep(i, a, b) for(int i=a; i<b; i++)
#define per(i, a, b) for(int i=b-1; i>=a; i--)
#define ifor(n) for(int i=0;i<n;i++) 
#define jfor(n) for(int j=0;j<n;j++)
#define Ifor(n) for(int i=1;i<n;i++) 
#define Jfor(n) for(int j=1;j<n;j++)
const int inf=0x3f3f3f3f;
int main(){
	int n;
	cin>>n;
	int flag=0;
	ifor(n){
		int a;
		cin>>a;
		if(a%2==0&&a%3!=0&&a%5!=0)flag=1;
	}
	if(flag==1)cout<<"DENIED"<<endl;
	else cout<<"APPROVED"<<endl;
}

Measured memory_bytes: 256
# include <stdio.h>
int a[103], b[103];
int main()
{
    int p1=0, p2=0, m=100;
    long long n;
    scanf("%lld",&n);
    ++n;
    while(n > 1)
    {
        if(n&1) a[++p1] = m--, --n;
        else b[++p2] = m--, n>>=1;
    }
    printf("%d\n",p1+p2<<1);
    for(int i=1; i<=p1; ++i)
        printf("%d ",a[i]);
    for(int i=p2; i>=1; --i)
        printf("%d ",b[i]);
    for(int i=101-p1-p2; i<=100; ++i)
        printf("%d ",i);
    puts("");
    return 0;
}


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

const ll mod=998244353;
ll jc[2000050];
ll quickpower(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1) res=res*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return res%mod;
}

void qjc(ll n){
    jc[0]=1;
    for(ll i=1;i<=n;i++) jc[i]=jc[i-1]*i%mod;
    return;
}
ll c(ll a,ll b){
    return jc[a]*quickpower((jc[b]*jc[a-b])%mod,mod-2)%mod;
}
int main(){
    ll n,m,k,ans=0;
    cin>>n>>m>>k;
    qjc(n);
    for(ll i=0;i<=k;i++){
        ans=(ans+m*c(n-1,i)%mod*quickpower(m-1,n-1-i)%mod)%mod;
    }
    cout<<ans%mod;
}


Measured memory_bytes: 5196
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e12
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn=100000;

int main(){
    
    int button[maxn]={0};
    int n;
    int ans=0;
    int next=0;
    cin >> n;
    
    rep(i,n){
        int c;
        cin >> c;
        c--;
        button[i]=c;
    }
    
        ans++;
        next = button[0];
        while(next != 1&&ans<n){
            ans++;
            next = button[next];
        }
    
    if(ans==n){
        cout << -1<<endl;
    }else{
        cout << ans<<endl;
    }
    
    
    
    return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int MaxN = 1e5;
int n;
long long k;
struct pp{
	int x, y;
}a[MaxN + 5];
int cmp(pp z,pp c)
{
	return z.x < c.x;
}

int main()
{
	scanf("%d%lld",&n,&k);
	for(int i = 1; i <= n; i++)
	{
		scanf("%d%d",&a[i].x,&a[i].y);
	}
	sort(a + 1, a + n + 1,cmp);
	long long sum = 0;
	for(int i = 1; i <= n; i++)
	{
		sum += a[i].y;
		if(sum >= k){
			printf("%d\n",a[i].x);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  for(int i = 1; i <= b; i++){
    int mod = (a*i) % b;
    if(mod == c){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}


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

#define pi 3.14159265358979323846264

#define ll long long
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)

#define sp(n) setprecision(n)
#define d7 1000000007
#define mkp make_pair
#define mkt make_tuple

using namespace std;

bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}

ll binomialCoeff(ll n, ll k){
    ll C[n + 1][k + 1];ll i, j;
    for (i = 0; i <= n; i++){
        for (j = 0; j <= min(i, k); j++){
            if (j == 0 || j == i){C[i][j] = 1;}
            else{C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);}}}
    return C[n][k];
 }

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

ll srihrg(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}


int main(int argc, const char * argv[]) {
 //cout<<"Om\n";
 //Praise to Lord
 //make cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);cout.tie(NULL);
// code now
   
    ll n;cin>>n;
    ll a[n];
    fori(n) cin>>a[i];
    map<ll,ll> mp;
    vector<ll> v;
    fori(n){
        if(mp[a[i]]==0) v.push_back(a[i]);
        mp[a[i]]++;
    }
    ll sum=0;
    
    fori(v.size()){
        if(mp[v[i]]>1){
            ll hj=mp[v[i]];
            sum+=(hj*hj-hj)/2;
        }
    }
    fori(n){
        if(mp[a[i]]==1){cout<<sum<<endl;}
        else{
            if(mp[a[i]]==2){cout<<sum-1<<endl;}
            else{
                ll ac,vb;
                ac=mp[a[i]];
                vb=mp[a[i]]-1;
                ac=(ac*ac-ac)/2;
                vb=(vb*vb-vb)/2;
                ll hj=sum-ac+vb;
                cout<<hj<<endl;
            }}
    }
    
//code ends
    return 0;
}


Measured memory_bytes: 12020
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using i64 = int64_t;
using point = pair<int, int>;

int32_t main()
{
    double r;
    cin >> r;

    printf("%lf", 2.0 * r * M_PI);
}


Measured memory_bytes: 3776
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *
 
 
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
 
 
if __name__ == '__main__':
    a = int(input())
 
    count = 0
 
    for i in range(1,a+1):
        if i %3 > 0 and i % 5 >0:
            count += i
    print(count)

Measured memory_bytes: 10540
#include <cstdio>
#include <cctype>
using namespace std;
 
int main(){
	char ch;
	while(1){
    	scanf("%c", &ch);
    	if(isalpha(ch)){
	    	if(isupper(ch))printf("%c", tolower(ch));
	    	if(islower(ch))printf("%c", toupper(ch));
	 	}
		else{
			printf("%c", ch);
			if(ch =='\n')
				break;
    	}
    }
}


Measured memory_bytes: 2556
#include<stdio.h>
#include <string.h>
#include<math.h>
#include<iostream>
using namespace std;

int main()
{
    int N;
    char c[200001];
    double x, y;
    int ans = -1;
    int count = 0;
    int i, j;


    cin >> N;

    for (i = 0; i < N; i++) {
        cin >> c[i];
    }

    i = 0;
    j = N - 1;
    while (1) {
        while (c[i] == 'R')
            i++;

        while (c[j] == 'W')
            j--;
        if (i < j) {
            c[i] = 'R';
            c[j] = 'W';
            count++;
        }
        else {
            break;
        }
    }

    for (; i < N; i++) {
        if (c[i] == 'R') {
            c[i] = 'W';
            count++;
        }
    }

    cout << count << endl;


    return 0;
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

const int dx[] = { -1 , 0 , 0 , 1 } ;
const int dy[] = { 0 , -1 , 1 , 0 } ;

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

void solve ( int test_case )
{
    int a , b , k ;
    cin >> a >> b >> k ;

    for ( int i = min ( a , b ) ; i > 0 ; i-- )
    {
        if ( a % i == 0 && b % i == 0 )
        {
            k -- ;
            if ( k == 0 )
            {
                cout << i ; line ; R ;
            }
        }
    }
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		int n = readInt(r);
		int[] price = new int[n];
		for(int i = 0 ; i < n ; i++) price[i] = readInt(r);

		int max = -2000000000;
		int min = price[0];
		for(int x = 1 ; x < n ; x++){
			max = Math.max(max,price[x] - min);
			min = Math.min(min,price[x]);
		}

		System.out.println(max);
	}

	public static int readInt(BufferedReader r) throws Exception{
		return Integer.parseInt(r.readLine());
	}

}

Measured memory_bytes: 42920
fun main(args: Array<String>) {
    val N = nextInt()
    val D = listOfLong()
    val S = D.sum()
    val Y = LongArray(N) { 0L }
    var x = 0L; for (n in 1..N - 1 step 2) x += D[n]
    Y[0] = S - x * 2
    for (n in 0 until N - 1) Y[n + 1] = 2 * D[n] - Y[n]
    println(Y.joinToString(separator = " "))
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfLong(delta: Long = 0L) = listOfString().map { it.toLong() + delta }


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;


int main() {
    // ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vi arr (N);
	F0R(i, N) cin >> arr[i];

	vi ans;

	F0R(i, N) {
		R0F(j, arr.size()) if (arr[j] == j + 1) {
			ans.push_back(arr[j]);
			arr.erase(arr.begin()+j);
			break;
		}
	}
	if (ans.size() != N) {
		print(-1);
	} else {
		reverse(ans.begin(), ans.end());
		for (int x : ans) print(x);
	}
}

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

int main(){
    string s;
    cin >> s;
    cout << s << flush;
    if(s[s.length()-1]=='s'){
        cout << "es" << endl;
    }else{
        cout << 's' << endl;
    }
}

Measured memory_bytes: 3628
import sys

input = sys.stdin.readline

def main():
    snflg = True
    ewflg = True
    S = input().rstrip('\n')
    if 'S' in S or 'N' in S:
        snflg = False       
        if 'S' in S and 'N' in S:
            snflg = 'Yes'
    if 'E' in S or 'W' in S:
        ewflg = False
        if 'E' in S and 'W' in S:
            ewflg = 'Yes'
    if snflg and ewflg:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ManyFunctions
{
	public static class Program
	{
		public static void Main(string[] args)
		{
			var s = Console.ReadLine();

			Console.WriteLine(ManyFunctions(s, ""));
		}

		public static string ManyFunctions(string s, string sp)
		{
			if(s.Length == 1) {
				sp += s;
				var sum = int.Parse(sp[0].ToString());
				var isPlus = false;

				foreach (var c in sp.Remove(0, 1)) {
					switch (c) {
						case '+':
							isPlus = true;
							break;
						case '-':
							isPlus = false;
							break;
						default:
							var x = int.Parse(c.ToString());
							if (isPlus) {
								sum += x;
							} else {
								sum -= x;
							}
							break;
					}
				}

				return sum == 7 ? sp + "=7" : "";
			}

			sp += s[0].ToString();
			s = s.Remove(0, 1);

			//+
			var ret = ManyFunctions(s, sp + "+");

			if(ret != "") {
				return ret;
			}

			//-
			ret = ManyFunctions(s, sp + "-");

			if (ret != "") {
				return ret;
			}

			return "";
		}
	}
}


Measured memory_bytes: 13140