akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        List<Double> inputDataList = new ArrayList<Double>();
        String input = null;

        try {
            while ((input = in.readLine()) != null) {
                inputDataList.add(Double.parseDouble(input));
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        List<Double> resultList = sort(inputDataList);

        System.out.println(resultList.get(0)
                - resultList.get(resultList.size() - 1));
    }

    private static List<Double> sort(List<Double> inputDataList) {

        if (inputDataList.size() == 1) {
            return inputDataList;
        }

        List<Double> firstHalfList = sort(inputDataList.subList(0,
                inputDataList.size() / 2));
        List<Double> secondHalfList = sort(inputDataList.subList(
                inputDataList.size() / 2, inputDataList.size()));

        int firstHalfListPosition = 0;
        int secondHalfListPosition = 0;
        List<Double> resultList = new ArrayList<Double>(firstHalfList.size()
                + secondHalfList.size());

        while (firstHalfListPosition < firstHalfList.size()
                || secondHalfListPosition < secondHalfList.size()) {

            if(firstHalfListPosition >= firstHalfList.size()) {
                resultList.add(secondHalfList.get(secondHalfListPosition));
                secondHalfListPosition++;
                continue;
            }

            if(secondHalfListPosition >= secondHalfList.size()) {
                resultList.add(firstHalfList.get(firstHalfListPosition));
                firstHalfListPosition++;
                continue;
            }

            if(firstHalfList.get(firstHalfListPosition) > secondHalfList.get(secondHalfListPosition)) {
                resultList.add(firstHalfList.get(firstHalfListPosition));
                firstHalfListPosition++;
            } else {
                resultList.add(secondHalfList.get(secondHalfListPosition));
                secondHalfListPosition++;
            }
        }

        return resultList;
    }

}

Measured memory_bytes: 16920
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <complex>
using namespace std;

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


int main()
{
        int n;
        while (cin >> n, n) {
                vector<int> vs = vector<int>(n);
                rep(i, n) cin >> vs[i];
                sort(vs.begin(), vs.end());
                int ans = 0;
                REP(i, 1, n-1)
                        ans += vs[i];
                ans /= n-2;
                cout << ans << endl;
        }
        return 0;
}

Measured memory_bytes: 1216
#include<stdio.h>
int main()
{  int a,b,c,k;
   scanf("%d%d%d%d",&a,&b,&c,&k);
   while(a>=b) 
    {  b=2*b;
       k--;
    }
   while(b>=c)
    {  c=2*c;
       k--;
	}
	if(k<0) printf("No");
	else printf("Yes");
} 

Measured memory_bytes: 1708
import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int s = sc.nextInt();
		int[] f =new int[1000001];
		
		int[] cc = new int[1000000];
		for(int i = 1;i < 1000001;i++){
			if(i == 1){
				f[i] = s;
			}else if(f[i-1] % 2 == 0){
				f[i] = f[i-1] /2;
			}else{
				f[i] = 3*f[i-1] + 1;
			}
//			System.out.println(f[i]);

			if(cc[f[i]] > 0){
				System.out.println(i);
				return;
			}
			cc[f[i]]++;
			
		}
		
	}


}

class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}



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

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        boolean first=true;
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            int i=0,n=0,m=0;
            int[][] card=null;
            int[] mat=null;
            while ((line = br.readLine()) != null) {
            	if(line.equals("-1 -1 -1"))break;
            	String[] str=line.split(" ");
            	int a=Integer.parseInt(str[0]);
            	int b=Integer.parseInt(str[1]);
            	int c=Integer.parseInt(str[2]);
            	if(a==-1||b==-1){
            		System.out.println("F");
            	}else if(a+b>=80){
            		System.out.println("A");
            	}else if(a+b>=65){
            		System.out.println("B");
            	}else if(a+b>=50){
            		System.out.println("C");
            	}else if(a+b>=30){
            		if(c>=50){
            			System.out.println("C");
            		}else{
            			System.out.println("D");
            		}
            	}else{
            		System.out.println("F");
            	}
            }
        }
    }

}

Measured memory_bytes: 24380
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;

int main() {
  int N,i;
  ll M=1000,S=0;
  cin>>N;
  vector<int> A(N+2);
  A[0]=201;
  A[N+1]=99;
  for (i=1;i<=N;i++) cin>>A[i];
  for (i=1;i<=N;i++) {
    if (A[i-1]>A[i] && A[i]<=A[i+1]) {
      S+=M/A[i];
      M%=A[i];
    } else if (A[i-1]<=A[i] && A[i]>A[i+1]) {
      M+=S*A[i];
      S=0;
    }
  }
  cout<<M<<endl;
  return 0;
}


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

constexpr int mod = 998244353;
constexpr int M = 350;
long long U[M][M][2*M], D[M][M][2*M], P[M][M][2*M];

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int K; cin >> K;
    K = min(K, M-10);
    vector<int> T;
    int cnt = 0, A = 0;
    for (auto &x: S) {
        if (x == '0') {
            T.emplace_back(cnt);
            cnt = 0;
        } else {
            cnt++, A++;
        }
    }
    int B = A + 10;
    T.emplace_back(cnt);
    int N = T.size(), C = 0;
    P[0][0][0] = 1;
    for (int i = 0; i < N; i++) {
        C += T[i];
        for (int j = 0; j <= B; j++) {
            for (int k = 0; k <= B*2; k++) {
                P[i][j][k] %= mod;
                int nj = j + T[i], nk = k;
                if (C > nj) {
                    int d = C - nj;
                    nj += d, nk += d;
                }
                if (nj <= A) {
                    if (nj < M && nk < 2*M) {
                        U[i+1][nj][nk] += P[i][j][k];
                        U[i+1][nj][nk] %= mod;
                    }
                    if (A+1-nj+nk < 2*M) {
                        U[i+1][A+1][A+1-nj+nk] += mod - P[i][j][k];
                        U[i+1][A+1][A+1-nj+nk] %= mod;
                    }
                }
            }
        }
        for (int j = 0; j <= B; j++) {
            for (int k = 0; k <= B*2; k++) {
                U[i+1][j+1][k+1] += U[i+1][j][k];
                U[i+1][j+1][k+1] %= mod;
            }
        }
        for (int j = 0; j <= B; j++) {
            for (int k = 0; k <= B*2; k++) {
                int nj = j, nk = k + T[i];
                if (nj < C) {
                    int d = C - nj;
                    nj += d, nk -= d;
                }
                if (nk > k) {
                    if (nj < M && nk < 2*M) {
                        D[i+1][nj][nk] += P[i][j][k];
                        D[i+1][nj][nk] %= mod;
                    }
                    if (j + T[i] < M) {
                        D[i+1][j+T[i]][k] += mod - P[i][j][k];
                        D[i+1][j+T[i]][k] %= mod;
                    }
                }
            }
        }
        for (int j = 0; j <= B; j++) {
            for (int k = 0; k <= B*2; k++) {
                if (k) {
                    D[i+1][j+1][k-1] += D[i+1][j][k];
                    D[i+1][j+1][k-1] %= mod;
                }
            }
        }
        for (int j = 0; j <= B; j++) {
            for (int k = 0; k <= B*2; k++) {
                assert(U[i+1][j][k] >= 0 && P[i+1][j][k] >= 0 && D[i+1][j][k] >= 0);
                P[i+1][j][k] = (U[i+1][j][k] + D[i+1][j][k]) % mod;
            }
        }        
    }
    long long Ans = 0;
    for (int i = 0; i <= 2*K; i++) {
        if (i & 1) assert(P[N][A][i] == 0);
        Ans += P[N][A][i] % mod;
    }
    cout << (Ans % mod + mod) % mod << "\n";
    return 0;
}

Measured memory_bytes: 404524
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    vector<int> a(n), b(n);
    rep(i, n) {
        cin >> a[i];
        b[i] = a[i];
    }    
    sort(b.begin(), b.end());

    int MAX = b[n-1];
    int MIN = b[0];

    if(0 <= MIN) {  // aが非負整数のみからなる場合
        cout << n-1 << "\n";
        for(int i = 1; i < n; i++) {
            cout << i << " " << i+1 << "\n";
        }
    }
    else if(MAX <= 0) {  // aが0以下の整数のみからなる場合
        cout << n-1 << "\n";
        for(int i = n; i > 1; i--) {
            cout << i << " " << i-1 << "\n";
        }
    }
    else {  // aに正の数も負の数も含まれる場合
        cout << 2*n-1 << "\n";
        int pos;
        if(MAX >= abs(MIN)) {  // すべての数にMAXを足せばaを非負整数のみにできる
            rep(i, n) {
                if(a[i] == MAX) {
                    pos = i+1;
                    break;
                }
            }
            for(int i = 1; i <= n; i++) {
                cout << pos << " " << i << "\n";
            }
            for(int i = 1; i < n; i++) {
                cout << i << " " << i+1 << "\n";
            }
        }
        else {  // すべての数にMINを足せばaを0以下の整数のみにできる
            rep(i, n) {
                if(a[i] == MIN) {
                    pos = i+1;
                    break;
                }
            }
            for(int i = 1; i <= n; i++) {
                cout << pos << " " << i << "\n";
            }
            for(int i = n; i > 1; i--) {
                cout << i << " " << i-1 << "\n";
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

map<ll,ll> pfmp; //各素因数の指数を格納
vector<ll> pfv(0); //異なる素因数を昇順に格納

void PF(ll N){
  ll n=N;
  if(n<=0) return;
  ll exp;
  if(n%2==0){
    if(pfmp[2]==0) pfv.push_back(2);
    exp=0;
    while(n%2==0){
      n/=2;
      exp++;
    }
    if(exp>pfmp[2]) pfmp[2]=exp;
  }
  if(n==1) return;
  for(ll i=3;i<=sqrt(N);i+=2){
    if(n%i==0){
      if(pfmp[i]==0) pfv.push_back(i);
      exp=0;
      while(n%i==0){
        n/=i;
        exp++;
      }
      if(exp>pfmp[i]) pfmp[i]=exp;
    }
  }
  if(n!=1){
    if(pfmp[n]==0){
      pfv.push_back(n);
      pfmp[n]=1;
    }
  } 
}

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

int main(){
  ll N; cin >> N;
  vector<ll> a(N);
  rep(i,N) cin >> a[i];
  rep(i,N){
    PF(a[i]);
  }
  ll LCM=1;
  rep(i,pfv.size()){
    rep(j,pfmp[pfv[i]]){
      LCM*=pfv[i]%MOD;
      LCM%=MOD;
    }
  }
  /*
  cout << "---" << endl;
  for(auto c:pfv){
    cout << c << ":" << pfmp[c] << endl;
  }
  cout << "---" << endl;
  cout << "LCM:" << LCM << endl;
  */
  ll ans=0;
  rep(i,N){
    ans+=LCM*modinv(a[i],MOD)%MOD;
    ans%=MOD;
  }
  /*
  for(auto c:pfv){
    cout << c << " " << pfmp[c] << endl;
  }
  */
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

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> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

constexpr int mod = 1000000007;

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

  int n, m;
  cin >> n >> m;
  set<int> broken;
  rep(i, m) {
    int b; cin >> b;
    broken.insert(b);
  }

  vector<ll> dp(n+2, 0);
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    if (!broken.count(i+1)) {
      dp[i+1] += dp[i];
      dp[i+1] %= mod;
    }
    if (!broken.count(i+2)) {
      dp[i+2] += dp[i];
      dp[i+2] %= mod;
    }
  }

  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()

struct UnionFind{
    vector<int> par;
    vector<int> dep;

    UnionFind(int siz){
        par.assign(siz,0);
        dep.assign(siz,0);
        for(int i = 0; i < siz; i++){
            par[i] = i;
        }
    };

    int find(int x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(dep[x] < dep[y]) par[x] = y;
        else{
            par[y] = x;
            if(dep[x] = dep[y]) dep[x]++;
        }
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }
};

struct edge{int from, to; double cost;};

bool comp(const edge& e1, const edge& e2){
    return e1.cost < e2.cost;
}

int main(){
    int n; 
    while(cin >> n && n){
        vector<vector<double>> v(n, vector<double>(4));
        for(int i = 0; i < n; i++){
            for(int j = 0; j < 4; j++) cin >> v[i][j];
        }

        vector<edge> e;
        for(int i = 0; i < n; i++){
            for(int j = i + 1; j < n; j++){
                double x = v[i][0] - v[j][0];
                double y = v[i][1] - v[j][1];
                double z = v[i][2] - v[j][2];
                double cost = sqrt(x*x + y*y + z*z);
                cost = max((double)0, cost - v[i][3] - v[j][3]);
                e.push_back({i, j, cost});
            }
        }

        UnionFind uf(n);
        sort(all(e), comp);
        double ans = 0;
        for(int i = 0; i < (n-1)*n/2; i++){
            if(uf.same(e[i].from, e[i].to)) continue;
            uf.unite(e[i].from, e[i].to);
            ans += e[i].cost;
        }
        printf("%.3f\n", ans);
    }
}


Measured memory_bytes: 3284
#include <iostream>

using namespace std;

int main(void) {
	string str;
	cin >> str;
	bool dance = true;
	for (int i = 0; i < str.length(); ++i) {
		if (i%2 == 0 && str[i] == 'L') {
			dance = false;
		}
		if (i%2 == 1 && str[i] == 'R') {
			dance = false;
		}
	}
	if (dance) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


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

#define FastRead        ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl            "\n"
#define sq(x)           ((x)*(x))
#define pi              acos(-1.0)
#define NUM             1000005

typedef long long ll;


int main()
{
    FastRead

    ll n,cnt=0,ans=0;

    cin>>n;

    vector<ll>v(3*n);

    for(auto &it:v)
        cin>>it;

    sort(v.begin(),v.end(),greater<ll>());

    for(ll i = 0; i < 3*n; i++)
    {
        if (cnt == n)
            break;
        if (i%2 != 0)
        {
            cnt++;
            ans += v[i];
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 5528
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
void ringring() {
	int a, b, c;
	cin >> a >> b >> c;

	cout << min(a + b, min(a + c, b + c)) << endl;

}
int main() {

	ringring();
	return 0;
}


Measured memory_bytes: 764
#include<stdio.h>
#include<math.h>

double to_deg(double r) {
    return r * 180.0 / (atan(1.0) * 4.0);
}

/**
 * 円周率を求める
 * @return 円周率
 */
double pi(void) {
    return atan(1.0) * 4.0;
}

int main(void){
  int a,b,x;
  double aki,theta;
  
  scanf("%d %d %d", &a, &b, &x);
  if(a * a * b / 2 <= x){
    aki = double(a * a * b - x);
    theta = atan(aki * 2 / (a * a * a));
    theta = to_deg(theta);
  }else{
    theta = atan(double(2 * x) / (a * b * b));
    theta = 90 - to_deg(theta);
  }
  
  printf("%lf\n",theta);

  return 0;
}

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

using ll = long long;

template <typename T> T inf;
template <> constexpr int inf<int> = 1e9;
template <> constexpr ll inf<ll> = 1e18;

int main() {
    int N, x;
    cin >> N >> x;
    if(x == 1 || x == 2 * N - 1) {
        cout << "No" << endl;
    } else if(N == 2) {
        cout << "Yes" << endl;
        for(int i = 0; i < 3; ++i) {
            cout << i + 1 << endl;
        }
    } else {
        set<int> ns;
        for(int i = 1; i <= 2 * N - 1; ++i) {
            ns.insert(i);
        }
        vector<int> v(2 * N - 1);
        v[N - 1] = x;
        ns.erase(x);
        if(x == 2 * N - 2) {
            v[N - 2] = x - 2; ns.erase(x - 2);
            v[N] = x + 1; ns.erase(x + 1);
            v[N + 1] = x - 1; ns.erase(x - 1);
        } else {
            v[N - 2] = x + 2; ns.erase(x + 2);
            v[N] = x - 1; ns.erase(x - 1);
            v[N + 1] = x + 1; ns.erase(x + 1);
        }
        cout << "Yes" << endl;
        for(int i = 0; i < 2 * N - 1; ++i) {
            if(v[i] == 0) {
                cout << *ns.begin() << endl;
                ns.erase(ns.begin());
            } else {
                cout << v[i] << endl;
            }
        }
    }
}


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

int min(int a, int b){
	return a <= b ? a : b;
}

int main(){
	int N, C, i, j, k, l, ans = 1000000000;
	scanf("%d%d", &N, &C);
	int **D = (int **)malloc(sizeof(int *) * C);
	for(i = 0; i < C; i++){
		D[i] = (int *)malloc(sizeof(int) * C);
		for(j = 0; j < C; j++){
			scanf("%d", &D[i][j]);
		}
	}
	int **c = (int **)malloc(sizeof(int *) * N);
	for(i = 0; i < N; i++){
		c[i] = (int *)malloc(sizeof(int) * N);
		for(j = 0; j < N; j++){
			scanf("%d", &c[i][j]);
			c[i][j]--;
		}
	}
	int **cp = (int **)malloc(sizeof(int *) * C);
	for(i = 0; i < C; i++){
//		printf("i = %d\n", i);
		cp[i] = (int *)malloc(sizeof(int) * 3);
		for(j = 0; j < 3; j++){
			cp[i][j] = 0;
		}
		for(k = 0; k < N; k++){
			for(l = 0; l < N; l++){
//				printf("(k, l) = (%d, %d)\n", k, l);
				cp[i][(k + l) % 3] += D[c[k][l]][i];
			}
		}
	}
	for(i = 0; i < C; i++){
		for(j = 0; j < C; j++){
			for(k = 0; k < C; k++){
				if(i != j && j != k && k != i){
					ans = min(ans, cp[i][0] + cp[j][1] + cp[k][2]);
				}
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
 
int main() {
  int N;
  cin >> N;
  
  double ans;
  
  ans = (double)(N/2+N%2)/N;
  
  cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int[] list=new int[N];
		for(int i=0;i<N;i++){
			list[i]=sc.nextInt();
		}
		int sum=0;
		for(int i=0;i<N;i++){
			sum=sum+list[i]%2;
		}
		if(sum%2==0){
			System.out.println("YES");			
		}else{
			System.out.println("NO");			
			
		}
	}
}

Measured memory_bytes: 33628
using System;

class Program
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        double x1 = double.Parse(s[0]);
        double y1 = double.Parse(s[1]);
        double x2 = double.Parse(s[2]);
        double y2 = double.Parse(s[3]);

        double disx = x2 - x1;
        double disy = y2 - y1;
        double z = disx * disx + disy * disy;
        z = Math.Sqrt(z);
        Console.WriteLine("{0:f4}",z);
        
    }
}

Measured memory_bytes: 9200
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(Scanner())
	x, _ := strconv.Atoi(Scanner())
	y, _ := strconv.Atoi(Scanner())
	x--
	y--
	ans := make([]int, n-1)
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			d := smaller(j-i, abs(x-i)+abs(y-j)+1)
			ans[d-1]++
		}
	}
	for i := 0; i < n-1; i++ {
		fmt.Println(ans[i])
	}
}
func abs(x int) int {
	if x < 0 {
		return -x
	} else {
		return x
	}
}
func smaller(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}


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

using ll = long long;
const int INF = INT_MAX;//2147483647
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var)  std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(int i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(int i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline double isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

int main() {
	int N,q;
	cin >> N >> q;
	string s;
	cin >> s;
	
	//平方分割してみる
	//1バケットに入っている要素数
	int bucket_num=floor(sqrt(N));
	//バケットの個数
	int bucket_size = (N + bucket_num - 1) / bucket_num;
	//バケット　バケット内に入っている2017っぽい数の個数
	vector<int> bucket(bucket_size,0);

	vector<int> aclist(N,0);
	rep(i,N-1){
		if(s[i]=='A' && s[i+1]=='C'){
			aclist[i]++;
		}
	}
	//バケットを作る
	rep(i,N){
		if(aclist[i]){
			bucket[i/bucket_num]++;
		}
	}

	debug(" ");
	debug(bucket_num);
	debug(bucket_size);
	debug(bucket);
	debug(aclist);

	vector<int> answerlist(q,0);
	rep(i,q){
		int x,y;
		cin >> x >> y;
		x--;y-=2;
		int answer=0;
		//バケットを走査
		// [x, y]の値を取得します　[x, y)がほしい場合はy-=1にしておいてね
		for (int i = 0; i < bucket_size; i++) {
			//bucket[i]の始点と終点
			int l = i * bucket_num;
			int r = (i + 1) * bucket_num - 1;
			//バケットの範囲外の場合はcontinue
			if (r < x || y < l){
				continue;
			}
			if (x <= l && r <= y) {
				//バケットが全て収まっている場合→バケットの値をそのまま使う
				answer += bucket[i];
			} else {
				//バケットの途中の場合→対象範囲を地道に調べる
				for (int j = max(x, l); j <= min(y, r); j++) {
					if(aclist[j]){
						answer++;
					}
				}
			}
		}
		answerlist[i]=answer;
	}

	rep(i,q)p(answerlist[i]);
	return 0;
}



Measured memory_bytes: 1920
x1, y1, x2, y2 = map(int, input().split())

dx = x2 - x1
dy = y2 - y1

x3 = x2 - dy
y3 = y2 + dx
x4 = x3 - dx
y4 = y3 - dy

print(x3, y3, x4, y4)


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

struct UnionFind{
    vector<long long> root;
    vector<long long> sizes;
    UnionFind(long long n): root(n + 1), sizes(n + 1,1){
        for(long long i = 0; i <= n; i++) root[i] = i;
    }
    long long find(long long x){
        if(x == root[x]) return x;
        return root[x] = find(root[x]);
    }
    void unite(long long x, long long y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(sizes[x] < sizes[y]) swap(x,y);
        root[y] = x;
        sizes[x] += sizes[y];
        sizes[y] = 0;
    }
    bool same(long long x, long long y){
        return find(x) == find(y);
    }
};

int main(){
    //input
    long long N,M;
    cin >> N >> M;
    long long p[N+1];
    long long i;
    for(i=1; i<=N; i++){
        cin >> p[i];
    }
    UnionFind uf(N);
    long long x,y;
    for(i=1; i<=M; i++){
        cin >> x >> y;
        uf.unite(x,y);
    }

    //calc
    long long ans=0;
    for(i=1; i<=N; i++){
        if(uf.find(i)==uf.find(p[i])){
            ans++;
        }
    }

    //output
    cout << ans << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 5600
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()
# row = [int(input().rstrip()) for _ in range(n)]

def resolve():
    import sys
    input = sys.stdin.readline
    import functools
    import operator

    n = int(input().rstrip())

    ans = 1
    for i in range(1, n+1):
        ans *= i
        ans = ans % 1000000007

    print(ans)



if __name__ == "__main__":
    resolve()


Measured memory_bytes: 67584
#include<bits/stdc++.h>
#define ll long long int 
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> v(n), sol(n);
	for(int i=0;i<n;i++)
		cin>>v[i];
	int res=0;
	for(int i=n-2;i>=0;i--){
		sol[i]=(v[i+1]<=v[i])?sol[i+1]+1:0;
		res=max(res,sol[i]);
	}
	cout<<res;
}

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

int main(){
  int x;
  cin >> x;
  if(400 <= x && x <= 599) cout << 8 << endl;
  if(600 <= x && x <= 799) cout << 7 << endl;
  if(800 <= x && x <= 999) cout << 6 << endl;
  if(1000 <= x && x <= 1199) cout << 5 << endl;
  if(1200 <= x && x <= 1399) cout << 4 << endl;
  if(1400 <= x && x <= 1599) cout << 3 << endl;
  if(1600 <= x && x <= 1799) cout << 2 << endl;
  if(1800 <= x && x <= 1999) cout << 1 << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m,k;
    cin>>n>>m>>k;
    long long int a[n],b[m];
    for(int i=0;i<n;i++)
        cin>>a[i];
    
    for(int i=0;i<m;i++)
        cin>>b[i];
    long long int res=0;
    int i=0;
    while(res+a[i]<=k && i<n)
    {
        res+=a[i];
        i++;
    }
    i--;
    int j=0;
    long long int maxi=i+1,ans=i+1;
    while(j<m)
    {
        if(res+b[j]<=k)
        {
            res+=b[j];
            j++;
            ans++;
        }
        else if(i>=0)
        {
            res-=a[i];
            i--;
            ans--;
        }
        maxi=max(maxi,ans);
        if(i<0 && res+b[j]>k)
            break;
    }
    cout<<maxi;
  return 0;
}

Measured memory_bytes: 6616
// https://beta.atcoder.jp/contests/abc073
// status:
// tag:

#define SUBMIT
//#define DEBUG

#include <bits/stdc++.h>

using namespace std;
using ui64 = uint64_t;

const int INF = INT_MAX / 4;
const int MAX_N = 200;
const int MAX_R = 8;
int r[MAX_R];
int d[MAX_N][MAX_N];
int N, M, R;

void floyd() {
    for (int k = 0; k < N; ++k) {
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

void init() {
    for (int i = 0; i < MAX_N; ++i) {
        for (int j = 0; j < MAX_N; ++j) {
            d[i][j] = (i == j) ? 0 : INF;
        }
    }
}

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    stringstream stream(R"(3 3 3
1 2 3
1 2 1
2 3 1
3 1 4
)");
#endif
    init();
    stream >> N >> M >> R;
    for (int i = 0; i < R; ++i) {
        int r_i;
        stream >> r_i;
        r[i] = r_i - 1;
    }
    for (int i = 0; i < M; ++i) {
        int A, B, C;
        stream >> A >> B >> C;
        d[A - 1][B - 1] = d[B - 1][A - 1] = C;
    }

    floyd();

    int ans = INF;
    sort(r, r + R);
    do {
        int dist = 0;
        for (int i = 1; i < R; ++i) dist += d[r[i - 1]][r[i]];
        ans = min(ans, dist);
    } while (next_permutation(r, r + R));

    cout << ans << endl;
#ifdef DEBUG
    cout << "floyd" << endl;
    for (int y = 0; y < N; ++y) {
        for (int x = 0; x < N; ++x) {
            cout << d[y][x] << " ";
        }
        cout << endl;
    }
#endif
    return 0;
}

Measured memory_bytes: 384
import sys

sys.setrecursionlimit(200000)

n = int(input())
# 値の初期化
path = [None]*(n + 1)
adjacent_list = [[] for i in range(n+1)]

for i in range(n - 1):
    a, b, c = list(map(int, input().split()))
    adjacent_list[a].append([b, c])
    adjacent_list[b].append([a, c])
# ノード番号、そこまでの距離,検索済みの要素を受け取る。


def dfs(node_n, distance, finished):
    # 検索済みに追加
    finished.add(node_n)
    # そこまでの距離を代入。値の更新などは特にない（はず）
    path[node_n] = distance
    # 対象ノードに対する隣接リストをforで回す
    for i in adjacent_list[node_n]:
        next = i[0]
        if next not in finished:
            # 検索済みでなかった場合、そこまでのコストを追加し再帰
            dfs(next, distance + i[1], finished)


q, k = list(map(int, input().split()))
dfs(k, 0, set())
# 各クエリへの返答
for i in range(q):
    s, g = list(map(int, input().split()))
    print(path[s] + path[g])


Measured memory_bytes: 140580
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 
using namespace std;
#define int long long
#define ld long double
#define endl '\n'
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define Fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const int M =1e9+7;

class graph
{
    public:
    vector<int> *g;
    int n;
    graph(int v)
    {
        n=v;
        g= new vector<int>[n];
    }
    void addedge(int u,int v)
    {
        g[u].pb(v);
        g[v].pb(u);
    }
};
void solve()
{
    int a,b,c;
    cin>>a>>b>>c;
   set<int> s;
   s.insert(a);
   s.insert(b);
   s.insert(c);
   if(s.size()==2)
   	cout<<"Yes"<<endl;
   else
   	cout<<"No"<<endl;
}
signed main()
{
    Fast;
    
    
    solve();
    
 return 0;    
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	string S; cin >> S;
	int a_z[26] = { 0 };
	for (int i = 0; i < S.length();i++) {
		a_z[S[i] - 'a']++;
	}
	for (int i = 0; i < 26;i++) {
		if (a_z[i] % 2 == 1) { cout << "No" << endl; return 0; }
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

string s;

int main(){
	cin >> s;
	int ans = (int)s.size();
	REP(i, (int)s.size() - 1) if(s[i] == s[i+1]) ans--, i+=2;
	cout << ans << endl;
}

Measured memory_bytes: 640
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
A = list(sorted((map(int, readline().split()))))

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    return gcd(b, a % b)

L = [0] * (N)
R = [0] * (N)
L[0] = A[0]
R[N - 1] = A[N - 1]

for i in range(1, N):
    L[i] = gcd(L[i - 1], A[i])

for i in range(N - 2, -1, -1):
    R[i] = gcd(R[i + 1], A[i])

ans = 0
# print(L)
# print(R)
for i in range(N):
    x = 0
    if i == 0:
        x = R[1]
    elif i == N - 1:
        x = L[N - 2]
    else:
        x = gcd(L[i - 1], R[i + 1])
    ans = max(ans, x)
print(ans)


Measured memory_bytes: 12860
from operator import itemgetter
import sys

n=int(input())
ls=[]
work=lim=0
i=0

for i in range(n):
    a,b=map(int,input().split())
    ls.append([a,b])
ls=sorted(ls,key=itemgetter(1))

for i in range(n):
    #print(i)
    work+=ls[i][0]
    #print(work,i)
    lim=ls[i][1]
    #print(lim,i)

    if lim<work:
        print("No")
        sys.exit()

print("Yes")


Measured memory_bytes: 39744
A, B, C, D = map(int, input().split())

def gcd(m, n) :
    r = m % n
    while r != 0 :
        m, n = n, r
        r = m % n
    return n

CD = (C * D) // gcd(C, D)

C1 = (A - 1) // C
C2 = B // C
D1 = (A - 1) // D
D2 = B // D
CD1 = (A - 1) // CD
CD2 = B // CD

print(B - A + 1 - (C2 - C1 + D2 - D1 - (CD2 - CD1)))

Measured memory_bytes: 38460
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.La;
		long p=Min(s[1]-1,s[2]);
		Console.WriteLine("{0}",(p*s[0])/s[1]-(s[0]*(p/s[1])));
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 27512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

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



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int[] a = in.nextIntArray(n);
			long sum = 0;
			long[] res = new long[n-1];
			for (int i = 0; i < n; i++) {
				sum += a[i];
			}

			long x = 0;
			long y = sum;
			for (int i = 0; i < n-1; i++) {
				x += a[i];
				y -= a[i];
				res[i] = Math.abs(x-y);
			}
			Arrays.sort(res);
			out.print(res[0]);
		}

	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}

	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


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

int main() {
    int N;
    ll K;
    cin >> N >> K;
    vector<vector<int>> A(70, vector<int>(N+1, 0));
    for (int i = 1; i <= N; i++) cin >> A[0][i];
    for (int j = 1; j <= 65; j++) {
        for (int k = 1; k <= N; k++) {
            A[j][k] = A[j-1][A[j-1][k]];
        }
    }
    
    ll pos = 1;
    int t = 0;
    while (K > 0) {
        if (K&1) pos = A[t][pos];
        t++;
        K >>= 1;
    }
    cout << pos << endl;
    return 0;
}

Measured memory_bytes: 58960
#include<bits/stdc++.h>
#include<iostream>
#include<bitset>
using namespace std;
 
 
#define all(x) (x).begin(),(x).end()
 
#define FOR(i,x) for(int i=0;i<(int)(x);i++)
#define FOR_S(i,x) for(int i=1;i<=(int)(x);i++)
#define FOR_R(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR_SR(i,x) for(int i=((int)(x));i>0;i--)
 
using ll = long long;
typedef long long ll;
typedef long long int64;
typedef long long lint;
typedef long long lli;
 
 
 
//bit
 
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
 
 
//variables
 
int N=0;
int M=0;
int ans=0;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 H[101010];
int dp[101010];
 
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> H[i];
    
    rep(i, 0, N) dp[i] = inf;
    dp[0] = 0;
 
    rep(i, 0, N) {
        chmin(dp[i + 1], dp[i] + abs(H[i] - H[i + 1]));
        chmin(dp[i + 2], dp[i] + abs(H[i] - H[i + 2]));
    }
 
    cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
using ll = long long;
using ull = unsigned long long;
const ll mod = 1e9 + 7;
ll a[N][3];
ll c[N];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < 3; ++j)
			cin >> a[i][j];
	ll ans = 0;
	for (int i = 0; i < 8; ++i)
	{
		int b[3];
		for (int j = 0, k = i; j < 3; ++j, k /= 2)
			b[j] = k % 2 ? 1 : -1;
		for (int j = 0; j < n; ++j)
			c[j] = b[0] * a[j][0] + b[1] * a[j][1] + b[2] * a[j][2];
		sort(c, c + n);
		ans = max(ans, accumulate(c + n - m, c + n, 0ll));
	}
	cout << ans;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		boolean fin = false;
		ArrayList<Integer> input = new ArrayList<Integer>();
		Scanner insert = new Scanner(System.in);
		while(true){
//			Scanner insert = new Scanner(System.in);
			String line = insert.nextLine();
			String array1[] = line.split(" ");
			int n = Integer.parseInt(array1[0]);
			int p = Integer.parseInt(array1[1]);
			if((n < 3) ||(n > 50) || (p < 2) || (p > 50)){
				break;
			}
			int tmpP = p;
			int[] hands = new int[n];
			for(int i = 0; i < hands.length; i ++) {
				hands[i] = 0;
			}
			int nowN = 0;
			while(true) {
				if(tmpP > 0) {
					hands[nowN]++;
					tmpP--;
				}
				else {
					if((tmpP == 0) && hands[nowN]>0) {

						tmpP = hands[nowN];
						hands[nowN] = 0;

					}
				}

				if((tmpP == 0) &&(hands[nowN] == p)) {

					input.add(nowN);
					break;
				}


				nowN++;
				if(nowN == (n)) {
					nowN = 0;
				}

			}

		}
		for(int a: input) {
			System.out.println(a);
		}
	}
}



Measured memory_bytes: 27404
//D 
#include <bits/stdc++.h>
using namespace std;
#define int long long 
typedef long long ll;
const ll mod = 1e9+7;
signed main(){
	ll n,k;
	cin >> n >> k;
	ll ans = 0,L = 0,R = n;
	int cnt = k;
	for(int i = k;i <= n+1;i++){
		L = (cnt*(cnt-1)/2)%mod,R = (n*cnt%mod - cnt*(cnt-1)/2%mod)%mod;
		cnt++;
		ans = (ans + (R-L+1))%mod;
//		cout << L << " " << R << " " << (R-L+1) << endl;
	} 
	cout << (ans+mod)%mod;
	return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
using namespace std;
int dp[100005] , x;
vector<int> v;
int main(){ios::sync_with_stdio(false),cin.tie(0);
	int n , k ;cin >> n >> k;
	for(int i=0 ; i<n ; ++i)
		cin >> x , v.push_back(x) , dp[x] = 1;

	for(int i=1 ; i<=k ; ++i){
		for(auto &c : v){
			if(i - c > 0 && dp[i-c] == 0) dp[i] = 1; 
		}
	}
	if(dp[k] == 1) cout<<"First\n";
	else cout << "Second\n";
}


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

int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  
  if ( k <= a ){
    cout << k;
  }
  else if ((a < k)&&( k <= a+b )){
    cout << a;
  }
  else {
    cout << a - (k-a-b);
  }
  
  return 0;
  
}


Measured memory_bytes: 3600
#include <iostream>

int main(void) {

    int r, d, x2000;
    std::cin >> r >> d >> x2000;

    int result = x2000;

    for (int i = 0; i < 10; i++) {
        result = result * r -d;
        std::cout << result << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#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 < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int N;
    string A, B, C;
    cin >> N >> A >> B >> C;

    int ans = 0;
    for(int i = 0; i < N; i++){
        if(A[i] == B[i] && A[i] == C[i] && B[i] == C[i]) continue;
        else if(A[i] != B[i] && A[i] != C[i] && B[i] != C[i]) ans += 2;
        else ans += 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
const ll inf=1e18L+5;
using namespace std;


int main()
{
	int n;
	cin>>n;
	vector<ll>a(n);
	vector<ll>s(n,0);
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(i!=0)
			s[i]+=s[i-1]+a[i];
		else
			s[i]=a[i];
	}

	ll dp[402][402];
	for(int l=n-1;l>=0;l--)
	{
		for(int r=l;r<n;r++)
		{
			if(l==r)
			{
				dp[l][r]=0;
				continue;
			}
			dp[l][r]=inf;
			ll range=0;
			if(l-1>=0)
				range=s[r]-s[l-1];
			else
				range=s[r];
			for(int i=l;i<r;i++)
				dp[l][r]=min(dp[l][r],dp[l][i]+dp[i+1][r]+range);
		}
	}
	cout<<dp[0][n-1];
}


Measured memory_bytes: 4864
import heapq

n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for _ in range(m)]
bc = sorted(bc, reverse = True, key = lambda x: x[1])
heapq.heapify(a)

for bbcc in bc:
  if a[0] >= bbcc[1]:
    break

  for _ in range(bbcc[0]):
    if a[0] < bbcc[1]:
      heapq.heappop(a)
      heapq.heappush(a, bbcc[1])
    else:
      break

print(sum(a))

Measured memory_bytes: 33784