akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
        #include <vector>
        #include <string>
        #include <stack>
        #include <bits/stdc++.h>
        #include <algorithm>
        using namespace std;
        #define M 1000000007

        int binarySearch(vector<int> input, int target){
            int start = 0;
            int end = input.size() -1;
            int result = -1;
            while(start<=end){
                int mid = end - (end-start)/2;
                if(input[mid]==target){
                    result = mid;
                    start = mid+1;
                }else if(input[mid]>target){
                    end = mid-1;
                }else{
                    start = mid+1;
                }
            }
            return result;
        }
        int lis(vector<int> v, int n, int maxVal){
            if(n==0)
                return 0;
            if(v[n-1]<maxVal){
                return max( 1+lis(v, n-1, v[n-1]), lis(v, n-1, maxVal) );
            }else
            return lis(v, n-1, maxVal);
        }
        void sw(string &s, int i, int j){
            char temp = s[i];
            s[i] = s[j];
            s[j] = temp;
        }
        void swap(string &s, int i, int j){
            for(int l=j; l>i; l--){
                sw(s, l, l-1);
            }
        }

        int get(int n){
            if(n%2==1)
                return n;
            return get(n/2);
        }

void dfs(vector<vector<int>> &graph, vector<bool> &visited, int start, int curr, int &max){
    if(visited[start])
    return;


    visited[start] = true;
    for(auto i: graph[start]){
        dfs(graph, visited, i, curr+1, max);
    }
}


    int main(){
            #ifndef ONLINE_JUDGE
            freopen("input.in", "r", stdin);
            freopen("output.in", "w", stdout);
            #endif

         int n; int k; cin>>n>>k;
         int h[n];
         for(int i=0; i<n; i++)
            cin>>h[i];
        int dp[n];
        for(int i=0; i<n; i++){
            dp[i] = INT_MAX;
        }
        dp[0] = 0;
        for(int i=0; i<n; i++){
            for(int j=1; j<=k; j++){
                if((i+j)<n){
                    int temp = dp[i] + abs(h[i+j] - h[i]);
                    if(dp[i+j]>=temp)
                        dp[i+j] = temp;
                }
            }
        }
        cout<<dp[n-1]<<"\n";
   }


Measured memory_bytes: 4400
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
} initializer;

struct dp {
  int ary[100010];
  constexpr dp() : ary() {
    rep(i, 100010) ary[i] = i;
    for (int i = 6; i < 100010; i *= 6) {
      for (int j = 0; j+i < 100010; ++j) ary[j+i] = min(ary[j+i], ary[j]+1);
    }
    for (int i = 9; i < 100010; i *= 9) {
      for (int j = 0; j+i < 100010; ++j) ary[j+i] = min(ary[j+i], ary[j]+1);
    }
  }
};

int main() {
  int n; cin>>n;
  constexpr auto a = dp();
  print(a.ary[n]);
  return 0;
}

Measured memory_bytes: 1148
#include <iostream>
#include <string>

typedef long long int llint;

int main(void){
  llint w_count = 0;
  std::string s;
  std::cin >> s;

  llint count = 0;
  for(int i=0; i<s.size(); i++){
    if(s[i] == 'W'){
      count += i - w_count;
      w_count++;
    }
  }

  std::cout << count << std::endl;

  return 0;
}




Measured memory_bytes: 640
#include<iostream>
#include<set>
using namespace std;
int main()
{
    int n;
    cin>>n;
    set<string>s;
    for(int i=0;i<n;i++)
    {
        string s1;
        cin>>s1;
        s.insert(s1);
    }
    cout<<s.size();
}



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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

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

  int a[n], b[n];

  for(int i=0; i<n-1; ++i){
    cin >> b[i];
  }
  
  ll sum = 0;

  for(int i=1; i<n; ++i){
    if(i == n-1) a[i] = b[i-1];
    else if(b[i] > b[i-1]) a[i] = b[i-1];
    else if(b[i] <= b[i-1]) a[i] = b[i];

    sum += a[i];
  }
  a[0] = b[0];
  cout << sum+a[0];

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
mt19937 _mt(chrono::steady_clock::now().time_since_epoch().count());
ll getrnd(ll l,ll r){return uniform_int_distribution<ll>(l,r-1)(_mt);}
/*
#define _cTime (chrono::system_clock::now())
#define progress (chrono::duration_cast<chrono::milliseconds>(_cTime-_sTime).count())
#define reset _sTime=_cTime
auto reset;
*/
constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vl v(n);
	rep(i,n)cin>>v[i];
	ll ans=v[0];
	range(i,1,n)ans=gcd(ans,v[i]);
	cout<<ans<<endl;
}



Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		final Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		char[] same = sc.next().toCharArray();
		
		boolean[] tf = new boolean[N];
		for(int fst = 0; fst <= 1; fst++){
			LOOP:
			for(int lst = 0; lst <= 1; lst++){
				Arrays.fill(tf, false);
				tf[    0] = fst == 1;
				tf[N - 1] = lst == 1;
				
				for(int i = 0; i < N; i++){
					final boolean prev = tf[(N + i - 1) % N];
					final boolean next = tf[(N + i + 1) % N];
					
					//System.out.println(fst + " " + lst + " " + i + " " + prev + " " + same[i] + " " + next);
					if((tf[i] && same[i] == 'o') || (!tf[i] && same[i] != 'o')){
						if(i < N - 2){
							tf[i + 1] = prev;
						}else if(next != prev){
							continue LOOP;
						}
					}else{
						if(i < N - 2){
							tf[i + 1] = !prev;
						}else if(next == prev){
							continue LOOP;
						}
					}
				}
				
				for(int i = 0; i < N; i++){
					System.out.print((tf[i] ? "S" : "W"));
				}
				System.out.println();
				return;
			}
		}
		
		System.out.println(-1);
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}
		
		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 31836
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int A, B, K;
    cin >> A >> B >> K;

    int n = B;
    if(A < B) {
        n = A;
    }

    vector<int> v;

    for(int i = 1; i <= n; i++) {
        if(A % i == 0 && B % i == 0) {
            v.push_back(i);
        }
    }

    sort(v.begin(), v.end(), greater<int>());

    cout << v[K - 1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
#define debug(var) cout << "[" << #var << "] " << var << endl
const ll mod = 1000000007;
 
int main() {
  int d;
  cin >> d;
  string a[4] = {"Christmas", "Christmas Eve", "Christmas Eve Eve", "Christmas Eve Eve Eve"};
  cout << a[25-d] << endl;
  return 0;
}

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

def main(S):
    ans = 'No'
    letters = set(S)
    tmp = []
    for letter in letters:
        tmp.append(S.count(letter))
    if tmp == [2, 2]:
        ans = 'Yes'
    return ans
    
if __name__ == '__main__':
    S = input()
    print(main(S))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<vector<ll>> dp(n+1, vector<ll>(n+1, LINF));
  rep(i, n+1) dp[i][i] = 0;
  rep(i, n) dp[i][i+1] = 0;
  vector<ll> sum(n+1);
  rep(i, n) sum[i+1] = sum[i]+a[i];
  for (int len = 2; len <= n; len++) {
    for (int i = 0; i+len <= n; i++) {
      ll res = LINF;
      for (int k = i+1; k < i+len; k++)
        chmin(res, dp[i][k]+dp[k][i+len]);
      dp[i][i+len] = res+sum[i+len]-sum[i];
    }
  }
  cout << dp[0][n] << endl;
  return 0;
}

Measured memory_bytes: 1536
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

def getScore(t, R, S, P):
    if t == 'r':
        return P
    if t == 's':
        return R
    return S

latest = [{'string': '', 'count': 0} for _ in range(K)]

ret = 0
for idx, t in enumerate(T):
    latest_idx = idx % K
    if idx + 1 <= K or t != latest[latest_idx]['string']:
        ret += getScore(t, R, S, P)
        latest[latest_idx]['string'] = t
        latest[latest_idx]['count'] = 1
        continue

    if latest[latest_idx]['count'] % 2 == 0:
        ret += getScore(t, R, S, P)
    latest[latest_idx]['count'] += 1

print(ret)

Measured memory_bytes: 74204
package main

import (
	"fmt"
	"math"
)

func getMin(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func getMinValues(i int) int {
	min := int(math.MaxInt64)
	tmpValue := 0
	for k := 1; k <= K; k++ {
		if i-k >= 0 {
			tmpValue = values[i-k] + abs(height[i]-height[i-k])
			if tmpValue < min {
				min = tmpValue
			}
		}
	}
	return min
}

var N, K int
var values []int
var height []int

func main() {
	fmt.Scan(&N, &K)
	height = make([]int, N)
	var tmp int
	for i := 0; i < N; i++ {
		fmt.Scan(&tmp)
		height[i] = tmp
	}
	values = make([]int, N)
	values[0] = 0
	for i := 1; i < N; i++ {
		values[i] = getMinValues(i)
	}
	fmt.Println(values[N-1])
	//fmt.Println(values)
}


Measured memory_bytes: 5504
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


if __name__ == '__main__':
    b, c = map(int, input().split())
    a =[]

    for i in range(b):
        s = input()
        a.append(s)
    a.sort()

    print("".join(a))

Measured memory_bytes: 5144
#include <iostream>
#include <algorithm>
typedef long long ll;
using namespace std;

int main(){
	ll N, H, sum;
	cin >> N >> H;
	ll i, meow=N;
	ll a, b[N], m=-1;
	for(i=0;i<N;i++){
		cin >> a >> b[i];
		m = max(a, m);
	}
	sum = 0;
	sort(b, b+N);
	reverse(b, b+N);
	for(i=0;i<N;i++){
		if(b[i] <= m){
			meow = i;
			break;
		}
		sum += b[i];
		if(sum >= H){
			cout << i+1 << endl;
			return 0;
		}
	}
	H -= sum;
	ll n = 0;
	while(true){
		if( m*n >= H ){
			cout << meow + n << endl;
			return 0;
		}
		n++;
	}
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int N, X[212345], O[212345];

int main() {

	scanf("%d", &N);
	rep(i, N) scanf("%d", &X[i]);
	rep(i, N) O[i] = X[i];

	sort(O, O + N);
	int m = O[N / 2], n = O[N / 2 - 1];

	rep(i, N) {
		if (X[i] <= n) printf("%d\n", m);
		else/* if (X[i] >= n)*/ printf("%d\n", n);
	}

	return 0;
}


Measured memory_bytes: 3712
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };

void printvll(vll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) cout << v[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}
void printvvll(vvll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) {
		rep(j, v[i].size()) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void prints(string s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) cout << s[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}

void printvs(vs s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) {
		rep(j, s[i].size()) {
			cout << s[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Yes(bool x) {
	if (x) cout << "Yes\n";
	else cout << "No\n";
}

void YES(bool x) {
	if (x) cout << "YES\n";
	else cout << "NO\n";
}

void yes(bool x) {
	if (x) cout << "yes\n";
	else cout << "no\n";
}


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

	ll  d, n, m, k, ans = 0, ret = M;
	bool flag = false, flag2 = false;
	string s, t;
	cin >> n >> m >> d >> k;
	cout << (n - d)*(m - k) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
int main() {
  long long n;
  cin >> n;
  long long x=1;
  long long y=1;
  long long z=1;
  for (long long i=0;i<n;i++) {
    y=(y*8%1000000007); 
  }
  for (long long i=0;i<n;i++) {
    x=(x*9%1000000007); 
  }
  for (long long i=0;i<n;i++) {
    z=(z*10%1000000007); 
  }
  long long ans=(z-x*2+y)%1000000007;
  if(ans<0){
  cout << ans+1000000007 << endl;
  }
  else{
  cout << ans << endl;
  }
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(void)
{ 
	int n;
	while( cin >> n && n )
	{
		vector < string > map(n);
		for ( int i = 0; i < n; i++ )
			cin >> map[i];

		int answer = 0;
		int cnt;

		for ( int i = 0; i < n; i++ )
		{
			for ( int j = 0; j < n; j++ )
			{
				if ( map[i][j] == '0' )
					continue;

				cnt = 0;
				while ( i+cnt < n )
				{
					if ( map[i+cnt][j] == '0' )
						break;
					cnt++;
				}
				answer = max( cnt, answer );

				cnt = 0;
				while ( j+cnt < n )
				{
					if ( map[i][j+cnt] == '0' )
						break;
					cnt++;
				}
				answer = max( cnt, answer );

				cnt = 0;
				while ( i+cnt < n && j+cnt < n )
				{
					if ( map[i+cnt][j+cnt] == '0' )
						break;
					cnt++;
				}
				answer = max( cnt, answer );

				cnt = 0;
				while ( i+cnt < n && j-cnt >= 0 )
				{
					if ( map[i+cnt][j-cnt] == '0' )
						break;
					cnt++;
				}
				answer = max( cnt, answer );
			}
		}

		cout << answer << endl;

	}
	return 0;
}

Measured memory_bytes: 996
#!/usr/bin/env python3
import sys

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

def solve(A: int, B: int, S: str):
    ret = YES
    for i, c in enumerate(S):
        if i == A and c != '-':
            ret = NO
        if i != A and not '0' <= c <= '9':
            ret = NO
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(A, B, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<stdio.h>

void swap(int *a, int *b){ //前後入れ替えを行う
    int temp=*a;
    *a=*b;
    *b=temp;
}

int bubbleSort(int A[],int N){
    int i,j;
    int sw=0;
    unsigned short flag=1;
    for(i=0;flag;i++){
        flag=0;
        for(j=N-1;j>=i+1;j--){
            if(A[j]<A[j-1]){
               swap(&A[j],&A[j-1]);
               flag=1;
               sw++;
            }
        }
    }
    return sw;
}

int main(void){
    int i,A[100],N,sw;
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    sw=bubbleSort(A,N);

    for(i=0;i<N;i++){
        if(i){
            printf(" ");
        }
        printf("%d",A[i]);
    }
    printf("\n%d\n",sw);
    return 0;
}


Measured memory_bytes: 1972
main :: IO ()
main = do
  [a, b, c, d] <- map read . words <$> getLine :: IO [Int]
  print $ solve (a, b) (c, d)

solve s@(a, b)  g@(c, d)
  | a == c = 0
  | b == d = 0
  | otherwise = x + y - gcd x y
  where
    x = abs $ a - c
    y = abs $ b - d


Measured memory_bytes: 508
#include<bits/stdc++.h>
#define pb push_back
using namespace std;

const int N = 2*1e5+7;
vector <int> adj[N];
vector <int> cover[3];
int mark[N], vis[N], p[N], n, m;

int dfs(int node, int color){
	mark[node] = color;
	cover[color].pb(node);
	for (auto v : adj[node]){
		if (!mark[v] && dfs(v, 3-color)) 
		    return 1;
		if (mark[v] != 3-color)
		    return 1;
	}
	return 0;
}

signed main(){
	cin >> n;
	for (int i=1; i<=n; i++){
		int x, y;
		cin >> x >> y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	for (int i=0; i<n; i++){
		if (!adj[i].empty()){
			if (!mark[i] && dfs(i, 2)) return 0;
		}
	}
	if (cover[1].size() <= n/3){
		for (int i=0; i<cover[1].size(); i++){
			p[cover[1][i]] = (i+1)*3;
			vis[(i+1)*3] = 1;
		}
		int idx = 0;
		for (int i=1; i<=n; i++){
			if (!vis[i]){
				vis[i] = 1;
				p[cover[2][idx]] = i;
				idx++;
			}
		}
		for (int i=1; i<=n; i++) cout << p[i] << " ";
		return 0;
	}
	else if (cover[2].size() <= n/3){
		for (int i=0; i<cover[2].size(); i++){
			p[cover[2][i]] = (i+1)*3;
			vis[(i+1)*3] = 1;
		}
		int idx = 0;
		for (int i=1; i<=n; i++){
			if (!vis[i]){
				vis[i] = 1;
				p[cover[1][idx]] = i;
				idx++;
			}
		}
		for (int i=1; i<=n; i++) cout << p[i] << " ";
		return 0;
	}
	int t, idx;
	t = 1; idx = 0;
	while (t <= n){
		p[cover[1][idx]] = t;
		vis[t] = 1;
		t+=3; idx++;
	}
	t = 2; idx = 0;
	while (t <= n){
		p[cover[2][idx]] = t;
		vis[t] = 1;
		t+=3; idx++;
	}
	t = 3;
	for (auto v : cover[1]){
		if (p[v] == 0){
			p[v] = t;
			t += 3;
		}
	}
	for (auto v : cover[2]){
		if (p[v] == 0){
			p[v] = t;
			t += 3;
		}
	}
	for (int i=1; i<=n; i++) cout << p[i] << " ";
}

Measured memory_bytes: 23028
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll n;
    cin >> n;
    vector<ll> l(n);
    REP(i,n)cin >> l[i];
    ll answer = 0;
    sort(ALL(l));
    for(int i = n-1;i >= 2;i--){
        for(int j = i-1;j >= 1;j--){
            for(int k = j-1; k >= 0;k--){
                if(l[i] < l[j]+l[k] )answer++;
            }
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<functional>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef queue<P> Q;

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(min(b,d)-max(a,c)>0)
        cout <<min(b,d)-max(a,c);
    else
        cout << '0';
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int m = sc.nextInt();
        int count = 0;
        for (int i = 0; i < m; i++) {
            int value = sc.nextInt();
            count += value;
        }
        System.out.println(Math.max(-1, n - count));
    }
}


Measured memory_bytes: 46104
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;

int main() {
  int a;
  cin >> a;
  if (a>=1000){
    cout << "ABD";
  } else {
    cout << "ABC";
  }
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
//配列の内容表示
dout << "====listの内容====\n";
for (int i = 0; i < N; i++) dout << list[i] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int x,y,i,x1,y1;
  int g1[]={1,3,5,7,8,10,12,4,6,9,11,2};
  scanf("%d%d",&x,&y);
  for(i=0;i<12;i++){
    if(x == g1[i]) x1=i;
    if(y == g1[i]) y1=i;
  }
  if(x1<7 &&y1<7){
    puts("Yes");
  }else if(7<=x1 && x1<11 && 7<=y1 && y1<11){
    puts("Yes");
  }else{
    puts("No");
  }
  return 0;
}


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

signed main()
{
    int n, ans;
    long double d, x, y;
    
    cin >> n >> d;
    ans = 0;
    for(int i=0; i<n ;i++ ){
        cin >> x >> y;
        
        if(d >= sqrt(x*x + y*y)){
            ans ++;
        }
    }
    
    cout << ans << endl;
    return (0);
}

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

int main()
{
    int H, W, h, w;
    scanf("%d%d%d%d",&H,&W,&h,&w);

    if (H % h == 0 && W % w == 0)
    {
        printf("No\n");
        return 0;
    }

    int cnt_neg = (H / h) * (W / w);

    for (int x = 1; x * 1ll * (h * w - 1) < 1000000000; x++)
    {
        int y = x * 1ll * (h * w - 1) + 1;
        if ((H * W - cnt_neg) * 1ll * x > cnt_neg * 1ll * y)
        {
            printf("Yes\n");
            for (int i = 1; i <= H; i++)
            {
                for (int j = 1; j <= W; j++)
                {
                    if (i % h == 0 && j % w == 0) printf("%d ", -y);
                    else printf("%d ", x);
                }
                printf("\n");
            }
            return 0;
        }
    }

    printf("No\n");
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b=0,c=0;
  string s;
  cin>>a>>s;
  for(int i=0;i<a;i++){
    if(s[i]=='I'){
      b++;
      if(b>c) c=b;
    }
    else{
      b--;
    }
  }
  cout<<c<<"\n";
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>


//マクロ
/*動かない・・・
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _roverload3(_1,_2,_3,name,...) name
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(...) _roverload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
//*/
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++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 FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
//*/
#define All(a) (a).begin(),(a).end()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define INFL 1e18
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
int n;

//使用する関数
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 (a > b) { a = b; return 1; }
	return 0;
}

ll calc(ll a, ll b, ll p) {
	if (b == 0) return 1;
	if (b % 2 == 0) {
		ll d = calc(a, b / 2, p);
		return (d*d) % p;
	}
	return (a*calc(a, b - 1, p)) % p;
}

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

	cin >> n;

	cout << (n + 1) / 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=1e7+9;
int main()
{
    FASTINOUT;
    int x,m;
    cin>>x>>m;
    cout<<(x==m?"Yes\n":"No\n");
    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> penalty(n);
  vector<bool> accept(n);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    string s;
    cin >> s;
    --k;
    if (s == "AC") {
      accept[k] = true;
    } else {
      if (!accept[k]) {
        ++penalty[k];
      }
    }
  }
  int ac = 0, pen = 0;
  for (int i = 0; i < n; i++) {
    if (accept[i]) {
      ++ac;
      pen += penalty[i];
    }
  }
  cout << ac << " " << pen << '\n';
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <list>
#include <map>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <numeric>
 
using namespace std;

const int maxn = 102;
int arr[maxn] = {};

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

    int N;
    cin >> N;

    int ans = 0;

    for (int i = 0; i < N-1; i++) {
        cin >> arr[i];
    }

    ans += arr[0] + arr[N-2];
    for (int i = 0; i < N-2; i++) {
        ans += min(arr[i], arr[i+1]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

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



Measured memory_bytes: 256
/*---------------Go Code GO---------------*/

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

#define     PI              acos(-1.0)
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define     precision(a)    fixed<<setprecision(a)
#define     endl            '\n'
#define     Flush           cout<<flush
#define     LLMX            0x3fffffffffffffff
#define     PW2(a)          (long long)1<<a

long long arr[500005];

int main()
{
    long long i,j,k,l,m,n,o,p,q,r,tst,ans=0,a,b;
    cin>>a>>b;
    ans=__gcd(a,b);
    map<long long, long long> mp;

    k=sqrt(ans);
    for(i=2; i<=k; i++)
    {
        while(ans%i==0)
        {
            ans=ans/i;
            mp[i]++;
        }
    }
    if(ans>1)
        mp[ans]++;
    ans=mp.size();
    cout<<ans+1<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[100];
        for(int i = 0;i < n;i++){
            array[sc.nextInt() - 1]++;
        }
        int score = 0;
        for(int i = 0;i < array.length;i++){
            int count = 0;
            for(int j = array.length - 1;j >= score;j--){
                count += array[j];
            }
            if(count > score && count > 0){
                score = i + 1;
            }
        }
        System.out.println(score);
    }
}


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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vvvl vector<vector<vector<long long>>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector<string>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define bitcheck(bit,i) (bit)&(1LL<<(i))
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define Lin(s) getline(cin,(s))

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//切り上げ除算
long long cutup(long long a,long long b){return (a+b-1)/b;}

//累乗
template<typename t>
constexpr t my_pow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
    }
    return x;
}
#define pow my_pow

//chmin,chmax
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;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll a,b;
    cin>>a>>b;
    if(a+b>=24)b-=24;
    cout<<a+b<<endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define eps 1e-6
#define ll long long
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
//#define int long long
#define MEM(x,y) memset(x,y,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define fi first
#define se second
#define endl "\n"
#define pii pair<int,int>
#define fi first
#define se second
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll Max(ll a,ll b){return a>=b?a:b;}
ll Min(ll a,ll b){return a<=b?a:b;}
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res,t;res=1;t=a%c;while(b){if(b&1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
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;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
using namespace std;
//head file
int main()
{
    int n;
    cin>>n;
    int a[n+1];
    rep(i,1,n+1)
    {
        cin>>a[i];
    }
    int cnt=0;
    rep(i,1,n+1)
    {
        if(i%2==1&&a[i]%2==1)
            cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3632
n,m,v,p=map(int,input().split())
a=list(map(int,input().split()))
a.sort()

def f(x):
  if x>=n-p:
    return 1
  elif a[x]+m<a[n-p]:
    return 0
  else:
    ct=(p-1)*m+m+x*m
    for i in range(x+1,n-p+1):
      ct+=a[x]+m-a[i]
    if ct>=m*v:
      return 1
    else:
      return 0

L=-1;R=n
while R-L>1:
  x=(L+R)//2
  if f(x)==1:
    R=x
  else:
    L=x
print(n-L-1)

Measured memory_bytes: 62576
h, w = map(int, input().split())
s = [list(input()) for _ in range(0, h)]

dx = [1, 0, -1, 0, 1, -1, -1, 1]
dy = [0, 1, 0, -1, 1, 1, -1, -1]

for i in range(0, h):
    for j in range(0, w):
        if s[i][j] != '.':
            continue

        cnt = 0
        for k in range(0, 8):
            ni = i + dy[k]
            nj = j + dx[k]

            if not (ni < 0 or h <= ni) and not (nj < 0 or w <= nj) and s[ni][nj] == '#':
                cnt += 1

        s[i][j] = str(cnt)

[print(''.join(s[ii])) for ii in range(0, h)]


Measured memory_bytes: 9108
#include <stdio.h>

#define MAX 100
//#define INF 10000000;


void MatrixChainOrder();
int min(int,int);

int m[MAX][MAX];
int p[MAX];

int n;

int main(){

  int i,j,r,c;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d%d",&r,&c);
    p[i]=r;
    p[i+1]=c;
  }

  MatrixChainOrder();

  printf("%d\n",m[1][n]);

  return 0;
}


void MatrixChainOrder(){

  int i,j,k,l,q;

  for(i=1;i<=n;i++) m[i][i]=0;

  for(l=2;l<=n;l++){

    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=1000000000;

      for(k=i;k<=j-1;k++){
	q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	m[i][j]=min(m[i][j],q);
}
}
}

}

int min(int x,int y){

  int m;

  if(x<=y){
    m=x;
    return x;
  }
  else{
    m=y;
    return y;
  }
}

Measured memory_bytes: 636
N = int(input())

rate = list( map(int, input().split()))

color = [0] * 8

a = 400 
free = 0
    
for i in range(0,N):
    if rate[i] < a:
        color[0] = 1
    elif a <= rate[i] < 2*a:
        color[1] = 1
    elif 2*a <= rate[i] < 3*a:
        color[2] = 1
    elif 3*a <= rate[i] < 4*a:
        color[3] = 1
    elif 4*a <= rate[i] < 5*a:
        color[4] = 1
    elif 5*a <= rate[i] < 6*a:
        color[5] = 1
    elif 6*a <= rate[i] < 7*a:
        color[6] = 1
    elif 7*a <= rate[i] < 8*a:
        color[7] = 1
    elif 8*a <= rate[i]:
        free += 1
        

min_color = 0
max_color = 0

min_color = color.count(1)
max_color = min_color + free

print( max(min_color,1), max_color)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
struct city{
	int id1;
	int id2;
	int year;
	int num;
};
city cities[100002];
bool cmp1(city a,city b){
	if(a.id1!=b.id1){
		return a.id1<b.id1;
	}else{
		return a.year<b.year;
	}
}
bool cmp2(city a,city b){
	return a.num<b.num;
}
void add0(int a){
	if(a<10){
		cout<<"00000";
	}else if(a<100){
		cout<<"0000";
	}else if(a<1000){
		cout<<"000";
	}else if(a<10000){
		cout<<"00";
	}else if(a<100000){
		cout<<"0";
	}
	cout<<a;
}
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>cities[i].id1>>cities[i].year;
		cities[i].num=i;
	}
	sort(cities,cities+m,cmp1);
	int t1=0;
	cities[0].id2=1;
	for(int i=1;i<m;i++){
		if(cities[i].id1!=cities[i-1].id1){
			cities[i].id2=1;
		}else{
			cities[i].id2=cities[i-1].id2+1;
		}
	}
	sort(cities,cities+m,cmp2);
	for(int i=0;i<m;i++){
		add0(cities[i].id1);
		add0(cities[i].id2);
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3072
n = int(input())
arr = [0] + list(map(int,input().split())) + [0]
tmp= [ abs(arr[i] - arr[i + 1]) for i in range(len(arr) - 1)]
_sum = sum(tmp)
for i in range(n):
    ans = _sum - tmp[i] - tmp[i + 1] + abs(arr[i + 2] - arr[i])
    print(ans)

Measured memory_bytes: 14040
/*
Dont BLUNDER
*/

// #pragma GCC optimize("O3")
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimization ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;


 */
//#define d long double
#define int long long
#define pii pair<int,int>
#define pb push_back
#define endl '\n'
#define pi acos(-1)

#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
int const mod1 = 998244353;
int const mod = 1000000007;
#define bitcount(x)       __builtin_popcountll(x)
#define l first
#define r second
const int inf = LLONG_MAX;
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// * Using PBDS *
/*typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
               os; */

struct cmp
{
	bool operator() (pii a, pii b) {
		return (a.l < b.l);
	}
};

int modexp(int x, int n) {
	if (n == 0) {
		return 1;
	}
	else if (n & 1) {
		return (modexp((x * x) % mod, n / 2) % mod * x % mod) % mod;
	}
	else {
		return (modexp((x * x) % mod, n / 2) % mod);
	}
}

int modinv(int n)
{
	return modexp(n, mod - 2);
}

int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}



signed main()
{

// #ifndef ONLINE_JUDGE

// 	freopen("inp.txt", "r", stdin);

// 	freopen("out1.txt", "w", stdout);
// #endif
	haha
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ans;
	ans = max(a * c, b * d);
	ans = max(ans, b * c);

	ans = max(ans, a * d);
	if ((b >= 0 && a < 0) || (d >= 0 && c < 0))
		ans = max(ans, 0ll);
	cout << ans;





}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

ll lcm(ll a,ll b){
    return (a*b/gcd(a,b));
}

int main(){
    ios::sync_with_stdio(false);
    string S; cin >> S;
    string ans="WA";
    int count=0,upper=0;
    if(S[0]=='A'){
        for(int i=2;i<=S.length()-2;i++){
            if(S[i]=='C') count++; 
        }
        if(count==1){
            rep(i,S.length()){
                if(('A'<=S[i])&&(S[i]<='Z')) upper++;
            }
            if(upper==2) ans="AC";
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

const int sz = 100010;
vector<int> G[sz];
vector<int> rG[sz];
int cmp[sz];
bool visit[sz];

void dfs(int v, vector<int> &vs){
  visit[v] = true;
  REP(i, G[v].size()) if(!visit[G[v][i]]) dfs(G[v][i], vs);
  vs.push_back(v);
}

void rdfs(int v, int k){
  visit[v] = true;
  cmp[v] = k;
  REP(i, rG[v].size()) if(!visit[rG[v][i]]) rdfs(rG[v][i], k);
}

int scc(int V){
  int k = 0;
  vector<int> vs;
  
  memset(visit, false, sizeof(visit));  
  REP(i, V) if(!visit[i]) dfs(i, vs);
  memset(visit, false, sizeof(visit));
  reverse(ALL(vs));
  REP(i, vs.size())if(!visit[vs[i]]) rdfs(vs[i], k++);
  return k;
}

void clear(){
  REP(i, sz){
    G[i].clear();
    rG[i].clear();
  }
}

void add_edge(int from, int to){
  G[from].push_back(to);
  rG[to].push_back(from);
}

int main(){
  int n;
  while(cin >> n && n){
    clear();
    char dir;
    vector<int> x(n * 2);
    vector<int> y(n * 2);
    vector<int> d(n * 2);
    
    REP(i, n){
      cin >> x[i] >> y[i] >> dir;
      x[i+n] = x[i];
      y[i+n] = y[i];
      
      if(dir == 'x'){
        x[i+n]++;
        d[i] = 0;
        d[i+n] = 2;
      }
      
      if(dir == 'y'){
        y[i+n]++;
        d[i] = 1;
        d[i+n] = 3;
      }
    }
    
    n *= 2;
    map<P, int> futon;    
    REP(i, n) futon[P(x[i], y[i])] = i;
    
    REP(i, n){
      int dx[4] = {1, 0, -1, 0};
      int dy[4] = {0, 1, 0, -1};     
      REP(j, 4){
        int xa = x[i] + dx[j];
        int ya = y[i] + dy[j];

        if(futon.find(P(xa, ya)) != futon.end()){
          int f = futon[P(xa, ya)];
          if(j == d[i]){
            add_edge(i, f + n);
            add_edge(i + n, f);
            add_edge(f, i + n);
            add_edge(f + n, i);
          }else{
            add_edge(i + n, f + n);
            add_edge(f + n, i + n);
            add_edge(i, f);
            add_edge(f, i);
          }
        }
      }
    }

    bool possible = true;
    scc(2 * n);
    REP(i, n){
      possible &= cmp[i] != cmp[n + i];
    }
    cout << (possible ? "Yes" : "No") << endl;
  }
  return 0;
}

Measured memory_bytes: 16868