akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
ll a, b;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> a >> b;

  ll ans = -1;
  FOR(i, 1, 20000) {
    int a_i = i * 0.08;
    int b_i = i * 0.1;
    if(a_i == a && b_i == b) {
      ans = i;
      break;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 384
#include<stdio.h>
int main() {
	int n,i,p,q,r,P,Q,R,C,x,y=0;
	int a[1000][5]={0};
	while(scanf("%d",&n) && n!=0){
		for(x=0; x<n; x++){
			scanf("%d %d %d %d",&i,&p,&q,&r);
			a[x][0]=i;
			a[x][1]=p;
			a[x][2]=q;
			a[x][3]=r;
			a[x][4]=p*4+q*9+r*4; 
		}
		scanf("%d %d %d %d",&P,&Q,&R,&C);
		for(x=0; x<n; x++){
			if(a[x][1]<=P && a[x][2]<=Q && a[x][3]<=R && a[x][4]<=C){
							y=1;
							printf("%d\n",a[x][0]);
			}
		}
		if(y==0)
			printf("NA\n");
		y=0;
	}
	return 0;
} 

Measured memory_bytes: 1068
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    try {
      double n = sc.nextDouble();
      double ans = Math.pow(n / 3, 3);
      System.out.printf("%f\n", ans);
    } finally {
      sc.close();
    }
  }
}

Measured memory_bytes: 37372
import itertools

mm = int(input())
kk = list(map(int, input().split()))
pp = list(set(kk))
answer_=[]

if len(kk)<2:
  answer=0
else:
  for qq in itertools.combinations(pp, 3):
    rr = list(qq)
    rrr = sorted(rr)
    a = rrr[0]
    b = rrr[1]
    c = rrr[2]
    if a+b>c:
      aa = kk.count(a)
      bb = kk.count(b)
      cc = kk.count(c)
      d = aa*bb*cc
      answer_.append(d)
    else:
      answer_.append(0)
  answer = sum(answer_)
  
print(answer)

Measured memory_bytes: 10208
#include<stdio.h>
int main(){
  char X,Y;
  scanf("%c %c",&X,&Y);
  if(X<='F'&&X>='A'&&Y<='F'&&Y>='A'){
  if(X<Y)  printf("<\n");
  else if(X>Y)  printf(">\n");
  else  printf("=\n");
  }
 return 0;
}

Measured memory_bytes: 128
n, k = map(int, input().split())
ans = 0
if k == 0:
    ans = n ** 2
else:
    for b in range(1, n + 1):
        if k < b:
            ans += n // b * (b - k)
        if (n % b >= k) and (n % b != 0):
            ans += n % b - k + 1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define INF 0x3f3f3f3f
#define lowbit(x) (x&(-x))
#define mid ((l+r)>>1)
using namespace std;
template<class T>il read(T &x){
	x=0;int f=1;char k=getchar();
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=x*10+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x>9) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
int n,m;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n),read(m);
	puts(n==m?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ACL
#ifdef ACL
#include <atcoder/all>
using namespace atcoder;
#endif
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
using LD = long double;
using VI = vector<int>;
using VVI = vector<vector<int> >;
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<vector<T> >;
template <typename T> using VVV = vector<vector<vector<T> > >;
void print() {cout << endl;}
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <typename T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <typename T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <typename T> void SORT (T &v) {sort(v.begin(), v.end());}
template <typename T> void SORTR (T &v) {sort(v.begin(), v.end(), greater<>());}
template <typename T> T GCD(T x,T y) {return __gcd(x,y);}
template <typename T> T LCM(T x,T y) {return x/__gcd(x,y)*y;}
template <typename T> int SZ(T v) {return v.size();}
template <typename T> T PCNT(T x) {return __builtin_popcountll(x);}
template <typename T> T BIT(T x) {return 1LL<<(x);}
int INF = 2000000000;
long double PI = acosl(-1);
int MOD = 1000000007;


int32_t main() {
    chrono::system_clock::time_point start_time, end_time;
    start_time = chrono::system_clock::now();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int T;
    cin >> T;
    int N,M,A,B;
    REP (i, T) {
        cin >> N >> M >> A >> B;
        cout << floor_sum(N,M,A,B) << endl;
    }

    
    

    end_time = chrono::system_clock::now();
    assert(chrono::duration_cast<chrono::milliseconds>(end_time-start_time).count() < 2000);
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/practice2/practice2_c && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/practice2/practice2_c && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/practice2/practice2_c && sh shellscripts/submit_cpp.sh
*/


Measured memory_bytes: 3632
n = int(input())
c0=0
c1=0
c2=0
c3=0
for i in range(n):
    s = input()
    if s == "AC":
        c0 += 1
    if s == "WA":
        c1 += 1
    if s == "TLE":
        c2 += 1
    if s == "RE":
        c3 += 1
print("AC x " + str(c0), "WA x " + str(c1), "TLE x " + str(c2), "RE x " + str(c3), sep="\n")



Measured memory_bytes: 69872
#include<stdio.h>
#define ab(a) ((a)>0?(a):-(a))
int main()
{
	long long x,k,d,i;
	scanf("%lld%lld%lld",&x,&k,&d);
	x=ab(x);
	if(d==0)
		printf("%lld",x);
	else if(x/d>k)
		printf("%lld",x-k*d);
	else
	{
		i=x%d;
		k-=x/d;
		k=k%2;
		if(k==1)
			printf("%lld",ab(i-d));
		else
			printf("%lld",i);
	}
	return 0;
}

Measured memory_bytes: 1728
//include
//------------------------------------------
#include <bits/stdc++.h> // only for GCC

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

//container util
//------------------------------------------
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

//repetition
//------------------------------------------
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

//constant
//--------------------------------------------
const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

// output vector
// ------------------------------------------
namespace std {
    template<typename T>ostream&operator<<(ostream&os, vector<T>const&v){
        iter(it,v) os<<*it<<(it+1==v.end()?"":",");
        return os;
    }
    template<typename T, typename U>ostream&operator<<(ostream&os,const pair<T,U>&p){
        return os << "[" << p.dirst << "," << p.second << "]";
    }
}

//clear memory
// ------------------------------------------
#define clr(a,i) memset((a), (i) ,sizeof(a))

int lcm(int a,int b){
   return a*b/__gcd(a,b);
}
 
vb pn(999984,1);
vi pnn(999984,0); 
void prime_number(ull n){
   pn[0]=false;pn[1]=false;
   loop(i,2,n){
      pnn[i]=pnn[i-1]+(int)pn[i];
      if(!pn[i]) continue;
      for(ull j=i*i;j<=n;j+=i){
         pn[j]=false;
      }
   }
}

int main(){
   ull n,s,g;
   ll p,m;
   int x;
   prime_number(999984);
   while(cin >> n&&n){
      x=0;
      rep(i,n){
         cin>>p>>m;
         if(p-m<2) s=1;
         else s=p-m-1;
         if(p+m>999983) g=999983;
         else g=p+m;
         x+=pnn[g]-pnn[s]-1;
      }
      cout << x << endl;
   }
   return 0;
}

Measured memory_bytes: 5156
n = int(input())
h = [int(w) for w in input().split()]

dp = [-1] * n
dp[0] = 0
dp[1] = abs(h[0] - h[1])

for i in range(2, n):
    dp[i] = min(dp[i - 2] + abs(h[i - 2] - h[i]),
                dp[i - 1] + abs(h[i - 1] - h[i]))

print(dp[n-1])


Measured memory_bytes: 20544
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>

using namespace std;

void solve()
{
	int N;
	cin >> N;
	string s;
	cin >> s;
	int Max = 0;
	int cnt = 0;
	for (int i = 0; i < N; ++i)
	{
		if (s[i] == 'I')
		{
			++cnt;
		}
		else
		{
			--cnt;
		}
		Max = max(Max, cnt);
	}
	cout << Max << endl;
}

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

Measured memory_bytes: 256
#include<iostream>
#include<utility>

using namespace std;

int main(){
	int x, y, i, k;

	cin >> x >> y;
	if(x < y) swap(x, y);
	do{
		k = x % y;
		x = y;
		y = k;
	}while(k != 0);
	cout << x << endl;

	return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define MAX 128
#define fst first
#define sec second
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define bit(n) (1LL << (n))
#define int long long
const double PI = 3.141593;
const ll MOD = 1e9 + 7;
const int INF = 100100100;
const double EPS = 1e-9;
template <class T>
bool chmax(T &a, const T &b){if (a < b){a = b;return 1;}return 0;}
template <class T>bool chmin(T &a, const T &b){if (b < a){a = b;return 1;}return 0;}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }     //最小公倍数
ll combination(ll n, ll r){if (r * 2 > n)r = n - r;ll dividend = 1;ll divisor = 1;for (ll i = 1; i <= r; ++i){dividend *= (n - i + 1);divisor *= i;}return dividend / divisor;}


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s;
    cin >> s;
    rep(i, s.length())
    {
        printf("%c",'x');
    }

    return 0;
}

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

using namespace std;
#define int long long
#define br cout<<"\n"
#define all(V) V.begin(),V.end()
#define rall(V) V.rbegin(),V.rend()
#define umap unordered_map
#define uset unordered_set

typedef vector<int> vi;
typedef vector<vi> vvi;

bool isPwrOf2(int x) { return x && (!(x&(x-1))); }
/*------------------------------------------------*/

/*------------------------------------------------*/

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    // #ifndef ONLINE_JUDGE
    //     freopen("./input.txt", "r", stdin);
    //     freopen("./output.txt", "w", stdout);
    // #endif
    /*------------------------------------------------*/
    int n; cin>>n;
    int arr[n];
    int cnt=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        cnt+= arr[i]-1;
    }
    cout<< cnt;
    /*------------------------------------------------*/
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-12;
long double pi = acos(-1);



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int n;
    cin>>n;
    int p[n*n];
    for(int i=0;i<n*n;i++){
        cin>>p[i];
        p[i]--;
    }
    int t[n][n]={};
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            t[i][j] = min({n-1-i, n-1-j, i, j});
        }
    }
    int ans = 0;
    bool used[n][n]={};
    for(int i=0;i<n*n;i++){
        int x = p[i]/n, y = p[i]%n;
        ans += t[x][y];
        used[x][y] = 1;
        queue<array<int,3>> q;
        for(int k=0;k<4;k++){
            int nx = x+dx[k], ny = y + dy[k];
            if(nx>=0 && ny>=0 && nx<n && ny<n){
                if(chmin(t[nx][ny],t[x][y])){
                    q.push({nx,ny,t[x][y]});
                }
            }
        }
        while(q.size()){
            int x = q.front()[0], y = q.front()[1], c = q.front()[2];
            q.pop();
            for(int k=0;k<4;k++){
                int nx = x+dx[k], ny = y + dy[k];
                if(nx>=0 && ny>=0 && nx<n && ny<n){
                    if(!used[x][y] && chmin(t[nx][ny],c+1)){
                        q.push({nx,ny,c+1});
                    }
                    if(used[x][y] && chmin(t[nx][ny],c)){
                        q.push({nx,ny,c});
                    }
                }
            }
        }
    }
    cout << ans << endl;
    

}

Measured memory_bytes: 5792
s = int(input())

l = [s]
temp = s
for i in range(2, 10**7):

    if temp % 2 == 0:
        temp //= 2
    else:
        temp = 3 * temp + 1

    if temp in l:
        print(i)
        exit()
    else:
        l.append(temp)


Measured memory_bytes: 9096
#include <iostream>
#include <algorithm>
#include<functional>
#include<stdio.h>
#include<stdlib.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#include<vector>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;
int main() {
	int n;
	cin >> n;
	float a[56];
	float s;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			if (a[i] > a[j]) {
				s = a[j];
				a[j] = a[i];
				a[i] = s;
			}
		}
	}
	if (n == 2) {
		cout << float((a[n - 1] + a[n - 2]) / 2);
	}
	else {
		for (int i = 0; i < n - 2; i++) {
			a[i + 1] = (a[i + 1] + a[i]) / 2;
		}
		cout << float((a[n - 1] + a[n - 2]) / 2);
	}
}


Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {
  
  val n = StdIn.readLine().toInt
  val result = Array.ofDim[Int](n, n)
  val r = (0 until n).map { _ =>
    val a = StdIn.readLine().split(' ').map(_.toInt)
    (0 until a(1)).foreach { k =>
      result(a(0)-1)(a(2+k)-1) = 1
    }
    result(a(0)-1).mkString(" ")
  }

  println(r.mkString(f"%n"))

}




Measured memory_bytes: 45772
/**
 * C - いっしょ / Be Together
 * https://atcoder.jp/contests/abc043/tasks/arc059_a
 **/
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<numeric>

using namespace std;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    int ave = round((double)accumulate(a.begin(), a.end(), 0) / n);
    int ans = 0;
    for(int i=0; i<n; i++) {
        ans += pow(a[i]-ave, 2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N=55555;
bool is_prime[MAX_N];
int prime[MAX_N];
int main(){
  int dp[1001][1001];
  for(int nn=0;nn<1;nn++){
    string s1,s2;
    cin>>s1>>s2;
    for(int i=0;i<1001;i++)fill(dp[i],dp[i]+1001,0);
    for(int i=0;i<s1.size()+1;i++)dp[i][0]=i;
    for(int i=0;i<s2.size()+1;i++)dp[0][i]=i;
    for(int i=0;i<s1.size();i++){
      for(int j=0;j<s2.size();j++){
        int x=1;
        if(s1[i]==s2[j]) x=0;
        dp[i+1][j+1]=min(dp[i][j]+x,min(dp[i][j+1]+1,dp[i+1][j]+1));
      }
    }
    cout<<dp[s1.size()][s2.size()]<<endl;
  }
  return 0;
}



Measured memory_bytes: 7100
H,W=map(int,input().split())

bom=[]
for i in range(H):
    bom.append(list(input()))

for h in  range(H):
    for w in range(W):
        if bom[h][w]=="#":
            continue

        cnt=0
        for x in range(-1,2):
            for y in range(-1,2):
                if h+x>=0 and w+y>=0 and h+x<H and w+y<W:
                    if bom[h+x][w+y]=="#":
                        cnt+=1
        bom[h][w]=str(cnt)
for i in bom:
    print("".join(i))


Measured memory_bytes: 3188
#include<stdio.h>
int main(void)
{
	int i,j,k,n,h[101],sum[100],s,flg;
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		for(i=0;i<=n;i++){
			scanf("%d",&h[i]);
		}
		for(i=0;i<=n;i++){
			k=0;
			for(j=0;j<=n;j++){
				if(!(j==i)){
					sum[k]=h[j];
					k++;
				}
			}
			s=sum[1]-sum[0];
			flg=1;
			for(j=0;j<n-1;j++){
				if(!(sum[j+1]-sum[j]==s)){
					flg=0;
				}
			}
			if(flg==1){
				printf("%d\n",h[i]);
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 2084
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
const int MAX = 700000;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
  COMinit();
  ll n,k;
  cin>>n>>k;
  vll a(n);
  rep(i,n) cin>>a[i];
  sort(all(a));
  ll ans=0;
  for(int i=k-1;i<n;i++){
    ans+=COM(i,k-1)*a[i];
    ans%=MOD;
  }
  reverse(all(a));
  for(int i=k-1;i<n;i++){
    ans-=a[i]*COM(i,k-1);
    ans%=MOD;
  }
  COUT(ans);
}


Measured memory_bytes: 17408
from collections import Counter
N = int(input())
an = list(map(int,input().split()))
at = tuple(Counter(an).items())
ans = 0
for a in at:
    if a[0] > a[1]:
        ans += a[1]
    elif a[0] < a[1]:
        ans += (a[1] - a[0])
print(ans)

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

#define    int                      long long int
#define    ld                       long double
#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL),cout.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int ttt; cin >> ttt; while(ttt--)
#define    ff                       first
#define    ss                       second
#define    all(container)            container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    sp(x)                    setprecision(x)
#define    bp(x)                    __builtin_popcount(x)
#define    endl                     "\n"

int power(int x, int y, int p)  
{  
    int 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; 
}

int32_t main()
{
    speed upp
    int n,k,c,x=0;
    cin>>n>>k>>c;
    c++;
    string s;
    cin>>s;
    vector<int>a,b;
    for(int i=0;i<n;)
    {
        if(x>=k)
            break;
        if(s[i]=='x')
            i++;
        else
        {
            a.pb(i);
            x++;
            i+=c;
        }
    }
    x=0;
    for(int i=n-1;i>=0;)
    {
        if(x>=k)
            break;
        if(s[i]=='x')
            i--;
        else
        {
            b.pb(i);
            x++;
            i-=c;
        }
    }
    x=0;
    vector<int>ans;
    for(int i=0;i<k;i++)
        if(a[i]==b[k-1-i])
        {
             x++;
            ans.pb(a[i]);
        }
    f(i,0,x-1)
        cout<<ans[i]+1<<endl;
}

Measured memory_bytes: 9704
#include "bits/stdc++.h"
#define _USE_MATH_DEFINES
#include <math.h>
 
using namespace std;
 
using LL = long long;
using VLL = std::vector<LL>;
using VVLL = std::vector<VLL>;
using VVVLL = std::vector<VVLL>;
using LD = long double;
using VLD = std::vector<LD>;
using VVLD = std::vector<VLD>;
using VVVLD = std::vector<VVLD>;
 
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; }return false; }

//template<class T=LL> inline vector<T> cinv(LL N){ vector<T> v(N); REP(i, N)cin>>v[i]; return move(v);}
//template<class T=LL> inline vector<T> cinv(LL N){ vector<T> v(N); REP(i, N)cin>>v[i]; return move(v);}
#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl
#define cmax(a,b) {if(a<b){a=b;}}
#define cmin(a,b) {if(a>b){a=b;}}
#define EACH(a,A) for(auto a: A)
//#define cmax(a,b) a = (a>b ? a:b)
//#define cmin(a,b) a = (a<b ? a:b) 
//cin,cout高速化のおまじない＋桁数指定
inline VLL cinvll(LL N){
  VLL A(N);
  REP(i,N){
    cin >> A[i];
  }
  return move(A);
}
struct Fast{
	Fast(){
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(std::numeric_limits<double>::max_digits10);
	}
} fast;



void func(){
  LL H,W;
  cin >> H>> W;
  VVLL M1(H,VLL(W,0));
  VVLL M2(H,VLL(W,0));

  REP(i,H){
    REP(j,W){
      cin >> M1[i][j];
    }
  }
  REP(i,H){
    REP(j,W){
      cin >> M2[i][j];
    }
  }

  VVLL M(H,VLL(W,0));
  REP(i,H){
    REP(j,W){
      LL a;
      cin >> a;
      M[i][j] = abs(M1[i][j]-M2[i][j]);
    }
  }
  REP(i,H){
    REP(j,W){
      //M[i][j]=80;
    }
  }
  LL N = 80*(H+W+1)+1;
  //N=100;
  vector<vector<vector<bool>>> A(H,vector<vector<bool>>(W,vector<bool>(N+1,false)));
  //VVVLL A(H,VVLL(W,VLL(N+1)));

  LL m0 = M[0][0];
  A[0][0][m0]=true;

  LL kmax = 0;
  REP(i,H){
    REP(j,W){
      for(LL k=0;k<=N;++k){
        if(A[i][j][k]){
          if(j+1<W){
            LL m = M[i][j+1];
            //cerr << abs(k-m) << endl;
            //cerr << abs(k+m) << endl;
            chmax(kmax,abs(k-m));
            chmax(kmax,abs(k+m));
            
            A[i][j+1][abs(k-m)]=true;
            A[i][j+1][abs(k+m)]=true;
          }
          if(i+1<H){
            LL m = M[i+1][j];
            //cerr << abs(k-m) << endl;
            //cerr << abs(k+m) << endl;
            chmax(kmax,abs(k-m));
            chmax(kmax,abs(k+m));
            A[i+1][j][abs(k-m)]=true;
            A[i+1][j][abs(k+m)]=true;
          }
          //cerr << kmax<< endl;
        }
      }
    }
  }

  LL nmin = N+1;
  REP(k,N+1){

    if(A[H-1][W-1][k]){
      chmin(nmin,k);
    }
  }
  cout << nmin;

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

Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    string s;
    cin >> s;
    s[0] = '2';
    s[1] = '0';
    s[2] = '1';
    s[3] = '8';
    cout << s << endl;
    return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  int ans = 0;
  cin >> N >> M;
  map<int, int> mp;
  for(int i = 1; i <= M; i++) {
    mp[i] == 0;
  }

  REP(i, N) {
    int K;
    cin >> K;
    REP(j, K) {
      int b;
      cin >> b;
      mp[b]++;
    }
  }

  for(int i = 1; i <= M; i++) {
    if(mp[i] == N) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
ans = 10e9
def digitSum(n):
    s = str(n)
    array = list(map(int, s))
    return sum(array)
for i in range(1,N):
  a = i
  b = N-i
  a = digitSum(a)
  b = digitSum(b)
  ans = min(ans, a+b)
print(ans)

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

bool calcInc( int* a, int n, int x )
{
    bool judge = true;
    for( int i = 0; i < n; i++ )
        if( a[i] != x )
            judge = false;
    if( judge )
        return !judge;

    int i = n - 1;
    a[i]++;

    if( judge && a[n-1] == x + 1 )
        return false;

    while( i >= 0 && a[i] > x )
    {
        a[i] -= ( x + 1 );
        a[i-1]++;
        i--;
    }

    return !judge;
}

int main()
{
    int n, x, m;

    cin >> n >> x >> m;

    int a[n];
    for( int i = 0; i < n; i++ )
        a[i] = 0;

    int b[m][3];
    for( int i = 0; i < m; i++ )
        for( int j = 0; j < 3; j++ )
            cin >> b[i][j];

    int max = -1, res[n];
    do
    {
        bool judge = true;
        for( int i = 0; i < m; i++ )
        {
            int sum1 = 0;
            for( int j = b[i][0]; j <= b[i][1]; j++ )
                sum1 += a[j-1];

            if( sum1 != b[i][2] )
                judge = false;
        }

        int sum2 = 0;
        for( int i = 0; i < n; i++ )
            sum2 += a[i];

        if( judge && max < sum2 )
        {
            max = sum2;
            for( int i = 0; i < n; i++ )
                res[i] = a[i];
        }
    }
    while( calcInc( a, n, x ) );

    if( max == -1 )
        cout << -1 << endl;
    else
    {
        for( int i = 0; i < n - 1; i++ )
            cout << res[i] << " ";
        cout << res[n-1] << endl;
    }
    return 0;
}


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

int main() {
  int a,b; cin >> a >> b;
  string str; cin >> str;
  
  string ans = "Yes";
  for(int i = 0; i < str.size(); i++) {
    if(i == a) {
      if(str.at(i) != '-') {
        ans = "No";
        break;
      }
    } else {
      int foo = str.at(i) - '0';
      if(foo < 0 || foo > 9) {
        ans = "No";
        break;
      }
    }   
  }
             
  cout << ans << endl;
  
  return 0;
}
  

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

string rotate_string(string s){
  int n = s.length();
  string res(n, 'a');
  res[0] = s[n-1];
  for(int i=1; i<n; i++){
    res[i] = s[i-1];
  }
  return res;
}

int main() {
  string s, t;
  cin >> s >> t;

  bool flag = false;

  int n = t.length();
  for(int i=0; i<n; i++){
    string tmp = rotate_string(t);
    if(s == t) flag = true;
    t = tmp;
  }

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(void){
  long long int K;

  cin >> K;

  int cnt = 0;
  long long int total = 100;
  for(;total < K;){
    total += total * 0.01;
    cnt++;
  }

  cout << cnt;

  return 0;
}

Measured memory_bytes: 3636
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
 
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
 
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
 
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    /*     input! {
        n: usize,
        mut plan: [(i32, i32, i32); n],  // Vec<(i32, i32, i32)>
    }
 */
    input! {
        n:isize,
        k:isize,
        xs: [isize;n],
    }
    let mut ans = 0;
    for x in xs.iter(){
        let small = std::cmp::min(*x,(k - x).abs());
        ans += small * 2;
    }
    println!("{}",ans);
}    


Measured memory_bytes: 4352
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

int main() {
	string N;
	cin >> N;
	
	for (int i = 0; i < N.size(); i++) {
		cout << "x" ;
	}
	
	
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;
vector<string>  grid;
ll check(ll row_state, ll col_state)
{
    ll ans = 0;
    for(ll i=0; i<grid.size(); i++)
    {
        for(ll j=0; j<grid[0].size(); j++)
        {
            if( (row_state & (1<<i)) || (col_state & (1<<j)) )
            {
                continue;
            }
            else if(grid[i][j] == '#')
            {
                ans++;
            }
        }
    }
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    ll h,w,k;
    cin>>h>>w>>k;
    for(ll i=0; i<h; i++)
    {
       string s;
       cin>>s;
       grid.pb(s);
    }
    ll row_states = 1<<h;
    ll col_states = 1<<w;
    ll ans = 0;
    for(ll i=0; i<row_states; i++)
    {
        for(ll j=0; j<col_states; j++)
        {
            if(check(i, j) == k)
            {
                ans++;
            }
        }
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
template <typename T, typename U>
T max(T x, U y)
{
    return x>y ? x : y;
}
template <typename T, typename U>
T min(T x, U y)
{
    return x<y ? x : y;
}
ll dp[1000000];
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;cin >> n;ll k;cin >> k;
    ll a[n];
    for (int i = 0; i < n; ++i)
    {
    	cin >> a[i];
    }
    for (int i = 0; i < n; ++i)
    {
    	dp[i]=1e18;
    }
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for (int i = 2; i < n; ++i)
    {
    	for(ll j=1;j<=k;j++)
    		if(i-j>=0)
    	dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
    }
    /*for (int i = 0; i < n; ++i)
    {
    	trace(dp[i]);
    }*/
    cout << dp[n-1];
    }

Measured memory_bytes: 1792
import sys

def solve():
    N, K = map(int, sys.stdin.readline().split())
    p = [tuple(map(int, sys.stdin.readline().split())) for i in range(N)]

    p.sort()

    cnt = 0

    for ai, bi in p:
        cnt += bi

        if cnt >= K:
            print(ai)
            return

if __name__ == '__main__':
    solve()

Measured memory_bytes: 16980
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=b-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int n,c[25],v[25];
int main(){
	cin >> n;
	cu(i,0,n)cin >> v[i];
	cu(i,0,n)cin >> c[i];
	int ans = 0;
	cu(i,0,n)ans += max(v[i] - c[i], 0);
	cout << ans;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class AEntranceExamination {
        public void solve(int testNumber, inclass in, PrintWriter out) {
            double x = in.nextInt(), t = in.nextInt();
            out.printf("%.3f", x / t);
        }

    }

    static class inclass {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private inclass.SpaceCharFilter filter;

        public inclass(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

const long long MOD = 1000000007;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int S;
  cin >> S;
  vector<vector<long long>> dp(S, vector<long long>(S+1));
  for(int i = 3; i < S+1; i++){  
    dp[0][i] = 1;
  }
  
  for(int i = 1; i < S; i++){  
    for(int j = 3; j < S+1; j++){  
       dp[i][j] = (dp[i][j-1] + dp[i-1][j-3]) % MOD;
    } 
  }

  /*
  for(int i = 0; i < S; i++){
    for(int j = 0; j < S+1; j++){  
      cout << dp[i][j] << " "; 
    }
    cout <<endl;
  }
  */ 
  long long ans = 0;
  for(int i = 0; i < S; i++){  
    ans += dp[i][S];
    ans %= MOD;
  }
  cout << ans <<endl;
  
}


Measured memory_bytes: 34612
#include <iostream>

using namespace std;

int main()
{
  int n, q; cin >> n >> q;
  int a[100005]; for (int i = 0; i < n; ++i) cin >> a[i];
  
  while (q--) {
    long long x; cin >> x;
    int l = 0, r = 0;
    long long sum = 0, cnt = 0;
    while(1) {
      if (sum <= x) {
        if (r == n) {cnt += (long long)(r-l)*(r-l+1)/2; break;}
        sum += a[r++];
      } else {
        sum -= a[l++];
        cnt += r-l;
      }
    }
    cout << cnt << endl;
  }
  return 0;
}


Measured memory_bytes: 3472
R=[0,3,6]
N=range(9)
Z=[0]*9

n=input()
while n:
  F=[[" " for _ in Z] for _ in Z]
  M=[map(int,raw_input().split()) for _ in Z]
  M1=[[M[y][x] for y in N] for x in N]
  M2=[M[y][x:x+3]+M[y+1][x:x+3]+M[y+2][x:x+3] for y in R for x in R]
  for y in N:
    A=M[y]
    p0=y/3*3
    for x in N:
      p=p0+x/3
      a=A[x]
      if A.count(a)>1 or M1[x].count(a)>1 or M2[p].count(a)>1: F[y][x]="*"
    print "".join([a+b for a,b in zip(F[y],map(str,A))])
  if n>1: print
  n-=1

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

using namespace std;

#define int long long
#define vi vector <int>
#define all(v) v.begin(), v.end()
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)
#define forn(i, from, n) for (int i = (int)(from); i < (int)(n); ++i)

const int INF = 1e9 + 9;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

#ifdef LOCAL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    int n;
    cin >> n;
    vi v(n);
    forn(i, 0, n)
        cin >> v[i];
    vi dp(n, INF);
    dp[0] = 0;
    dp[1] = abs(v[1] - v[0]);
    forn(i, 2, n)
        dp[i] = min(dp[i - 1] + abs(v[i - 1] - v[i]), dp[i - 2] + abs(v[i - 2] - v[i]));
    cout << dp[n - 1];
    return 0;
}

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

int main() {
    int r;
    cin >> r;
    cout << r*r;
    return 0;
}


Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;
 
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int a[501][501];
string ans[250001];

int main() {
  string a,b,c;
  cin >> a >> b >> c;
  cout << a[0] << b[1] << c[2] << endl;
}


Measured memory_bytes: 2176
#include <iostream>

using namespace std;

int main(void){
    int H=0,W=0;
  
        
    while(true){
        cin>>H>>W;
          if(H==0&&W==0)
              break;
        for(int i=0;i<H;++i){
           for(int j=0;j<W;++j){
               cout<<"#";
           }
            cout<<"\n";
           
       }
        cout<<"\n";
       
    }
    return 0;
    
}




Measured memory_bytes: 3056
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;

    cout << a * b - a - b + 1 << endl;
    return 0;
}


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


Measured memory_bytes: 2108
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            switch (S)
            {
                case "SUN":
                    Console.WriteLine("7");
                    break;
                case "MON":
                    Console.WriteLine("6");
                    break;
                case "TUE":
                    Console.WriteLine("5");
                    break;
                case "WED":
                    Console.WriteLine("4");
                    break;
                case "THU":
                    Console.WriteLine("3");
                    break;
                case "FRI":
                    Console.WriteLine("2");
                    break;
                case "SAT":
                    Console.WriteLine("1");
                    break;
            }
            

        }
    }
}

Measured memory_bytes: 13152
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
DbgTimer D_t;
  #define TSTART() D_t.start()
  #define TSTOP() D_t.stop()
#else
  #define DUMP(i) 
  #define TSTART()
  #define TSTOP()  
#endif
 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());

using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const int EPS = 1e-9;



int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d;
  while(cin >> a >> b >> c >> d){
    TSTART();
    int ans = max(0,min(b,d)-max(a,c));
    cout << ans << endl;
    TSTOP();
  }
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	int N;
	cin >> N;
	vll num(4);
	ll d = 10;
	rep(i, 0, 4) {
		num[i] = N % d;
		N -= num[i];
		num[i] *= 10;
		num[i] /= d;
		d *= 10;
	}

	rep(i, 0, (1LL << 3)) {
		ll tmp = num[3];
		rep(j, 0, 3) {
			if (i & (1LL << j)) {
				tmp += num[j];
			}
			else {
				tmp -= num[j];
			}
		}
		if (tmp == 7) {
			cout << num[3];
			for (ll j = 2; j >= 0; j--) {
				if (i & (1LL << j)) {
					cout << '+';
				}
				else {
					cout << '-';
				}
				cout << num[j];
			}
			cout << "=7" << endl;
			return 0;
		}
	}

	return 0;

}


Measured memory_bytes: 3608
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
class A implements Comparable<A>{
	public A(){}
	public A(int i,int v){
		index =i;
		value = v;
	}
	int index;
	int value;
	
	public int compareTo (A a){
		return value > a.value ? 1 : -1;
	}
}
public class Main {
	public static void main(String args[]){//double 处理果盘
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		A[] a = new A[n];
		for (int i=0;i<n;i++){
			a[i] = new A(i+1,in.nextInt());
		}
		Arrays.sort(a);
		for(int i=0;i<n;i++){
			System.out.print(a[i].index+" ");
		}
	}
}	
		
	

Measured memory_bytes: 65016