akhauriyash/Code-Regression huggingface dataset:
/*
                IftekharMd.Shishir
                Dept. of Information and Communication Engineering
                University of Rajshahi
                19.04.20

*/
#include<bits/stdc++.h>

#define ll          long long int
#define ull         unsigned long long int
#define f(i,n)      for(i=0;i<n;i++)
#define F(i,n)      for(i=n;i>=0;i--)
#define fa(i,a,b)   for(i=a;i<b;i++)
#define Fa(i,a,b)   for(i=a;i>=b;i--)

#define vec         vector<long long int>
#define que         queue<long long int>    // a.push(x)   a.pop()    a.back()    a.front()
#define sea         set<long long int>
#define sed         set<long long int, greater<long long int> >   // a.insert();
#define pb(x)       push_back(x)
#define pob()       pop_back()
#define sor(a)      sort(a.begin(),a.end())
#define rev(a)      reverse(a.begin(),a.end())
#define ins(a,x)    insert(a.begin(),x)          // push in front
#define points(x)   fixed<<setprecision(x)
#define gcd(x,y)    __gcd(x,y)
#define beshi       LONG_LONG_MAX
#define kom         LONG_LONG_MIN
#define done        return 0

const double PI= 2*acos(0.0);
const long long MOD= 1000000007;

/*----------[ string to integer ]--------------
string str;  int x=0;
stringstream demo(str);
demo >> x;
cout<< x <<endl;
*/

/*----------[ integer to string ]--------------
string name;  int x=345;
stringstream demo;
demo << x;
name=demo.str();
cout<< name <<endl;
*/
using namespace std;

int main()
{
    ll n,m,x,s=0,i;
    cin>>n>>m;
    f(i,m){cin>>x;s+=x;}
    if(n-s>=0)cout<<n-s<<endl;
    else cout<<-1<<endl;
    done;
}




Measured memory_bytes: 3620
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	
	double a,b,c,d,e,f;
	while(cin>>a){
		cin>>b>>c>>d>>e>>f;
		double coeff = a*e-b*d;
		double x = (e*c-b*f)/coeff, y = (-c*d+a*f)/coeff;
		if(abs(x)<=1e-7) x=0;
		if(abs(y)<=1e-7) y=0;
		printf("%.3lf %.3lf\n",round(x*1000.0)/1000.0,round(y*1000.0)/1000.0);
	}
	return 0;
}


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

int main(){
  string s; cin>>s;
  int K; cin>>K;
  set<string> st;
  rep(i,s.length()){
    for(int j=i+1;j<=s.length()&&j-i<=K;j++){
      st.insert(s.substr(i,j-i));
    }
  }
  int cnt=1;
  for(auto ss:st){
    if(cnt==K){
      cout<<ss<<endl;
      return 0;
    }
    cnt++;
  }
  return 0;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct UnionFind {
    UnionFind(int n) {
        rank.assign(n, 0);
        parent.resize(n);
        for (int i = 0; i < n; ++i) {
            parent[i] = i;
        }
    }

    int find(int x) {
        if (x == parent[x])
            return x;
        return parent[x] = find(parent[x]);
    }

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

    void unit(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;

        if (rank[x] < rank[y]) {
            parent[x] = y;
        }
        else {
            parent[y] = x;
            if (rank[x] == rank[y])
                rank[x]++;
        }
    }

    vector<int> rank;
    vector<int> parent;
};

struct Data {
    ll a, b, c;
};

Data A[100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    UnionFind uf(N);

    REP(i, N) {
        cin >> A[i].a >> A[i].b;
        A[i].c = i;
    }

    priority_queue<Data, vector<Data>, function<bool(Data, Data)>> q([](Data a, Data b) { return a.c > b.c; });
    sort(A, A + N, [](Data a, Data b) { return a.a < b.a; });
    REP(i, N - 1) {
        q.push(Data{A[i].c, A[i + 1].c, abs(A[i].a - A[i + 1].a)});
    }
    sort(A, A + N, [](Data a, Data b) { return a.b < b.b; });
    REP(i, N - 1) {
        q.push(Data{A[i].c, A[i + 1].c, abs(A[i].b - A[i + 1].b)});
    }

    ll ans = 0;
    while (!q.empty()) {
        auto d = q.top();
        q.pop();
        if (uf.same(d.a, d.b))
            continue;
        uf.unit(d.a, d.b);
        ans += d.c;
    }

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

Measured memory_bytes: 11632
#include <bits/stdc++.h>
using namespace std;
 
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair
 
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
const int N = 1e5 + 10;
int n;
vi adj[N];

// dp[u][0] = matching maximo subarbol u
// dp[u][1] = matching maximo subarbol u, con u libre
int dp[N][2];
void dfs(int u, int p) {
    dp[u][0] = dp[u][1] = 0;
    bool add = false;
    for (auto v : adj[u]) if (v != p) {
        dfs(v,u);
        dp[u][1] += dp[v][0];
        add |= dp[v][1] == dp[v][0];
    }
    dp[u][0] = dp[u][1] + add;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    forn(_,n-1) {
        int u,v; cin >> u >> v;
        u--; v--;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    dfs(0,0);
    cout << (2*dp[0][0] == n ? "Second" : "First");
    return 0;
}


Measured memory_bytes: 6656
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    new Main().solev();
  }

  public void solev() {

    Scanner input = new Scanner(System.in);
    int a = input.nextInt();
    int b = input.nextInt();

    int add = a + b;
    int sub = a - b;
    int mul = a * b;

    int result = 0;
    result = Math.max(add, sub);
    result = Math.max(result, mul);
    System.out.println(result);
  }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf ll(10e15)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll t;
    t=1;
    while(t--)
    {
        ll x,y,z;
        cin>>x>>y>>z;
        cout<<z<<" "<<x<<" "<<y;
    }
    return 0;
}

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

using namespace std;

int main(){
  int n;
  bool shiri=1;
  map<string,int> mps;
  string ss;
  char prev;
  cin >> n;
  cin >> ss;
  prev=ss.back();
  mps[ss]++;
  for(int i=1;i<n;i++){
    cin >> ss;
    if(!(ss.front()==prev)) shiri=0;
    mps[ss]++;
    if (mps[ss]>1) shiri=0;
    prev=ss.back();
  }
  if (shiri) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
s = input()

ans = len(s)
m = 1
for i in range(len(s)):
    if s[i]== str(m):
        if i<(len(s)+1)//2:
            ans = len(s)-i
            m = (m+1)%2
        else:
            ans = min(ans,i)

print(ans)


Measured memory_bytes: 39792
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long max = 0;
        long sum = 0;
        int n = nextInt(scanner);
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt(scanner);
        }
        max = a[0];
        for (int i = 1; i < n; i++) {
            if (a[i] < max) {
                sum += max - a[i];
            }else if (a[i] > max) {
                max = a[i];
            }
        }
        System.out.println(sum);
    }


    private static int nextInt(Scanner scanner) {
        return Integer.parseInt(scanner.next());
    }

    private static long nextLong(Scanner scanner) {
        return Long.parseLong(scanner.next());
    }

    private static float nextFloat(Scanner scanner) {
        return Float.parseFloat(scanner.next());
    }

    private static double nextDouble(Scanner scanner) {
        return Double.parseDouble(scanner.next());
    }


}









Measured memory_bytes: 59648
s_=input()
t=input()
 
filled_idx=[i for i in range(len(s_)) if s_[i]!="?"]
 
for t_s in range(len(s_)-len(t),-1,-1):
    t_e=t_s+len(t)
    s=s_[:t_s]+t+s_[t_e:]
    if(all(s[i]==s_[i] for i in filled_idx)):
        s=s.replace("?","a")
        print(s)
        break
else:
    print("UNRESTORABLE")

Measured memory_bytes: 38384
/*Points to be noted :
1)Don't be afraid to fail.
2)Never give up easily,keep trying.
3)Don't care about other ppl's progress.
4)Spend much time on each problem & keep trying. I WILL DO IT!💯*/

// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//


#include<bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define int long long int
#define ld long double
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define r0 return 0;
#define tc int t;cin>>t;while(t--)
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define md 998244353
#define inf 1000000000000000 //1e15
#define gcd __gcd
#define lcm(a,b) ((a)*(b))/gcd(a,b)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
int min(int a,int b){
    return (a<b)?a:b;
}
int max(int a,int b){
    return (a>b)?a:b;
}
int fp(int a,int b){
    if(b==0) return 1;
    int x=fp(a,b/2);
    x=(x*x)%mod;
    if(b&1) x=(x*a)%mod;
    return x;
}
int factorial(int n)
{
    int fact=1;
    for(int i=2;i<=n;i++)
    fact=fact*i;
    
    return fact;
}
int ncr(int n,int r)
{
    return factorial(n)/(factorial(r)*factorial(n-r));
}
void c_p_c()
{
    crap;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
signed main()
{
    c_p_c();
    int x,y;
    cin>>x>>y;
    if(y&1)
    cout<<"No"<<endl;
    else if(y<(2*x))
    cout<<"No"<<endl;
    else if(y>(4*x))
    cout<<"No"<<endl;
    else
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 3636
N = int(input())
A = list(map(int, input().split()))

nums = A[:]
import fractions

gcd_queue = [
    (nums[0], True),
    (nums[1], True),
    (fractions.gcd(nums[0], nums[1]), False),
]
for n in nums[2:]:
    tmp_queue = []
    for q in gcd_queue:
        if q[1] == True:
            tmp_queue.append((fractions.gcd(q[0], n), True))
        else:
            tmp_queue.append((fractions.gcd(q[0], n), False))
            tmp_queue.append((q[0], True))
    gcd_queue = set(tmp_queue[:])

ans = 0
for q in gcd_queue:
    ans = max(ans, q[0])
print(ans)

Measured memory_bytes: 14588
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

#define EPS 1e-6

vector<pair<int,int> > v;
vector<pair<int,int> > p(20);
int n;
int ans;
int comb[10][10];

bool equal(double a,double b)
{
	return ((abs(a - b) < EPS)?true:false);
}

void check()
{
	vector<double> tmp;
	REP(i,n/2)
	{
		int j = i*2;
		pair<double,double> a,b,c;
		a = p[j];b = p[j+1];
		c.FI = a.FI - b.FI;
		c.SE = a.SE - b.SE;
		double in = 1000000;
		if(c.SE != 0)in = c.FI / c.SE;
		tmp.PB(in);
	}
	sort(ALL(tmp));
	int ret = 0;
	REP(i,tmp.size())
	{
		int cou = 0;
		while(i < tmp.size()-1 && equal(tmp[i],tmp[i+1])) 
		{
			i++;cou++;
		}
		if(cou)ret += comb[cou+1][2];
	}
	ans = max(ans,ret);
}

void dfs(int num,int memo)
{
	if(num <= 1)
	{
		check();
		return;
	}
//	cout << "!" << endl;
	int tmp = 0;
	while(memo & (1<<tmp))tmp++;
	p[n-num] = v[tmp];
	memo |= (1<<tmp);
	
	for(int i = tmp+1;i < n;i++)
	{
//		cout << "!!" << endl;
		if(!(memo&(1<<i)))
		{
//			cout << "!!!" << endl;
			p[n-num+1] = v[i];
//			SHOW1d(ME,n);
			dfs(num-2,memo|(1<<i));
		}
	}
	
}

int main()
{
	REP(i,10)comb[i][i] = comb[i][0] = 1;
	REP(i,10)
	{
		for(int j = 1;j < i;j++)comb[i][j] = comb[i-1][j] + comb[i-1][j-1];
	}
	
//	SHOW2d(comb,8,8);
	
	cin >> n;
	REP(i,n)
	{
		int a,b;cin >> a >> b;
		v.PB(MP(a,b));
	}
	
	dfs(n,0);
	
	cout << ans << endl;
	
	return 0;
}

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

int main(){
  vector<int> arr;
  
  for(int i = 0; i<6;i++){
    int x;
    cin >> x;
    arr.push_back(x);
  }
  
  if(arr[4] - arr[0] > arr[5]){
    cout << ":(" << endl;
  }
  else{
    cout << "Yay!" << endl;
  }
  
  return 0;
}

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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(A.rbegin(), A.rend());
    ll ans = 0;
    for (int i = 1; i < N; ++i) {
        ans += A[i/2];
    }
    cout << ans << endl;
}


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

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var h     = int.Parse(spl[0]);
        var w     = int.Parse(spl[1]);

        var buf = new StringBuilder();
        var x = '#';

        buf.Append(x);
        for(int i=0; i<w; i++) {
            buf.Append(x);
        }
        buf.Append(x);
        buf.AppendLine();

        for(int i=0; i<h; i++) {
            buf.Append(x);
            var s = input.ReadLine();
            buf.Append(s);
            buf.Append(x);
            buf.AppendLine();
        }
        
        buf.Append(x);
        for(int i=0; i<w; i++) {
            buf.Append(x);
        }
        buf.Append(x);
        buf.AppendLine();

        return buf;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }

}


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

int n, m;
string a, b;
int f[3002][3002];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin>>a>>b;
    n = a.size(), m = b.size();
    a = '.' + a , b = ',' + b ;
    for (int i=1;i<=n;i++){
        for (int j=1;j<=m;j++){
            if (a[i] == b[j]) f[i][j] = f[i-1][j-1] + 1;
            else f[i][j] = max(f[i-1][j], f[i][j-1]);
        }
    }
    if (f[n][m] == 0){
        exit(0);
    }
    int i = n, j = m;
    string res;
    while (i > 0 && j > 0){
        if (a[i] == b[j]){
            res = res + a[i];
            i--, j--;
        }
        else if (f[i-1][j] > f[i][j-1]) i--;
        else  j--;
    }

    reverse(res.begin(), res.end());
    cout<<res;
}


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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define DUP(x, y) (((x) + (y) - 1) / (y))

using ll = std::int64_t;
using vint = std::vector<int>;
using vll = std::vector<ll>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

void Main() {
    int n, m;
    cin >> n >> m;
    vint x(m);
    rep(i, m) cin >> x[i];


    sort(ALL(x));

    vint d(m - 1);
    rep(i, m - 1) d[i] = abs(x[i + 1] - x[i]);

    sort(ALL(d));

    int ans = 0;
    rep(i, m - n) {
        ans += d[i];
    }

    cout << ans << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}



Measured memory_bytes: 1024
//ABC076A
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

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

Measured memory_bytes: 256
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( iter = $ iter : ident , $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut $ iter = s . split_whitespace ( ) ; input_inner ! { $ iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , mut $ var : usize $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , $ var : usize $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , { chars : $ base : expr } ) => { read_value ! ( $ iter , String ) . chars ( ) . map ( | c | ( c as u8 - $ base as u8 ) as usize ) . collect ::< Vec < usize >> ( ) } ; ( $ iter : expr , { char : $ base : expr } ) => { read_value ! ( $ iter , { chars : $ base } ) [ 0 ] } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , char ) => { read_value ! ( $ iter , chars ) [ 0 ] } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
use std::*;
fn main() {
    input! { s: { chars: 'a' } };
    let n = s.len();
    let mut a = vec![0u32; n + 1];
    for i in 0..n {
        a[i + 1] = (1 << s[i]) ^ a[i];
    }
    let mut dp = vec![1_001_001_001; n + 1];
    dp[0] = 0;
    let mut t = collections::HashMap::new();
    for i in 0..n {
        let mut d = dp[i] + 1;
        let ni = i + 1;
        if a[ni].count_ones() <= 1 {
            d = 1;
        } else {
            d = cmp::min(d, *t.get(&((a[ni]) as u32)).unwrap_or(&1_001_001_001) + 1);
            for j in 0..26 {
                d = cmp::min(
                    d,
                    *t.get(&((a[ni] ^ 1 << j) as u32)).unwrap_or(&1_001_001_001) + 1,
                );
            }
        }
        dp[ni] = d;
        t.entry(a[ni]).or_insert(1_001_001_001);
        let m = cmp::min(t[&a[ni]], d);
        t.insert(a[ni], m);
    }
    println!("{}", dp[n]);
}


Measured memory_bytes: 16568
import java.util.Scanner;

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 = a * b;
		int d = a + b + a + b;
		System.out.println(c + " " + d);
	}
}

Measured memory_bytes: 26056
#include <bits/stdc++.h>
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) v.begin(), v.end()

using namespace std;

ll mod = 1e9+7;
inline ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

inline ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}

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

inline ll nCr(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return (dividend / divisor);
}

// 因数分解
inline vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}

inline bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

//階乗
inline ll factorialMethod(ll k){
    ll sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

inline ll vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
    if (index != vec.size()) { // 発見できたとき
        return 1;
        
        
    }
    else { // 発見できなかったとき
        return 0;
    }
}

void recursive_comb(ll *indexes, ll s, ll rest, std::function<void(ll *)> f) {
    if (rest == 0) {
        f(indexes);
    } else {
        if (s < 0) return;
        recursive_comb(indexes, s - 1, rest, f);
        indexes[rest - 1] = s;
        recursive_comb(indexes, s - 1, rest - 1, f);
    }
}

void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}

int main(){
    ll ans = 0;
    ll h;
    cin >> h;
    
    ll temp = 1;
    while(h != 0){
        h /= 2;
        ans += temp;
        temp *= 2;
        
//        cout << ans << endl;
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define ll long long int
#define inf 1450000090
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sdl(x) scanf("%lld",&x)
#define nax 100010
#define mp make_pair
#define sz(x) (int)(x.size())
#define pl pair <ll , ll>
#define pii pair < int , pair <int ,int > >
#define MOD 1000000007
using namespace std;
int main(int argc, char const *argv[])
{
  //freopen("input.txt","read",stdin);
  //freopen("output.txt","write",stdout);
  int a,b,c;
  cin >> a >> b >> c;
  if(b-a == c-b)
    puts("YES");
  else
    puts("NO");
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    for(int i=0; i<n; ++i)
        {
        cin >> p[i];
        q[i]=p[i];
        }
    sort(p.begin(), p.end());
    int cnt=0;
    for(int i=0; i<n; ++i)
        {
        cnt+=p[i]!=q[i];
        }
    if(cnt<=2)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
// B frog2 https://atcoder.jp/contests/dp/tasks/dp_b

#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int N,K;
    cin >> N >>K;
    int h[N],dp[N];
    for(int i=0;i<N;i++){
        cin >> h[i];
    }
    dp[0]=0;
    dp[1]=abs(h[0]-h[1]);
    for(int i=1;i<N;i++){
        int min=INT_MAX;
        for(int j=1;j<=K;j++){
            if(i-j>=0){
            if(dp[i-j]+abs(h[i]-h[i-j])<min){
                min=dp[i-j]+abs(h[i]-h[i-j]);
            }
            }
        }
            dp[i]=min;
        
    }
    cout << dp[N-1] << endl;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

class Point {
    public:
        double x, y;

    Point(double x = 0, double y = 0): x(x), y(y) {}

    Point operator+ (Point p) { return Point(x + p.x, y + p.y); }
    Point operator- (Point p) { return Point(x - p.x, y - p.y); }
    Point operator* (double a) { return Point(x * a, y * a); }
    Point operator/ (double a) { return Point(x / a, y / a); }

    double norm() { return x * x + y * y; }
    double abs() { return sqrt(norm()); }

    bool operator< (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }
    bool operator== (const Point &p) const {
        return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
    }
};
struct Segment {
    Point p1, p2;
    Segment(Point p1, Point p2): p1(p1), p2(p2) {}
};
typedef Point Vector;
typedef Segment Line;
typedef vector<Point> Polygon;

class Circle {
    public:
        Point c;
        double r;
        Circle(Point c = Point(), double r = 0.0): c(c), r(r) {}
};

double dot(Vector v1, Vector v2) {
    return v1.x * v2.x + v1.y * v2.y;
}

double cross(Vector v1, Vector v2) {
    return v1.x * v2.y - v1.y * v2.x;
    }

Point project(Segment s, Point p) {
    Vector base = s.p2 - s.p1;
    double r = dot(p - s.p1, base) / base.norm();
    return s.p1 + base * r;
}

Point reflect(Segment s, Point p) {
    Point x = project(s, p);
    return p + (x - p) * 2;
}

int main() {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    Point p1(x1, y1), p2(x2, y2);
    Segment s(p1, p2);

    int q; cin >> q;
    vector<Point> ps;
    rep(i, q) {
        double x, y; cin >> x >> y;
        ps.push_back(Point(x, y));
    }

    cout << fixed << setprecision(10);
    rep(i, q) {
        Point r = reflect(s, ps[i]);
        cout << r.x << " " << r.y << endl;
    }
}



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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int min = a;
  if(min > b) min = b;
  if(min > c) min = c;

  int ans = 0;
  if(a == min && b <= c){
    ans = b-a +c-b;
  }
  else if(a == min && b > c){
    ans = c-a + b-c;
  }
  else if(b == min && a <= c){
    ans = a-b + c-a;
  }
  else if(b == min && a > c){
    ans = b-c + a-c;
  }
  else if(c == min && a <= b){
    ans = a-c + b-a;
  }
  else{
    ans = b-c + a-b;
  }
  cout << ans << endl;
}


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

int main() {
    int N;
    cin >> N;
    vector <int>  A(N);
    double sum = 0;
    for(int i = 0; i < N; i++)
    {
        cin >> A[i];
        sum += (1/(double) A[i]);
    }
    cout << setprecision(10)<<  1 / sum << endl;
    return 0;  

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
typedef vector<P> vec;
 
double eps=1e-7;
bool eq(double a,double b){return (b-a<eps&&a-b<eps);}
double dot(P a,P b){return real(b*conj(a));}
double cross(P a,P b){return imag(b*conj(a));}
P project(P a,P b,P c){b-=a;c-=a;return a+b*real(c/b);}
P reflect(P a,P b,P c){b-=a;c-=a;return a+conj(c/b)*b;}
int ccw(P a,P b,P c){
  b-=a,c-=a,a=c*conj(b);
  if(a.imag()>eps)return 1;//ccw
  if(a.imag()<-eps)return -1;//cw
  if(a.real()<-eps)return 2;//ob
  if(abs(b)+eps<abs(c))return -2;//of
  return 0;//os
}
 
//segment ab , point c
double dist(P a,P b,P c){
  if(dot(b-a,c-a)<0)return abs(c-a);
  if(dot(a-b,c-b)<0)return abs(c-b);
  return abs(cross(b-a,c-a))/abs(b-a);
}
 
bool isintersect(P a,P b,P c,P d){
  return ((ccw(a,b,c)*ccw(a,b,d)<=0)&&(ccw(c,d,a)*ccw(c,d,b)<=0));
}
 
//segment ab , segment cd
P intersect(P a,P b,P c,P d){
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}
 
double dist(P a,P b,P c,P d){
  if(isintersect(a,b,c,d))return 0;
  double ab=min(dist(a,b,c),dist(a,b,d));
  double cd=min(dist(c,d,a),dist(c,d,b));
  return min(ab,cd);
}
 
double calcArea(vec &t){
  double res=0;
  int n=t.size();
  for(int i=0;i<n;i++)res+=cross(t[i],t[(i+1==n?0:i+1)]);
  return abs(res/2.0);
}
 
int main(){
  int n;
  cin>>n;
  vec t;
  double x,y;
  for(int i=0;i<n;i++){
    cin>>x>>y;
    t.push_back(P(x,y));
  }
  int ans=1;
  for(int i=0;i<n;i++){
    int j=(i+1)%n;
    int k=(i+2)%n;
    if( ccw(t[i],t[j],t[k]) == -1 )ans=0;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3288
import java.util.*


fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    // A
//    val a = scanner.nextInt()
//    val b = scanner.nextInt()
//    val c = scanner.nextInt()
//    solveA(a, b, c)

    // B
    val arr = scanner.next().toCharArray()
    val halfSize = arr.size / 2
    halfSize
    val lastIndex = arr.size - 1
    var count = 0
    for (i in 0 until halfSize) {
        if (arr[i] != arr[lastIndex - i]) {
            count++
        }
    }
    println(count)
}

Measured memory_bytes: 31008
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,w) for (int i = 0;i < (w); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;


int main(){
  string s;cin >> s;
  int ans = 0;
  int cnt = 0;
  rep(i,s.size()){
    if(s[i]=='A' || s[i]=='G' || s[i]=='T' || s[i]=='C') {
      cnt++;
      ans = max(ans,cnt);
    }else cnt = 0;
  }
  cout << ans << endl;

  
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
/*v(int) adj[200001];
void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
int main()
{
  lli n,d;
  cin>>n>>d;
  int c=0;
  rep(i,n){
      lli a,b;
      cin>>a>>b;
      if(a*a+b*b<=d*d) c++;
  }
  cout<<c<<endl;
}


Measured memory_bytes: 3616
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9+7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
#define INT_MAX 1e9+7

int main(){
    ll h,w,K; cin >> h >> w >> K;
    char s[h][w];
    rep(i,h) rep(j,w) cin >> s[i][j];
    ll ans[h][w];
    rep(i,h) rep(j,w) ans[i][j] = -1;
    ll now = 1;
    ll cur = 0;
    rep(i,h){
        cur = 0;
        rep(j,w){
            if(s[i][j]=='#'){
                REP(k,cur,j+1){
                    ans[i][k] = now;
                }
                now++;
                cur = j+1;
            }
        }
        if(cur != 0) {
            now--;
            REP(j, cur, w) {
                ans[i][j] = now;
            }
        }
        if(cur != 0) now++;
    }
    rep(i,h){
        rep(j,w){
            ll t = 0;
            if(ans[i][j]==-1){
                REP(k,i,h){
                    if(ans[k][j]!=-1){
                        t = k;
                        break;
                    }
                }
                REP(k,i,t){
                    ans[k][j] = ans[t][j];
                }
            }
        }
    }
    for(ll i=h-1; i>=0; i--){
        rep(j,w){
            ll t = 0;
            if(ans[i][j] == -1){
                for(ll k=i; k>=0; k--){
                    if(ans[k][j] != -1){
                        t = k;
                        break;
                    }
                }
                for(ll k=i; k>t; k--){
                    ans[k][j] = ans[t][j];
                }
            }
        }
    }
    rep(i,h){
        rep(j,w){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define pii pair<ll,ll>
#define mp make_pair
#define N 201000
#define ll long long

ll n,m,l,r,x;
vector<pii> a[N],b[N];
ll dp[N],tag[N<<2],mx[N<<2],ans;

void pd(ll o) {
	ll ls=o<<1,rs=o<<1|1;
	tag[ls]+=tag[o]; tag[rs]+=tag[o];
	mx[ls]+=tag[o]; mx[rs]+=tag[o];
	tag[o]=0;
}

void upd(ll o,ll L,ll R,ll l,ll r,ll x) {
	if (l<=L && r>=R) {
		tag[o]+=x; mx[o]+=x;
		return;
	}
	pd(o);
	ll mid=(L+R)>>1;
	if (l<=mid) upd(o<<1,L,mid,l,r,x);
	if (r>mid) upd(o<<1|1,mid+1,R,l,r,x);
	mx[o]=max(mx[o<<1],mx[o<<1|1]);
}

ll query(ll o,ll L,ll R,ll l,ll r) {
	if (l<=L && r>=R) return mx[o];
	pd(o);
	ll mid=(L+R)>>1;
	ll ret=-1000000000000000ll;
	if (l<=mid) ret=max(ret,query(o<<1,L,mid,l,r));
	if (r>mid) ret=max(ret,query(o<<1|1,mid+1,R,l,r));
	return ret;
}

int main()
{
	scanf("%lld%lld",&n,&m);
	for (ll i=1;i<=m;i++) {
		scanf("%lld%lld%lld",&l,&r,&x);
		a[l].push_back(mp(l-1,x));
		b[r].push_back(mp(l-1,x));
	}
	dp[0]=0;
	for (ll i=1;i<=n;i++) {
		for (auto t:a[i]) upd(1,0,n,0,t.first,t.second);
		dp[i]=query(1,0,n,0,i-1);
		upd(1,0,n,i,i,dp[i]);
		ans=max(ans,dp[i]);
		//printf("%lld\n",dp[i]);
		for (auto t:b[i]) upd(1,0,n,0,t.first,-t.second); 
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 36352
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#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 <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    int N,M;cin >> N >> M;
    vector<long long> diff(M-1);
    vector<int> retu(M);
    long long ans = 0;
    for(int i = 0;i<M;i++) cin >> retu.at(i);
    sort(retu.begin(),retu.end());
    for(int i = 0;i<M-1;i++){
        diff.at(i) = abs(retu.at(i)-retu.at(i+1));
        ans += diff.at(i);
    }
    sort(diff.begin(),diff.end());
    reverse(diff.begin(),diff.end());

    int count = min(N-1,M-1);
    for(int i = 0;i<count;i++){
        ans -= diff.at(i);
    }
    cout << ans << endl;

}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a-1; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
vector<vector<ll>> v;
vector<ll> cost;



int main(){
    ll w, h, n; cin >> w >> h >> n;
    ll l=0, r=w, t=h, b=0, res=0;
    rep(i, n){
        ll x, y, op;    cin >> x >> y >> op;
        if(op==1)   l = max(x, l);
        else if(op==3) b = max(y, b);
        else if(op==2) r = min(x, r);
        else t = min(y, t);
    }
    if(l<r && b<t) res = (r-l)*(t-b);
    cout << res << endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define fi first
#define se second
#define endl '\n'
#define mx 1e18
#define mod 1000000007
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll powe(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return powe(((x%mod)*(x%mod))%mod,n/2);
    else                             //n is odd
        return ((x%mod*(powe(((x%mod)*(x%mod))%mod,(n-1)/2))%mod)%mod);
}
int main()
{
    int n,k;cin>>n>>k;
    vector<int>a(n+1);
  for(int i=1;i<=n;i++)cin>>a[i-1];
  vector<vector<int>>dp(n+1,vector<int>(k+1,0));
  dp[0][0]=1;
  for(int i=0;i<n;i++)
  {
      for(int j=0;j<=k;j++)
      {
          if(j==0)
              dp[i+1][j]=dp[i][j];
            else  if(j>=1)
              dp[i+1][j]=(dp[i][j]%mod+dp[i+1][j-1]%mod)%mod;
             if(j-a[i]-1>=0)
             {
                 dp[i+1][j]=(dp[i+1][j]-dp[i][j-a[i]-1]+mod)%mod;
             }
          
          
          
      }
  }
  cout<<dp[n][k];
  
}

Measured memory_bytes: 40192
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()


int main(){
    int R;
    cin >> R;
    cout << 2 * R * PI << endl;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define ALL(x) (x).begin(),(x).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
using namespace std;
typedef long long ll;

int N,Q;
string S;

// dp[i+1]: i文字目までの「ACのA」個数
vector<int> dp;

int main()
{
  cin >> N >> Q;
  cin >> S;

  dp.resize(N+1,0);
  dp[0] = 0;
  REP(i,0,N) {
    // i文字目まで
    if (S.substr(i,2) == "AC") {
      dp[i+1] = dp[i] + 1;
    } else {
      dp[i+1] = dp[i];
    }
  }

  REP(i,0,Q) {
    int l,r;
    cin >> l >> r;
    --l; --r;
    // 添字ずれ
    cout << dp[r] - dp[l] << endl;
  }

  return 0;
}


Measured memory_bytes: 1408
N,M=map(int,input().split())
k=[list(map(int,input().split())) for _ in range(M)]
p=list(map(int,input().split()))

ans=0
for i in range(2**N):
    switch=[False]*N

    for j in range(N):
        if ((i>>j) & 1):
            switch[N-j-1]=True

    light=True
    for m in range(M):
        cnt=0
        for o in range(k[m][0]):
            if switch[k[m][o+1]-1]==True:
                cnt+=1

        if not (cnt%2==p[m]):
            light=False

    if light==True:
        ans+=1
      
            
print(ans)

#パクリ元　https://www.planeta.tokyo/entry/3963/

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
#include <set>

using namespace std;

pair<int,int> d[300];
pair<int,int> dd[2000];

int main(){
while(1){
 int m;
 scanf("%d",&m);
if(m==0){
return 0;
}
 for(int i = 0; i < m; i++){
  int a,b;
  scanf("%d%d",&a,&b);
  d[i] = make_pair(a,b);
 }
 int n;
 scanf("%d",&n);
 set<pair<int,int> > mp;
 for(int i = 0; i < n; i++){
  int a,b;
  scanf("%d%d",&a,&b);
  dd[i] = make_pair(a,b);
  mp.insert(make_pair(a,b));
 }
 for(int i = 0; i < n; i++){
  bool ok = true;
  pair<int,int> shift = make_pair(dd[i].first - d[0].first,dd[i].second - d[0].second);
  for(int j = 0; j < m; j++){
   if(mp.end() == mp.find(make_pair(d[j].first + shift.first,d[j].second + shift.second))){
    ok = false;
    break;
   }
  }
  if(ok){
   printf("%d %d\n",shift.first,shift.second);
   break;
  }
 }
}
}

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


int main() {
    int k, a, b;
    cin >> k >> a >> b;

    for (int i=a; i<b+1; i++) {
        if (i % k ==0) {
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;



    return 0;
}



Measured memory_bytes: 3620
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))

using namespace std;
int n;
int a[1000];
int b[1000];
int c[1000];
int ans;
int main(){
  cin >> n;
  REP(i,n){
    int v;
    cin >> v;
    b[i] = v;
  }
  REP(i,n){
    int d;
    cin >>d;
    c[i] = d;
  }
  REP(i,n){
    a[i]= b[i]- c[i];
  }
  sort(a,a+n);
  reverse(a,a+n);
  REP(i,n){
    ans += max(0,a[i]);
    //cout << ans <<endl;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define ll             long long 
#define mod            1000000007
#define FIO            ios_base::sync_with_stdio(false); cin.tie(NULL);
                  
void initial()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
}

#define pi   3.14159265358979323846264338327950288419716939937510


int main() 	 	
{
	initial();
	FIO;

	int r;
	cin>>r;

	long double circum = 2*pi*r;

	cout<<fixed<<setprecision(20)<<circum<<endl;
}



Measured memory_bytes: 3776
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = list(map(int, input().split()))

    ma = max(A)
    B = [True] * (ma+1)
    A.sort()
    for a in A:
        for i in range(a+a, ma+1, a):
            B[i] = False

    import collections
    ans = 0
    for k, v in collections.Counter(A).items():
        if B[k] and v == 1:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 43040
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,k,a,b,L,c,tmp,ans,dp[2000][2000],rans=1e15;
vector<ll> v;
int main(void){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a;
        v.push_back(a);
        dp[i][0]=a;
    }
    for(int i=0;i<n;i++){
        for(int j=1;j<n;j++){
            dp[i][j]=min(dp[i][j-1],v[(i+j)%n]);
        }
    }
    for(int i=0;i<n;i++){
        ans=0;
        for(int j=0;j<n;j++){
            ans+=dp[j][i];
            //cout<<dp[j][i]<<" ";
        }
        //cout<<endl;
        ans+=k*i;
        rans=min(ans,rans);
    }
    cout<<rans<<endl;
}


Measured memory_bytes: 31488