akhauriyash/Code-Regression huggingface dataset:
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll n,k,c;
    cin>>n>>k>>c;
    string s;
    cin>>s;
    s='&'+s;
    map <ll,ll> left,right;
    for(int i=n;i>=1;i--)
    {
        if(s[i]=='x')
            right[i]=right[i+1];
        else
            right[i]=1+right[i+c+1];
    }
    for(int i=1;i<=n;i++)
    {
        if(s[i]=='x')
            left[i]=left[i-1];
        else
            left[i]=1+left[i-1-c];
    }
    vl ans;
    vl indx;
    indx.pb(0);
    set <ll> bound;
    for(int i=1;i<=n;i++)
    {
        if(s[i]=='o')
        {
            bound.insert(i);
            indx.pb(i);
        }
    }
    indx.pb(n+1);
    set <tuple<ll,ll,ll>> maxi;
    for(int i=1;i<=n;i++)
    {
        maxi.insert(make_tuple(left[i-1]+right[max((ll)i+1,i+c)],i-1,max((ll)i+1,i+c)));
        maxi.insert(make_tuple(right[i+1]+left[min((ll)i-1,i-c)],min((ll)i-1,i-c),i+1));
        if(s[i]=='x')
            continue;
        ll temp=0;
        while(true)
        {
            auto it=maxi.end();
            it--;
            auto t=(*it);
            ll l=get<1>(t);
            ll r=get<2>(t);
            if(l>=i || r<=i)
                maxi.erase(it);
            else
            {
                temp=max(temp,get<0>(t));
                break;
            }
        }
        if(temp>=k)
        {
            bound.erase(i);
        }
        // cout<<i<<' '<<temp<<'\n';
    }
    for(auto it:bound)
        cout<<it<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 61896
#include<bits/stdc++.h>
using namespace std;
const bool DBG = 1;

#define TRACE(x)    x
#define WATCH(x)    TRACE(cout << #x" = " << x << endl)
#define WATCHR(a,b) TRACE(for(auto it=a; it!=b;) cout<<*(it++)<<" ";cout<<endl)
#define WATCHC(V)   TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pair<int,int>> vpii;

void fill(vector<vector<char>> &pat, int d, char c, int i, int j) {
	int dimI = pat.size();
	int dimJ = pat[0].size();
	for(int k = 0; k < d/2; k++) {
		for(int l = k; l < d-k; l++) {
			if(j+l < 0 || j+l >= dimJ) continue;
			if(i+k >= 0 && i+k < dimI) pat[i + k][j + l] = c;
			if(i-k >= 0 && i-k < dimI) pat[i - k][j + l] = c;
		}
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(15);

	int H, W, d;
	cin >> H >> W >> d;

	if(d % 2 == 1) {
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				int v = (i % 2) ^ (j % 2);
				if(v) {
					cout << 'R';
				} else {
					cout << 'Y';
				}
			}
			cout << endl;
		}
	} else {
		vector<vector<char> > pat(2*d, vector<char>(2*d));
		fill(pat, d, 'R', 0, 0);
		fill(pat, d, 'R', d, d);
		fill(pat, d, 'R', 2*d, 0);
		fill(pat, d, 'Y', d, 0);
		fill(pat, d, 'Y', 0, d);
		fill(pat, d, 'Y', 2*d, d);
		fill(pat, d, 'G', d/2, d/2);
		fill(pat, d, 'G', 3*d/2, -d/2);
		fill(pat, d, 'G', 3*d/2, 3*d/2);
		fill(pat, d, 'B', d/2, -d/2);
		fill(pat, d, 'B', d/2, 3*d/2);
		fill(pat, d, 'B', 3*d/2, d/2);

		int D = 2*d;
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				cout << pat[i%D][j%D];
			}	cout << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 4480
def f(n):
    for i in range (1,n):
        n*=i
    return n
        
while True:
    n=int(input())
    if n==0:
        break
    else:
        a=str(f(n))
        s=0
        l=len(a)
        for i in range(l-1,-1,-1):
            if a[i]=='0':
                s+=1
            else:
                break
        print(s)




Measured memory_bytes: 5708
N = int(input())
A = [int(x) for x in input().split()]
A.sort(reverse=True)
H=0
W=0
for i in range(N-1):
  if A[i]==A[i+1]:
    H=A[i]
    A[i]=0
    A[i+1]=0
    break
A.sort(reverse=True)
for i in range(N-1):
  if A[i]==A[i+1]:
    W=A[i]
    A[i]=0
    A[i+1]=0
    break
print(H*W)

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

template <typename Monoid>
struct LazySegmentTree{
private:
    int N;
    vector<Monoid> node, lazy;

public:
    LazySegmentTree(int sz = 0){
        init(sz);
    }
    void init(int sz){
        N = 1;
        while(N < sz) N <<= 1;
        node.resize(2*N-1,0);
        lazy.resize(2*N-1,0);

    }
    void build(vector<Monoid>& v){
        int sz = int(v.size());
        init(sz);
        for(int i=0; i<sz; i++){
            node[i+N-1] = v[i];
        }
        for(int i=N-2; i>=0; i--){
            node[i] = node[i*2+1] + node[i*2+2];
        }
    }
    // node[k]
    void eval(int k){
        if(lazy[k] != 0){
            node[k] += lazy[k];
            if(k < N-1){ // 最下段でないとき
                lazy[2*k+1] += lazy[k] / 2;
                lazy[2*k+2] += lazy[k] / 2;
            }
            lazy[k] = 0;
        }
    }
    // [a,b)
    void add(int a, int b, Monoid x){add(a, b, x, 0, 0, N);}
    void add(int a, int b, Monoid x, int k, int l, int r){
        if(b <= l || r <= a) return;
        eval(k);
        if(a <= l && r <= b){
            lazy[k] += x * (r-l);
        }
        else{
            add(a, b, x, 2*k+1, l, (l+r)/2);
            add(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = node[2*k+1] + node[2*k+2];
        }
    }
    // [a,b)
    Monoid getSum(int a, int b){return getSum(a, b, 0, 0, N);}
    Monoid getSum(int a, int b, int k, int l, int r){
        if(b <= l || r <= a) return 0;
        
        eval(k);
        if(a <= l && r <= b) return node[k];
        Monoid vl, vr;
        vl = getSum(a, b, 2*k+1, l, (l+r)/2);
        vr = getSum(a, b, 2*k+2, (l+r)/2, r);
        return vl + vr;
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    LazySegmentTree<ll> seg(n);
    for(int i=0;i<q;i++){
        int c;
        cin >> c;
        if(c == 0){
            ll s, t, x;
            cin >> s >> t >> x;
            seg.add(s-1,t,x);
        }
        else{
            int s;
            cin >> s;
            cout << seg.getSum(s-1,s) << endl;
        }
    }
    return 0;
}



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

using namespace std;


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

int H, W; 
vector<string> maze;


void solve() {
    cin >> H >> W;
    maze.resize(H);
    for (int i = 0; i < H; i++) cin >> maze[i];

    vector<vector<int>> dist(H, vector<int>(W, -1));
    queue<pair<int, int>> q;

    for (int i = 0; i < H; i++) {
        for (int  j = 0; j < W; j++) {
            if (maze[i][j] == '#') {
                dist[i][j] = 0;
                q.push(make_pair(i, j));
            }
        }
    }

    while (!q.empty()) {
        auto cur = q.front();
        q.pop();
        for (int i = 0; i < 4; i++) {
            int nx = cur.first + dx[i], ny = cur.second + dy[i];
            if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            if (dist[nx][ny] == -1) {
                dist[nx][ny] = dist[cur.first][cur.second] + 1;
                q.push(make_pair(nx, ny));
            }
        }
    }

    int res = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            res = max(res, dist[i][j]);
        }
    }

    cout << res << endl;
}


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

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

long long mod = 1000000007;

int main(){
  long long N,K;
  cin >> N >> K;
  vector<long long> S(N+1,0),Sr(N+1,0);
  Sr[N] = N;
  for(int i=1;i<=N;i++){
    S[i] = S[i-1]+i;
    S[i] %= mod;
  }
  for(int i=N-1;i>=0;i--){
    Sr[i] = Sr[i+1]+i;
    Sr[i] %= mod;
  }
  
  long long ans=0;
  for(int i=N+1;i>=K;i--){
    ans += (Sr[(N+1)-i]+mod) - S[i-1] + 1;
    ans %= mod;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6324
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<vector<int>> f(n,vector<int>(10));
  for(int i=0;i<n;i++){
    for(int j=0;j<10;j++){
      cin >> f[i][j];
    }
  }
  vector<vector<int>> p(n,vector<int>(11));
  for(int i=0;i<n;i++){
    for(int j=0;j<11;j++){
      cin >> p[i][j];
    }
  }
  int ans=-(1<<30);
  for(int bit=1;bit<(1<<10);bit++){
    int cc=0;
    for(int i=0;i<n;i++){
      int c=0;
      for(int j=0;j<10;j++){
        if(bit>>j&1&&f[i][j]){
          c++;
        }
      }
      cc+=p[i][c];
    }
    ans=max(ans,cc);
  }
  cout << ans << endl;
}

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

int main() {
  int N, A;
  cin >> N >> A;
  
  N %= 500;
  
  if ( N - A > 0 ){
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
  
  return 0;

}

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

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		int n=ir.nextInt();
		out.println(48-n);
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

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

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}

Measured memory_bytes: 21204
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=1e9+7;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=105;
int a[N],f[N][N][N],n,res;
int main(){
	scanf("%d",&n);
	fp(i,1,n+n-1)scanf("%d",&a[i]);
	sort(a+1,a+n+n);
	f[n][1][0]=1;
	for(R int i=n-1;i;--i){
		R int dl=(a[i]!=a[i+1]),dr=(a[n+n-i]!=a[n+n-i-1]);
		fp(j,0,n+n-1)fp(k,0,n+n-1-j)if(f[i+1][j][k]){
			fp(l,1,j+dl)upd(f[i][j+dl-l+1][k+dr+(l>1)],f[i+1][j][k]);
			fp(r,1,k+dr)upd(f[i][j+dl+1][k+dr-r],f[i+1][j][k]);
		}
	}
	fp(i,0,n+n-1)fp(j,0,n+n-1-i)upd(res,f[1][i][j]);
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
using lli=long long int;
using vi=vector<int>;  using vs=vector<string>; using gi=greater<int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define soao(c) sort((c).begin(),(c).end()) //昇順
#define sodo(c) sort((c).begin(),(c).end(),gi()) //降順
#define rev(c) reverse((c).begin(), (c).end())


int main(){
    string S,T; cin>>S>>T;
    bool can=true;
    rep(i,S.size()){
        if(S.at(i)!=T.at(i)) can=false;
    }
    if(can) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3628
def out_calc(num):
    for i in range(0, num):
        print("#",end="")
    print("")


def in_calc(num, num2):
    for i in range(0, num-2):
        print("#", end="")
        for j in range(0, num2-2):
            print(".", end="")
        print("#")


def main():
    array = []
    while True:
        value = input().split()
        value = [int(x) for x in value]
        if value[0] == 0 and value[1] == 0:
            break
        else:
            array.append(value)

    for i in range(0, len(array)):
        out_calc(array[i][1])
        in_calc(array[i][0], array[i][1])
        out_calc(array[i][1])
        print("")


if __name__ == '__main__':
    main()

Measured memory_bytes: 9156
using System;

namespace ConsoleApp7
{
    class Program
    {
        static void Main(string[] args)
        {
            string A = Console.ReadLine();
          double a = double.Parse(A);
            double b = Math.PI;
            Console.WriteLine("{0} {1}",(a*a*b).ToString(".000000"),(2*a*b).ToString(".000000"));
            
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 9328
N = int(input())
Num = [[0] * 10 for i in range(10)]

for i in range(1, N+1):
    lon = len(str(i)) - 1
    a = i % 10
    b = i // (10 ** lon)
    Num[a][b] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += Num[i][j] * Num[j][i]

print(ans)


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
}
int main(void){
    int k;
    cin >> k;
    long long ans = 0;
    for(int a = 1; a <= k; a++){
        for(int b = 1; b <= k; b++){
            int g = gcd(a, b);
            for(int c = 1; c <= k; c++){
                ans += gcd(g, c);
            }
        }
    }
    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;

ll comb[51][51];

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  ll N, A, B; cin >> N >> A >> B;
  ll v[N];
  for(int i=0;i<N;i++) cin >> v[i];
  // nCkを前計算
  for(ll i=1;i<=N;i++) comb[i][1] = i;
  for(ll i=2;i<=N;i++){
    for(ll j=2;j<=i;j++){
      comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
    }
  }
  sort(v, v+N, greater<ll>());
  ll sum[N+1];
  // 同じvの数と初めのindex
  pair<ll, ll> same[N];
  sum[0] = 0;
  for(int i=0;i<N;i++){
    sum[i+1] = sum[i] + v[i];
  }
  int s = 1;
  for(int i=0;i<N-1;i++){
    if(v[i] == v[i+1]){
      s++;
    }else{
      for(int j=i;j>i-s;j--) same[j] = make_pair(s, i-s+1);
      s = 1;
    }
  }
  for(int j=N-1;j>N-1-s;j--) same[j] = make_pair(s, N-1-s+1);
  // for(int i=0;i<N;i++) cout << same[i].first << " " << same[i].second << endl;
  // ans(average) = ans.first / ans.second
  pair<ll, ll> ans;
  ans = make_pair(0, 1);
  ll num = 0;
  for(ll i=A;i<=B;i++){
    ll f = same[i-1].first;
    ll k = i-same[i-1].second;
    // cout << f << " " << k << " " << comb[f][k] << endl;
    if(ans.first * i < sum[i] * ans.second){
      ans = make_pair(sum[i], i);
      num = comb[f][k];
    }else if(ans.first * i == sum[i] * ans.second){
      num += comb[f][k];
    }
  }
  cout << setprecision(12) << (double)((double)ans.first / (double)ans.second) << endl;
  cout << num << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int R = sc.nextInt();

		if (R < 1200) {
			System.out.println("ABC");
		} else if (1200 <= R && R < 2800) {
			System.out.println("ARC");
		} else {
			System.out.println("AGC");
		}


	}
}

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

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

    ll t[n], a[n];
    rep(i, n){
        cin >> t[i] >> a[i];
    }

    ll c_t = t[0], c_a = a[0];
    rep(i, n-1){
        ll tmp_t = ceil(c_t / (long double)(t[i+1]));
        ll tmp_a = ceil(c_a / (long double)(a[i+1]));

        ll tmp = max(tmp_t, tmp_a);
        c_t = tmp * t[i+1];
        c_a = tmp * a[i+1];
    }

    cout << c_t + c_a << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,m;
typedef pair<int,int> pii;
pii a[100009];
bool cmp(pii a,pii b){
    return a.first^b.first?a.first<b.first:a.second>b.second;
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        scanf("%d%d",&a[i].first,&a[i].second);
    }
    sort(a+1,a+n+1,cmp);
    ll ans=0;
    int cur=1;
    priority_queue<int>q;
    for(int i=m;~i;i--){
        while(cur<=n&&i+a[cur].first<=m)q.push(a[cur].second),++cur;
        if(q.size())ans+=q.top(),q.pop();
    }
    cout<<ans<<endl;
}


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;
	vector<int> v;
	vector<long long> dist;

	if(N >= M){
		cout << 0 << endl;
		return 0;
	}

	for(int i = 1; i <= M; i++){
		int x;
		cin >> x;
		v.push_back(x);
	}

	sort(v.begin(), v.end());

	for(int i = 0; i < v.size() - 1; i++){
		long long d = v[i + 1] - v[i];
		dist.push_back(d);
	}

	sort(dist.begin(), dist.end());

	for(int i=1; i<=N-1; i++){
		dist.pop_back();
	}

	long long ans = 0;
	for(int i=0; i<dist.size(); i++){
		ans += dist[i];
	}

	cout << ans << endl ;
	return 0;
}

Measured memory_bytes: 1784
#include<stdio.h>
#define INF 1000000
#define N 2000000
 
void insert(int *, int);
void increase(int *, int, int);
int extractmax(int *);
void maxHeapify(int *, int);
 
int n=0;
int S[N];
 
int main()
{
 
  int i=0, k, j, max[N];
  char com[10];
 
 
  while(1){
    scanf("%s", com);
     
    if(com[0] == 'i'){
      scanf("%d", &k);
      insert(S, k);
    }
 
    else if(com[1] == 'x'){
      max[i] = extractmax(S);
      i++;
    }
 
    else if(com[1] == 'n') break;
 
  }
 
  for(j = 0; j < i; j++){
    printf("%d\n", max[j]);
  }
 
  return 0;
 
}
 
void insert(int *S, int k)
{
  n += 1; 
  S[n] = -INF;
  increase(S, n, k);
}
 
void increase(int *S, int i, int key)
{
 
  int temp;
 
  S[i] = key;
 
  while(i > 1 && S[i/2] < S[i]){
    temp = S[i];
    S[i] = S[i/2];
    S[i/2] = temp;
    i = i/2;
  }
}
 
int extractmax(int *S)
{
  int max;
 
  max = S[1];
  S[1] = S[n];
  n--;
  maxHeapify(S, 1);
 
  return max;
}
 
void maxHeapify(int *A, int i)
{
 
  int l, r, largest;
  int temp;
 
  l = 2*i;
  r = 2*i+1;
   
  if(l <= n && A[l] > A[i]) largest = l;
  else largest = i;
 
  if(r <= n && A[r] > A[largest]) largest = r;
 
  if(largest != i){
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    maxHeapify(A, largest);
  }
}

Measured memory_bytes: 7456
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 2e5 + 10;
int n , x[N] , y[N];

int main(){
    scanf("%d",&n);
    rep(i,0,n) scanf("%d%d",x+i,y+i);
    int mn=min(*min_element(x,x+n),*min_element(y,y+n));
    int mx=max(*max_element(x,x+n),*max_element(y,y+n));
    ll ans = 2e18;
    vector<pii> v;
    rep(i,0,n) v.pb(x[i]<y[i]?mp(x[i],y[i]):mp(y[i],x[i]));
    sort(all(v));
    multiset<int> S;
    rep(i,0,n) S.insert(v[i].fi);
    rep(i,0,n+1) {
        ans = min(ans,ll(mx-mn)*(*S.rbegin()-*S.begin()));
        if(i!=n) {
            S.erase(S.find(v[i].fi));
            S.insert(v[i].se);
        }
    }
    int mn2=2e9,mx2=-2e9;
    rep(i,0,n) {
        int a=x[i],b=y[i];
        if(a>b) swap(a,b);
        mx2=max(mx2,a);
        mn2=min(mn2,b);
    }
    ans=min(ans,ll(mx2-mn)*(mx-mn2));
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 12784
S = input()

y = S[0:4]
m = S[5:7]
d = S[8:10]

if y < "2019":
    print("Heisei")

elif (y == "2019") and (m < "04"):
    print("Heisei")

elif (y == "2019") and (m == "04") and (d <= "30"):
    print("Heisei")

elif (y == "2019") and (m == "04") and (d > "30"):
    print("TBD")

elif (y == "2019") and (m >= "05"):
    print("TBD")

elif (y > "2019"):
    print("TBD")

Measured memory_bytes: 8964
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

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

	if (R < 1200) { cout << "ABC" << endl; }
	else if (R >= 1200 && R < 2800) { cout << "ARC" << endl; }
	else { cout << "AGC" << endl; }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;    //Here's a small hint that helped motivate my solution.
typedef long long int ll;
int main() {
	// Suppose we have three terms x, y, and z. After subtracting z from y, we get y-z, and after subtracting
	//that from x, we get x-y+z. As you can see, the z is being added now, since it was subtracted twice. In general, subtracting a number an 
	//even number of times is equivalent to adding that number. Can we take advantage of this somehow?
	ll no;
	cin>>no;
	ll a;
	vector<ll> p,n;
	for(int i=0;i<no;i++){
	   cin>>a;
	   if(a>=0) p.push_back(a);
	   if(a<0) n.push_back(a);
	}
	ll b;
	int flag=0;
	if(p.size()==0){
	    sort(n.rbegin(),n.rend());
	    flag=1;
	     a=n[0];b=n[1];
	    ll val=n[0]-n[1];
	    p.push_back(val);
	    n.erase(n.begin(),n.begin()+2);
	}
	if(n.size()==0) {
	    if(p.size()==2) {
	        sort(p.begin(),p.end()); cout<<p[1]-p[0]<<"\n"<<p[1]<<" "<<p[0]<<endl; return 0;
	    }
	    if(p.size()>2) {
	       sort(p.begin(),p.end());
	        a=p[0];b=p[1];
	       ll val=p[0]-p[1];
	         n.push_back(val);
	            p.erase(p.begin(),p.begin()+2);
	        flag=1;
    	}
	    
	}
// 	for(int i=0;i<p.size();i++) cout<<p[i];
// 	cout<<endl;
// 	for(int i=0;i<n.size();i++) cout<<n[i];
// 	cout<<endl;
		ll sum=0;
	    ll s=0;
	    for(int i=0;i<p.size();i++) sum+=p[i];
	    for(int i=0;i<n.size();i++) s+=n[i];
	    s*=-1;
	    sum+=s;
	    cout<<sum<<endl;
	    if(flag) cout<<a<<" "<<b<<endl; 
	if(p.size()!=0 && n.size()!=0){
	    
	    ll val=n[0];
	    for(int i=0;i<p.size()-1;i++){
	        cout<<val<<" "<<p[i]<<endl;
	        val=val-p[i];
	    }
	    cout<< p[p.size()-1]<<" "<<val<<endl;
	    val=p[p.size()-1]-val;
	    for(int i=1;i<n.size();i++){
	        cout<<val<<" "<<n[i]<<endl;
	        val=val-n[i];
	    }
	    return 0;
	}
}


Measured memory_bytes: 2804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7;
ll n,k;
int s = (n+1) * (n + 2) / 2;
const int INF = 1<<29;

ll kosu(ll x){
    return ((2*n-x+1)*x/2 - x*(x-1) /2 +1); 
}

int main(){
    cin >> n >> k;
    ll ans = 0;
    
    for(int i=k;i<=n+1;i++){
        ans += kosu(i);
        ans = ans%MOD;
    }
    cout << ans%MOD << endl;

}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define int long long
map<int,int> mp;
signed main(){
  int n;
  int a[222222];
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  int tmp=0,aa[222222];
  for(int i=0;i<n;i++){
    tmp+=a[i];
    aa[i]=tmp;
    mp[tmp]++;
  }
  int ans=mp[0];
  for(int i=0;i<n;i++){
    mp[aa[i]]--;
    ans+=mp[aa[i]];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 16000
#include <stdio.h>
int main()
{
	int a, s, m, h, S;
        scanf("%d", &S);
	h = S / 3600;
	a = S % 3600;
	m = a / 60;
        s = a % 60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}

Measured memory_bytes: 2756
import math
X,Y=list(map(int,input().split()))
mod=10**9+7




if (X+Y)%3!=0:
    print(0)
    exit()
    
    
n=(2*X-Y)//3
m=(2*Y-X)//3
if n<0 or m<0:
    print(0)
    exit()


tmp=1
for i in range(n,n+m):
    tmp=(tmp*(i+1))%mod
bunsi=tmp
bunbo=1
tmp=1
for i in range(m):
    tmp=(tmp*(i+1))%mod
bunbo=pow(tmp,mod-2,mod)
#ans=div(bunsi,bunbo)
ans=bunsi*bunbo
print(ans%mod)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    int a[100][100],retu[100]={0},gyou[100]={0},sum=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> a[i][j];
            retu[i] += a[i][j];
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            gyou[i] += a[j][i];
        }
        sum = sum+gyou[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cout << a[i][j] << " ";
        }
        cout << retu[i] << endl;
    }
    for(int i=0;i<m;i++)cout << gyou[i] << " ";
    cout << sum << endl;
    
    
}



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

struct UnionFind {
  vi data;
  UnionFind(int size) : data(size, -1) {}

  int find(int x) {
    return data[x] < 0 ? x : data[x] = find(data[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  int size(int x) {
    return -data[find(x)];
  }
};

main() {
  int N, K, L; cin >> N >> K >> L;
  UnionFind ar(N), br(N);
  rep(i, K) {
    int p, q; cin >> p >> q;
    ar.unite(--p, --q);
  }
  rep(i, L) {
    int r, s; cin >> r >> s;
    br.unite(--r, --s);
  }

  map<pii, int> mp;
  rep(i, N) {
    mp[pii(ar.find(i), br.find(i))]++;
  }
  rep(i, N) {
    if (i != 0) cout << ' ';
    cout << mp[pii(ar.find(i), br.find(i))];
  }
  cout << endl;
}

Measured memory_bytes: 13568
N, M = map(int, input().split())
L = [0 for _ in range(M)]
R = [0 for _ in range(M)]
for i in range(M):
    L[i], R[i] = map(int, input().split())

l = max(L)
r = min(R)
print(r - l + 1 if l <= r else 0)

Measured memory_bytes: 11016
#include<cstdio>
using namespace std;
typedef long long ll;
int main() {
  ll d, n, m;
  scanf("%lld%lld%lld", &n, &m, &d);
  if (d == 0) printf("%.10f\n", (double)(m - 1) / n);
  else printf("%.10f\n", (double)2 * (m - 1) * (n - d) / (n * n));
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

template<int MOD>
class ModInt {
public:
    ModInt() :value(0) {}
    ModInt(long long val) :value((int)(val<0 ? MOD + val % MOD : val % MOD)) { }

    ModInt& operator+=(ModInt that) {
        value = value + that.value;
        if (value >= MOD)value -= MOD;
        return *this;
    }
    ModInt& operator-=(ModInt that) {
        value -= that.value;
        if (value<0)value += MOD;
        return *this;
    }
    ModInt& operator*=(ModInt that) {
        value = (int)((long long)value * that.value % MOD);
        return *this;
    }
    ModInt &operator/=(ModInt that) {
        return *this *= that.inverse();
    }
    ModInt operator+(ModInt that) const {
        return ModInt(*this) += that;
    }
    ModInt operator-(ModInt that) const {
        return ModInt(*this) -= that;
    }
    ModInt operator*(ModInt that) const {
        return ModInt(*this) *= that;
    }
    ModInt operator/(ModInt that) const {
        return ModInt(*this) /= that;
    }
    ModInt pow(long long k) const {
        ModInt n = *this, res = 1;
        while (k) {
            if (k & 1)res *= n;
            n *= n;
            k >>= 1;
        }
        return res;
    }
    ModInt inverse() const {
        long long a = value, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }
    int toi() const { return value; }

private:
    int value;
};
typedef ModInt<1000000007> mint;
ostream& operator<<(ostream& os, const mint& x) {
    os << x.toi();
    return os;
}

void solve() {
    const int MAX = (int)2e5 + 10;
    int N;
    cin >> N;
    vector<mint> sum(MAX), dp(N + 1);
    vi C(N);
    dp[0] = 1;
    rep(i, N) {
        cin >> C[i];
        dp[i + 1] = dp[i];
        if (i > 0 && C[i] != C[i - 1]) {
            dp[i + 1] += sum[C[i]];
        }
        if (i == 0 || C[i] != C[i - 1]) {
            sum[C[i]] += dp[i];
        }
    }
    cout << dp.back() << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 2560
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define GRAYCODE(i) ((i) ^ ((i) >> 1))

using ll = long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;

const int MOD = 1000000007;
const int INF = 1000000000;

template<class T>
bool chmax(T &a, const T &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T>
bool chmin(T &a, const T &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}




int main(){
    int n, minv = INF, maxv = 0; cin >> n;
    VI w(n), s(n);
    REP(i, n){
        cin >> w[i]; chmin(minv, w[i]);
        s[i] = w[i]; chmax(maxv, w[i]);
    }
    VI nextidx(maxv + 1);
    SORT(s);
    int ans = 0;
    VB used(n, false);
    REP(i, n) nextidx[s[i]] = i;
    REP(i, n){
        if(used[i]) continue;
        int cur = i, sum = 0, minincircle = maxv, cirmem = 0;
        while(1){
            used[cur] = true; ++cirmem;
            int v = w[cur]; chmin(minincircle, v);
            sum += v;
            cur = nextidx[v];
            if(used[cur]) break;
        }
        ans += min(sum + (cirmem-2)*minincircle,
                   sum + minincircle + (cirmem+1)*minv);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3204
#include<bits/stdc++.h>
#define Int long long
#define MOD 1000000009
using namespace std;


int main(){
    int n;
    cin>>n;
    vector<int> a(n),b(n),c(n);
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    vector<int> dp1(n),dp2(n),dp3(n);
    dp1[0]=a[0];
    dp2[0]=b[0];
    dp3[0]=c[0];
    for(int i=1;i<n;i++){
        dp1[i]=max(a[i]+dp2[i-1],a[i]+dp3[i-1]);
        dp2[i]=max(b[i]+dp1[i-1],b[i]+dp3[i-1]);
        dp3[i]=max(c[i]+dp2[i-1],c[i]+dp1[i-1]);
    }
    cout<<max(dp1[n-1],max(dp2[n-1],dp3[n-1]));
    return 0;
}


Measured memory_bytes: 5608
#include<stdio.h>

int main(void){
  int m, f, r;

  while(1){
    scanf("%d %d %d", &m, &f, &r);
    if(m == -1 && f == -1 && r == -1) break;

    if(m == -1 || f == -1) printf("F\n");
    else if(m + f >= 80) printf("A\n");
    else if(m + f >= 65) printf("B\n");
    else if(m + f >= 50) printf("C\n");
    else if(m + f >= 30 && r >= 50) printf("C\n");
    else if(m + f >= 30 && r < 50) printf("D\n");
    else if(m + f < 30) printf("F\n");
   
  }


  return 0;
}



Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
typedef int64_t i64;
#define SortAsc(c) std::sort(c.begin(),c.end())

int main()
{
  int a,b ;
  cin >> a >> b;
  if (a* b % 2 == 0) {
	  cout << "Even" << endl;
  }
  else{
	  cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
using namespace std;

const double PI=acos(-1);

int main(){
    int n, d, cnt = 0;
    cin >> n >> d;

    vector<vector<int>> l(n, vector<int>(d));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < d; j++){
            cin >> l[i][j];
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            int sum = 0;
            for(int k = 0; k < d; k++){
                sum += pow(l[i][k] - l[j][k], 2);
            }
            if(pow((int)sqrt(sum), 2) == sum) cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
 
int main()
{
int N ;
cin >> N ;
int M ;
M=N ;
int a[10] ;

for(int i=1; i<=10; i++){
a[10-i]=0 ;
while(a[10-i]*pow(10,(10-i)-1)<=N ){
a[10-i]++ ;
}
if(a[10-i]>0){a[10-i]=a[10-i]-1 ;}
N=N-a[10-i]*pow(10,9-i) ;
}
for(int i=1; i<=9; i++) {
a[i+1]=a[i+1]+a[i] ;
}
if(M%a[9]==0){
  cout << "Yes" << endl;
}
else{
cout << "No" << endl;
}

    return 0;
}

Measured memory_bytes: 384
fn main() {
    let stdin = std::io::stdin();
    let mut input = String::new();
    stdin.read_line(&mut input).unwrap();
    input.retain(|c| !c.is_ascii_whitespace());
    let input = input.parse::<i32>().unwrap();
    println!("{}", input * (1 + input * (1 + input)));
}

Measured memory_bytes: 2112
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<string>
#include<stack>
#include<set>
#define int long long
using namespace std;
signed main() {
    int x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    int y=x/d;
    if(x>0&&x/d>=k) {
        cout<<x-k*d<<endl;
    } else {
        x-=y*d;
        k-=y;
        if((k)%2==0) {
            cout<<abs(x)<<endl;
        } else {
            cout<<min(abs(x-d),abs(x+d))<<endl;
        }
    }
    return 0;
}


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

int a[100010], n;
int dfs(int k, int p){
	if(k == n+1)return -1;
	if(p == 2)return k;
	return dfs(k+1, a[p]);
}

int main(){
	scanf("%d", &n);
	for(int i = 1;i <= n;i++)scanf("%d", &a[i]);
	int ans = dfs(0, 1);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main{

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
      
        if(a == b && b == c && c == a){
          System.out.println("Yes");
        }else{
          System.out.println("No");
        }
	}
}

Measured memory_bytes: 35656
#include<iostream>
    #include<cstdlib>
    #include<math.h>
    #include<set>
    #include<string>
    #include<stdlib.h>
    using namespace std ;
    int main(){
      int r,g,b;
      cin>>r>>g>>b;
      if((10*g+b)%4==0)cout<<"YES"<<endl;
      else cout<<"NO"<<endl;
      return 0;
    }

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>

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

int main(){
    int n, x, m=1000*1000;
    cin >> n >> x;
    rep(i,n){
        int in;
        cin >> in;
        x -= in;
        m = min(m,in);
    }
    
    cout << n+(x/m) << endl;


return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[33] = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k; cin >> k; 
    cout << a[k] << 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++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;

int main() {
  string S;
  cin >> S;
  int N = S.length();
  vector<int> T;
  int ten = 10;
  rep(i, N){
    if(i == 0) {
      T.push_back(S[N-1]-'0');
      continue;
    }
    int tmp = S[N-i-1]-'0';
    tmp *= ten;
    tmp += T[i-1];
    T.push_back(tmp % 2019);
    ten = ten * 10 % 2019;
  }
  ll ans = 0;
  rep(i, 2019){
    int tmp = 0;
    if(i == 0) tmp++;
    rep(j, N) {
      if (T[j] == i)tmp++;
    }
    ans += tmp * (tmp - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}

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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)+1):((m)-(n)+1)),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

int main() {

  Real mi, ma, x;
  mi = INF;
  ma = -INF;

  while (cin >> x, cin) {
    mi = min(mi, x);
    ma = max(ma, x);
  }

  cout << (ma - mi) << endl;

  return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<string>
#include<cctype>
#include<iomanip>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

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

	double x1, y1, x2, y2;

	cin >> x1 >> y1 >> x2 >> y2;

	cout << fixed;
	cout << setprecision(5) << sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));

	return 0;
}


Measured memory_bytes: 3308
X = int(input())

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

ans = X
check = False
while check == False:
    check = is_prime(ans)
    if check == True:
        break
    ans += 1
print(ans)

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


int main(){

    int n; cin >> n;
    bool flag = false;
    for(int i = 0; i < n; i++){
        char c; cin >> c;
        if(c == 'Y') flag = true;
    }

    if(flag) cout << "Four" << endl;
    else cout << "Three" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#include <iostream>
 
using namespace std;
 
int main()
{
    int n,i,k;
    
    cin>>n;
    cin>>k;
    int h[n+1];
 
    for(i=1;i<=n;i++)
    {
        
        cin>>h[i];
    }
    int dp[n+1];
 
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]) + dp[1];
    for(i=2;i<=n;i++)
    {
        dp[i]=2e9;
        for(int j=1;j<=k;j++)
        {
            if(i-j >=1)
            {
                int ht=abs(h[i]-h[i-j])+dp[i-j];
                dp[i]=min(dp[i],ht);
            }
        }
    }
 
    cout<<dp[n];
 
    return 0;
 
   
}

Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
#include<ext/pb_ds/priority_queue.hpp>
using namespace std;

const int N = 55;
const int M = 155;
typedef long long LL;
const LL mo = 1000000007;

int n,m,Ans,A[M],d[N],f[N][M][M];
bool Min[N],Max[N];

void Add(int &x,const int &y) {x += y; if (x > mo) x -= mo;}

int main()
{
	#ifdef DMC
		freopen("DMC.txt","r",stdin);
	#endif
	
	cin >> n; m = 2 * n - 1;
	for (int i = 1; i <= m; i++) scanf("%d",&A[i]);
	sort(A + 1,A + m + 1); int mid = 1 + m >> 1;
	for (int i = 2; i <= n; i++)
	{
		if (A[mid - i + 1] != A[mid - i + 2]) ++d[i],Min[i] = 1;
		if (A[mid + i - 1] != A[mid + i - 2]) ++d[i],Max[i] = 1;
	}
	f[1][1][1] = 1;
	for (int i = 1; i < n; i++)
		for (int j = 1; j <= m; j++)
			for (int k = 1; k <= j; k++)
			{
				if (!f[i][j][k]) continue;
				int tot = j + d[i + 1];
				int pos = Min[i + 1] ? k + 1 : k;
				for (int l = 1; l < pos; l++)
					Add(f[i + 1][tot - (pos - l - 1)][l],f[i][j][k]);
				Add(f[i + 1][tot][pos],f[i][j][k]);
				for (int l = pos + 1; l <= tot; l++)
					Add(f[i + 1][tot - (l - pos - 1)][pos + 1],f[i][j][k]);
			}
	for (int i = 1; i <= m; i++)
		for (int j = 1; j <= i; j++)
			Add(Ans,f[n][i][j]);
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 3072
import java.util.Scanner

object Main {
  def solve(sc: => Scanner): Unit = {
    val N = sc.nextInt
    var S = sc.next.dropWhile(_=='o')
    while (S.length > 0 && !(S.length >= 2 && S(0) == 'x' && S(1) == 'x')) {
      S = S.drop(1).dropWhile(_=='o')
    }
    println(math.min(N - S.length + 1, N))
  }


  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)

    solve(sc)
  }
}

Measured memory_bytes: 63920
#include<stdio.h>
int X[2020];
void op(int num,int t){
	if(t<num){
		if(X[t+1]-X[t]>1)
			++X[t];}
	else if(t==num&&X[t]<2019) ++X[t];
}
int main(){

	int N,M;
	int Y[105];
	scanf("%d",&N);
	for(int i=1;i<=N;++i)
		scanf("%d",X+i);
	scanf("%d",&M);
	for(int i=0;i<M;++i){
		scanf("%d",Y+i);
		op(N,Y[i]);}

	for(int i=1;i<=N;++i)
		printf("%d\n",X[i]);
	return 0;
}


Measured memory_bytes: 2112
nm = input().split()
minArr = []
maxArr = []

for m in range(int(nm[1])):
    tmp = input().split()
    minArr.append(int(tmp[0]))
    maxArr.append(int(tmp[1]))

if(min(maxArr) - max(minArr)) < 0:
    print(0)
else:
    print(min(maxArr) - max(minArr)+1)


Measured memory_bytes: 11036
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<vc> vcc;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
#define mina(a,b) (a)=min((a),(b));
#define maxa(a,b) (a)=max((a),(b));
const int INF = 1e9 + 7;
int gcd (int a, int b) {
	return b ? gcd (b, a % b) : a;
}
void solve(){
    int n; cin>>n;
    int t; cin>>t;
    for(int i = 0; i < n-1; i++){
        int l; cin>>l;
        t=gcd(t,l);
    } 
    cout<<t;

}
int main(){
    int T=1;
    //cin>>T;
    for(int i = 0; i < T; i++) solve(); 
}

Measured memory_bytes: 384