akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}


int d;
string s;
ll dp[10010][2][200];

signed main() {

    cin >> s >> d;
    int n = s.size();
    dp[0][0][0] = 1;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < d; j++) {
            
            for(int k = 0; k < 10; k++) {
                int t = j + k;
                dp[i+1][1][t%d] += dp[i][1][j];
                dp[i+1][1][t%d] %= SMOD;
            }
            for(int k = 0; k < s[i]-'0'; k++) {
                int t = j + k;
                dp[i+1][1][t%d] += dp[i][0][j];
                dp[i+1][1][t%d] %= SMOD;
            }
            dp[i+1][0][(j+s[i]-'0')%d] += dp[i][0][j];
            dp[i+1][0][(j+s[i]-'0')%d] %= SMOD;
            
        }
    }

    cout << (dp[n][0][0]+dp[n][1][0]-1+SMOD)%SMOD << endl;
  
    return 0;
}



Measured memory_bytes: 31488
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cstdlib>

using namespace std;

int arr[5];

int main()
{
	for(int a=0;a<5;a++)
	{
		scanf("%d",&arr[a]);
	}
	sort(arr,arr+5);
	for(int a=4;a>=0;a--)
	{
		printf("%d",arr[a]);
		if(a>0)
		printf(" ");
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 1208
/**
 * The man who codes no bugs
 * McCheng is the man studying Maths in CUHK with IQ200
 * @author McCheng
 */

#include <bits/stdc++.h>
#define int long long
using namespace std;

class ALphabet {
public:
    static constexpr int kStressCount = 0;
    static void generateTest(ostream& test) {}
	void solve(istream& cin, ostream& cout) {
char c;
cin>>c;
if (c>='a' && c<='z') cout<<'a';
else cout << 'A';
	}
};

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream &in(cin);
    ostream &out(cout);
    out << fixed;
    out.precision(20);
    ALphabet solver;
    solver.solve(in, out);
}


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

int main(){
  int k,c;
  int i;
  int sum;

  while(cin>>k,k){
    sum=0;
    
    for(i=0;i<(k*(k-1)/2);i++){
      cin>>c;
      sum+=c;
    }
    printf("%d\n",sum/(k-1));
  }
  return 0;
}

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


int main() {
    vector<int> a(5);
    rep(i,5){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    int k;
    cin >> k;
    int p = a.at(4)-a.at(0);
    if(k>=p){
        cout <<"Yay!"<<endl;
    }
    else{
        cout <<":("<<endl;
    }
}

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

public class Main {
	Scanner sc = new Scanner(System.in);
	int n,m;
	List<List<Integer>> graph;
	List<Integer> V;


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

	void solve() {
		n = nextInt();
		m = nextInt();
		graph = new ArrayList<List<Integer>>();
		V = new ArrayList<Integer>();

		for(int i=0;i<=n;i++) {
			V = new ArrayList<Integer>();
			graph.add(V);
		}

		for(int i=0;i<m;i++) {
			int a = nextInt();
			int b = nextInt();
			graph.get(a).add(b);
			graph.get(b).add(a);
		}
		sc.close();

		int res = 0;
		for(int i=1;i<=1;i++)res += SearchforAllVerticesPass(i);

		System.out.println(res);
	}

	private int SearchforAllVerticesPass(int gi) {
		int[] f = new int[n+1];
		return SearchforAllVerticesPass(gi,0+1,f);
	}

	private int SearchforAllVerticesPass(int gi,int cnt, int[] f) {
		List<Integer> VL=graph.get(gi);

		f[gi]=1;
		int sum=0;

		for(int i=0;i<VL.size();i++) {
			if(f[VL.get(i)]==1)continue;
			if(cnt+1==n)sum++;
			else sum+=SearchforAllVerticesPass(VL.get(i),cnt+1,f);
		}

		f[gi]=0;
		return sum;
	}


	private int nextInt() {
		return Integer.parseInt(sc.next());
	}
	private long nextLong() {
		return Long.parseLong(sc.next());
	}
	private String next() {
		return sc.next();
	}

}

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

const int N = 100005;

int n, x, a[N];

int main() {
	scanf("%d%d", &n, &x);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] + a[i - 1] > x) {
			int yu = min(a[i], a[i] + a[i - 1] - x);
			ans += yu;
			a[i] -= yu;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define sortall(obj) sort(ALL(obj));
typedef string str;

#define sts(a) string (a);cin >> a
#define For(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) For(i,0,n)
#define print(a) cout << a << endl

int main(){
    string s;cin >> s;
    int mn=100000;
    vector<int> sum(10);
    for(int i=0;i<s.size()-2;i++){
        sum.at(i)=(s.at(i)-'0')*100+(s.at(i+1)-'0')*10+(s.at(i+2)-'0');
    }
    rep(i,sum.size()){
        mn=min(mn,abs(sum.at(i)-753));
    }
    print(mn);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<double> VI;
typedef vector<VI> VVI;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

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

	int n, m, p, a, b;
	while (true) {
		cin >> n >> m >> p >> a >> b;
		if (n == 0) break;
		a--; b--;
		vector<double> t(n);
		for (int i = 0; i < n; i++) cin >> t[i];
		reverse(t.begin(), t.end());
		vector<P> e[30];
		for (int i = 0; i < p; i++) {
			int x, y, z; cin >> x >> y >> z;
			x--; y--;
			e[x].push_back(P(y,z));
			e[y].push_back(P(x,z));
		}
		VVI dis(1 << 8, vector<double>(m, INF));
		dis[0][a] = 0;
		queue < pair<double, P> > q;//?????¢,P(????????°?????????)
		q.push(make_pair(0, P(0, a)));
		while (!q.empty()) {
			pair<double, P>  next = q.front(); q.pop();
			double d = -next.first;
			int flag = next.second.first, vec = next.second.second;
			//cout << d << " " << flag << " " << vec << endl;
			if (dis[flag][vec] < d) continue;
			int tmp = flag;
			for (int i = 0; i < n; i++) {
				if(tmp%2){
				}
				else {
					int ftmp = flag | (1 << i);
					//cout << flag << " " << ftmp << endl;
					for (int j = 0; j < (int)e[vec].size(); j++) {
						int node = e[vec][j].first,w=e[vec][j].second;
						double dnow = dis[flag][vec], dnext = dis[ftmp][node];
						//cout << dnow << " " << dnext <<" "<< flag<<" "<<ftmp<<endl;
						if (dnext > dnow + double(w/t[i])) {
							dis[ftmp][node] = dnow + double(w/t[i]);
							q.push(make_pair(-dis[ftmp][node], P(ftmp, node)));
							//cout << flag<<" "<<ftmp << " "<<dis[ftmp][node]<<endl;
						}
					}
				}
				tmp /= 2;
			}
		}
		double res = INF;
		for (int i = 0; i < (1 << n); i++) {
			res = min(res, dis[i][b]);
		}
		res != INF ? cout << fixed << setprecision(10) << res << endl : cout << "Impossible" << endl;
	}
}

Measured memory_bytes: 3400
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl
#define first(v) get<0>(v)
#define second(v) get<1>(v)
#define third(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;



int main(){
    ll N;
    cin >> N;
    ll sum=0;
    ll ans=INF;
    ll count=0;
    ll sumuntil=0;
    vector<ll> A(N,0);
    priority_queue<ll, vector<ll>, greater<ll>> pq;
    for(ll i=0;i<N;i++){
        cin>>A[i];
        A[i]-=i;
        sum+=A[i];
        pq.push(A[i])
    ;}
    sort(A.begin(), A.end());
    for(ll i=0;i<N;i++){
        while(!pq.empty()&&pq.top()<=A[i]){
            count++;
            sumuntil+=pq.top();
            pq.pop();
        }
        chmin(ans,sum-N*A[i]+2*(A[i]*count-sumuntil));
    ;}

    print(ans);



    
    return 0;
}


Measured memory_bytes: 3956
import java.io.*;
import java.util.*;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int a = in.nextInt();
        int b = in.nextInt();
        out.println(a * b);
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

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

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

        long nextLong() {
            return Long.parseLong(next());
        }

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

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


Measured memory_bytes: 32956
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
typedef long long int l;
using namespace std;


int main(){
   string str;
   cin>>str;
   for(int i=0;i<str.size();i++){
       if(i%2==1){
           if(str[i]=='R'){
                 cout<<"No";
                 return 0;
           }
               }
               if(i%2==0){
           if(str[i]=='L'){
                 cout<<"No";
                 return 0;
           }
               }
   }
   cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<utility>
#include<array>
#include<set>
#include <numeric>
#define EPS (1e-7)
using namespace std;


#define ll long long


int main() {

	string S, simplize = "";
	int ans = 0;
	
	cin >> S;
	simplize += S[0];
	for (auto i = 1; i < S.size(); i++)
	{
		if (S[i] != simplize[simplize.size() - 1]) {
			simplize += S[i];
		}
	}

	ans = simplize.size() - 1;

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


Measured memory_bytes: 640
#include<stdio.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)
#define add(x)(x=(x+t)%MOD)

int dp[210][1100];
int N,K,MOD;
int main(){
	scanf("%d%d%d",&N,&K,&MOD);
	dp[0][0]=1;
	rep(n,0,2*N)rep(k,0,(1<<K)-1){
		int t=dp[n][k];
		if(k<1<<(K-1))add(dp[n+1][2*k+1]);
		if(k)add(dp[n+1][(k^(1<<(31-__builtin_clz(k))))*2]);
	}
	printf("%d\n",(dp[2*N][0]+(N==K))%MOD);
}


Measured memory_bytes: 2648
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);

	int n;  cin >> n;
	V a(n);
	int max_num = 0;
	REP(i, n){
		int input;  cin >> input;
		a[i] = input;
		max_num = max(max_num, input);
	}

	int nearest = -1, keep = INF;
	REP(i , n){
		if(a[i] != max_num && keep > abs(max_num - a[i] * 2)){
			keep = abs(max_num - a[i] * 2);
			nearest = a[i];
		}
    }

	cout << max_num << " " << nearest << endl;

	return 0;
}

Measured memory_bytes: 768
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(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 SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define MSG(x) std::cout << #x << " : " << x << "\n";
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int n; cin>> n;
    vector<int> p(n);
    rep (i, n) { cin >> p[i]; }

    int cnt = 0;
    for (int i = 0; i < n - 2; ++i)
    {
        vector<int> tmp;
        tmp.push_back(p[i]);
        tmp.push_back(p[i+1]);
        tmp.push_back(p[i+2]);

        sort(ALL(tmp));
        if (tmp[1] == p[i+1])
        {
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int h, w;
void solve(int a[50][50],int x,int y){
	int i, j;
	a[y][x] = 0;
	for(i = y - 1;i <= y + 1;i++){
		for(j = x - 1;j <= x + 1;j++)
			if(0 <= i && i < h && 0 <= j && j < w && a[i][j]) solve(a,j,i);
	}
	return;
}

int main(void){
	int i, j, flag[50][50], count;
	scanf("%d%d",&w,&h);
	while(w != 0 || h != 0){
		for(i = 0;i < h;i++)
			for(j = 0;j < w;j++) scanf("%d",&flag[i][j]);
		count = 0;
		for(i = 0;i < h;i++){
			for(j = 0;j < w;j++){
				if(flag[i][j]){
					count++;
					solve(flag,j,i);
				}
			}
		}
		printf("%d\n",count);
		scanf("%d%d",&w,&h);
	}
	return 0;
}

Measured memory_bytes: 1220
#include<iostream>
 
using namespace std;
 
int n;
string now,unlock;
 
string make(string s, int start, int end, bool f){
  if(f){
    while(1){
      for(int i = start; i <= end; i++){
    if(s[i] == '9') s[i] = '0';
    else s[i]++;
      }
      if(s[start] == unlock[start]) break;
    }
  }else{
    while(1){
      for(int i = start; i <= end; i++){
    if(s[i] == '0') s[i]='9';
    else s[i]--;
      }
      if(s[start] == unlock[start]) break;
    }
  }
  return s;
}
 
int solve(string s, int rev, int fin){
 
   
  if(fin >= n) return rev;
 
  if(s[fin] == unlock[fin]) return solve(s,rev,fin+1);
 
  int ans = (1<<25);
 
  int rc=0,lc=0;
  //r -> --. l -> ++;
 
 
  if(s[fin] < unlock[fin]){
    lc = unlock[fin]-s[fin];
    rc = (10-unlock[fin]-'0')+s[fin]-'0';
  }else{
    lc = (10-s[fin]-'0')+unlock[fin]-'0';
    rc = s[fin]-unlock[fin];
  }
 
  bool isR=false;
  if(rc < lc) isR = true;
 
   
  for(int i = fin; i < n; i++){
    ans = min(ans,solve(make(s,fin,i,isR),rev+1,fin+1));
  }
  return ans;
}
 
int main(){
   
  while(cin >> n && n){
    cin >> now >> unlock;
    cout << solve(now,0,0) << endl;
  }
   
  return 0;
}

Measured memory_bytes: 1212
S=input()
if S=="ooo" :
  print(1000)
elif S=="oox" :
  print(900)
elif S=="oxo" :
  print(900)
elif S=="xoo" :
  print(900)
elif S=="oxx" :
  print(800)
elif S=="xox" :
  print(800)
elif S=="xxo" :
  print(800)
else :
  print(700)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数


int main()
{
  int n, a, b ;
  cin >> n >> a>> b ;
  string s ;
  cin >> s ;
  int cnta = 0 ;
  int cntb = 0 ;
  
  REP(i,n){
    if(s.at(i)=='a'){
      if(cnta<a+b){
        cout << "Yes" <<endl ;
        cnta++ ;
      }
      else{
        cout <<"No"<<endl ;
      }
    }
    else if(s.at(i)=='b'){
      if(cnta<a+b && cntb<b){
        cout <<"Yes"<<endl ;
        cnta++ ;
        cntb++ ;
      }
      else{
        cout <<"No"<<endl ;
      }
    }
    else{
      cout <<"No"<<endl ;
    }
  }
  
      
    


  return 0 ;
}



Measured memory_bytes: 896
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

def f(a,b):
  return math.ceil(a/b)*b-a

n = readInt()
ab = [readInts() for i in range(n)]
ans = 0
for a,b in ab[::-1]:
  ans += f(a+ans,b)

print(ans)

Measured memory_bytes: 28276
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

template <typename T>
struct edge
{
    int src, to;
    T cost;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}

    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    edge &operator=(const int &x)
    {
        to = x;
        return *this;
    }

    operator int() const { return to; }
};

//Weighted edge set
template <typename T>
using Edges = vector<edge<T>>;

//Weighted graph
template <typename T>
using WeightedGraph = vector<Edges<T>>;

template <typename T>
T Prim(WeightedGraph<T> &g)
{
    T res = 0;
    vector<bool> used(g.size(), false);
    priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> que;
    que.emplace(0, 0);
    while (que.empty() != true)
    {
        auto p = que.top();
        que.pop();
        if (used[p.second] == true)
            continue;
        used[p.second] = true;
        res += p.first;
        for (auto &e : g[p.second])
        {
            que.emplace(e.cost, e.to);
        }
    }
    return res;
}

int N;
ll a, b;

int main()
{
    cin >> N;
    vector<pair<pair<ll, ll>, int>> x, y;
    WeightedGraph<ll> G(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a >> b;
        a--, b--;
        x.emplace_back(make_pair(a, b), i);
        y.emplace_back(make_pair(b, a), i);
    }

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    for (int i = 0; i + 1 < N; i++)
    {
        ll a = x[i].first.first, b = x[i].first.second, na = x[i + 1].first.first, nb = x[i + 1].first.second;
        int p1 = x[i].second, p2 = x[i + 1].second;
        G[p1].emplace_back(p2, min(abs(a - na), abs(b - nb)));
        G[p2].emplace_back(p1, min(abs(a - na), abs(b - nb)));
    }

    for (int i = 0; i + 1 < N; i++)
    {
        ll a = y[i].first.first, b = y[i].first.second, na = y[i + 1].first.first, nb = y[i + 1].first.second;
        int p1 = y[i].second, p2 = y[i + 1].second;
        G[p1].emplace_back(p2, min(abs(a - na), abs(b - nb)));
        G[p2].emplace_back(p1, min(abs(a - na), abs(b - nb)));
    }
    
    cout << Prim(G) << endl;
}

Measured memory_bytes: 24868
N = int(input())
A = [0]
for i in range(N):
    a = int(input())
    A.append(a)
#print(A)
ans = 1
now = A[1]
visited = {}
while (not now in visited) and now != 2:
    ans += 1
    visited[now] = 1
    now = A[now]
#print(visited)
if now != 2:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 59736
n = int(input())
txy = [list(map(int, input().split())) for _ in range(n)]
T=X=Y=0
ans = "Yes"
for t,x,y in txy:
    if abs(T-t) < abs(X-x)+abs(Y-y):
        ans = "No"
        break
    a = abs(T-t) - (abs(X-x)+abs(Y-y))
    if a%2!=0:
        ans = "No"
        break
    T,X,Y = t,x,y
print(ans)

Measured memory_bytes: 27052
/*
 * Note: This template uses some c++11 functions , so you have to compile it with c++11 flag.
 *       Example:-   $ g++ -std=c++11 c++Template.cpp
 *
 * Author : Denzil Bernard  / Edgar Monis
 * Handle: 1_mn_RMY / the_king_in_the_north
 *
 */

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
//#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define read(type) readInt<type>()
#define ll long long
typedef pair< ll, ll> PII;
typedef vector<ll> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<ll,ll> MPII;
typedef set<ll> SETI;
typedef multiset<ll> MSETI;

ll SI(){
    ll x;
    cin>>x;
    return x;
}


ll mod(ll a){
	return a<0?-a:a;
}


/********** Main()  function **********/
int main()
{
    ll a = SI(), b= SI();
    cout<<a*b;
    
    return 0;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#define SIZE 200005
#define INF 10000000000000000LL

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
typedef pair <ll,P> PP;

struct edge
{
	int to;
	ll cost;
	edge(int to=0,ll cost=0):to(to),cost(cost){}
};
struct UF
{
	int par[SIZE],rank[SIZE];
	
	void init(int n)
	{
		for(int i=0;i<n;i++)
		{
			par[i]=i;
			rank[i]=0;
		}
	}
	int find(int x)
	{
		if(par[x]==x) return x;
		return par[x]=find(par[x]);
	}
	void unite(int x,int y)
	{
		x=find(x);
		y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y]) par[x]=y;
		else
		{
			par[y]=x;
			if(rank[x]==rank[y]) rank[x]++;
		}
	}
	bool same(int x,int y)
	{
		return find(x)==find(y);
	}
};
UF uf;
vector <edge> vec[SIZE];
ll X[SIZE];
int v1[SIZE],v2[SIZE];
ll d1[SIZE],d2[SIZE];
int id[SIZE],ch[SIZE];
int now_id;

void dfs(int v=0,int p=-1)
{
	id[v]=now_id++;
	d1[v]=d2[v]=INF;
	v1[v]=v2[v]=-1;
	for(int i=0;i<vec[v].size();i++)
	{
		edge e=vec[v][i];
		if(e.to!=p)
		{
			dfs(e.to,v);
			ll vl=d1[e.to]+e.cost;
			int vv=v1[e.to];
			if(vl>e.cost+X[e.to])
			{
				vl=e.cost+X[e.to];
				vv=e.to;
			}
			if(vl<d1[v])
			{
				swap(vl,d1[v]);
				swap(vv,v1[v]);
			}
			if(vl<d2[v])
			{
				swap(vl,d2[v]);
				swap(vv,v2[v]);
			}
		}
	}
	ch[v]=now_id;
}
void make(int v=0,int p=-1)
{
	for(int i=0;i<vec[v].size();i++)
	{
		edge e=vec[v][i];
		if(e.to!=p)
		{
			ll vl=d1[v]+e.cost;
			int vv=v1[v];
			if(id[e.to]<=id[vv]&&id[vv]<ch[e.to])
			{
				vl=d2[v]+e.cost;
				vv=v2[v];
			}
			if(vl>e.cost+X[v])
			{
				vl=e.cost+X[v];
				vv=v;
			}
			if(vl<d1[e.to])
			{
				swap(vl,d1[e.to]);
				swap(vv,v1[e.to]);
			}
			if(vl<d2[v])
			{
				swap(vl,d2[e.to]);
				swap(vv,v2[e.to]);
			}
			make(e.to,v);
		}
	}
}
int A[SIZE],B[SIZE];
ll C[SIZE];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%lld",&X[i]);
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		ll c;
		scanf("%d %d %lld",&a,&b,&c);a--,b--;
		vec[a].push_back(edge(b,c));
		vec[b].push_back(edge(a,c));
		A[i]=a,B[i]=b,C[i]=c;
	}
	dfs();
	make();
	uf.init(n+2);
	ll ret=0;
	for(int i=0;i<n;i++)
	{
		if(v1[v1[i]]==i&&i<v1[i]) continue;
		ret+=d1[i]+X[i];
		uf.unite(i,v1[i]);
	}
	for(int i=0;i<n-1;i++)
	{
		if(!uf.same(A[i],B[i]))
		{
			ret+=min(X[A[i]],d1[A[i]]);
			ret+=min(X[B[i]],d1[B[i]]);
			ret+=C[i];
		}
	}
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 43520
import bisect

N, M, V, P = map(int, input().split())
A = list(map(int, input().split())) + [-M-1]
A.sort()

Ap = A[-P] # 初期状態でP番目に大きい点数
I = N + 2 - P
right = N + 1 - P
left = 0

while left + 1 < right:
  mid = (left + right) // 2
  b = A[mid] + M
  if b < Ap:
    left = mid
  else:
    v = V - (bisect.bisect_right(A, A[mid])-1) - (P-1)
    if v <= 0:
      right = mid
    else:
      mv = M*v
      for i in range(mid+1, I):
        if A[i] == A[mid]:
          continue
        mv -= b - A[i]
        if mv <= 0:
          break
      if mv <= 0:
        right = mid
      else:
        left = mid

print(N + 1 - right)

Measured memory_bytes: 62576
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <utility>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long int N, K; cin >> N >> K;
  long long int x[100010];
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }
  long long int c = 300010000;
  for (int i = 0; i < N-(K-1); i++) {
    long long int t;
    if (x[i+(K-1)] < 0)
      t = abs(x[i]);
    else if (x[i] >= 0)
      t = x[i+(K-1)];
    else {
      t = min(abs(x[i]), x[i+(K-1)])*2 + max(abs(x[i]), x[i+(K-1)]);
    }
    c = min(c, t);
  }
  cout << c << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
struct tree
{
    int key, left, right, parent;
};
void my_sort_sub(int *t, int p, int n)
{
    int l = p * 2, r = p * 2 + 1, largest;
    if (l <= n && t[l] > t[p])
        largest = l;
    else
        largest = p;
    if (r <= n && t[r] > t[largest])
        largest = r;
    if (largest != p)
    {
        swap(t[largest], t[p]);
        my_sort_sub(t, largest, n);
    }
}
void my_sort(int *t, int n)
{
    for (int i = n / 2; i >= 1; --i)
    {
        my_sort_sub(t, i, n);
    }
}
int main()
{
    int H, key;
    cin >> H;
    int mytree[H + 1];
    for (int i = 1; i <= H; ++i)
        cin >> mytree[i];
    my_sort(mytree, H);
    for (int i = 1; i <= H; ++i)
        cout << ' ' << mytree[i];
    cout << '\n';
}


Measured memory_bytes: 4964
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include<unordered_map>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll GCD(ll x, ll y) {
	return x ? GCD(y % x, x) : y;
}

ll LCM(ll m, ll n)
{
	if ((0 == m) || (0 == n))
		return 0;

	return ((m / GCD(m, n)) * n); // lcm = m * n / GCD(m,n)
}
int main() {
	int n;
	cin >> n;
	ll ans = 1;
	rep(i, n) {
		ll t;
		cin >> t;
		ans = LCM(ans, t);
	}
	cout << ans << endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<map>
#include<iostream>
#include<queue>
#include<algorithm>

using namespace std;

#define INF 1000000000
typedef pair<int,int> P;
int v,e,r;
int s[1000000],t[1000000],d[10000000];
  vector<P> vec[500000];

void dijkstra(){
  priority_queue<P,vector<P>,greater<P> > pq;
  pq.push(P(0,r));
  int res[v];
  fill(res,res+v,INF);
  res[r]=0;

  while(!pq.empty()){
    P tmp=pq.top(); pq.pop();
    if(tmp.first>res[tmp.second]) continue;
    for(int i=0;i<vec[tmp.second].size();i++){
        if(res[vec[tmp.second][i].first]>res[tmp.second]+vec[tmp.second][i].second){
          res[vec[tmp.second][i].first]=res[tmp.second]+vec[tmp.second][i].second;
          pq.push(P(res[vec[tmp.second][i].first],vec[tmp.second][i].first));
      }
    }
  }
  for(int i=0;i<v;i++){
    if(res[i]==INF) printf("INF\n");
    else  printf("%d\n",res[i]);
  }
}




int main(){
  scanf("%d%d%d",&v,&e,&r);
  for(int i=0;i<e;i++){
    scanf("%d%d%d",&s[i],&t[i],&d[i]);
    vec[s[i]].push_back(P(t[i],d[i]));
  }



/*  for(int i=0;i<e;i++){
    s[i+e]=t[i];
    t[i+e]=s[i];
    d[i+e]=d[i];
  }
*/
  dijkstra();

  return 0;
}

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

int main(){
    int n,i;
    cin >> n;
    string s;
    cin >> s;
    int cost=0;
    for(i = 1; i < n; i++){
        if(s[i] == 'E')
            cost++;
    }
    int min = cost;
    for(i = 1; i < n; i++){
        if(s[i] == 'E')
            cost--;
        if(s[i-1] == 'W')
            cost++;
        if(cost < min)
            min = cost;
    }
    cout << min;
}

Measured memory_bytes: 900
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():






    n = I()
    a = LI()

    ans = 0
    mn = 0

    for i in range(n):
        if a[i] <0:
            mn += 1
            a[i] *= -1

    if (mn %2 == 0):
        ans = sum(a)
    else:
        ans = sum(a)-min(a)*2

    print(ans)

                    


main()


Measured memory_bytes: 21448
n,m = map(int,input().split())

ken = [(i,) + tuple(map(int,input().split())) for i in range(m)]

def func(elem):
    return elem[1:3]
ken.sort(key=func)

currKen = ken[0][1]
cnt = 1
for i in range(len(ken)):
    if ken[i][1] == currKen:
        ken[i] +=(cnt,)
        cnt += 1
    else:
        currKen = ken[i][1]
        cnt = 1
        ken[i] +=(cnt,)
        cnt += 1


#print(ken)
ken = sorted(ken,key = lambda x: x[0])

for k in ken:
    print("%.6d%.6d"%(k[1],k[3]))



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

#define ff first
#define ss second
#define maxn 2000006
#define pb push_back
#define ll long long
#define lll __int128
#define vll vector<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define pll pair<ll,ll>
#define ull unsigned long long
#define f(i,x,n) for(int i=x;i<=n;i++)

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

using namespace std;

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

	ll a,b; cin>>a>>b;

	cout<<ceil((double)(b-1)/(a-1));

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.ABC_103
{
    class C
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            var array = new int[n];
            for (int i = 0; i < n; i++)
            {
                array[i] = int.Parse(input[i]);
            }
            long f = 0;
            for(int i = 0; i < n; i++)
            {
                f += array[i] - 1;
            }
            Console.WriteLine(f);
        }
    }
}


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

string n;
int ans = 0, _size;

void func(string x, int n3, int n5, int n7){
  if(x.size() == _size){
    if( n3 >= 1 && n5 >= 1 && n7 >= 1) {
      if(atoi(n.c_str()) >= atoi(x.c_str())){
        ++ans;
      }
    }
    return;
  }
  
  func(x + "3", n3+1, n5, n7);
  func(x + "5", n3, n5+1, n7);
  func(x + "7", n3, n5, n7+1);
}


int main(){

  cin >> n;

  _size = n.size();

  for(_size = 3; _size <= n.size(); ++_size){
    func("3", 1, 0, 0);
    func("5", 0, 1, 0);
    func("7", 0, 0, 1);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;  
#define pb push_back
#define F first
#define S second
#define ppp pair<ll,pair<ll,ll>>
#define pp pair<ll,ll>
#define all(x) (x).begin(),(x).end()
#define pi 3.14159265358
#define MOD 998244353
int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
   	 ll n,i,j,k;

   	 cin>>n;

   	 vector<ll> v;
   	 for(i=2;i<=sqrt(n);i++)
   	 {	
   	 	ll occ=0;
   	 	while(n%i==0)
   	 	{
   	 		n=n/i;
   	 		occ++;
   	 	}
   	 	if(occ!=0)
   	 		v.pb(occ);
   	 }

   	 if(n!=1)
   	 	v.pb(1);

   	 ll ans=0;
   	 for(i=0;i<v.size();i++)
   	 {
   	 	ll sum=0;
   	 	for(j=1; ;j++)
   	 	{
   	 		if(sum+j>v[i])
   	 			break;
   	 		sum+=j;
   	 	}

   	 	ans+=j-1;
   	 	//cout<<v[i]<<" "<<j<<endl;
   	 }

   	 cout<<ans<<endl;



}



Measured memory_bytes: 3656
#include <stdio.h>
int dp[50002];
int min(int a,int b){
  if(a<b)return a;
  else return b;
}
int main(){
  int n,m;
  int i,j;
  int c[22];
  int count=0;
  int inf=10000000;
  scanf("%d %d",&n,&m);
  for(i=0;i<m;i++)scanf("%d",&c[i]);
 
  for(i=0;i<=n;i++)dp[i]=inf;
  dp[0]=0;
   
  for(i=0;i<m;i++){
    for(j=c[i];j<=n;j++){
      dp[j]=min(dp[j],dp[j-c[i]]+1);
    }
  }
  
  printf("%d\n",dp[n]);
  return 0;
}

Measured memory_bytes: 2912
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<set>
using namespace std ;
using ll = long long ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using pll = pair<ll,ll> ;

vvll x(100001),y(100001) ;

void DFS(vector<pll> &p,vector<bool> &use,set<int> &posx,set<int> &posy,ll &cnt,int cur){
	if(use[cur]) return ;
	int w = p[cur].first ;
	int h = p[cur].second ;
	posx.insert(w) ;
	posy.insert(h) ;
	cnt++ ;
	use[cur] = true ;
	auto itr = lower_bound(x[w].begin(),x[w].end(),cur) ;
	if(itr!=x[w].begin()){
		itr-- ; DFS(p,use,posx,posy,cnt,*itr) ;
		itr++ ;
	}
	itr++ ;
	if(itr!=x[w].end()) DFS(p,use,posx,posy,cnt,*itr) ;
	itr = lower_bound(y[h].begin(),y[h].end(),cur) ;
	if(itr!=y[h].begin()){
		itr-- ; DFS(p,use,posx,posy,cnt,*itr) ;
		itr++ ;
	}
	itr++ ;
	if(itr!=y[h].end()) DFS(p,use,posx,posy,cnt,*itr) ;
}

int main(){
	ll n ; cin >> n ;
	vector<pll> p(n) ;
	for(int i=0;i<n;i++){
		ll a,b ;
		cin >> a >> b ;
		p[i].first = a ;
		p[i].second = b ;
		x[a].push_back(i) ;
		y[b].push_back(i) ;
	}
	ll ans = 0 ;
	vector<bool> use(n,false) ;
	for(int i=0;i<n;i++){
		if(use[i]) continue ;
		set<int> posx,posy ;
		ll cnt = 0 ;
		DFS(p,use,posx,posy,cnt,i) ;
		ans += posx.size()*posy.size()-cnt ;
	}
	cout << ans << endl ;
}

Measured memory_bytes: 26312
#Good question
import sys
A,B = map(int,input().split())

if not ( 0 <= A <= 10**9 and 0 <= B <= 10**9 ): sys.exit()

if A % 2 != B % 2:
    print('IMPOSSIBLE')
    sys.exit()
else:
    print(int((A+B)/2))


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

void trace(vector<int> &vi) {
    cout << "*** trace ***" << endl;
    for (auto i : vi)
        cout << i << " ";
    cout << endl;
}

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

    int N;
    cin >> N;

    vector<int> bi;
    for (int i = 0, input; i < N - 1; i++) {
        cin >> input;
        bi.push_back(input);
    }

    int sum = 0;
    sum += bi.front() + bi.back();
    for (int i = 0; i < bi.size() - 1; i++) {
        sum += min(bi.at(i), bi.at(i + 1));
    }

    // trace(bi);
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>



#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;
vector<vector<string>> graph;

//nikkei2019_qual_c

int main(void) {
	ll n;
	cin >> n;
	vector <tuple<ll, tuple<ll, ll>>> v = vector < tuple<ll, tuple<ll, ll>>>();
	rep(i, 0, n) {
		ll a, b;
		cin >> a >> b;
		v.push_back(make_tuple(a + b, make_tuple(a, b)));
	}
	sort(v.rbegin(), v.rend());
	ll takahashi = 0, aoki = 0;
	rep(i, 0, n) {
		if (i % 2 == 0) {
			takahashi += get<0>(get<1>(v[i]));
		}
		else {
			aoki += get<1>(get<1>(v[i]));
		}
	}

	cout << takahashi - aoki << endl;
}


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

using namespace std;
using ll = long long;
using ld = long double;

void solve() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  sort(a.begin(), a.end(), greater<ll>());
  ll ans = 0;
  for (int i = 1; i < n; i++) {
    ans += a[i / 2];
  }

  cout << ans << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 4780
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: August 14
 * 
 */

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>
#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define ef else if
#define wh while
#define el else
#define ivv(x) int x; cin>>x
#define lv(x) bint x; cin>>x
#define sv(x) string x; cin>>x
#define cv(x) char x; cin>>x
#define fv(x) float x; cin>>x
#define dv(x) double x; cin>>x
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {
    // your solution goes here 
    ivv(n);
    int counter(0);
    for(int i=1;i<=n;++i){
        string s = to_string(i);
        counter+=(s.size()&1);
    }
    cout<<counter<<endl;
    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAXN 100000
#define INF 1000000000
   
using namespace std;
int a[MAXN+80];
void get(int &v)
{
	char c;
	while((c=getchar())!=EOF&&isdigit(c)==0);
	v=c-'0';
	while((c=getchar())!=EOF&&isdigit(c))
		v=(v<<1)+(v<<3)+c-'0';
	return ;
}
int gcd(int a,int b)
{
	int t;
	while(b)
	{
		t=a%b;
		a=b;
		b=t;
	}
	return a;
}
int main()
{
	int n,i,k,G=0;
	get(n);
	get(k);
	for(i=1;i<=n;i++)
		get(a[i]);
	sort(a+1,a+n+1);
	for(i=1;i<n;i++)
		G=gcd(a[i+1]-a[i],G);
	if((G==0&&a[i]!=k)||(G!=0&&(a[n]<k||(a[n]-k)%G)))
		printf("IM");
	puts("POSSIBLE");
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
map<ll,ll>hoge;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  ll ho=n;
  cout<<n<<": ";
  while(n%2 == 0){n/=2;hoge[2]++;}
  for(int i=3;i<=sqrt(ho);i+=2){
    bool fl=true;
    for(int j=2;j<=sqrt(i);j++){
      if(i%j == 0){fl=false;break;}
    }
    if(fl){
      while(n%i == 0){n/=i;hoge[i]++;}
    }
  }
  if(n>1)hoge[n]++;
  vi ans;
  for(auto a:hoge){
    for(int i=0;i<a.S;i++)
      ans.pb(a.F);
  }
  for(int i=0;i<ans.size();i++){
    cout<<ans[i];
    if(i!=ans.size()-1)cout<<" ";
  }
  cout<<endl;
  return 0;
}



Measured memory_bytes: 3184
n = gets.to_i
s = gets.split("").map &:to_s

i = 0
max = 0

loop do
    break if i == n
    
    if (s[i] == 'O') && (s[i+1] == 'X') || (s[i] == 'X') && (s[i+1] == 'O')

        i += 2
        max += 1
    else

        i += 1
    end
    
end

puts max


Measured memory_bytes: 13092
n=int(input())
l=[list(map(str,input().split())) for i in range(n)]
for i in range(n):
    l[i][1]=int(l[i][1])
    l[i].append(i+1)
l.sort(key=lambda x:x[1], reverse=True)
l.sort(key=lambda x:x[0])
for i in range(n):
    l[i].append(i+1)

for i in range(n):
    print(l[i][2])


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include<stdio.h>
int main(void)
{
    switch(getchar_unlocked())
    {
      case '2': puts("14"); return 0;
      case '3': puts("39"); return 0;
      case '4': puts("84"); return 0;
      case '5': puts("155"); return 0;
      case '6': puts("258"); return 0;
      case '7': puts("399"); return 0;
      case '8': puts("584"); return 0;
      case '9': puts("819"); return 0;
      default: switch(getchar_unlocked())
      {
        case '0': puts("1110"); return 0;
        default: puts("3");
      }
    }
    return 0;
}


Measured memory_bytes: 1460
h, w, K = map(int, input().split())
c = []
for i in range(h):
  a = list(str(input()))
  c.append(a)
cnt = 0
blk = 0
for i in range(2 ** h):
  for j in range(2 ** w):
    for k in range(h):
      for l in range(w):
        if ((i >> k) & 1 == 0) and ((j >> l) & 1 == 0) and (c[k][l] == '#'):
          blk += 1
    if blk == K:
      cnt += 1
    blk = 0
print(cnt)

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

//string型文字列をint型整数にして返す
int str_to_num(string s) {return atoi(s.c_str());}
//約数の総数を返す
int count_divisor(int n){int c[n/2] = {1}; int n_half = n/2; for(int i=2;i<n_half;i++){if(n%i==0){n /= i;c[i]+=1;i--;if(n>1) continue;else break;}  }int r = 1;for(int i=2;i<n_half;i++){r *= c[i];}return r;}
//各桁の数の和を返す
int dig_num(int n){return (n<10) ? n: dig_num(n/10) + n%10;}

int main(){
  int N; cin >> N;
  int D; cin >> D;
  int w = D*2+1;
  int r = N/w + (N%w>0);
  
  cout << r << '\n';
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include<cmath>
#include <functional>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod2 = 1000000007;
constexpr ll mod = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// --------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll ans = -INF;
  chmax(ans,a*c);
  chmax(ans,a*d);
  chmax(ans,b*c);
  chmax(ans,b*d);
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3660
def main():
    """
    1 <=  N <= 2 * 10^5
    1 <= ai <= 10^9
    """
    N = int(input())
    *A, = map(int, input().split())

    #ans = WA3(N, A)
    ans = editorial(N, A)
    print(ans)


def editorial(N, A):
    ans = 0
    C = sorted(a - i for i, a in enumerate(A, 1))
    if N % 2 == 1:
        b = C[N // 2]
    else:
        # 中央値だけど、整数？
        s = C[N // 2 - 1] + C[N // 2 - 1]
        b = s // 2

    ans = sum(abs(c - b) for c in C)
    return ans


if __name__ == '__main__':
    main()


Measured memory_bytes: 25708