akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define vec(x) vector<x>
ll gcd(ll a,ll b){while(b){ll tmp = a % b;a = b;b = tmp;}return a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
#define rep(x, y) for(int x = 0; x < (y); x++)
#define rrep(x, y) for(int x = (y); x >= 0; x--)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++)
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define out(x) for(auto i : x) cout << i << " "; cout << endl;
#define outln(x) for(auto i : x) cout << i << " " << endl;
#define vec_cpy(to,from) copy(all(to),back_inserter(from))
#define ary_cpy(to,from) memcpy(to, from, sizeof from)
#define MOD = 1000000007; 
#ifdef DEBUG
#define debug_echo(e) cout << "L" << __LINE__ << ": " << e << endl
#define debug_var(e) cout << "L" << __LINE__ << ": " << #e << " = " << e << endl
#define debug_echo_dp(dp, N) { cout << "[ "; rep(i, N) cout << dp[i] << " ";  cout << "]" << endl; }
#else
#define debug_echo(e)
#define debug_var(e)
#define debug_echo_dp(dp, N)
#endif

int main(){
  int m[] = {1,5,10,50,100,500};
  int c,sum = 0;
  rep(i,6){
    cin >> c;
    sum += c * m[i];
  }

  cout << (sum >= 1000 ? 1 : 0) << endl;
}

Measured memory_bytes: 3092
#include <iostream>

using namespace std;

#define int long long
#define f(i,l,n) for(int i=l;i<n;i++)

int xc2(int x){
	if(x<2)
		return 0;
	return  (x*(x-1))/2;
}

signed main(){
	int n;
	cin>>n;
	int freq[n+1];
	int ncs[n+1];
	int actual[n+1];
	f(i,0,n+1){
		freq[i]=0;	
		ncs[i]=0;
	}
	f(i,1,n+1){
		cin>>actual[i];
		freq[actual[i]]++;
	}
	int nc2sum=0;
	f(i,1,n+1){
		ncs[i]=xc2(freq[i]);
		nc2sum+=ncs[i];
	}
	f(i,1,n+1){
		cout<<nc2sum+1-freq[actual[i]]<<endl;
	}


}

Measured memory_bytes: 6392
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class ACalc {
        public void solve(int testNumber, Scanner s, PrintWriter sout) {
            int n = s.nextInt();
            sout.println(n + (int) Math.pow(n, 2) + (int) Math.pow(n, 3));
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 32652
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	vll a(n),b(n) ;
	vector<pll> p(n) ;
	for(int i=0;i<n;i++){
		cin >> a.at(i) >> b.at(i) ;
		p.at(i).first = a.at(i)+b.at(i) ;
		p.at(i).second = i ;
	}
	sort(all(p)) ;
	reverse(all(p)) ;
	ll ans = 0 ;
	for(int i=0;i<n;i++){
		if(i&1) ans -= b.at(p.at(i).second) ;
		else ans += a.at(p.at(i).second) ;
	}
	cout << ans << endl ;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b && b!=c){
    cout << "Yes"
         << "\n";
  }else if(a == c && a!=b){
    cout << "Yes\n";
  }else if(b ==c && a!=b){
    cout << "Yes\n";
  }else{
    cout << "No\n";
  }
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> q(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];
    vector<int> a(n);
    rep(i,n) {
        a[i] = i+1;
    }
    map<vector<int>, int> mp;
    do{
        mp[a] = mp.size();
    }while(next_permutation(a.begin(), a.end()));
    int ans = abs(mp[p] - mp[q]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5248
#include <algorithm>
#include <cassert>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

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

    set<int> p, q;
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        if (b < a)
            swap(a, b);

        if (a == 1)
            p.insert(b);
        if (b == N)
            q.insert(a);
    }

    vector<int> v;
    set_intersection(p.begin(), p.end(),
                     q.begin(), q.end(),
                     back_inserter(v));

    cout << (v.empty() ? "IMPOSSIBLE" : "POSSIBLE") << '\n';

    return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, nuint_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; 
#define int long long
#define MOD 1000000007
#define what_is(x) cerr << #x << " is " << x << endl;
#define loop(i,a,n) for(int i=a;i<n;i++)
#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, szof(x))
#define sortall(x) sort(aint(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626 
 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int, int> pt;

signed main() {

	fastio();
	//#define LOCAL_DEFINE	
	#ifdef LOCAL_DEFINE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	//https://leetcode.com/problems/maximum-nesting-depth-of-two-valid-parentheses-strings/
	int n;
	cin>>n;
	vector<int> arr(n,0),arr1(n,0),arr2(n,0);
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	for(int i=0;i<n;i++)
	{
		cin>>arr1[i];
	}
	for(int i=0;i<n-1;i++)
	{
		cin>>arr2[i];
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		ans+=((arr1[arr[i]-1]));
		if(i>0 && (arr[i]==(arr[i-1]+1)))
			ans+=(arr2[arr[i-1]-1]);

	}
	cout<<ans;
	return 0;
 
 }

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, M: int, A: "List[int]"):
    A.sort()
    A.reverse()
    c = 0
    s = sum(A)
    for a in A:
        if a * 4 * M >= s:
            c += 1
    if c >= M:
        ret = YES
    else:
        ret = NO
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
#include <functional>																							   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;	
const int mod = 1e9+7;																							   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra																													   																				   list<int>::iterator it;																								   
																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS//////////////////////////////////////////////////////

vector< pair<LL,LL> > V;

///////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	LL n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		LL a, b;
		cin >> a >> b;
		V.pb(mp(a, b));
	}
	
	//cout << endl;
	sort(V.begin(), V.end());
	//for(auto it : V){
		//cout << it.first << " " << it.second << endl;
	//}
	
	LL licznik = 0;
	LL ans = 0;

	for(auto it : V){
		if(licznik + it.second <= m){
			ans += (it.first * it.second);
			licznik += it.second;
		}
		else{
			LL temp = m - licznik;
			ans += (it.first * temp);
			licznik += temp;
		}
		if(licznik == m){
			break;
		}
	}
	
	cout << ans << endl;
	
	
	
	
						
	return 0;
}


Measured memory_bytes: 2420
// clang-format off

#include <bits/stdc++.h>

#define int long long int
#define main signed main()
#define bye return 0
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define each(p, v) for (auto p = (v).begin(); p != (v).end(); p++)
#define all(v) (v).begin(), (v).end()
#define prec(n) fixed << setprecision(n)
#define dump(x) cerr << "(L" << __LINE__ << ") " << #x << " = " << (x) << endl
#define clr(x, a) memset(x, a, sizeof(x))

#define sum(v) accumulate(all(v), 0)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define odd(n) ((n) % 2)
#define even(n) (!odd(n))

#define INF 1000000000
#define INFLL 1000000000000000000LL
#define MOD 1000000007
#define PI acos(-1)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>

using namespace std;

// clang-format on

main {
  int n;
  cin >> n;
  int c = INF;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      int a = i, b = n / i;
      c = min(c, max<int>(to_string(a).size(), to_string(b).size()));
    }
  }
  cout << c << endl;
  bye;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
#define pi 3.1415926535898
using namespace std;
const ll mod=1e9+7;
ll pows(ll n,ll a,ll p)
{
    ll ans=1;
    while(a)
    {
        if(a&1)
        {
            ans=ans*n%p;
        }
        n=n*n%p;
        a>>=1;
    }
    return ans%p;
}

int main()
{
    ll n;
    ll zero=0;
    ll ans=1;
    map <pair <ll,ll>,ll> m;
    map <pair <ll,ll>,ll>::iterator it;
    scanf("%lld",&n);
    for(ll i=1; i<=n; i++)
    {
        ll u,v,now;
        cin>>u>>v;
        if(u==0&&v==0)
        {
            zero++;
            continue;
        }
        now=__gcd(u,v);
        u/=now;
        v/=now;
        if(u<0)
        {
            u=-u;
            v=-v;
        }
        m[make_pair(u,v)]++;
    }
    for(it=m.begin(); it!=m.end(); it++)
    {
        if(it->second==0)
        {
            continue;
        }
        ll x=it->first.first,y=it->first.second;
        ll p=pows(2,m[make_pair(x,y)],mod);
        y=-y;
        if(y<0)
        {
            x=-x;
            y=-y;
        }
        if(m.count(make_pair(y,x)))
        {
            p=(p+pows(2,m[make_pair(y,x)],mod)-1);
            m[make_pair(y,x)]=0;
        }
        ans=(ans*p)%mod;
    }
    printf("%lld\n", ((ans+zero-1)%mod+mod)%mod);
    return 0;
}


Measured memory_bytes: 16224
import java.util.Scanner;

public class Main {

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

		sc.close();
		int result = 0;

		// 処理
		if (400 <= x && x <= 599) {
			result = 8;
		} else if (600 <= x && x <= 799) {
			result = 7;
		} else if (800 <= x && x <= 999) {
			result = 6;
		} else if (1000 <= x && x <= 1199) {
			result = 5;
		} else if (1200 <= x && x <= 1399) {
			result = 4;
		} else if (1400 <= x && x <= 1599) {
			result = 3;
		} else if (1600 <= x && x <= 1799) {
			result = 2;
		} else if (1800 <= x && x <= 1999) {
			result = 1;
		}

		System.out.print(result);

	}

}


Measured memory_bytes: 35724
/*
    Author: Arham_doshi
    @quote "Code like there's no tommorow!"
     ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
    */
    #include <bits/stdc++.h>
     
    #define int         long long
    #define double      long double
    #define pb          push_back
    #define pf          push_front
    #define pii         pair<int,int>
    #define vi          vector<int>
    #define vii         vector<pii>
     
    #define mi          map<int,int>
    #define mii         map<pii,int>
    #define piii           pair<int,pair<int,int> >
     
     
    #define all(a)      (a).begin(),(a).end()
    #define rall(a)     (a).rbegin(),(a).rend()
    #define x           first
    #define y           second
    #define sz(x)       (int)x.size()
    #define endl        '\n'
    #define hell        998244353 
    #define PI          3.141592653589
    #define bs(v,n)     binary_search(all((v)),(n))
    #define lb(v,n)     lower_bound(all((v)),(n))
    #define ub(v,n)     upper_bound(all((v)),(n))
    #define fo(i,l,u)   for(i=l;i<u;i++)
    #define rfo(i,l,u)  for(i=l;i>=u;i--)
    #define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
    #define _init(b)     memset(b,-1,sizeof(b))
    #define _init0(b)     memset(b,0,sizeof(b))
    #define MOD         1000000007
    #define ef else if
    #define N           200005
     
     
    using namespace std;
     
    int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }  
    bool mod(double a,double b) {return a/b - floor(a/b);}
     
    int occurs(vi v,int n){
    auto it=lb(v,n);auto it1=ub(v,n);int x=it1-it;return x;}
     
    int logb(int base, int x) {
        return (log(x) / log(base));
    }
     
     
     int power(int n,int Pow){
                int result=1;
                while(Pow>0){
                    if(Pow%2==1){
                        result=(result*n)%MOD;
                    }
                    n=(n*n)%MOD;
                   Pow/=2LL;
                }
                return result;
            }
            
    int inverse(int a){
        return power(a,1000000005);
    }        
     
    int fun(int n,int r,int p){
        int i,fact[n+5];
        
        fact[0]=1;
        fact[1]=1;
        fo(i,2,n+1){
            fact[i]=fact[i-1]*i;
            fact[i]%=p;
        }
        
        int ans=fact[n];
        ans*=inverse(fact[r]);
        ans%=p;
        ans*=inverse(fact[n-r]);
        return ans%=p;
        
    }
     
    signed main()
    {
        int i,j,x,y,a,b;
          cin>>x>>y;
        if(x<y) swap(x,y);  
        int c=2*y-x;
        
        if(c>=0&&c%3LL==0){
            
            b=c/3LL;
            a=(x-b)/2LL;
            
                
                
            cout<<fun(a+b,b,1000000007LL);
            
            
            
            
        }
        else{
            cout<<0;
        }
     
        return 0;
    }

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : abs(a);}
template<typename T> T lcm(T a, T b) {return a / gcd(a, b) * b;}
template<typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) {fill((T*)array, (T*)(array+N), val);}

const int Max = 1e6;
int a[Max], b[Max];

int main() {
    Fill(a, 0);
    Fill(b, 0);
    int n;
    cin >> n;
    rep(i, n) {
        int v;
        cin >> v;
        if(i % 2 == 0) a[v]++;
        else b[v]++;
    }
    int am = inf, bm = inf;
    int ma, mb;
    rep(i, Max) {
        if(chmin(am, n / 2 - a[i])) ma = i;
        if(chmin(bm, n / 2 - b[i])) mb = i;
    }
    int am2 = inf, bm2 = inf;
    a[ma] = 0, b[mb] = 0;
    if(ma == mb) {
        rep(i, Max){
            chmin(am2, n / 2 - a[i]);
            chmin(bm2, n / 2 - b[i]);
        }
        if(am2 > bm2) bm = bm2;
        else am = am2;
    }
    cout << am + bm << endl;
}

Measured memory_bytes: 8064
#include <iostream>
#include <math.h>
#include <cassert>
#include <vector>
#include <deque>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
    long long int n;
    cin>>n;
    long int count=1000;
    while(n>count){
		count+=1000;
	}
	cout<<count-n<<endl;
		
	return 0;
}


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

int cnt[2001];
int psum[2001];
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n,t;
	vector <int> v;

	cin >> n;

	for(int i=0;i<n;i++)
	{
		cin >> t;
		cnt[t]++;
		v.push_back(t);
	}

	psum[0]=0;
	for(int i=1;i<=2000;i++)
	{
		psum[i] = psum[i-1] + cnt[i];
	}

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

	long long int res = 0;

	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			int x = v[i] + v[j];
			int y = abs(v[i] - v[j]);
			res += (psum[x-1] - psum[y]);
			if(y<v[i] && v[i]<x)
			{
				res--;
			}
			if(y<v[j] && v[j]<x)
			{
				res--;
			}
		}
	}

	cout << res/3 << '\n';

	return 0;
}

Measured memory_bytes: 256
use std::collections::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let s: String = read();
    let s = s.chars().collect::<Vec<_>>();
    let mut ans = 1000;
    for i in 0..s.len() - 2 {
        let tmp = s[i].to_digit(10).unwrap() * 100 +
                  s[i + 1].to_digit(10).unwrap() * 10 +
                  s[i + 2].to_digit(10).unwrap() * 1;
        ans = std::cmp::min((tmp as i32 - 753).abs(), ans);
    }
    println!("{:?}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
#include <functional>
using namespace std;
typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA cerr << "AAAAA" << endl
#define debug_ cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    cout << #v << endl;                \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    cout << #v << endl;                       \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

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

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

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const ll LINF = 1001002003004005006ll;
const ll INF = 1001001001;
const double pi = acos(-1);

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll MIN = LINF;
    for (int i = 1; i <= 100; i++)
    {
        ll tmp = 0;
        for (int j = 0; j < n; j++)
        {
            tmp += (i - a[j]) * (i - a[j]);
        }
        MIN = min(MIN, tmp);
    }
    cout << MIN << endl;

    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;
 
typedef pair <int, int> pii;
 
const long long Inf = 2e18;
const long long mod = 998244353;
const double Pi = acos(-1);
 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n;

int main()
{
	cin >> n;
	int ans = 100000;
	for(int i = 0; i <= 20; i++)
	{
		if(1000 * i >= n)
			ans = min(ans, abs(i * 1000 - n));
	}
	cout << ans;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    string w;
    cin >> w;
    int len_w = w.size();
    bool even = true;
    rep(i,len_w){
        int count = 0;
        rep(j,len_w){
            if (w[i] == w[j]){
                count++;
            }
        }
        if (count % 2 == 1){
            even = false;
        }
    }
    if (even) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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


int main() {

	int count = 0, count_max = 0;
	int tmp;
	int i;

	int N, N_out = 1;
	
	cin >> N;

	for (i = 1; i <= N; i++)
	{
		tmp = i;
		
		while (tmp%2 == 0 && tmp != 0)
		{
			count++;
			tmp /= 2;
		}

		if (count >= count_max)
		{
			count_max = count;
			N_out = i;
		}
		count = 0;
	}
	
	cout << N_out << endl;
	
	
}

Measured memory_bytes: 3632
#include<cstdio>
int main(){
	long long int n,m;
	scanf("%lld%lld",&n,&m);
	if(n==1){
		if(m==1){
			printf("1\n");
		}
		else{
			printf("%lld\n",m-2);
		}
	}
	else{
		if(m==1){
			printf("%lld\n",n-2);
		}
		else{
			printf("%lld\n",(n-2)*(m-2));
		}
	}
}


Measured memory_bytes: 128
import fractions
mod=10**9+7
N=int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // fractions.gcd(ans, a[i])

count=0
for i in a:
    count+=ans//i
print(count%mod)

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

using namespace std;

const int INF = 1 << 30;

int main()
{
  int N, A[100];
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int ret = INF;
  for(int i = -100; i <= 100; i++) {
    int sub = 0;
    for(int j = 0; j < N; j++) {
      sub += (A[j] - i) * (A[j] - i);
    }
    ret = min(ret, sub);
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
# import numpy as np
import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)
# from decimal import Decimal


def main():
    a,b,c = map(int,input().split())

    if (a == c) or (b == c):
        res = 'No'
        print(res)
        sys.exit()

    test = c - a - b

    if test <= 0:
        res = 'No'
        print(res)
        sys.exit()

    right = (a - (b + c) * 2) * a + (b - c) ** 2

    if 0 < right:
        res = 'Yes'
    else:
        res = 'No'

    print(res)



main()


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>

//#define PI 3.141592653589

using namespace std;



int main()
{
	int a[4], b[4];
	int hit, blow;
	
	while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3])
	{
		hit = 0;
		blow = 0;
		
		for (int i=0; i<4; i++)
		{
			if (a[i] == b[i]) hit++;
		}
		for (int i=0; i<4; i++)
		{
			for (int j=0; j<4; j++)
			{
				if (i == j) continue;
				if (a[i] == b[j]) blow++;
			}
		}
		
		cout << hit << " " << blow << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 10007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------
int a[110][110];
int b[110];
int c[110];
//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //------------------------------
    int n,m;cin>>n>>m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    for(int j=0;j<m;j++)cin>>b[j];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            c[i]+=a[i][j]*b[j];
        }
    }
    for(int i=0;i<n;i++)cout<<c[i]<<endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------


































Measured memory_bytes: 3208
#include<iostream>

using namespace std;

int main(){

	int a = 0;
	int b = 0;

	cin >> a >> b;

	if (a > b){
		cout << "a > b" << endl;
	}
	if (a == b){
		cout << "a == b" << endl;
	}
	if (a < b){
		cout << "a < b" << endl;
	}


}

Measured memory_bytes: 3072
#include <iostream>

using namespace std;

int main()
{
	int L, R, d;
	cin >> L >> R >> d;

	int i = 0;
	while (true)
	{
		if ((L + i) % d == 0) break;
		else i++;
	}

	int j = 0;
	while (true)
	{
		if ((R - j) % d == 0) break;
		else j++;
	}

	cout << (R - j - L - i) / d + 1 << endl;
}

Measured memory_bytes: 3592
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
L = 0; R = 10 ** 6
for _ in range(M):
    l, r = lr()
    if l > L:
        L = l
    if r < R:
        R = r

answer = max(0, R - L + 1)
print(answer)


Measured memory_bytes: 3060
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<ctime>
#define rg register
#define _ 305
#define mod 1000000007
using namespace std;
int limit[_][_],rec[_],Num,n,m;
int dp[_][_][_];  //dp[i][j][k]: 红色上回出现在i，绿色上回出现在j, blue上回出现在k 的方案数
struct pp
{
	int next,to,w;
}Lim[_];
inline int read()
{
	rg int save=0,w=1;rg char q=getchar();
	while(q<'0'||q>'9'){if(q=='-')w=-1;q=getchar();}
	while(q>='0'&&q<='9')save=(save<<3)+(save<<1)+q-'0',q=getchar();
	return save*w;
}
inline void get(int from,int to,int ww)
{
	Lim[++Num]=(pp){rec[from],to,ww};
	rec[from]=Num;
}
inline void Input()
{
	n=read(), m=read();
	rg int i;
	for(i=1;i<=m;++i)
	{
		int l=read(),r=read(),x=read();
		limit[l][r]=x;
		get(r,l,x);
	}
}
inline int max(int x,int y){   return x<y?y:x;   }
inline bool check(int r,int g,int b)
{
	int pos=max(r,max(g,b));
	for(int j=rec[pos];j;j=Lim[j].next)
	{
		int to=Lim[j].to, ww=Lim[j].w, cnt=0;
		if(r>=to) cnt++;
		if(g>=to) cnt++;
		if(b>=to) cnt++;
		if(cnt^ww) return 0;
	}
	return 1;
}
inline void DP()
{
	rg int i,j,k;
	dp[0][0][0]=1;
	for(i=0;i<=n;++i)
	{
		for(j=0;j<=n;++j)
		{
			for(k=0;k<=n;++k)
			{
				if((j==k&&(j^0))||(j==i&&(j^0))||(i==k&&(i^0))) continue;
				int pos=max(i,max(j,k));
				if(check(pos+1,j,k)) dp[pos+1][j][k]=(dp[pos+1][j][k]+dp[i][j][k])%mod;
				if(check(i,pos+1,k)) dp[i][pos+1][k]=(dp[i][pos+1][k]+dp[i][j][k])%mod;
				if(check(i,j,pos+1)) dp[i][j][pos+1]=(dp[i][j][pos+1]+dp[i][j][k])%mod;
			}
		}
	}
}
inline void doit()
{
	DP();
	rg int j,k; int ans=0;
	for(j=0;j<=n;++j)
		for(k=0;k<=n;++k)
			ans=(ans+dp[n][j][k])%mod;
	for(j=0;j<=n;++j)
		for(k=0;k<=n;++k)
			ans=(ans+dp[j][n][k])%mod;
	for(j=0;j<=n;++j)
		for(k=0;k<=n;++k)
			ans=(ans+dp[j][k][n])%mod;
	printf("%d\n",ans);
}
int main()
{
	Input();
	doit();
	return 0;
}


/*
                bool ff1=0,ff2=0,ff3=0,flag=0;
				for(int p=rec[i];p;p=Lim[p].next)
				{
					int to=Lim[p].to, ww=Lim[p].w;
					if(ww==3)
					{
						if(k<to||j<to){ flag=1; break; }
						
					}
					else if(ww=2)
					{
						if(k<to&&j<to){ flag=1; break; }
						if(k>=to&&j>=to) ff3=1;
					}
					else
					{
						if(k>=to&&j>=to){ flag=1; break; }
						
					}
				}
				if(flag) continue;
				if(!ff1) dp[i][j][i]=(dp[i][j][i]+dp[i-1][j][k])%mod;
				if(!ff2) dp[i][i][k]=(dp[i][i][k]+dp[i-1][j][k])%mod;
				if(!ff3) dp[i][j][k]=(dp[i][j][k]+dp[i-1][j][k])%mod;
*/


Measured memory_bytes: 111232
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();

		Scanner sc = new Scanner(System.in);
		main.solve(sc);
		sc.close();
	}

	void solve(Scanner sc) {
		String s = sc.next();
		System.out.println(s.replaceAll(",", " "));

	}
}


Measured memory_bytes: 21588
#include<stdio.h>

int main(){
  long long a,b,n,ans;
  scanf("%lld%lld%lld",&a,&b,&n);
  if(n>=b){
    ans=(a*(b-1)-(a*(b-1))%b)/b;
  }else{ans=(a*n-(a*n)%b)/b;}
  printf("%lld",ans);
  return 0;
}


Measured memory_bytes: 1700
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

/*
 * 1 2 3 4 5
 * 1
 * 1 2
 * 2 1 3
 * 3 1 2 4
 * 4 2 1 3 5
 * 5 3 1 2 4
 * n % 2 == 0 I need all the even indexed elements to push front 
 */
int main() {
	int n;
	cin >> n;
	deque <int> dq;
	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		if (n % 2 == 0) {
			if (i % 2 == 1)
				dq.push_back(x);
			else
				dq.push_front(x);
		}
		else {
			if (i % 2 == 0)
				dq.push_back(x);
			else
				dq.push_front(x);
		}
	}
	while(!dq.empty()) {
		cout << dq.front() << " ";
		dq.pop_front();
	}
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
#define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
// #define space printf(" ")
#define endl '\n'
#define vi vector<int>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mp make_pair
#define F first
#define S second
#define pb(x) push_back(x)
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define sd(x) scanf("%d", &(x))
#define pd(x) printf("%d", (x))
#define pdn(x) printf("%d\n", (x))
#define slld(x) scanf("%lld", &(x))
#define plld(x) printf("%lld", (x))
#define plldn(x) printf("%lld\n", (x))
#define sllf(x) scanf("%llf", &(x))
#define pllf(x) printf("%.9llf", (x))
#define pllfn(x) printf("%.9llf\n", (x))
#define sch(x) scanf("%c", &(x))
#define pch(x) printf("%c", (x))
#define pchn(x) printf("%c\n", (x))
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0)
#define gcd __gcd
#define clr(x) memset(x,0,sizeof(x))
#define all(a) (a).begin(), (a).end()
#define foreach(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin);freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp()//true for a before b
{
	bool ans = 0;
	return ans;
}

struct ST_Node
{

	ST_Node()
	{
		return;
	}
	void assign_value_(int val)
	{
		return;
	}
	void merge_nodes_(ST_Node& left, ST_Node& right)
	{
		return;
	}
};

const int N = (1e5) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 50;

vll dig;
ll dp[20][2];

void compute(ll n)
{
	while(n > 0LL)
	{
		dig.pb(n%10LL);
		n /= 10LL;
	}
	reverse(all(dig));
	return;
}

ll func(int i, bool flag)
{
	if(i >= sz(dig))
		return 0LL;
	if(dp[i][flag] > 0LL)
		return dp[i][flag];
	ll ans = 0LL;
	if(flag)
		ans = 9LL + func(i+1,1);
	else if(dig[i] > 0)
		ans = max(dig[i] + func(i+1,0), dig[i]-1LL + func(i+1,1));
	else
		ans = dig[i] + func(i+1,0);
	dp[i][flag] = ans;
	return ans;
}

int main()
{
	sws;
	// clock_t clk;
	// clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	ll n, ans = 0LL;
	cin >> n;
	if(n < 10LL)
	{
		cout << n;
		return 0;
	}
	compute(n);
	ans = func(0,0);
	cout << ans;
	// Code ends here

	// clk = clock() - clk;
	// cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 

const ll INF = 2e9;
const ll large_P = 1e9 + 7;


int main(){
  ll N;
  cin >> N;
  
  ll res = 0;
    
  
  ll i = 2;
  ll j = 2;
  ll range = pow(N, 0.50) + 1;
  //cout << range << endl;
  while(range > i && N-1 > i){
    if((N)% i == 0 || (N-1)%i == 0){
      ll temp = N;
      while(temp%i == 0) temp /= i;
      temp %= i;
      
      if(temp == 1) {
        res++;
        //cout << i << endl;
      }
      
      temp = N;
      if((N)% i == 0) j = N/i;
      else j = (N-1)/i;
      while(temp%j == 0) temp /= j;
      temp %= j;
      
      if(temp == 1 && i*i != N && i*i != N-1 && j > i && j < N-1) {
        res++;
        //cout << i << endl;
      }
    }
    i++;
  }
  
  
  if(N != 2) res += 2; // K = N, N-1
  else res++; // K = N


  

  cout << res << endl;
}

Measured memory_bytes: 384
/* ChongQing 2017
 * author: chirurgien
*/
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

const int MOD = 1e8 + 7;
const int MAXN = 3e2 + 10;
const int MAXV = 1e3 + 10;

queue <int> que[MAXN];
int cnt[MAXN];
int vis[MAXN];
int main() {

    int n, m, res;
    scanf("%d%d", &n, &m);
    memset(vis, 0, sizeof vis);
    for(int i = 1; i <= n; i++)
        while(que[i].size()) que[i].pop();
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j < m; j++) {
            int x;
            scanf("%d", &x);
            que[i].push(x);
        }
    }
    for(int i = 1; i <= m; i++) {
        memset(cnt, 0, sizeof cnt);
        int count = 0;
        int people = que[1].front();
        for(int j = 1; j <= n; j++) {
            int pre = que[j].front();
            while(vis[pre]) {
                que[j].pop();
                pre = que[j].front();
            }
            cnt[pre]++;
            if(cnt[pre] > count) {
                count = cnt[pre];
                people = pre;
            }
        }
        vis[people] = 1;
        if(1 != i)
            res = min(res, count);
        else
            res = count;
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
#define VI vector<int>
#define VL vector<LL>
#define VII vector< vector<int> >
#define VLL vector< vector<LL> >
#define VS vector<string>
#define PII pair<int,int>
#define PIS pair<int,string>
#define PSI pair<string,int>
#define PLL pair<ll,ll>
LL facctorialMethod(int k);
int main(){
    LL n,ans;
    cin >> n;
    ans = 0;
    for(int i = 1; i <= n; i++) {
        if(!(i%3 == 0 || i%5 == 0)){
            ans += i;
//            cout << ans << endl;
        }
    }
    cout << ans << endl;

    return 0;
}

LL facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i){
        sum *= i;
    }
    return sum;
}


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

A.insert(0, 0)
A.append(K)

# print(A)

start = A[1] - A[0]
goal = A[-1] - A[-2]

mixi = 0
sum_len = 0

# SorG = max(start, goal)

SorG = start + goal

for i in range(len(A) - 1):
    if A[i+1] - A[i] > mixi:
        mixi = A[i+1] - A[i]
    sum_len += A[i+1] - A[i]

if max(SorG, mixi) == SorG or SorG == mixi:
    result = sum_len - (start + goal)
elif max(SorG, mixi) == mixi:
    result = sum_len - mixi

print(result)
    


Measured memory_bytes: 26444
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define REP(i, n) for(int i=0; i<n; i++)
#define RER(i, n) for(int i=n-1; i>=0; i--)
#define ALL(v) v.begin() v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int n, m;

signed main(){
    cin >> n >> m;
    cout << (n-1)*(m-1) << endl;
    return 0;
}

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

vector<int> G[100100];

int main()
{
    int n, m;
    cin >> n >> m;
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> dist(n, -1);
    vector<int> pre(n, -1);
    queue<int> que;
    dist[0] = 0;
    que.push(0);
    while (!que.empty())
    {
        int v = que.front();
        que.pop();
        for (int nv : G[v])
        {
            if (dist[nv] != -1)
                continue;
            dist[nv] = dist[v] + 1;
            pre[nv] = v;
            que.push(nv);
        }
    }
    cout << "Yes" << endl;
    rep(i, n) {
        if(i == 0) continue;
        int ans = pre[i];
        ans++;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 10736
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans, dp[3200][3200], a[210000], b[200000];
string str, ss;
bool f;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<LL>vec;
vector<edge>ed;
vector<LL>v;
map<LL,LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		ma[a[i]]++;
	}
	sort(a, a + n, [](LL x, LL y) {return x > y; });
	rep(i, n) {
		LL num = 0;
		if (ma[a[i]] == 0)continue;
		rep(j, 40)
			if (a[i] < ((LL)1 << j)) {
				num = ((LL)1 << j) - a[i];
				break;
			}

		if (a[i] == num) {
			if (ma[num] > 1) {
				ans += 1;
				ma[num] -= 2;
			}
		}
		else if (ma[num] > 0) {
			ans += 1;
			ma[num]--;
			ma[a[i]]--;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 27776
def count_characters(word, dic, kcs, kcs2, kcs2_1):
    prev1 = None
    i = 0
    l = len(word)
    while i < l:
        c = word[i]
        if c in kcs2_1 and i < l - 1:
            c2 = word[i + 1]
            if (c + c2) in kcs2:
                if prev1 != None:
                    dic[prev1][c + c2] += 1
                prev1 = c + c2
                i += 2
                continue
        if prev1 != None:
            dic[prev1][c] += 1
        prev1 = c
        i += 1

kcs = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
kcs2 = ["ld", "mb", "mp", "nc", "nd", "ng", "nt", "nw", "ps", "qu", "cw", "ts"]
kcs2_1 = ["l", "m", "n", "p", "q", "c", "t"]

n = int(input())
dic = {}
for c in (kcs + kcs2):
    table = {}
    for c1 in (kcs + kcs2):
        table[c1] = 0
    dic[c] = table

for i in range(n):
    words = input().split()
    for word in words:
        count_characters(word, dic, kcs, kcs2, kcs2_1)

for c in (kcs + kcs2):
    occurence_table = dic[c]
    max_c = "a"
    max_n = 0
    for k, v in occurence_table.items():
        if v > max_n:
            max_n = v
            max_c = k
    print(c, max_c, max_n)

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int x;
    cin >> x;

    cout << (1999 - x) / 200 + 1 << "\n";

    return 0;
}


Measured memory_bytes: 3596