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

public class Main{
 
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int i,j,n,max=0,min=0,dist=0;
        n=scan.nextInt();
        int r[]=new int [n];
        for(i=0;i<n;i++) {
            r[i]=scan.nextInt();
            if(r[max]<r[i]) {
                max=i;
            }
            if(r[min]>r[i]) {
                min=i;
            }
        }
        if(min<max) {
            System.out.println(r[max]-r[min]);
            scan.close();
            return;
        }
        
        min=r[0];
        for(i=1;i<n;i++){
        	if(i==1){
        		dist=r[i]-min;
        	}
        	if(dist<r[i]-min){
        		dist=r[i]-min;
        	}
        	if(min>r[i]){
        		min=r[i];
        	}
        }
        System.out.println(dist);
        scan.close();
    }
}



Measured memory_bytes: 71556
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <cmath>
 
using namespace std;
 
// typedef
typedef long long ll;
typedef long double ldbl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
 
// container util
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for (typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
// repetition
#define FOR(i,m,n) for (ll (i) = ((ll) m); (i) < ((ll) n); ++(i))
#define RFOR(i,m,n) for (ll (i) = ((ll) (m)-1); (i) >= ((ll) n); --(i))
#define REP(i,n) FOR(i,0,n)
 
// i/o
#define TFOUT(b,t,f) cout << ((b)? (t) : (f)) << endl
 
//constant
const double    EPS        = 1e-10;
const double    PI         = acos(-1.0);
const int       INFTY_INT  = (1<<21);
const ll        INFTY_LL   = (1LL<<60);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

int main() {
    int n, c; cin >> n >> c;
    vvi d;
    REP(i, c) {
        vi v;
        REP(j, c) {
            int e; cin >> e;
            v.push_back(e);
        }
        d.push_back(v);
    }
    vvi grids;
    REP(i, n) {
        vi v;
        REP(j, n) {
            int e; cin >> e;
            e--;
            v.push_back(e);
        }
        grids.push_back(v);
    }
    vvi counts(3, vi(c));
    REP(i, n) {
        REP(j, n) {
            counts[(i+j)%3][grids[i][j]]++;
        }
    }
    vvi d_sums(3, vi(c));
    REP(t, 3) {
        REP(x, c) {
            REP(y, c) {
                d_sums[t][y] += counts[t][x]*d[x][y];
            }
        }
    }

    int ans = -1;
    REP(c0, c) {
        REP(c1, c) {
            if (c0 == c1) continue;
            REP(c2, c) {
                if (c1 == c2 || c2 == c0) continue;
                int candidate = d_sums[0][c0] + d_sums[1][c1] + d_sums[2][c2];
                if (ans == -1 || ans > candidate) ans = candidate;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1280
#include <iostream>

using namespace std;

int main()
{
	int N, K/*, l[50]*/, max(0), index(0), max_lenght(0);
	bool imput(false);
	cin >> N >> K;
	if( (N>=1) && (K>=1) && (N<=50) && (K<=50) && (K<=N)) imput = true;

	if(imput)
	{
		int *l = new int [N];
		for(int i(0); i < N; i++)
			cin >> l[i];

	
		for(int i(0); i<K; i++)
		{
			max = 0;
			for(int i(0); i<N; i++)
			{
				if(l[i] >= max)
				{
					max = l[i];
					index = i;
				}
			}
			l[index] = 0;
			max_lenght+= max;
		}
		delete l;
	}

	cout << max_lenght<<endl;
	system("pause");
	return(0);
}

Measured memory_bytes: 504
export default solve;

// =================================================
// ABC086C
// =================================================

// reader
if (!process.env.LOCAL_DEBUG) {
  require('fs').readFile('/dev/stdin', 'utf8', (err: any, data: string) => {
    if (err) console.error(err);
    main(data.trim().split('\n'));
  });
}

// main
function main(lines) {
  console.log(solve(lines));
}

// solver
function solve(lines: string[]): string {
  const { destinations } = parseLines(lines);

  let canArrive = true;
  loop: for (let i = 0; i < destinations.length; i++) {
    const [step, x, y] = destinations[i];
    const [previousStep, previousX, previousY] = destinations[i - 1] || [0, 0, 0];
    const distance = step - previousStep;
    const stepsToArrive = Math.abs(x - previousX) + Math.abs(y - previousY);
    if (distance % 2 !== stepsToArrive % 2 || distance < stepsToArrive) {
      canArrive = false;
      break loop;
    }
  }
  return canArrive ? 'Yes' : 'No';
}

// helpers
function parseLines(lines: string[]) {
  const N = +lines[0];
  const destinations = lines.slice(1, 1 + N).map(line => line.split(' ').map(s => +s));
  const obj = { N, destinations };
  debug(obj);
  return obj;
}

// general helpers
function debug(message?: any, ...optionalParams: any[]) {
  if (!!process.env.LOCAL_DEBUG) console.log(message, ...optionalParams);
}


Measured memory_bytes: 52792
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define MP make_pair
#define PB push_back
#define PI 3.1415926535897932384626433832795
typedef long long ll;
#define MOD 998244353
ll gcd(ll a,ll b){if (b == 0)return a;return gcd(b, a % b);} 
#define cases int t;cin>>t;while(t--) 
ll power(ll x,ll y,ll p){ll res=1;x=x%p;if(x==0)return 0;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res%MOD;}  

int main(){
   int n,m;
   cin>>n>>m;
   int a[m];
   ll sum = 0;
   REP(i,m){
       cin>>a[i];
       sum += a[i];
   } 
   if(sum > n){
       cout<<"-1\n";
   }
   else{
       cout<<n - sum<<endl;
   }


}


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

#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define MOD 1000000007
#define edl '\n'
#define IOFAST ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
#define PI 3.14159265
#define loop(i,n) for(ll i =0; i<n; i++)

#define vi vector<int>
#define vvi vector<vector<int>>
#define vvpii vector<vector<pair<int, int>>>
#define vpii vector<pair<int, int>>

int main(){
    int N; 
    cin>>N; 
    vector<ll> l(N);
    loop(i, N) cin>>l[i];
    ll ans=0; 
    loop(i, N){
        for (ll j=i+1; j<N; j++){
            for(ll k=j+1; k<N; k++){
                if ((l[i]!=l[j]) && (l[i]!=l[k]) && (l[k]!=l[j])) {
                    if ((l[i]+l[j]>l[k]) && (l[j]+l[k]>l[i]) && (l[i]+l[k]>l[j])) {
                        ans++;
                    }
                }
            }
        }
    }
    cout<<ans;

}


Measured memory_bytes: 3632
m=str('JOI')
w=str('IOI')

while True:
    x=0
    y=0
    try:
        n=str(input())
    except EOFError:
        break
    a=len(n)
    N=list(n)
    for i in range(a-2):
        C=[]
        for j in range(3):
            C.append(N[j])
        B=''.join(C)
        c=N[0]
        if B==m:
            x=x+1
        if B==w:
            y=y+1
        N.remove(c)
        N.append(c)
    print(x)
    print(y)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod


#include <bits/stdc++.h>
using namespace std;
signed main(){
    int A,B,K; cin>>A>>B>>K;
    for(int i=0; i<K; i++){
    if(A+i<=B) cout<<A+i<<endl;
    }
    for(int i=K; i>0; i--){
        if(B-i>=A+K-1) cout<<B-i+1<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s, t;
    cin >> s;
    cin >> t;
    int count=0;
    for(int i=0;i<3;++i){
        if(s[i]==t[i]){
            count = count+1;
        }
    }
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 384
s = int(input())
p =1
ans = []
while True:
    mod = s%(4**p)
    mods_sum = sum([ans[x]*((-2)**x)for x in range(len(ans))])%(4**p)
    now_mod = (mod-mods_sum)%(4**p)
    for a,b in zip([1,1,0,0],[0,1,0,1]):
        if (a-2*b)*(4**(p-1))%(4**p) == now_mod:
            ans.append(a)
            ans.append(b)
    total = 0
    for i,digit in enumerate(ans):
        total += digit*((-2)**i)
    if total == s:
        break
    p +=1
ans.reverse()
ans = list(map(str,ans))
ans =int(''.join(ans))
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<complex>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
const double eps = 1e-10;

#define RIGHT 1
#define LEFT -1

typedef complex<double> P;
typedef vector<P> Polygon;
typedef pair<P,P> Line;

double cross(P a,P b){
  return a.real()*b.imag()-a.imag()*b.real();
}

P intersection_ll(P a1,P a2,P b1,P b2){
  P a=a2-a1,b=b2-b1;
  return a1+a*cross(b,b1-a1)/cross(b,a);
}


int ccw(P a,P b){
  if ( cross(a,b)<0)return RIGHT;
  else if ( cross(a,b)>0)return LEFT;
  return 2;
}

vector<P> Convex_Cut(Polygon in,int n,P a1,P a2,int cutpos){
  vector<P> ret;
  rep(i,n){
    P now = in[i],next=in[(i+1)%n];
    if( ccw(a1-a2,now-a2)==cutpos)ret.push_back(now);
    if ( ccw(a1-a2,now-a2)*ccw(a1-a2,next-a2)<0)
      ret.push_back(intersection_ll(a1,a2,now,next));
  }
  return ret;
}

//cutpos ha mondai izon. which side will remain
Line make_line(P ori,P b,int cutpos){
  P tmp=(ori+b);
  tmp.real()/=2;tmp.imag()/=2;
  P ret=b-tmp;
  swap(ret.real(),ret.imag());
  ret.real()*=-1;
  if ( ccw(ret,ori-tmp)!= cutpos)return make_pair(tmp,ret+tmp);
  return make_pair(ret+tmp,tmp);
}

double Polygon_Area(vector<P> a,int n){
  double sum=0;
  rep(i,n){
    sum+=(a[i%n].real()-a[(i+1)%n].real())*(a[i%n].imag()+a[(i+1)%n].imag());
  }
  if( sum<0)sum*=-1;
  return sum/2;
}


void solve(int n,int m,Polygon in,vector<P> CutLine){
  vector<Line> ver;
  rep(i,CutLine.size())
    if ( i == m)continue;
    else ver.push_back(make_line(CutLine[m],CutLine[i],LEFT));

  rep(i,ver.size())
    in=Convex_Cut(in,in.size(),ver[i].first,ver[i].second,LEFT);
  
  printf("%.4lf\n",Polygon_Area(in,in.size()));
}

main(){
  int n,m;
  while(cin>>n>>m&&n){
    Polygon a;
    vector<P> CutPoint;
    rep(i,n){
      P tmp;cin>>tmp.real()>>tmp.imag();a.push_back(tmp);
    }
    rep(i,m){
      P tmp;
      cin>>tmp.real()>>tmp.imag();
      CutPoint.push_back(tmp);
    }
    
    rep(i,m)
      solve(n,i,a,CutPoint);
    
  }
}

Measured memory_bytes: 0
#include <iostream>
#include<algorithm>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
int dp[6006][2002];
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, mod; cin >> n >> mod;
	dp[0][0] = 1;
	rep(i, 3 * n) {
		rep(j, n + 1) {
			if (!dp[i][j])continue;
			dp[i + 1][j] += dp[i][j];
			dp[i + 2][j + 1] += dp[i][j] * (3*n - i - 1);
			dp[i + 3][j + 1] += dp[i][j] * ((3 * n - i - 1)*(3 * n - i - 2)  % mod) % mod;
			dp[i + 1][j] %= mod;
			dp[i + 2][j + 1] %= mod;
			dp[i + 3][j + 1] %= mod;
		}
	}
	int s = 0;
	rep(i, n + 1)s = (s + dp[3 * n][i]) % mod;
	cout << s << endl;
}

Measured memory_bytes: 92672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

ll n;
vector<ll> lun;

void dfs(vector<ll> &a) {
  if (a.size() == n) {
    //処理
    //DEBUGS(a);
    ll t = 0;
    REP(i, a.size()) { t += (ll)pow(10, a.size() - i - 1) * a[i]; }
    lun.push_back(t);
    return;
  }

  if (a.empty()) {
    REP(i, 9) {
      a.push_back(i + 1);
      dfs(a);
      a.pop_back();
    }
  } else {
    for (ll i = a.back() - 1, j = 0; i < 10 && j < 3; i++, j++) {
      if (i < 0) continue;
      a.push_back(i);
      dfs(a);
      a.pop_back();
    }
  }
}

int main() {
  ll k;
  cin >> k;

  REP(i, 10) {
    vector<ll> a;
    n = i + 1;
    dfs(a);
  }
  sort(ALL(lun));
  cout << lun[k - 1] << endl;
  return 0;
}


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

int main() {
   double sum = 0;
   int N; cin >> N;
   vector<double> x(N);
   vector<string> u(N);
   for(int i = 0;i < N;i++){
     cin >> x.at(i);
     cin >> u.at(i);
     if(u.at(i) == "JPY"){
       sum += x.at(i);}
     else if(u.at(i) == "BTC"){
       sum += 380000.0 * x.at(i);}
   }
  cout << sum << endl;
     
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<int> p;
  int point = 0;
  for (int i = 1; i < N + 1; i++)
  {
    int a;
    cin >> a;
    if (a != i)
    {
      point++;
    }
  }
  if (point == 2 || point == 0)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
while True:                                        
  h, w = [int(n) for n in input().split()]         
  if h == 0 and w == 0:                            
    quit()                                         
                                                   
  for i in range(0, h):                            
    for j in range(0, w):                          
      if i == 0 or i == h-1 or j == 0 or j == w-1: 
        print("#", end='')                         
      else:                                        
        print(".", end='')                         
    print()                                        
  print()                                          

Measured memory_bytes: 9068
from collections import defaultdict

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

s = input()
if len(s)%2==1:
  s = s[:-1]
else:
  s = s[:-2]
while 1:
  if s[:len(s)//2]==s[len(s)//2:]:
    print(len(s))
    exit()
  else:
    s = s[:-2]

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

int main() {
	int n, m, max = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		m = i * i;
		for (int j = 1; j <= n; j++) {
			if (m > n) {
				break;
			}
			else if (m <= n && m > max) {
				max = m;
			}
			m *= i;
		}
	}
	cout << max << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(v)    begin(v), end(v)
#define in        []{lint n; cin>>n; return n;}()

//	最大公約数 O(log N)
#define GCD greatest_common_divisor
template <typename T>
T greatest_common_divisor( const T a, const T b ) {
	if( b == 0 ) {
		return a;
	} else {
		return greatest_common_divisor( b, a%b );
	}
}

//	最小公倍数 O(log N) GCD依存
#define LCM least_common_multiple
template <typename T>
T least_common_multiple( const T a, const T b ) {
	return a * b / greatest_common_divisor( a, b );
}

int main() { cin.tie(0); ios::sync_with_stdio(false);
    lint A = in, B = in, C = in, D = in;

    lint a = B / LCM( C, D );
    lint b = (A-1) / LCM(C,D);
    lint c = a - b; // どっちでも割り切れる

    lint d = B / C - (A-1) / C;
    lint e = B / D - (A-1) / D;

    //cout << c << " " << d << " " << e << "\n";

    cout << (B-A) - d - e + c + 1 << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

int main() {
    cin>>N;
    vec res(N + 1, 0);
    for(ll x = 1; x * x <= N; ++x){
        for(ll y = 1; y * y <= N; ++y){
            for(ll z = 1; z * z <= N; ++z){
                ll temp = (x + y + z) * (x + y + z) - (x * y + y * z + z * x);
                if(temp <= N) ++res[temp];
            }
        }
    }
    reps(i, 1, N + 1) cout<<res[i]<<endl;
}


Measured memory_bytes: 3592
a, b, c, x, y = map(int, input().split())
sum1 = a * x + b * y
if x >= y:
    sum2 = c * y * 2 + (x - y) * a
    sum3 = c * x * 2
else:
    sum2 = c * x * 2 + (y - x) * b
    sum3 = c * y * 2
print(min(sum1, sum2, sum3))

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    int N,M;
    cin >> N >> M;
    if(N == M){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n,k;
  cin>>n>>k;
  vector<int> arr(n+1),dp(n+1,INT_MAX);
  for(int i=0; i<n; i++) cin>>arr[i+1];
  dp[1] = 0;
  int i=1;
  while(i<=n){
    for(int j=1; j<=k; j++){
      if(i+j > n)
        break;
      dp[i+j] = min(dp[i+j],dp[i] + abs(arr[i+j] - arr[i]));
    }
    i++;
  }
  cout<<dp[n];
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
	using namespace std;
	#define ll long long int
	#define pb push_back
	#define f first
	#define s second
	const int mod=1e9+7;
	#define all(x) x.begin(),x.end()
	#define endl '\n'
	#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
	//int arr[900006]
	int main(){
		IOS;
		int n,k;
		cin>>n>>k;
		map<int,int>mp;
		for(int i=0;i<k;i++){
			//mp[i+1]=0;
			int d;
			cin>>d;
			while(d--){
				int a;
				cin>>a;
				mp[a]++;
			}
		}
		//for(auto u:mp)if(u.second==0) cnt++;
		cout<<n-mp.size()<<endl;
		return 0;
	}


Measured memory_bytes: 3656
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
	if (!y)
		return x;
	return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
	return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
	assert(__gcd(a, m) == 1);
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m, a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
	if (y == 0)
		return 1LL;
	else if (y == 1)
		return x;
	else
	{
		ll ans = modPow(x, y / 2, m) % m;
		if (y & 1)
		{
			return (((ans * ans) % m) * x) % m;
		}
		else
		{
			return (ans * ans) % m;
		}
	}
}

vector<string> split(char d,string s)
{
	stringstream ss(s);
	string t;
	vector<string> words;
	while(getline(ss,t,d))
	{
		words.pb(t);
	}

	return words;
}

int main(int argc, char *argv[])
{
#ifdef LOCAL
	auto start = chrono::high_resolution_clock::now();
#endif
	
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin>>n;

	ll ans=0;

	for(int i=1;i<=n;++i)
	{
		if(i%3==0 || i%5==0)continue;
		ans+=i;
	}
	cout<<ans;


#ifdef LOCAL
	auto end = chrono::high_resolution_clock::now();
	double time_taken =
		chrono::duration_cast<chrono::nanoseconds>(end - start).count();

	time_taken *= 1e-9;

	cout << "Time taken by program is : " << fixed
		 << time_taken * 1000 << setprecision(9);
	cout << " sec" << endl;
#endif
	return 0;
}

Measured memory_bytes: 3644
n, m = [int(i) for i in input().split()]
table = [[int(i) for i in input().split()] for m in range(m)]

maxtable1 = sorted(table, key = lambda x: x[0])
maxtable2 = sorted(table, key = lambda x: x[1])

print(max(0, maxtable2[0][1] - maxtable1[m-1][0] + 1))

Measured memory_bytes: 24276
#include <stdio.h>
#include <stdlib.h>

int partition(int a[],int l,int r);
void quicksort(int a[],int l,int r);

int main(void){
    int N,M,X,Y,*x,*y,i;
    scanf("%d %d %d %d",&N,&M,&X,&Y);
    x = (int*)malloc(sizeof(int)*N);
    y = (int*)malloc(sizeof(int)*M);
    for(i=0;i<N;i++) scanf("%d",&x[i]);
    for(i=0;i<M;i++) scanf("%d",&y[i]);
    quicksort(x,0,N-1);
    quicksort(y,0,M-1);
    if(y[0]-x[N-1]>=1&&y[0]-X>=1&&Y-x[N-1]>=1) printf("No War\n");
    else printf("War\n");
    return 0;
}

int partition(int a[],int l,int r){
    int i=l,j=r;
    while(1){
        for(;i<r;i++){
            if(a[i]>=a[r]) break;
        }
        for(;j>=0;j--){
            if(a[j]<a[r]) break;
        }
        if(i<j){
            int tmp;
            tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }else{
            int tmp;
            tmp = a[r];
            a[r] = a[i];
            a[i] = tmp;
            break;
        }
    }
    return i;
}

void quicksort(int a[],int l,int r){
    int i;
    if(r<=l) return;
    i = partition(a,l,r);
    quicksort(a,l,i-1);
    quicksort(a,i+1,r);
}

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

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int X = scan.nextInt();
        int Y = scan.nextInt();
        System.out.println(X + Y / 2);
    }
}


Measured memory_bytes: 21844
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B81 solver = new B81();
        solver.solve(1, in, out);
        out.close();
    }

    static class B81 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();

            for (int i = 1; i <= 9; i++)
                for (int j = 1; j <= 9; j++) {
                    if (i * j == n) {
                        out.println("Yes");
                        return;
                    }
                }

            out.println("No");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



Measured memory_bytes: 21460
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC100.A
{
    class Program
    {
        static void Main ()
        {
            var sc = new Scanner ();
            var a = sc.Nextint ();
            var b = sc.Nextint ();
            Console.WriteLine ((a <= 8 && b <= 8) ? "Yay!" : ":(");
        }
    }
    class Scanner
    {
        string[] s;
        long i;

        char[] cs = new char[] { ' ' };

        public Scanner ()
        {
            s = new string[0];
            i = 0;
        }

        public string Next ()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine ();
            while (st == "") st = Console.ReadLine ();
            s = st.Split (cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next ();
            i = 0;
            return s[i++];
        }

        public int Nextint ()
        {
            return int.Parse (Next ());
        }
        public int[] Arrayint (int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Nextint () + add;
            }
            return Array;
        }

        public long NextLong ()
        {
            return long.Parse (Next ());
        }

        public long[] ArrayLong (int N, long add = 0)
        {
            long[] Array = new long[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextLong () + add;
            }
            return Array;
        }

        public double NextDouble ()
        {
            return double.Parse (Next ());
        }

        public double[] ArrayDouble (long N, double add = 0)
        {
            double[] Array = new double[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDouble () + add;
            }
            return Array;
        }

        public decimal NextDecimal ()
        {
            return decimal.Parse (Next ());
        }

        public decimal[] ArrayDecimal (long N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDecimal ();
            }
            return Array;
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
 
int main(){
  string S;
  cin>>S;
  rep(i,S.size()) cout<<'x';
  cout<<endl;
}

Measured memory_bytes: 256
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f

using namespace std;

const int N = 1e4 + 5;
const int M = 1e4 + 7;

int i,j,T,t,n,m,l,s,c[105],a,b,g[105],dp[N][105],p,k,d,flag;
map<int,int> mp;

int main()
{
    ios::sync_with_stdio(false);
    cin >> n;
    while(n--){
        cin >> m;
        if(mp[m]==0) mp[m]=1;
        else break;
    }
    if(n>=0) cout << "NO";
    else cout << "YES";
    return 0;
}


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

using namespace std;

typedef long long ll;

const int N = 310;
const int MOD = 1e9 + 7;

struct node
{
	int l, x;

	node (int a, int b)
	{
		l = a, x = b;
	}
	node () { }
};
vector <node > com[N];

int n, m;
ll f[N][N][N];

inline int read()
{
	int x = 0, ch = '~';

	while(!(ch >= '0' && ch <= '9')) ch = getchar();
	while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1), x += ch - '0', ch = getchar();

	return x;
}

bool check(int k, int i, int j)
{
	bool flag = true;

	for(int c = 0; c < (int )com[k].size(); c++)
	{
		int l = com[k][c].l, x = com[k][c].x, cnt = 0;

		if(k >= l) cnt++;
		if(i >= l) cnt++;
		if(j >= l) cnt++;

		if(cnt != x)
		{
			flag = false;
			break;
		}
	}

	if(!flag)
		f[k][i][j] = 0;

	return flag;
}

int main()
{
	n = read(), m = read();
	for(register int k = 1; k <= m; k++)
	{
		int l = read(), r = read(), x = read();
		com[r].push_back(node(l, x));
	}

	f[1][0][0] = 1;

	for(register int k = 1; k < n; k++)
		for(int i = 0; i < k; i++)
			for(int j = 0; !j || j < i; j++)
			{
				if(!check(k, i, j)) continue;

				f[k + 1][i][j] += f[k][i][j], f[k + 1][i][j] %= MOD;
				f[k + 1][k][i] += f[k][i][j], f[k + 1][k][i] %= MOD;
				f[k + 1][k][j] += f[k][i][j], f[k + 1][k][j] %= MOD;
			}

	ll answ = 0;
	for(register int k = 0; k < n; k++)
		for(int i = 0;!i || i < k; i++)
			if(check(n, k, i))
				answ += f[n][k][i], answ %= MOD;

	printf("%lld", answ * 3 % MOD);

	return 0;
}

Measured memory_bytes: 225536
fun main(args: Array<String>) {
    val (A,B) = readLine()!!.split(" ").map{it.toInt()}
    println(if((B - 1) % (A - 1) > 0) (B - 1) / (A - 1) + 1 else (B - 1) / (A - 1) )
}

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

int main()
{
    int h, w;
    cin >> h >> w;
    int dist[10][10];
    rep(i, 10)
    {
        rep(j, 10)
        {
            cin >> dist[i][j];
        }
    }
    vector<int> kab(h * w);
    rep(i, h * w) cin >> kab[i];

    //ワーシャルフロイド法
    rep(k, 10)
    {
        rep(i, 10)
        {
            rep(j, 10)
            {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    ll ans = 0;
    rep(i, h * w)
    {
        ans += dist[kab[i]][1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

bool contain(const string &S, char c) {
  for (char s: S) {
    if (s == c) {
      return true;
    }
  }
  return false;
}

void solve() {
  string S;
  cin >> S;

  for (char c = 'a'; c <= 'z'; c++) {
    if (!contain(S, c)) {
      cout << c << endl;
      return;
    }
  }
  cout << "None" << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 512
using System;

namespace ABC160A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            if (s[2] == s[3])
            {
                if (s[4] == s[5])
                    Console.WriteLine("Yes");
                else
                    Console.WriteLine("No");
            }
            else
                Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 11092
#include <stdio.h>
#define N 100
int main()
{
  int A[N],flag=1,n,i,count=0,c;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&A[i]);
    }
  while(flag)
    {
      flag=0;
      for(i=n-1;i>=1;i--)
	{	  
	  if(A[i]<A[i-1])
	    {
	      c=A[i];
	      A[i]=A[i-1];
	      A[i-1]=c;
	      flag=1;
	      count++;
	    }
	}
    }
  for(i=0;i<n;i++)
    {
      printf("%d",A[i]);
      if(i!=n-1)
	printf(" ");
    }
  printf("\n");
  printf("%d",count);
  printf("\n");
  return 0;
}



Measured memory_bytes: 2140
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;


int main()
{
	FAST;
	int maxValue = 0;

	int n;
	cin >> n;
	string str;
	cin >> str;
	int x = 0;

	for(int i=0 ; i<n ; i++)
	{
		if(str[i] == 'I')
			x++;
		else
			x--;
		maxValue = max(maxValue , x);
	}
	cout << maxValue;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007
//#define mod 998244353

int N,K;
int V[55];
signed main(){
    scanf("%lld %lld",&N,&K);
    rep(i,N)scanf("%lld",&V[i]);
    //最後に戻すことにすると、
    //K個まで取ることができる
    //プラスか0の宝石はとっといたほうがいい
    //左からi、右からj個取る
    int ans=0;
    for(int i=0;i<=min(N,K);i++){
        for(int j=0;j<=min(N,K)-i;j++){
            //捨てる動作はk回できる
            int k=K-i-j;
            vector<int> funokazu;
            int sans=0;
            rep(a,i){
                sans+=V[a];
                if(V[a]<0)funokazu.pb(V[a]);
            }
            rep(a,j){
                sans+=V[N-a-1];
                if(V[N-a-1]<0)funokazu.pb(V[N-a-1]);
            }
            sort(funokazu.begin(),funokazu.end());
            int trash=0;
            rep(a,min(k,(int)funokazu.size())){
                trash+=funokazu[a];
            }
            //printf("%lld %lld %lld %lld\n",i,j,sans-trash,trash);
            ans=max(ans,sans-trash);
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int main(){
    LL N,M;
    cin>>N>>M;
    LL ans=1900*M+(N-M)*100;
    REP(i,M){
        ans*=2;
    }
    cout<<ans<<endl;
	return(0);
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    S = input()

    if S == "SSS":
        print(0)
    elif S == "RRR":
        print(3)
    elif S in ["RRS", "SRR"]:
        print(2)
    else:
        print(1)

if __name__ == "__main__":
    main()



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

int main(){
  int k,a,b,c,d;
  cin >> k;
  a=k/1000;
  b=(k/100)%10;
  c=(k/10)%10;
  d=k%10;
  int e[2]={1,-1};
  char f[2]={'+','-'};
  repeat(i,8){
    if((a+e[i&1]*b+e[(i>>1)&1]*c+e[(i>>2)&1]*d)==7){
      cout << a << f[i&1] << b << f[(i>>1)&1] << c << f[(i>>2)&1] << d << "=7\n";
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define MP(a,b) make_pair(a,b)
typedef long long LL;
typedef pair<int, int> PI;
typedef vector<int> VI;
const LL MOD = 1000000007LL;

int main() {
	int N;
	cin >> N;
	LL A, B, C, D;
	cin >> A >> B >> C >> D;
	bool OK = 0;
	rep(i, N) {
		if ((-D)*i + C*(N - 1 - i) <= B - A&&B - A <= (-C)*i + D*(N - 1 - i)) {
			OK = 1;
			break;
		}
	}
	if (OK) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        int cost;
        int temp;
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
    
        if(a>b){
            temp = b;
            b = a;
            a = temp;
        }
        if(b>c){
            temp=c;
            c=b;
            b=temp;
        }
        if(a>b){
            temp = b;
            b = a;
            a = temp;
        }
        cost = (b-a)+(c-b);
        System.out.println(cost);
    } 
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
  int e,y,a;
  cin >> e;
  if(e==0){
    cin >> y;
    if(y <= 1911){
	a = 1911 - y;
	a = 44 - a;
	cout << "M" << a << endl; 
    } else if(y <= 1925){
	a = 1925 - y;
	a = 14 - a;
	cout << "T" << a << endl;
    } else if(y <= 1988){
	a = 1988 - y;
	a = 63 - a;
	cout << "S" << a << endl;
    } else if(y <= 2016){
	a = 2016 - y;
	a = 28 - a;
	cout << "H" << a << endl;
    }
  } else {
    cin >> y;
    if(e==1) {
	a = 44 - y;
	a = 1911 - a;
	cout << a << endl;
    }
    if(e==2) {
	a = 14 - y;
	a = 1925 - a;
	cout << a << endl;
    }
    if(e==3) {
	a = 63 - y;
	a = 1988 - a;
	cout << a << endl;
    }
    if(e==4) {
	a = 28 - y;
	a = 2016 - a;
	cout << a << endl;
    }
  }
  return 0;
}



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

int main()
{
    string s;
    cin >> s;
    vector<ll> keep;
    ll ans = 0;
    
    for( int i = 0; i < ( 1 << (s.size()-1) ); i++ )
    {
        ll sum = s[0] - '0';
        for( int j = 0; j < s.size()-1; ++j )
        {
            if( i & (1<<j) )
            {
                ans = ans + sum;
                sum = s[j+1] - '0';
            }
            else
            {
                sum = sum*10;
                sum = sum + ( s[j+1] - '0' );
            }
        }
        ans = ans + sum;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
    int R[MAX], n;
    
    cin >> n;
    for(int i = 0; i < n; i++) cin >> R[i];
    int maxv = -2000000000;
    int minv = R[0];
    
    for (int i = 1; i < n ; i++){
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    cout << maxv << endl;
    
    return 0;
    
}


Measured memory_bytes: 3868
using System;

class P
{
public static void Main()
{
//????????????????????????
            var a = Console.ReadLine().Split(' ');

            double x1 = Double.Parse(a[0]);
            double y1 = Double.Parse(a[1]);
            double x2 = Double.Parse(a[2]);
            double y2 = Double.Parse(a[3]);

            double x = x2 - x1;
            double y = y2 - y1;

            double D = Math.Sqrt(x * x + y * y);

            //??????
            Console.WriteLine("{0:f5}", D);
}
}

Measured memory_bytes: 9292
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const long double PI = acos(-1);
const long long INF = (1 << 30);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  ll a, b, t;
  cin >> a >> b >> t;

  cout << (int)(((t+0.5)/a))*b << endl;
  return 0;
}

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

int dp[100005], a[100005];
int n;

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

    dp[1]=0;
    for(int i=2; i<=n; i++)
    {
        dp[i]=dp[i-1] + abs(a[i]-a[i-1]);
        if(i>2)
            dp[i]=min(dp[i], dp[i-2] + abs(a[i]-a[i-2]));
    }
    cout<< dp[n] <<endl;
}



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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define X real()
#define Y imag()

typedef double D;
typedef complex<D> P;

const D eps=1e-9;
const D EPS=1e-7;
const D inf=1e12;

struct L : public vector<P> { // line and segment
  L(const P& a,const P &b){
    push_back(a);
    push_back(b);
  }
};

D cross(P a,P b){ return (conj(a)*b).Y; }

P projection(L l,P p){
  P b=l[1]-l[0],c=p-l[0];
  return l[0]+b*(c/b).X;
}

bool intersectSP(L s,P p){
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0])<eps;
}

D distanceSP(L s,P p) {
  const P r=projection(s,p);
  return intersectSP(s,r)?abs(r-p):min(abs(s[0]-p),abs(s[1]-p));
}

P crosspoint(L l,L m) {
  D A=cross(l[1]-l[0],m[1]-m[0]);
  D B=cross(l[1]-l[0],l[1]-m[0]);
  if (abs(A)<eps&&abs(B)<eps) return m[0]; // same line
  if (abs(A)<eps) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
  return m[0]+B/A*(m[1]-m[0]);
}

int N;
P ps[101];

const double GR=(sqrt(5.0)-1.0)/2.0;

double f(double x,double y){
  // actual content of func
  P p=P(x,y);
  double res=inf;
  rep(i,N)minch(res,distanceSP(L(ps[i],ps[(i+1)%N]),p));
  return res;
}

double yargmax(double crtx){
  double lb=inf,ub=-inf;
  rep(i,N){
    D mnx=min(ps[i].X,ps[(i+1)%N].X);
    D mxx=max(ps[i].X,ps[(i+1)%N].X);
    if(mnx-eps<crtx&&crtx<mxx+eps){
      if(abs(ps[i].X-ps[(i+1)%N].X)<eps){
        minch(lb,min(ps[i].Y,ps[(i+1)%N].Y));
        maxch(ub,max(ps[i].Y,ps[(i+1)%N].Y));
      }else{
        P cp=crosspoint(L(ps[i],ps[(i+1)%N]),L(P(crtx,-1000000),P(crtx,+1000000)));
        minch(lb,cp.Y);
        maxch(ub,cp.Y);
      }
    }
  }
  double x=ub-GR*(ub-lb),y=lb+GR*(ub-lb);
  double vx=f(crtx,x),vy=f(crtx,y);
  while(ub-lb>EPS){
    if(vx<vy){
      lb=x; x=y; vx=vy; y=lb+GR*(ub-lb); vy=f(crtx,y);
    }else{
      ub=y; y=x; vy=vx; x=ub-GR*(ub-lb); vx=f(crtx,x);
    }
  }
  return (x+y)/2.0;
}

D xmax(D mnx,D mxx){
  D lb=mnx,ub=mxx;
  D x=ub-GR*(ub-lb),y=lb+GR*(ub-lb);
  double vx=f(x,yargmax(x)),vy=f(y,yargmax(y));
  while(ub-lb>EPS){
    if(vx<vy){
      lb=x; x=y; vx=vy; y=lb+GR*(ub-lb); vy=f(y,yargmax(y));
    }else{
      ub=y; y=x; vy=vx; x=ub-GR*(ub-lb); vx=f(x,yargmax(x));
    }
  }
  return f((x+y)/2.0,yargmax((x+y)/2.0));
}

int main(){
  while(1){
    cin>>N;
    if(N==0)break;
    rep(i,N){
      D x,y;
      cin>>x>>y;
      ps[i]=P(x,y);
    }
    D mnx=inf,mxx=-inf;
    rep(i,N){
      minch(mnx,ps[i].X); maxch(mxx,ps[i].X);
    }
    printf("%.10f\n", xmax(mnx,mxx));
  }
  return 0;
}



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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rp(i,n){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    
    int i=0,ans=0;
    while(i<n){
        int cnt=0;
        int x=a.at(i);
        while(i<n&&a.at(i)==x){
            cnt++;
            i++;
        }
        ans += cnt%2;
    }
    
    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll N, M;
    cin >> N >> M;
    VVP G(N+1);
    rep(i, 0, M){
        ll l, r, d;
        cin >> l >> r >> d;
        G[l].push_back({r, d});
        G[r].push_back({l, -d});
    }

    VB seen(N+1, false);
    rep(i, 1, N+1){
        if(seen[i] || G[i].empty()) continue;
        ll srt = i;
        VL d(N+1, -1e18);
        {
            queue<PL> que;
            que.push({0, srt});
            d[srt] = 0;
            seen[srt] = true;
            while(!que.empty()){
                auto q = que.front();
                que.pop();
                for(auto g : G[q.second]){
                    if(d[g.first] != -1e18 && d[g.first] != q.first + g.second){
                        cout << "No" << endl;
                        return 0;
                    }
                    if(d[g.first] == -1e18){
                        d[g.first] = q.first + g.second;
                        seen[g.first] = true;
                        que.push({d[g.first], g.first});
                    }
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 14448