akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,b,a) for(i=b-1;i>=(ll)a;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

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

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  if(n<r)return 0;
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  // startupcpp();
  // int codeforces;cin>>codeforces;while(codeforces--){
  ll i,j,N,H,W,ans;
  string s;
  vec v(3);
  rep(i,3)cin>>v[i];
  swap(v[0],v[1]);
  swap(v[0],v[2]);
  output(v);
  return 0;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
a = list(map(int, input().split()))

if len(set(a)) == 1 and a[0] == 0:
    print('Yes')
elif N % 3 == 0:
    l = [*Counter(a).values()]
    res = 0
    for s in set(a):
        res ^= s
    if len(l) == 3 and res == 0 and len(set(l)) == 1:
        print('Yes')
    elif len(l) == 2 and a.count(0) == N//3:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 20916
#include <iostream>
#include <cstdio>
#include <utility>
#include <vector>
using namespace std;

int main(){
  double xp1,yp1,xp2,yp2;
  cin >> xp1 >> yp1 >> xp2 >> yp2;
  pair<double,double> p1 = make_pair(xp1,yp1);
  pair<double,double> p2 = make_pair(xp2,yp2);

  pair<double,double> a = make_pair(xp1-xp2,yp1-yp2);

  int q; cin >> q;
  vector<pair<double,double>> query;

  for(int i = 0;i < q;i++){
    double xp,yp; cin >> xp >> yp;
    pair<double,double> p = make_pair(xp,yp);
    pair<double,double> b = make_pair(xp-xp1,yp-yp1);
    //正射影ベクトルはa(b,a)/(a,a)になる.
    double dot_ab = a.first * b.first + a.second * b.second;
    double dot_aa = a.first * a.first + a.second * a.second;
    pair<double,double> prj = make_pair(a.first*dot_ab/dot_aa,a.second*dot_ab/dot_aa);

    pair<double,double> ans = make_pair(p1.first + prj.first, p1.second + prj.second);
    query.push_back(ans);
  }

  for(int i = 0;i < q;i++){
    printf("%.14lf %.14lf\n",query[i].first,query[i].second);
  }
}



Measured memory_bytes: 3308
#include<stdio.h>


int main() {
    //変数の宣言
    int hako;
    int n, i, min = 10000000, max = -10000000;
    long long total=0;
    
    //入力
    scanf("%d", &n);
    for (i=0; i<n; i++) {
        scanf("%d", &hako);
        
        total += hako;
        
        if (min > hako) {
            min = hako;
        }
        
        if (max < hako) {
            max = hako;
        }
        
    }
    
    
    
    //出力
    printf("%d %d %lld\n", min, max, total);
    
    return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	long long sum=0;
	cin >> n;
	for(int i=1;i<=n;i++){
		if(i%3!=0&&i%5!=0){
			sum+=i;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define ll long long
const int MOD = 1e9+7;
using namespace std;

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



Measured memory_bytes: 256
N,M=map(int,input().split())
H=list(map(int,input().split()))
Loser=[]
for i in range(M):
  A,B=map(int,input().split())
  Low = A if H[A-1]< H[B-1] else B
  if H[A-1] != H[B-1] and not(Low in Loser):
    Loser.append(Low)
  elif H[A-1] == H[B-1]:
    if not(A in Loser):
      Loser.append(A)
    if not(B in Loser):
      Loser.append(B)  
print(N-len(Loser))      


Measured memory_bytes: 84860
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mat = lambda x, y, v: [[v]*y for _ in range(x)]
ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)]
mod = 1000000007
sys.setrecursionlimit(1000000)

class PowMod:
	def __init__(self, N, base=[2]):
		self.mem = {}
		for b in base:
			pows = [1]
			for i in range(1, N+1):
				pows.append(pows[-1]*b % mod)
			self.mem[b] = pows

	def pow(self, b, n):
		return self.mem[b][n]

N = ri()

pm = PowMod(N, base=[8,9,10])
ans = pm.pow(10, N) - pm.pow(9, N)*2 + pm.pow(8, N)
#print(pm.pow(10, N), pm.pow(9, N), pm.pow(8, N))
print(ans % mod)


Measured memory_bytes: 167236
#include<stdio.h>
int main()
{
    int N,a[4][4],i,j;
    for(i=1;i<=3;i++)
    {
        for(j=1;j<=3;j++)
        {
            scanf("%d",&a[i][j]);
        }
    }
    if(a[1][1]+a[2][2]==a[1][2]+a[2][1]&&a[1][2]+a[2][3]==a[2][2]+a[1][3]&&a[2][1]+a[3][2]==a[3][1]+a[2][2]&&a[2][2]+a[3][3]==a[3][2]+a[2][3])
    {
        printf("Yes\n");
    }
    else
        printf("No\n");
}



Measured memory_bytes: 128
#include <sstream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cassert>
#include <ctime>
#include <map>
#include <math.h>
#include <cstdio>
#include <set>
#include <deque>
#include <memory.h>
#include <queue>

#pragma comment(linker, "/STACK:64000000")
typedef long long ll;

using namespace std;

const int MAXN = 1 << 18;
const int MOD = 1000 * 1000 * 1000 + 7;
const int INF = 2e9;
const double PI = acos(-1.0);

int main() {
#ifdef _MSC_VER
	freopen("input.txt", "r", stdin);
#endif

	int n;
	while (cin >> n) {
		vector<int> a(n);
		for (int i = 0; i < n; i++) cin >> a[i];

		int cur = 0;
		int ans = 1;
		for (int i = 0; i < n; i++) {
			if (a[i] < (i - cur) * 2 + 1) {
				ans = 1LL * ans * (i - cur + 1) % MOD;
				cur++;
			}
			else {
				continue;
			}
		}
		while (cur < n) ans = 1LL * ans * (n - cur++) % MOD;
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(998244353)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
ll prime[1000005];
ll phi[1000005];
vector<ll>p;
void sieve(int n){
	prime[1] = 1;
	for(int i=2;i<=n;i++){
		if(prime[i] == 0){
			prime[i] = i;
			p.pb(i);
		}
	      for(int j=0;j<(int)(p.size()) && p[j] <= prime[i] && i*p[j] <= n;j++){
		   prime[i*p[j]] = p[j];
	      }
    }
}
int main()
{
	int n;
	cin>>n;
	ll ans = 0;
	sieve(n);
	for(int i=1;i<n;i++){
		ll num = 1;
		int j = i;
		while(j != 1){
			ll cnt = 0;
			int p = prime[j];
			while(j%p == 0){
				j/=p;
				cnt++;
			}
			num*=(cnt+1);
		}
		ans+=num;
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 12032
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, n) for (int i = 0; i < n; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void)
{
  long double a, b, x;
  scanf("%Lf %Lf %Lf", &a, &b, &x);

  long double y = (2.0 * x) / (a * b);
  if (y > a)
  {
    y = a;
    b = 2.0 * b - (2.0 * x) / (a * a);
  }
  long double tan = b / y;
  printf("%.10Lf\n", atanl(tan) * 180.0 / M_PI);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>

using namespace std;

int main() {
	int H, W;
	while (true) {
		cin >> H >> W;
		if (H == 0 && W == 0) break;
		for (int i = 1; i <= H; ++i) {
			for (int j = 1; j <= W; ++j) {
				     if (i % 2 == 1 && j % 2 == 1) cout << "#";
				else if (i % 2 == 1 && j % 2 == 0) cout << ".";
				else if (i % 2 == 0 && j % 2 == 1) cout << ".";
				else if (i % 2 == 0 && j % 2 == 0) cout << "#";
			}
			cout << "\n";
		}
		cout << endl;
	}
}


Measured memory_bytes: 3080
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]

D.sort(key=lambda d: d[2], reverse=True)
for cx in range(100+1):
    for cy in range(100+1):
        f = True
        for i, (x, y, h) in enumerate(D):
            if i == 0:
                ch0 = h + abs(x - cx) + abs(y - cy)
            else:
                ch = h + abs(x - cx) + abs(y - cy)
                if h != 0 and ch0 != ch:
                    f = False
                if h == 0 and ch0 > ch:
                    f = False
        if f:
            print(cx, cy, ch0)
            exit(0)


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

#define INF 1<<30
#define MAX_V 100010

// graph by adjacency list
struct Edge {
  int dst, weight;
  Edge(int dst, int weight) :
    dst(dst), weight(weight) { }
  bool operator < (const Edge &e) const {
    return weight > e.weight;
  }
};

struct Graph {
  int V;
  std::vector<Edge> E[MAX_V];

  Graph(int V) : V(V) { }

  void add_edge(int src, int dst, int weight) {
    E[src].push_back(Edge(dst, weight));
  }
};

struct Node {
  int v, dist;
  Node(int v, int dist) :
    v(v), dist(dist) { };
  bool operator < (const Node &n) const {
    return dist > n.dist; // reverse
  }
};

struct ShortestPath {
  const Graph g;
  int start;
  int dist[MAX_V], prev[MAX_V];

  ShortestPath(const Graph g, int start) :
    g(g), start(start) { }

  void dijkstra() {
    std::priority_queue<Node> que;
    std::fill(dist, dist + g.V, INF);
    dist[start] = 0;
    que.push(Node(start, 0));
    prev[0] = -1;

    while (!que.empty()) {
      Node n = que.top(); que.pop();
      int v = n.v, cost = n.dist;
      if (dist[v] < cost) continue;
      for (Edge e : g.E[v]) {
	if (dist[v] + e.weight < dist[e.dst]) {
	  dist[e.dst] = dist[v] + e.weight;
	  prev[e.dst] = v;
	  que.push(Node(e.dst, dist[e.dst]));
	}
      }
    }
  }

  std::vector<int> build_path(int goal) {
    std::vector<int> path;
    for (int v = goal; v != -1; v = prev[v]) {
      path.push_back(v);
    }
    std::reverse(path.begin(), path.end());
    return path;
  }
};

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int V, E, start;
  cin >> V >> E >> start;
  Graph g(V);
  REP(i, E) {
    int src, dst, weight;
    cin >> src >> dst >> weight;
    g.add_edge(src, dst, weight);
  }

  ShortestPath sp(g, start);
  sp.dijkstra();
  REP(i, V) {
    if (sp.dist[i] == INF) {
      cout << "INF" << endl;
    } else {
      cout << sp.dist[i] << endl;
    }
  }
  return 0;
}

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

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

    if (a < b && b < c) {
        cout << "Yes"
             << "\n";
    } else {
        cout << "No"
             << "\n";
    }
    return 0;
}



Measured memory_bytes: 3032
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

template <class T> T gcd(T x, T y) {
    // 最小公倍数を求める
    if (y == 0)
        return x;
    gcd(y, x % y);
}

template <class T> T lcm(T x, T y) {
    // 最大公約数を求める
    T GCD = gcd(x, y);
    T ans = x / GCD * y;
    return ans;
}

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

    int N, M;
    cin >> N >> M;
    string s, t;
    cin >> s >> t;
    ll L    = lcm<ll>(N, M);
    auto no = []() {
        print("-1");
        exit(0);
    };
    map<ll, ll> sm, tm;
    REP(i, N) { sm[i * L / N + 1] = i; }
    REP(i, M) { tm[i * L / M + 1] = i; }
    vector<pair<int, int>> v;
    for (auto &&i : sm) {
        if (tm.count(i.first)) {
            v.emplace_back(i.second, tm[i.first]);
        }
    }
    for (auto &&i : v) {
        if (s[i.first] != t[i.second])
            no();
    }

    print(L);

    return 0;
}

Measured memory_bytes: 10880
package main
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)
var sc *bufio.Scanner
func nextStr() string {
    sc.Scan()
    return sc.Text()
}
func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}
func gcd(a, b int) int {
    if a < b {
        a, b = b, a
    }
    if a%b == 0 {
        return b
    }
    return gcd(b, a%b)
}
func main() {
    sc = bufio.NewScanner(os.Stdin)
    sc.Buffer(make([]byte, 0), 1000000001*3)
    sc.Split(bufio.ScanWords)
    a, b := nextInt(), nextInt()
    gcd := gcd(a, b)
    ans := 1
    gcdCopy := gcd
    for d := 2; d*d <= gcd; d++ {
        if gcdCopy%d != 0 {
            continue
        }
        ans++
        for gcdCopy%d == 0 {
            gcdCopy /= d
        }
    }
    if gcdCopy > 1 {
        ans++
    }
    fmt.Println(ans)
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main()
{
    string s;
    cin >> s;

    for(int i=0;i<4;i++)
    {
        if(s[i] == s[i+1])
        {
            cout <<"Bad"<< endl;
            return 0;
        }
    }

    cout <<"Good"<< endl;
    return 0;


    

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<iomanip>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>

#define int long long

using namespace std;

const int INF = 1e17 + 7;

void solve() {
    int n, m, k;
    cin >> n >> m >> k;
    set<pair<int, int>> s;
    map<int, int> c, r;
    map<int, vector<int>> ch;
    for (int i = 0; i < k; ++i) {
        pair<int, int> t;
        cin >> t.first >> t.second;
        ++c[t.first];
        ++r[t.second];
        ch[t.second].push_back(t.first);
        s.insert(t);
    }
    for (auto& t : ch)
        sort(t.second.begin(), t.second.end());
    vector<int> a, b;
    int mx = 0, ans = 0;
    for (auto t : r) mx = max(mx, t.second);
    for (auto t : r) if (t.second == mx) a.push_back(t.first);
    ans += mx;
    mx = 0;
    for (auto t : c) mx = max(mx, t.second);
    for (auto t : c) if (t.second == mx) b.push_back(t.first);
    ans += mx;
    for (auto x : a) {
        int cnt = 0, it = 0;
        for (int i = 0; i < ch[x].size(); ++i) {
            while (it < b.size() && b[it] < ch[x][i]) ++it;
            if (it == b.size()) break;
            if (ch[x][i] == b[it]) ++cnt;
        }
        if (cnt < b.size()) {
            cout << ans;
            return;
        }
    }
    cout << ans - 1;
}

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

    int t = 1;
    //cin >> t;
    while (t--) solve();

    return 0;
}

Measured memory_bytes: 100208
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int (*rd)()=read<int>;
//const u32 P=;
//inline u32 &inc(u32 &a, u32 b) {return (a+=b)<P?a:(a-=P);}
//inline u32 &dec(u32 &a, u32 b) {return (a-=b)&0x80000000?(a+=P):a;}
//inline u32 sum(u32 a, u32 b) {return (a+=b)<P?a:a-P;}
//inline u32 dif(u32 a, u32 b) {return (a-=b)&0x80000000?a+P:a;}
//u64 power(u64 a, int b) {
//	u64 ans=1;
//	for(; b; a=a*a%P, b/=2) if(b&1) ans=ans*a%P;
//	return ans;
//}

int g[64];
int solve_min(s64 n) {
	if(n==1) return 0;
	int k=0;
	while((1llu<<k)-g[k]<n) ++k;
	return k;
}
void gg() {
	puts("-1");
	exit(0);
}
int n, k, c[13], ans;
bool eq;
void dfs(int id, int least) {
	if(id==n) {
		int hub[5];
		for(int i=0; i<k; ++i) hub[i]=i;
		while(std::next_permutation(hub, hub+k)) {
			int s[13]={};
			for(int i=0; i<n; ++i) {
				for(int j=0; j<k; ++j) s[i]|=(c[i]>>j&1)<<hub[j];
			}
			if(memcmp(s, c, n*sizeof(int))) {
				std::sort(s, s+n);
				if(memcmp(s, c, n*sizeof(int))<=0) return;
			} else if(!eq) return;
		}
		if(ans==1000) gg();
		++ans;
		return;
	}
	int &x=c[id];
	for(; least<=(1<<k)-n+id; ++least) {
		c[id]=least;
		dfs(id+1, least+1);
	}
}
int main() {
	for(int i=2; i<64; ++i) g[i]=solve_min(i);
	s64 m=read<s64>();
	k=solve_min(m);
	eq = 1llu<<(k-1)>=m;
	while(k!=0 && (m<k || m>1llu<<(k-1))) {
		if(m<k) {
			n=m;
			m=k;
			k=n;
		}
		if(m>1llu<<(k-1))
			m=(1llu<<k)-m;
	}
	if(k>=6 || (k==5&&m>=14)) gg();
	n=m;
	dfs(0, 0);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3764
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
using namespace std;

int main(){
	int a,b,k;
	cin >> a >> b >> k;
	for(int i=0;i<k;i++){
		if(a+i>b)
			break;
		cout << a+i << "\n";
	}
	if(b-a>=k){
		for(int i=k;i>0;i--){
			if(b-i+1>=a+k)
				cout << b-i+1 << "\n";
			}
	}
	return 0;
}


Measured memory_bytes: 256
def main():
    from itertools import accumulate as ac
    from bisect import bisect_left as bl
    n, m, k = map(int, input().split())
    a = [0]+list(map(int, input().split()))
    b = [0]+list(map(int, input().split()))
    aa = list(ac(a))
    bb = list(ac(b))
    ans = 0
    for i in range(n+1):
        if aa[i] > k:
            break
        ans = max(ans, i+bl(bb, k-aa[i]+0.1)-1)
    print(ans)


main()


Measured memory_bytes: 129664
n=int(input())
s = 0
a = 0
b = 0
for i in range(n):
    t,x,y=map(int,input().split())
    if t-s - abs(x-a) - abs(y-b)>=0 and (t-s - abs(x-a) - abs(y-b)) %2 == 0:
        s = t
        a = x
        b = y
    else:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 8952
#include<iostream>
#include<string.h>
#include<queue>
#include<map>
#include<vector>
#include <cstdlib>
#include<algorithm>
#include <cstdio>
#include <cctype>
using namespace std;
const long long INF=10000000000000LL;
typedef long long ll;
typedef pair<ll,ll> P;
ll N,M,K=1;
ll T,a,b;
ll A[55],B[55],C[55],D[55],Q,l,r;
ll ans;
//bool D[100005];
ll S[100005]={};
string str;
map<string,int> m;

int main(){
	cin>>N>>M;
	for(int i=0;i<N;++i){
		cin>>A[i]>>B[i];
	}
	for(int i=0;i<M;++i){
		cin>>C[i]>>D[i];
	}
	for(int i=0;i<N;++i){
		ans=INF;
		T=INF;
		for(int j=0;j<M;++j){
			if(labs(A[i]-C[j])+labs(B[i]-D[j])<T){
				ans=j;
				T=labs(A[i]-C[j])+labs(B[i]-D[j]);
			}

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


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

const double EPS = 1e-8;

int dcmp(double d) {
    if (fabs(d) < EPS) {
        return 0;
    }
    return d < 0? -1 : 1;
}

struct Vector {
    double x, y;
    Vector(double x=0, double y=0): x(x), y(y){
    }
};

typedef Vector Point;

double dot(const Vector& a, const Vector& b) {
    return a.x * b.x + a.y * b.y;
}

double cross(const Vector& a, const Vector& b) {
    return a.x * b.y - a.y * b.x;
}

Vector operator-(const Vector& a, const Vector& b) {
    return Vector(a.x - b.x, a.y - b.y);
}

bool intersectProp(const Point& a1, const Point& a2, const Point& b1, const Point& b2) {
    double c1 = cross(a2 - a1, b1 - a1);
    double c2 = cross(a2 - a1, b2 - a1);
    double c3 = cross(b2 - b1, a1 - b1);
    double c4 = cross(b2 - b1, a2 - b1);
    
    return dcmp(c1 * c2) == -1 && dcmp(c3 * c4) == -1;
}

bool onSegment(const Point& a, const Point& b, const Point& p) {
    Vector pa = a - p;
    Vector pb = b - p;
    return dcmp(cross(pa, pb)) == 0 && dcmp(dot(pa, pb)) <= 0;
}

bool intersect(const Point& a1, const Point& a2, const Point& b1, const Point& b2) {
    return intersectProp(a1, a2, b1, b2) || onSegment(a1, a2, b1) 
            || onSegment(a1, a2, b2) || onSegment(b1, b2, a1) || onSegment(b1, b2, a2);
}

int main() {
    Point points[4];
    int q;
    cin >> q;
    for (int kase = 0; kase < q; kase++) {
        for (int i = 0; i < 4; i++) {
            cin >> points[i].x >> points[i].y;
        }
        Vector v1 = points[1] - points[0];
        Vector v2 = points[3] - points[2];

        int ans =  intersect(points[0], points[1], points[2], points[3])? 1 : 0;
        
        cout << ans << endl;
    }
   
    return 0;
}

Measured memory_bytes: 3192
N = int(input())
lst = []
lst_2 = []
input_ = input().split()
for i in range(N):
	lst.append(int(input_[i]))
lst_s = sorted(lst)
for i in range(N):
  if lst[i] != lst_s[i]:
    lst_2.append(i)
if len(lst_2) <= 2:
	print("YES")
else:
	print("NO")

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
using namespace std;

#define N 1000005

int ans=N;
int n1,n2,a[N],b[N],m;

inline int read(){
	int s=0,t=1;
	char c=getchar();
	while((c<'0'||c>'9')&&c!='-')c=getchar();
	if(c=='-')c=getchar(),t=-1;
	while(c>='0'&&c<='9')s=(s<<1)+(s<<3)+(c^48),c=getchar();
	return s*t;
}

int main(void){
	n1=read();
	n2=read();
	m=read();
	for(int i=1;i<=n1;i++)
	a[i]=read();
	for(int i=1;i<=n2;i++)
	b[i]=read();
	for(int i=1;i<=n1;i++)
	ans=min(ans,a[i]); 
	int s=ans;
	ans=ans+b[1];
	for(int i=1;i<=n2;i++)
	ans=min(ans,s+b[i]);
	for(int i=1;i<=m;i++){
		int x,y,c;
		x=read();
		y=read();
		c=read();
		ans=min(ans,a[x]+b[y]-c);
	}
	printf("%d\n",ans);
}

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

int main() {
	int a, b, c, x, cnt = 0;
	cin >> a >> b >> c >> x;
	rep(i, a + 1) {
		rep(j, b + 1) {
			rep(k, c + 1) {
				if (500 * i + 100 * j + 50 * k == x) cnt++;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll z=1000000007;
ll dp[100005];

int main()
{
  IOS;
  ll t=1;
//  cin>>t;
  for(ll i=0;i<100005;i++)
  {
    dp[i]=z;
  }
  dp[0]=0;
  while(t--)
  {
    ll i,l,p,j,ans=0,n,k;
    cin>>n>>k;
    ll a[n];
    for(i=0;i<n;i++)
    {
      cin>>a[i];
    }
    for(i=0;i<n;i++)
    {
      for(j=i+1;j<=i+k;j++)
      {
        if(j<n)
        dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));
      }
    }

    cout<<dp[n-1]<<"\n";

  }

    return 0;
}


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

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

  vector<int> a(n);
  for (auto&& e : a)
    cin >> e;

  vector<int64_t> c(n + 1);
  for (const auto& e : a)
    c[e]++;

  int64_t ans = 0;
  for (const auto& e : c)
    ans += e * (e - 1) / 2;

  for (const auto& e : a)
    cout << ans - (c[e] - 1) << endl;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
  ll res = 1;
  while(b){
    if(b&1)res = res * x % MOD;
    x = x * x % MOD;
    b>>=1;
  }
  return res;
}

ll modinv(ll x){
  return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
  if(was_output)cout << " ";
  cout << a;
  was_output = true;
}
void outendl(){
  was_output = false;
  cout << endl;
}
ll in(){
  ll res;
  scanf("%lld", &res);
  return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
  for(auto &i:x)is >> i;
  return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
  is >> x.first >> x.second;
  return is;
}

template<class t>
void in(t&x){
  cin >> x;
}

template<class t>
void out(t x){
  cout << x;
}

int main(){
  int ans = 0;
  rep(i,4){
    char d;
    in(d);
    if(d=='+')++ans;
    else --ans;
  }
  cout << ans << 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 P = pair<int, int>;
using namespace std;

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int N;
    cin >> N;
    vector<P> p(N);
    rep(i, N) {
        cin >> p[i].first >> p[i].second;
    }
    sort(p.begin(), p.end());
    cout << p[p.size()-1].first+p[p.size()-1].second << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int main(){

    ll x, num_500, num_5;

    cin >> x;

        num_500 = x/500;
        x = x - 500 * num_500;
        num_5 = x / 5;

    cout << num_500 * 1000 + num_5 * 5;

    return 0;
}

Measured memory_bytes: 256
//by Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<s32>
#define p32 pair<int,int>
#define p64 pair<ll,ll>
#define fi first
#define se second
#define ln '\n'
#define debug(x) cout << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream& operator<<(ostream& out, const pair<T,U>& p){
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename ...Args>
void print_container(const ContainerType<ValueType, Args...>& c){
	cout << "{ ";
	for(const auto& v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

int main()
{
	FASTIO;
	ll n;
	cin >> n;
	ll ans = ((n - 1) * n) / 2;
	cout << ans << ln;
	return 0;
}


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

using namespace std;

int main()
{
  uint64_t H, W;
  cin >> H >> W;
  
  vector<string> S(H);
  for (uint64_t y = 0; y < H; ++y) { cin >> S[y]; }
  
  vector<vector<int64_t>> left_x(H), right_x(H);
  for (uint64_t y = 0; y < H; ++y) {
    left_x[y] = vector<int64_t>(W, 0);
    for (int64_t x = 0; x < W; ++x) {
      if (S[y][x] == '#') {
         left_x[y][x] = x + 1;
      } else {
         left_x[y][x] = x > 0 ?  left_x[y][x - 1] : 0;
      }
    }
    
    right_x[y] = vector<int64_t>(W, W - 1);
    for (int64_t x = W - 1; x >= 0; --x) {
      if (S[y][x] == '#') {
         right_x[y][x] = x - 1;
      } else {
         right_x[y][x] = x < W - 1 ?  right_x[y][x + 1] : W - 1;
      }
    }
  }
  
  vector<vector<int64_t>> up_y(W), down_y(W);
  for (uint64_t x = 0; x < W; ++x) {
    up_y[x] = vector<int64_t>(H, 0);
    for (int64_t y = 0; y < H; ++y) {
      if (S[y][x] == '#') {
        up_y[x][y] = y + 1;
      } else {
        up_y[x][y] = y > 0 ?  up_y[x][y - 1] : 0;
      }
    }
    
    down_y[x] = vector<int64_t>(H, H - 1);
    for (int64_t y = H - 1; y >= 0; --y) {
      if (S[y][x] == '#') {
        down_y[x][y] = y - 1;
      } else {
        down_y[x][y] = y < H - 1 ?  down_y[x][y + 1] : H - 1;
      }
    }
  }
  
  uint64_t max_lighting = 0;
  for (uint64_t y = 0; y < H; ++y) {
    for (uint64_t x = 0; x < W; ++x) {
      if (S[y][x] == '.') {
        if (left_x[y][x] < 0 || up_y[x][y] < 0 || right_x[y][x] >= W || down_y[x][y] >= H) { continue; }
        uint64_t lighting = (right_x[y][x] - left_x[y][x]) + (down_y[x][y] - up_y[x][y]) + 1;
        max_lighting = max(max_lighting, lighting);
      }
    }
  }
  cout << max_lighting << endl;
  
  return 0;
}

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

int main() {
  int K;
  string S;
  cin >> K;
  cin >> S;

  if(S.size()<=K){
    cout << S << endl;
  }else{
    for(int i=0;i<K; i++){
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mk make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    std::cin >> n;
    int t=0,h=0;
    rep(i,n){
        string a,b;
        std::cin >> a>>b;
        if(a>b)t+=3;
        if(a==b)t+=1;
        if(a==b)h+=1;
        if(a<b)h+=3;
        
    }
    std::cout << t<<' '<<h << std::endl;
}


Measured memory_bytes: 3180
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    double a,b;
    cin >> a >> b;
    int ans = (a+b)/2;
    if((a+b)/2-ans>0)
    {
        cout << ans + 1 << endl;
    }
    else
    {
        cout << ans << endl;
    }
}


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

int main(){
  int A,B,K;
  cin>>A>>B>>K;
  set<int> C;
  for(int i=A;i<A+K&&i<=B;i++)
    C.insert(i);
  for(int i=B;i>B-K&&i>=A;i--)
    C.insert(i);
  for(int i:C)
    cout<<i<<endl;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

#     13
#   12  11
# 13  06  13
#   05  04
# 10  03  09
#   02  01
# 13  00  13
#   08  07
#     13

def main():
    rr = []

    tt = [
            [13, 7, 8, 0, 1, 2, 3],
            [7, 13, 0, 1, 9, 3, 4],
            [8, 0, 13, 2, 3, 10, 5],
            [0, 1, 2, 3, 4, 5, 6],
            [1, 9, 3, 4, 13, 6, 11],
            [2, 3, 10, 5, 6, 13, 12],
            [3, 4, 5, 6, 11, 12, 13]
    ]

    while True:
        s = S()
        if s == '#':
            break

        fil = [int(c) for c in s]
        i2 = [2**i for i in range(128)]
        f3 = {}
        for k in range(3**7):
            a = []
            kk = k
            for _ in range(7):
                a.append(k%3)
                k //= 3
            if 2 in a:
                continue
            a.reverse()
            e = 0
            for c in a:
                e *= 2
                e += c
            f3[kk] = fil[e]

        for k in range(3**7):
            a = []
            kk = k
            for _ in range(7):
                a.append(k%3)
                k //= 3
            if 2 not in a:
                continue
            a.reverse()
            ki = a.index(2)
            e = 0
            y = 0
            for i in range(7):
                e *= 3
                y *= 3
                if i == ki:
                    y += 1
                else:
                    e += a[i]
                    y += a[i]

            fe = f3[e]
            fy = f3[y]
            if fe == fy:
                f3[kk] = fe
            else:
                f3[kk] = 2

        f = True
        for k in range(2**13):
            ba = [1 if i2[i] & k else 0 for i in range(13)] + [2]
            ca = []
            for i in range(7):
                ti = tt[i]
                e = 0
                for c in ti:
                    e *= 3
                    e += ba[c]
                ca.append(f3[e])
            y = 0
            for c in ca:
                y *= 3
                y += c
            if ca[3] != f3[y]:
                f = False
                break

        if f:
            rr.append('yes')
        else:
            rr.append('no')

    return '\n'.join(rr)




print(main())



Measured memory_bytes: 9216
program ccc
implicit none

integer :: n, m, i
integer,allocatable,dimension(:) :: x, y
integer,dimension(1) :: v

read*, n, m
allocate(x(m))
allocate(y(m-1))
read*, x

if(m==1.or.n>=m) then
write(*,'(i0)') 0
return
end if

call heapsort(m,x)
do i=1,m-1
y(i)=abs(x(i)-x(i+1))
end do

call heapsort(m-1,y)
do i=m-1,m-1-(n-2),-1
y(i)=0
end do

write(*,'(i0)') sum(y)

end program

subroutine heapsort(n,array)
  implicit none
  integer,intent(in) :: n
  integer,intent(inout) :: array(1:n)
 
  integer ::i,k,j,l
  integer :: t
 
  if(n.le.0)then
     write(6,*)"Error, at heapsort"; stop
  endif
  if(n.eq.1)return

  l=n/2+1
  k=n
  do while(k.ne.1)
     if(l.gt.1)then
        l=l-1
        t=array(L)
     else
        t=array(k)
        array(k)=array(1)
        k=k-1
        if(k.eq.1) then
           array(1)=t
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j.le.k)
        if(j.lt.k)then
           if(array(j).lt.array(j+1))j=j+1
        endif
        if (t.lt.array(j))then
           array(i)=array(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
  enddo

  return
end subroutine heapsort

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

using namespace std;

using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;
constexpr ll mo2 = 998244353;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n,m;
    cin>>n>>m;
    vector<int> v(n);
    int sum = 0;
    for(auto &a : v) cin>>a,sum+=a;
    int count = 0;
    for(int i=0;i<n;++i){
        if(4*m*v[i] >= sum)count++;
    }
    if(m <= count)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    vector<vector<int>> dp(n + 1, vector<int>(m + 1));
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (s[i - 1] == t[j - 1])
                dp[i][j] = dp[i - 1][j - 1] + 1;
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    string lcs;
    int i = n, j = m;
    while (i > 0 && j > 0) {
        if (s[i - 1] == t[j - 1])
            lcs += s[i - 1], i--, j--;
        else if (dp[i][j - 1] > dp[i - 1][j]) 
            j--;
        else 
            i--;
    }
    reverse(lcs.begin(), lcs.end());
    cout << lcs;
    return 0;
} 

Measured memory_bytes: 38580
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
    int n;
    ll ans=0LL;
    cin >>n;
    for(int i=0;i<=n;i++){
        if(i%3 and i%5 ){
            ans+=i;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

struct Task {
	int64_t d;
	int64_t l;
	int64_t p;
};

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

	int n, m; cin >> n >> m;
	vector<Task> tasks(n);
	for (auto & task : tasks) {
		cin >> task.d >> task.p;
		task.l = m - task.d;
	}

	sort(tasks.begin(), tasks.end(), [](const auto& rhs, const auto& lhs) {
		return rhs.l > lhs.l;
		});

	priority_queue<Task, vector<Task>, function<bool(const Task&, const Task&)>>
		cand([](const auto& lhs, const auto& rhs) { return lhs.p < rhs.p; });

	int64_t sum = 0;
	auto it = tasks.begin();
	FOR_DW(d, m, 0) {
		while (it != tasks.end() && it->l == d) {
			cand.push(*it);
			it++;
		}
		if (!cand.empty()) {
			sum += cand.top().p;
			cand.pop();
		}
	}

	cout << sum << endl;

	

	return 0;
}

Measured memory_bytes: 7156
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;

struct mint {
    ll x;
    mint(ll x=0):x(x%mod){}

    mint& operator+=(const mint a) {
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint& operator-=(const mint a) {
        if((x -= mod-a.x) >= mod) x -= mod;
        return *this;
    }

    mint& operator*=(const mint a) {
        x = (x * a.x) % mod;
        return *this;
    }

    mint& operator/=(const mint a) {
        *this *= a.inv();
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }

    mint pow(ll n) const {
        mint a(*this);
        mint res = 1;
        while (n > 0) {
            if (n & 1) res *= a;
            a *= a;
            n >>= 1;
        }
        return res;
    }

    mint inv() const {
        return pow(mod - 2);
    }
};

mint dp[100005][4];

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

  long n;
  cin >> n;

  long res = 0;
  vector<long> ainv(n+1);
  rep (i, n) {
    long x;
    cin >> x;
    ainv[x] = i;
  }

  set<long> c;
  c.insert(n);
  c.insert(-1);
  rep(i, n) {
    int x = i+1;
    auto it = c.lower_bound(ainv[x]);
    long r = *it;
    it--;
    long l = *it;
    res += (r-ainv[x]) * (ainv[x] - l) * x;
    c.insert(ainv[x]);
  }

  cout << res << endl;
}

Measured memory_bytes: 14968
// ABC_154_A

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
	string s, t;
	cin >> s >> t;

	int a, b;
	cin >> a >> b;

	string u;
	cin >> u;

	int ans = s.compare(u);
	if(ans) cout << a << " " << b - 1 << "\n";
	else cout << a - 1  << " " << b << "\n";

	return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
	static void Main()
	{
		string[] D1 = Console.ReadLine().Split(' ');
		int n = int.Parse(D1[0]), m = int.Parse(D1[1]);
		string[] D2 = new string[n];
		int[] D3 = new int[m];
		for (int i = 0; i < n; i++)
		{
			D2[i] = Console.ReadLine();
		}
		for (int i = 0; i < m; i++)
		{
			D3[i] = int.Parse(Console.ReadLine());
		}
		for (int i = 0; i < n; i++)
		{
			int DO = 0;
			string[] D4 = D2[i].Split(' ');
			for (int j = 0; j < m; j++)
			{
				DO += D3[j] * int.Parse(D4[j]);
			}
			Console.WriteLine(DO);
		}
	}
}

Measured memory_bytes: 17876