akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) ((a)<<(b))
#define Rshift(a,b) ((a)>>(b))
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define sz(a) int(a.size())
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    double a = 3.1415926535897979323;
    double r;
    cin >> r;
    printf("%.10lf" ,r * a * 2);
}


Measured memory_bytes: 3772
#include <stdio.h>

int main()
{
	int a,b,c,x,d;
	int T=0;

	scanf("%d %d %d",&a,&b,&c);
	for (x = a;x <= b;x++) {
		if (c%x == 0) {
			T++;
		}
	}
	printf("%d\n",T);
	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
int MAX_V = 1000000;
int prime[1000001];
int main() {
  int i, j, k, l, n;
  int m = 0;
  int data[30] = {0};
  int count[30] = {0};
  for (i = 2; i <= MAX_V; i++) {
    prime[i] = 1;
  }
  for (i = 2; i * i <= MAX_V; i++) {
    if (prime[i]) {
      for (k = 2 * i; k <= MAX_V; k += i) {
        prime[k] = 0;
      }
    }
  }
  while (l != EOF) {
    l = scanf("%d", &data[m]);
    m++;
  }
  for (n = 0; n < m - 1; n++) {
    for (j = data[n]; 1 < j; j--) {
      if (prime[j] == 1) {
        count[n]++;
	  }
    }
    printf("%d\n", count[n]);
  }
  return 0;
}

Measured memory_bytes: 4500
class UnionFind:
    def __init__(self,n):
        self.parent = {}
        for i in range(n):
            self.parent[i] = i

    def get_root(self,x):
        r = x
        depth = 0
        path = [r]
        while self.parent[r]!=r:
            r = self.parent[r]
            path.append(r)
            depth += 1
        for n in path:
            self.parent[n] = r
        return r,depth

    def unite(self,x,y):
        rx,dx = self.get_root(x)
        ry,dy = self.get_root(y)
        if rx!=ry:
            if dx > dy:
                self.parent[ry] = rx
            else:
                self.parent[rx] = ry

    def same(self,x,y):
        rx,_ = self.get_root(x)
        ry,_ = self.get_root(y)
        if rx==ry: return 1
        else: return 0


n,q = map(int,raw_input().split(' '))
tree = UnionFind(n)

answers = []
for _ in range(q):
    com,x,y = map(int,raw_input().split(' '))
    if com==0:
        tree.unite(x,y)
    elif com==1:
        answers.append(tree.same(x,y))

for a in answers:
    print a

Measured memory_bytes: 10308
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {	
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int q = Integer.parseInt(sc.next());
		String s = sc.next();
		int[] map = new int[s.length()+1];
		int count=0;
		for(int i=0;i<s.length();i++) {
			if(s.charAt(i)=='A'&&i+1<s.length())
				if(s.charAt(i+1)=='C') {
					count++;
					map[i+1] = map[i] + count;
				}
			map[i+1] = count;
			
		}
		
		
		for(int i=0;i<q;i++) {
			int a = Integer.parseInt(sc.next());
			int b = Integer.parseInt(sc.next());
			System.out.println(map[b-1]-map[a-1]);
		}
		
	}
	
	
}


Measured memory_bytes: 55208
// STRIVER_79 
// Lets goto the next level 
// AIM 6* at CC and CM at CF *__* 

#include <algorithm>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define mod (int)(1e9 + 21)
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define int long long
#define ll long long 
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define in(x) scanf("%intd", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxheap priority_queue<int>
#define minheap priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define fi first
#define se second
#define kitna se
#define endl "\n"
#define pi pair<int, int>
#define LL long long 
const int MAXN = (int)((1e5) + 10);
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}  
bool isPrime(int N){ for(int i=2;i*i<=N;++i){if(N%i==0) return false;}return true;}
int cbrt(int x){ int lo=1,hi=min(2000000ll,x);while(hi-lo>1){int mid=(lo+hi)/2;if(mid*mid*mid<x){lo=mid;}else hi=mid;}if(hi*hi*hi<=x) return hi;else return lo;} 
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const int nax =  (int)(1*1e5+10);

// int SPF[N+5];

// void SOF()
// {
//     SPF[1] = 1;
//     for (int i=2; i<N; i++)
//         SPF[i] = i;
//     for (int i=4; i<N; i+=2)
//         SPF[i] = 2;
 
//     for (int i=3; i*i<N; i++)
//         {
//         if (SPF[i] == i)
//             {
//             for (int kon=i*i; kon<N; kon+=i)
//                 if (SPF[kon]==kon)
//                    SPF[kon] = i;
//             }
//         }
// }
int n,w;
int wt[nax],val[nax]; 
int dp[100][nax]; 

int func(int ind,int weight)
{
	if(weight>w)
		return -1e18;
	//if(weight==w) return 0;
	if(ind==n) return 0; 
	if(dp[ind][weight]!=-1) return dp[ind][weight]; 
	int ans = -1e9 + 5; 
	ans = max(ans,val[ind] + func(ind+1,weight+wt[ind]));
	ans = max(ans,func(ind+1,weight)); 
	return dp[ind][weight] = ans;

	
}





signed main(){

int t=1; 
//cin >> t;
// string s; 
// getline(cin,s);

while(t--)
{
	cin >> n >> w;
	for0(i,n)
	cin >> wt[i] >> val[i]; 

	ini(dp,-1); 

	cout << func(0,0); 	

}

rr;
}

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

int main()
{
  string s;
  cin >> s;
  for (int i = 1; i < 3; ++i)
  {
    if (s[i] != s[i-1]) 
    {
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std ;
typedef long long ll ;
# define rep (i , n ) for ( int i =0; i < n ; i++)
# define _sort(arg) sort(begin(arg), end(arg))

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

	ll N, A, B;

	cin >> N >> A >> B;

	if (A > B)
	{
		cout << 0 << endl;
		return 0;
	}

	if ((N == 1) && (A != B))
	{
		cout << 0 << endl;
		return 0;
	}

	ll min = A * (N - 1) + B;
	ll max = A + B * (N-1);

	cout << max - min + 1 << endl;


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
using pii = pair<int,int>;
const int INF = 1e7 + 7;
int H , W , K , st_x , st_y , end_x , end_y;

int main()
{
    //freopen("killer_01.txt" , "r" , stdin);
    //freopen("killer_01_out.txt" , "w" , stdout);

    cin >> H >> W >> K ;
    cin >> st_x >> st_y >> end_x >> end_y ;
     --st_x , --st_y , --end_x , --end_y;
    vector<vector<char>> g (H , vector<char> (W));

    for(int i = 0 ; i < H ; i ++)
        for(int j = 0 ; j < W ; j++)
            cin >> g[i][j];

    vector<vector<int>> dist(H , vector<int> (W,INF));
    dist[st_x][st_y] = 0;
    queue<pii> q;
    vector<int> dir1 = {-1,1,0,0};
    vector<int> dir2 = {0,0,1,-1};
    q.push({st_x , st_y});


    while(!q.empty())
    {
        auto f = q.front() ; q.pop();
        int x = f.F , y = f.S , d = dist[x][y];
        if(x == end_x && y == end_y)
        {
            cout << d << endl;
            return 0;
        }
        for(int pos = 0 ; pos < 4 ; pos++)
            for(int i = 1 ; i <= K ; i++)
            {   
                int xx = x + i*dir1[pos] , yy = y + i*dir2[pos];
                if(xx < 0 || yy < 0 || xx >= H || yy >= W || dist[xx][yy] <= d || g[xx][yy] == '@') break;
                if(dist[xx][yy] > d + 1)
                {
                    dist[xx][yy] = d + 1;
                    q.push({xx,yy});
                }
            }
    }

    cout << -1 << endl;
    return 0;    



}

Measured memory_bytes: 11960
//Name: Convenient Location
//Level: 2
//Cateogry: グラフ,Graph,全点間最短距離,All- points shortest path
//Note:

/**
 * Warshall-Floydで全点間最短距離を求め、行ごとに総和を求めて最小になるものを出力する。
 * 存在している街の番号を別に管理しないといけないのが面倒くさいが、隣接行列としては10×10でとってしまい、
 * どこにも行けない街があったら弾くという処理にすると楽。
 *
 * オーダーは O(N^3)。
 */

#include <iostream>
#include <vector>

using namespace std;

bool solve() {
    int N;
    if(!(cin >> N)) return false;
    if(!N) return false;

    vector<vector<int>> dist(10, vector<int>(10, -1));
    for(int i = 0; i < N; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        dist[a][b] = dist[b][a] = c;
        dist[a][a] = 0;
        dist[b][b] = 0;
    }

    for(int k = 0; k < 10; ++k) {
        for(int i = 0; i < 10; ++i) {
            for(int j = 0; j < 10; ++j) {
                if(dist[i][k] == -1 || dist[k][j] == -1) continue;
                const int nd = dist[i][k] + dist[k][j];
                if(dist[i][j] == -1 || dist[i][j] > nd) {
                    dist[i][j] = nd;
                }
            }
        }
    }

    int town = -1;
    int sum = -1;
    for(int i = 0; i < 10; ++i) {
        int tmp = 0;
        bool valid = false;
        for(int j = 0; j < 10; ++j) {
            if(dist[i][j] != -1) {
                tmp += dist[i][j];
                valid = true;
            }
        }
        if(valid && (sum == -1 || tmp < sum)) {
            town = i;
            sum = tmp;
        }
    }
    cout << town << ' ' << sum << endl;
    return true;
}

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

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 1216
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// }}}

int N;
vector<int> a;

void solve()
{
    vector<int> b(a);
    sort(ALL(a), greater<int>());
    REP(i, N){
        cout << (b[i] == a[0] ? a[1] : a[0]) << endl;
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    a.resize(N);
    REP(i, N) cin >> a[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


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

using namespace std;
const int N=1000005;
const long long inf = 1e18;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
long long d[N][4];
int m, n, k, x1, Y1, x2, y2;
vector <vector <char > >  a;


void setup() {
    cin >> m >> n >> k;
    cin >> x1 >> Y1 >> x2 >> y2;
    a.resize(m+1);
    for(int i=0 ; i<=m ; ++i) a[i].resize(n+1);
    for(int i=1 ; i<=m ; ++i) for(int j=1 ; j<=n ; ++j) cin >> a[i][j];
}

#define pii pair<int, int >
#define mp make_pair
#define F first
#define S second
int decode(int i, int j) {return (i-1)*n + j;}
void IJK() {
    for(int i=1 ; i<=m*n ; ++i)
        for(int j=0 ; j<4 ; ++j) d[i][j] = inf;
    priority_queue < pair <long long, pii > > q;
    for(int j=0 ; j<4 ; ++j) {
            int u = decode(x1, Y1);
            d[u][j] = 0;
            q.push(mp(0, mp(u, j)));
    }
    while(!q.empty()) {
        long long l = -q.top().F;
        int u = q.top().S.F;
        int dir = q.top().S.S;
        q.pop();
        if(l != d[u][dir]) continue;

        int y = u % n; if(y == 0) y = n;
        int x = u/n; if(u % n) ++x;

        for(int i=0 ; i<4 ; ++i) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(nx < 1 || ny < 1 || nx > m || ny > n || a[nx][ny]=='@') continue;
            long long w;
            if(i == dir) w = l + 1;
            else w = ((l-1)/k + 1)*k + 1;

            int nxtVer = decode(nx, ny);
            if(d[nxtVer][i] > w) {
                d[nxtVer][i] = w;
                q.push(mp(-w, mp(nxtVer, i)));
            }
        }
    }

    long long ans=inf;
    for(int i=0 ; i<4 ; ++i) {
            long long &x = d[decode(x2, y2)][i];
            x = ((x-1)/k + 1)*k;
            ans = min(ans, x);
    }
    if(ans==inf) ans = -k;
    cout << ans/k;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if(fopen(".inp", "r")) freopen(".inp", "r", stdin);
    setup();
    IJK();

    return 0;
}


Measured memory_bytes: 39608
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;
const int inf = 1e9;

int main(){
	int h,n;
	cin >> h >> n;
	vector<int> a(n), b(n);
	for(int i=0; i<n; i++){
		cin >> a[i] >> b[i];
	}
	vector<int> dp(h+1, inf);
	dp[h] = 0;
	for(int i=0; i<n; i++){
		for(int j=h; j>0; j--){
			if(dp[j] == inf) continue;
			int next = max(j-a[i], 0);
			dp[next] = min(dp[next], dp[j]+b[i]);
		}
	}
	cout << dp[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;

bool check(long long n, long long a[100005]){
    rep(i,n){
        if(a[i] > 0 || a[i] % n != 0){
            return 0;
        }
    }
    return 1;
}

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

    long long k = 0;
    long long a[100005], d[100005];
    rep(i,n){
        cin >> a[i];
        k += a[i];
    }

    long long sum = (n * n + n) / 2;
    if(k % sum == 0){
        k /= sum;
    }else{
        cout << "NO" << endl;
        return 0;
    }


    a[n] = a[0];
    rep(i,n){
        d[i] = a[i + 1] - a[i];
        d[i] -= k;
    }

    if(check(n,d)) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
#define MAX_N 201
#define MOD 998244353

int x[MAX_N], y[MAX_N], p[MAX_N];

int main(void)
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d%d", &x[i], &y[i]);
    p[0] = 1;
    for (int i = 0; i < n; i++)
        p[i + 1] = (p[i] << 1) % MOD;
    int ans = p[n] - n - 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i; j++) {
            int cnt = 0;
            for (int k = 0; k < j; k++) {
                if ((x[i] - x[j]) * (y[i] - y[k]) == (x[i] - x[k]) * (y[i] - y[j]))
                    cnt++;
            }
            ans -= p[cnt];
            ans += MOD;
            ans %= MOD;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    int N, X;
    cin >> N >> X;
    vector<int> L(N);
    rep(i, N) cin >> L.at(i);

    vector<int> D(N + 1);
    D.at(0) = 0;
    for (int i = 1; i < N + 1; i++) {
        D.at(i) = D.at(i - 1) + L.at(i - 1);
    }

    int ans = 0;
    for (int i = 0; i <= N; i++) {
        if (D.at(i) <= X) {
            ans = i + 1;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3540
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	double a, b, h, m;
	cin >> a >> b >> h >> m;

	const double pi = acos(-1);
	m += h * 60;

	double adeg = pi * m / 30;
	double bdeg = pi * m / 360;

	double ax = a * cos(adeg);
	double ay = a * sin(adeg);
	double bx = b * cos(bdeg);
	double by = b * sin(bdeg);

	double dx = ax - bx;
	double dy = ay - by;
	double ans = sqrt(dx*dx + dy * dy);
	printf("%.15f\n", ans);

	/*double degab = bdeg - adeg;

	double leng = sqrtf(a*a + b * b - 2 * a*b*cos(degab));
	printf("%.10f\n", leng);
*/

	return 0;
}

Measured memory_bytes: 4080
while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    if op == '?':
        break
    if op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a // b)


Measured memory_bytes: 5592
#include<bits/stdc++.h>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define put(x) cout<<#x<<" = "<<x<<endl;
#define X first
#define Y second
#define pb push_back
#define int num
#pragma GCC optimize("O2")
using namespace std;
typedef long long num;
typedef pair<int,int> point;
const int maxn=1e5+10,inf=1e9+10;

int n,a,b,c,d;

int32_t main(){
    scanf("%lld",&n);
    while(n--){
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	if(d<b || a-b<0){
	    printf("No\n");
	    continue;
	}
	if(b<=c+1){
	    printf("Yes\n");
	    continue;
	}
	a%=b;
	int g=__gcd(b,d);
	int x=(b-a-1),y=(c-a);
	x=x>0?x/g:(x-g+1)/g;
	y=y>0?y/g:(y-g+1)/g;
	if(x>y){
	    printf("No\n");
	}else{
	    printf("Yes\n");
	}
    }
}


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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    while(1){
        c -= b;
        if(c <= 0){
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if(a <= 0){
            cout << "No" << endl;
            return 0;
        }
    }
}

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

int main(){
    int  n,k;
    cin >> n >> k;
    int num = 1;
    for(int i=0;i<n;i++){
        if(num*2 < num+k){
            num = num*2;
        }
        else if(num*2 > num+k){
            num = num+k;
        }
        else num = num*2;
    }
    cout << num << endl;

  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  ll a, b, h;
  IN(a, b, h);
  OUT((a+b)*h/2);
  return 0;
}

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

#define ub upper_bound
#define sum(a) accumulate(all(a),0ll)
#define lb lower_bound
#define all(v) begin(v),end(v)
#define allr(v) rbegin(v),rend(v)
#define sort_dec(v) sort(all(v),[](auto e1,auto e2){return e1>e2;})
#define For(n) for(ll i=0;i<n;i++)
#define Forj(n) for(ll j=0;j<n;j++)
typedef long long int ll;
typedef unsigned long long int ull;
#define fi first
#define se second
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define Mp 1e9+7
#define vpll vector< pair<ll,ll> >
#define bug(n) {cout<<n;return;}
#define cont(n) {cout<<n<<endl;continue;}
#define pb push_back
 
void solve()
{
	ll n,k;
	cin>>n>>k;
	ll a[n];
	For(n)cin>>a[i];
	ll dp[n];
	dp[0]=0;
	rep(i,1,n){
		dp[i]=Mp;
		rep(j,1,k+1)if(i-j>=0)dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
	}
	cout<<dp[n-1];
}
 
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	 
	// freopen("error.txt", "w", stderr);
	 
	int t=1;
	 
	while(t--)
	{
		solve();
	}

	cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
	 
	return 0;
}

Measured memory_bytes: 5292
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.next());
        int K = Integer.parseInt(scanner.next());
        Integer[] A = new Integer[N];
        for (int i = 0; i < N; i++) {
            A[i] = Integer.parseInt(scanner.next());
        }
        Arrays.sort(A, Comparator.reverseOrder());
        long ans = 0;
        for (int i = 0; i < N; i++) {
            if (i >= K)
                ans += A[i];
        }
        System.out.println(ans);
    }

}


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

int main(void){
  vector<int> x;
  x.resize(3);
  cin >> x[0] >> x[1] >> x[2];
  sort(x.begin(), x.end());
  cout << x[2] * 10 + x[1] + x[0] << endl;
}


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

int main() {
  int N;
  cin >> N;
  if (N /10 % 111 == 0 || N %1000 %111 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

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

  int n; cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  vector<int> h(n);
  int maxh = 0;

  rep(i, n) {
    cin >> x.at(i) >> y.at(i) >> h.at(i);
    maxh = max(maxh, h.at(i));
  }

  for(int H=maxh; H<maxh+201; H++) {
    rep(i, 101) {
      rep(j, 101) {
        bool flag = true;
        rep(k, n) {
          if (h.at(k) != max(H - abs(i-x.at(k)) - abs(j-y.at(k)), 0)) {
            flag = false;
            break;
          }
        }
        if (flag) {
          cout << i << ' ' << j << ' ' << H << endl;
          return 0;
        }
      }
    }
  }
}

Measured memory_bytes: 256
using System;

namespace A___Good_Integer
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Console.ReadLine();
            if((n[0]==n[1]&&n[1]==n[2])||(n[1] == n[2] && n[2] == n[3]))
            {
                Console.WriteLine("Yes");
            }
            else 
            {
                Console.WriteLine("No");
            }
        }
    }
}

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

int main() {
  int n;
  cin >> n;
  int result;
  
  if (100<= n && n<=111) result=111;
  else if (112<= n && n<=222) result=222;
  else if (223<= n && n<=333) result=333;
  else if (334<= n && n<=444) result=444;
  else if (445<= n && n<=555) result=555;
  else if (556<= n && n<=666) result=666;
  else if (667<= n && n<=777) result=777;
  else if (778<= n && n<=888) result=888;
  else result =999;
  
  cout << result;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#include <deque>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
int ans=0;
using namespace std;
int N;
int K;

int main(){
	cin >> N >> K;
	vector<int> V(N);
	rep(i,0,N) cin >> V[i];
	rep(i,0,min(K,N)+1){
		rep(j,0,i+1){
			vector<int> tmp;
			rep(left,0,j){
				tmp.push_back(V[left]);
			}
			rep(right,0,i-j){
				tmp.push_back(V[N-1-right]);
			}
			int pit = 0;
			sort(all(tmp));
			rep(k,0,K-i){
				if(k < tmp.size() && tmp[k] > 0) pit += tmp[k];
			}
			rep(k,K-i,i){
				pit += tmp[k];
			}
			ans = max(ans,pit);
		}
	}
	cout << ans << endl;
}


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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#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)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

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

// First element is weight, second element is value.
using Item = std::pair<int, ull>;

// Time complexity is O(n * W),
// auxiliary space is O(W),
// where n = items.size(),
//       W = min(capacity, sum(weight)).
ull knapsack_01_small_capacity(const std::vector<Item> &items, int capacity) {
    int n = items.size();
    int weight_sum = 0;
    for (const Item &item: items) {
        weight_sum += item.first;
    }
    int W = std::min(capacity, weight_sum);
    std::vector<ull> dp(W + 1, 0);
    for (const Item &item: items) {
        for (int w = W; w >= item.first; --w) {
            dp[w] = std::max(dp[w], dp[w - item.first] + item.second);
        }
    }
    return dp[W];
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, T;
    cin >> N >> T;
    vector<int> A(N), B(N);
    vector<Item> items(N);
    REP(i, N) {
        cin >> A[i] >> B[i];
        items[i] = Item(A[i], B[i]);
    }
    sort(all(items));

    vector<ull> cummax(N);
    cummax[0] = items[N - 1].second;
    FOR(i, 1, N) {
        cummax[i] = max(cummax[i - 1], items[N - 1 - i].second);
    }
    PRINTA(cummax, 0, cummax.size());

    int capacity = T - 1;
    vector<vector<ull>> dp(N, vector<ull>(capacity + 1, -1));
    REP(i, capacity + 1) dp[0][i] = 0;
    REP(i, N) dp[i][0] = 0;

    ull result = 0;

    FOR(i, 1, N) {
        FOR(j, 1, capacity + 1) {
            if (j - items[i - 1].first >= 0 && dp[i - 1][j - items[i - 1].first] != -1) {
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - items[i - 1].first] + items[i - 1].second);
            } else {
                dp[i][j] = dp[i - 1][j];
            }
        }
        amax(result, dp[i][capacity] + cummax[N - i - 1]);
    }


    cout << result << endl;

    return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define fo(i, n) for(int i = 0; i < n; ++i)
#define rep(i, a, b) for(int (i) = (a); (i) < (b); ++(i))

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 200200;
const int mod = 1e9 + 7;
const ll INF = 1e18;
int n,m;
string s[100],t[100];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n>>m;
	fo(i,n)
		cin>>s[i];
	fo(i,m)
		cin>>t[i];
	if(m>m)	return cout<<"No",0;
	fo(i,n)
		fo(j,n)
		{
			if(i+m-1>=n||j+m-1>=n) continue;
			bool ok=1;
			fo(a,m)fo(b,m)
				if(s[i+a][j+b]!=t[a][b])
					ok=0,a=m+1;
			if(ok) return cout<<"Yes",0;
		}
	cout<<"No";
	return 0;	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef  long long ll;
using namespace std;
const int maxn = 1e6+5;
char k[30][30];
int sum = 0;
struct node
{
    int l, r;
};
int dx[] = {1, -1 , 0,0};
int dy[] = {0, 0, 1, -1};
int h, w;
int mp[30][30];
void dfs(int x, int y) {
   sum = 0;
   queue<node> q;
   node a, b;
   a.l = x;
   a.r = y;
   q.push(a);
   while(!q.empty()) {
      b = q.front();
      q.pop();
      int flag = 0;
      for(int i = 0; i < 4; i++) {
        int xx = b.l + dx[i];
        int yy = b.r + dy[i];
        if(xx==x&&yy==y) continue;
        if(xx >= 1&&xx <= h&&yy >= 1&&yy <= w&&k[xx][yy] == '.'&&!mp[xx][yy]) {
            q.push({xx, yy});
            mp[xx][yy] = mp[b.l][b.r]+1;
            sum = max(sum, mp[xx][yy]);
        }
      }
   }
}
int main()
{
    cin >> h >> w;
    int maxx = 0;
    for(int i = 1; i <= h; i++) {
        scanf("%s",k[i]+1);
    }
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++) {
            if(k[i][j] == '.') {
                memset(mp, 0, sizeof(mp));
                dfs(i, j);
                maxx = max(maxx, sum);
            }
        }
    }
    cout << maxx << endl;
}


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  ll N, A, B;
  cin >> N >> A >> B;
  cout << max(0ll, (B - A) * (N - 2) + 1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

/*

*/

ll a[5],k;

int main(void){
	rep(i,5)cin>>a[i];
	cin>>k;
	cout<<(a[4]-a[0]>k?":(":"Yay!")<<endl;
	return 0;
}

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

int main()
{
    int N,d,sum=0;
    cin >> N;
    if (N<=9) {
        cout << N;
    } else if (N<=99) {
        cout << 9;
    } else if (N<=999) {
        cout << N-99 + 9;
    } else if (N<=9999) {
        cout << 900+9;
    } else if (N<=99999) {
        cout << N-9999 + 900 + 9;
    } else {
        cout << 90000 + 900 + 9;
    }
    return 0;
}


Measured memory_bytes: 256
#通らない区間は高々1区間のみなので、区間の合計から最長距離を除いた距離が最短距離となる
k, n = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
#各座標間の距離の合計
total = 0
#各座標間の距離
dist = []

#各座標間の距離を求めつつ、合計を算出
for i in range(n):
    if i == n - 1:
        #座標0をまたいだ場合を考慮する
        temp = (k - a[i]) + a[0]
    else:
        temp = a[i + 1] - a[i]
    total += temp
    dist.append(temp)

ans = total - max(dist)
print(ans)

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

int main(){
 int N,X;
 cin >> N >> X;
 int m[101];
 int min_m = 1000;
 int sum = 0;
 int num = 0;
 for(int i = 0; i < N;i++) {
   cin >> m[i];
   min_m = min(min_m,m[i]);
   sum += m[i];
 }
 num = N + (X - sum) / min_m;
 cout << num << endl;
 
 
 
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct card {
  char mark;
  int value;
};

int main(int argc, char *argv[])
{
  int N, i, j, minj;
  struct card *C, *C1, *C2, tmp;
  int stable;
  char rd[3];
  char m[4];
  int order, max = 0;

  scanf("%d", &N);

  C = (struct card *)malloc(sizeof(struct card) * N);
  C1 = (struct card *)malloc(sizeof(struct card) * N);
  C2 = (struct card *)malloc(sizeof(struct card) * N);
  
  for (i = 0; i < N; i++) {
    scanf("%s", rd);
    C[i].mark = rd[0];
    C[i].value = atoi(&rd[1]);
    C1[i].mark = C[i].mark;
    C1[i].value = C[i].value;
    C2[i].mark = C[i].mark;
    C2[i].value = C[i].value;
  }

  stable = 1;
  for (i = 0; i < N; i++) {
    for (j = N - 1; j > i; j--) {
      if (C1[j].value < C1[j-1].value) {
	tmp.mark = C1[j].mark;
	tmp.value = C1[j].value;
	C1[j].mark = C1[j-1].mark;
	C1[j].value = C1[j-1].value;
	C1[j-1].mark = tmp.mark;
	C1[j-1].value = tmp.value;
      }
    }
  }

  for (i = 0; i < N; i++) {
    if (i != N - 1) printf("%c%d ", C1[i].mark, C1[i].value);
    else printf("%c%d\n", C1[i].mark, C1[i].value);
  }
  if (stable == 1) printf("Stable\n");
  else printf("Not stable\n");

  for (i = 0; i < N; i++) {
    minj = i;
    for (j = i; j < N; j++) {
      if (C2[j].value < C2[minj].value) minj = j;
    }
    if (i != minj) {
      tmp.mark = C2[i].mark;
      tmp.value = C2[i].value;
      C2[i].mark = C2[minj].mark;
      C2[i].value = C2[minj].value;
      C2[minj].mark = tmp.mark;
      C2[minj].value = tmp.value;
    }
  }

  stable = 1;
  for (i = 1; i <= 9; i++) {
    order = 0;
    for (j = 0; j < N; j++) {
      if (C[j].value == i) m[order++] = C[j].mark;
    }
    order = 0;
    for (j = 0; j < N; j++) {
      if (C2[j].value == i) {
	if (C2[j].mark != m[order]) {
	  stable = 0;
	  break;
	}
	order++;
      }
    }
    if (stable == 0) break;
  }

  for (i = 0; i < N; i++) {
    if (i != N - 1) printf("%c%d ", C2[i].mark, C2[i].value);
    else printf("%c%d\n", C2[i].mark, C2[i].value);
  }
  if (stable == 1) printf("Stable\n");
  else printf("Not stable\n");

  return 0;
}

Measured memory_bytes: 608
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
    int a,b,i,heightb=0;
    scanf("%d%d",&a,&b);

    for(i=1;i<=b-a;i++){
        heightb += i;
    }
    printf("%d\n",heightb-b);

    return 0;
}

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

#define MAX 400002

int n;
int q;

struct st{
	int a;
	int b;
	long long int c;
};
vector<st> v;
long long int id[MAX];
bool cmp(st a,st b){
	return a.c<b.c;
}
int belong[MAX];
inline int root(int b){
	if(belong[b]==-1){
		return b;
	}
	return belong[b]=root(belong[b]);
}
void merge(int a,int b){
		a=root(a);
		b=root(b);
		if(a==b)return;
		belong[a]=b;
}
int main(){
	for(int i=0;i<MAX;i++){
		id[i]=LLONG_MAX/2LL;
	}
	cin>>n>>q;
	for(int i=0;i<q;i++){
		long long int a,b,c;
		scanf("%lld%lld%lld",&a,&b,&c);
		v.push_back({a,b,c});
		id[a]=min(id[a],c+1);
		id[b]=min(id[b],c+2);
	}
	long long int cur=LLONG_MAX;
	for(int i=0;i<2*n;i++){
		cur=min(cur,id[i]);
		id[i%n]=min(id[i%n],cur);
		cur+=2;
	}
	for(int i=0;i<n;i++){
		v.push_back({i,(i+1)%n,id[i%n]});
	}
	sort(v.begin(),v.end(),cmp);
	memset(belong,-1,sizeof(belong));
	long long int num=0;
	for(int i=0;i<v.size();i++){
		if(root(v[i].a)!=root(v[i].b)){
			merge(v[i].a,v[i].b);
			num+=v[i].c;
		}
	}
	printf("%lld\n",num);
	return 0;
}


Measured memory_bytes: 15080
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



int main(){
	
	int A,B;
	cin>>A>>B;
	
	int ans = 0;
	
	for(int i=A;i<=B;i++){
		string s = to_string(i);
		string t = s;
		reverse(t.begin(),t.end());
		if(s==t)ans++;
	}
	
	cout<<ans<<endl;
		
    return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/06/15  Problem: diverta2019-2 C / Link: https://atcoder.jp/contests/diverta2019-2  ----- */


// 操作をしても変わらない要素に着目する

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

	LL N; cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}

	SORT(a);
	vector<int> minus, plus;
	FOR(i, 1, N - 1) {
		if (a[i] <= 0) {
			minus.push_back(a[i]);
		}
		else {
			plus.push_back(a[i]);
		}
	}

	//minus.push_back(a.back());
	//plus.push_back(a.front());
	vector<PII>ans;
	int L = a.front();
	for (auto it : plus) {
		ans.push_back(PII(L, it));
		L = L - it;
	}
	DD(de(L));
	int R = a.back();
	for (auto it : minus) {
		ans.push_back(PII(R, it));
		R = R - it;
	}
	DD(de(R));
	ans.push_back(PII(R, L));
	cout << R - L << endl;
	for (auto it : ans) {
		cout << it.first << " " << it.second << endl;
	}

	return 0;
}


Measured memory_bytes: 3828
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    #n = int(stdin.readline().rstrip())
    l,r,d = map(int, stdin.readline().rstrip().split())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    ans = 0
    for i in range(l,r+1):
        if i%d == 0:
            ans += 1
    print(ans)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 9172
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstring>

#define FOR(i, a, b) for (int i = a; i < b; i++)
#define FORN(i, a, b) for (int i = a; i <= b; i++)
#define P(s) cout << s << endl
#define PC(condition, _true, _false) if (condition) _true; else _false;

using namespace std;
//
// Created by karayuu on 2019-3-28.
//

int main() {
    double x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    double dis = sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
    printf("%.5f", dis);
}


Measured memory_bytes: 3208
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define REPS(i,n) for(int i=1;i<=(n);i++)
#define RREPS(i,n) for(int i=(n);i>0;i--)
#define mp make_pair
#define pb(a) push_back(a)
#define VSORT(v) sort(v.begin(), v.end());
#define inf 1e9

int main(){
    string S;
    cin >> S;
    bool flag[26] = {};
    string ans;
    int len = S.length();
    if(S == "zyxwvutsrqponmlkjihgfedcba"){
        cout << -1 << endl;
        return 0;
    }
    else if(len != 26){
        REP(i,len) flag[(int)S[i] - 97] = true;
        REP(i,26){
            if(! flag[i]){
                S += char(i+97);
                break;
            }
        }
        cout << S << endl;
        return 0;
    }
    else{
        vector<char> ans;
        REP(i,len) ans.pb(S[i]);
        next_permutation(ans.begin(),ans.end());
        REP(i,len){
            cout << ans[i];
            if(ans[i] != S[i]) break;
        }
        cout << endl;
    }
    return 0;
}


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

int main(){
   long long n,a,b,c,d,e;
    cin >> n >> a >> b >> c >> d >> e;
   long long m,x;
    m = min(a,b);
    m = min(m,c);
    m = min(m,d);
    m = min(m,e);

    if(n < m){
        x = 1;
    }else if(n%m == 0){
        x = n/m;
    }else{
        x = n/m +1;
    }
    cout << x+4 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
const ll MOD = 1e9 + 7;
#define rep(i,k) for(int i=0;i<k;i++)
ll n, i, j, k, o, p, l, z,x,y,h,w,sa=0,m;
ll a[200010] = {}, b[200010], inf = 1000000000000;
string s;
vector<vector<ll>> va(100005);
queue<ll> q;
pair<ll, ll> pp;
ll par[100005];

ll root(ll x) {
	if (par[x] == x) {
		return x;
	 }
	else {
		return par[x] = root(par[x]);
	}
}

bool same(ll x, ll y) {
	return root(x) == root(y);
}

void unite(ll x, ll y) {
	x = root(x);
	y = root(y);
	if (x == y)return;
	par[x] = y;
}
void shokika(ll* par, ll n) {
	rep(i, n)par[i] = i;
}
int main() {
	cin >>n>>k;
	if (k > (n-1) * (n - 2) / 2) {
		cout << -1;
		return 0;
	}
	x = (n - 1) * (n - 2) / 2 - k;
	cout << x + n - 1 << "\n";
	rep(i, n-1)	cout<< 1<<" "<<i+2<<"\n";
	o = 0;
	for (i = 2; i < n; i++)for (j = i + 1; j <= n; j++) {
		if (o == x)return 0;
		cout << i << " " << j << "\n";
		o++;	
	}
	
	return 0;
	
}

Measured memory_bytes: 2688
N=int(input())
A=[]
for i in range(N):
  A.append(int(input())-1)
L=[]
i=0
cnt=0
while True:
  if cnt>10**6:
    print(-1)
    exit()  
  i=A[i]
  L.append(i)
  cnt+=1
  if i==1:
    print(cnt)
    exit()


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

struct node{
  struct node *right;
  struct node *left;
  struct node *p;
  int key;
};
typedef struct node * node;

#define NIL NULL

void insert(int);
void inorder(node );
void preorder(node );
node treeSearch(node , int );

node T;

int main(){
  int n;
  char read[8];
  int k;
  int i;
  int x;

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    if(scanf("%s",read)==EOF)break;
    if(read[0]=='i'){
      scanf("%d",&k);
      insert(k);
    }
    if(read[0]=='p'){
      inorder(T);
      printf("\n");
      preorder(T);
      printf("\n");
    }
    if ( read[0] == 'f' ){
      scanf("%d", &x);
      node t = treeSearch(T, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}

void insert(int k){

  node y = NIL;
  node x = T;
  node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;


  
 
  y=NIL;
  x=T;
  while(x!=NIL){
    y=x;
    if(z->key<x->key)x=x->left;
    else x=x->right;

  }
  z->p=y;
  if(y==NIL){
    T=z;
  }
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
  
	       
}
void preorder(node u){

  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

node treeSearch(node u, int k){
  if(u==NIL){
    return u;
  }
  if(u->key==k){
    return u;
  }
  if(u->key>k){
    treeSearch(u->left,k);
  }
  else  treeSearch(u->right,k);
}



Measured memory_bytes: 20488
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

map<string, int> ans;

int main(void){
	string s;
	ans["SUN"] = 7;
	ans["MON"] = 6;
	ans["TUE"] = 5;
	ans["WED"] = 4;
	ans["THU"] = 3;
	ans["FRI"] = 2;
	ans["SAT"] = 1;  
	cin >> s;
	cout << ans[s] << endl;
	return 0;
}


Measured memory_bytes: 256
from sys import stdin, stdout
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()

def main():
	N, M = (int(x) for x in rll())
	A = [int(x) for x in rll()]
	tot = sum(A)
	cutoff = tot/(4*M)
	A.sort(reverse = True)
	count = 0
	for i, num in enumerate(A):
		if num >= cutoff:
			count += 1
		else:
			break
	if count >= M:
		stdout.write("Yes");stdout.write("\n")
	else:
		stdout.write("No");stdout.write("\n")
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 38396
// 2018/12/09 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;

	int cnt = 0;

	while(N>0){
		int x = (N-1)/(K+1)+1;
		N -= x;
		cnt++;
	}

	cout << cnt << endl;

	return 0;
}



Measured memory_bytes: 3124
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        s: chars,
    }
    let mut ans = 0;
    let mut s1 = HashSet::new();
    let mut s2 = HashSet::new();
    for i in 1..n {
        s1.insert(s[i - 1]);
        s2 = s[i..n].iter().map(|&x| x).collect();
        let m = s1.intersection(&s2).collect::<HashSet<_>>().len();
        ans = max(ans, m)
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        // Your code here!
        int[] a = Console.ReadLine().ToCharArray().Select(x => int.Parse(x.ToString())).ToArray();
        int n = a.Length - 1;
        
        
        for(int i = 0; i < Math.Pow(2, n); i++)
        {
            string[] s = new string[3];
            for(int j = 0; j < n; j++)
            {
                if((1 & i>>j) == 1) s[j] = "+";
                else s[j] = "-";
            }
            
            int sum = a[0];
            for(int k = 0; k < s.Length; k++)//7になるかどうか調べる
            {
                if(s[k] == "+") sum += a[k + 1];
                else sum -= a[k + 1];
            }
            
            if(sum == 7)
            {
                Console.WriteLine(a[0] + s[0] + a[1] + s[1] + a[2] + s[2] + a[3] + "=7");
                return;
            }
        }
        
    }
}

Measured memory_bytes: 13396