akhauriyash/Code-Regression huggingface dataset:
N = int(input())
coordinate = [0]
coordinate = coordinate + list(map(int, input().split()))
coordinate.append(0)
summ = 0

for i in range(N + 1):
    summ += abs(coordinate[i + 1] - coordinate[i])

diff_coorinate = []

for i in range(N):
    distance = abs(coordinate[i + 2] - coordinate[i])
    diff_coorinate.append(distance)

for i in range(N):

    next = coordinate[i + 1] - coordinate[i]
    n_next = coordinate[i + 2] - coordinate[i + 1]
    
    if (next * n_next >= 0):
        ans = summ
    elif (coordinate[i + 2] - coordinate[i] >= 0):
        d = abs(min(next, n_next))
        ans = summ - 2 * d
    else:
        d = max(next, n_next)
        ans = summ - 2 * d
    
    print(ans)


Measured memory_bytes: 14048
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
typedef long double lb;
typedef vector<int,vector<int>> vvec;
typedef long double ld;
typedef pair<int,int> P;

//----***Like a Pythonista***----
#define REP(i,j,n) for (ll i=j;i<(n);i++)
#define RREP(i,n,j) for (ll i = n; j<i;i--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
inline ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }

//----***定数***----
const int MOD=1000000007;
#define INF 1e9;
#define EPS 1e-9;

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
#define here  cout<<"Here"<<endl;


//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}initial_;

signed main(){
  int N,a;cin>>N;
  vector<int> A(N),B(N+1),C(N+1);
  int odd_n=0,even_n=0;
  REP(i,0,N){
    cin>>a;
    A[i]=a;
  }
  B[0]=0;
  C[0]=0;
  REP(i,1,N+1){
    if(i%2==1){
      B[i]=B[i-1]+A[i-1];
      C[i]=C[i-1]-A[i-1];
    }
    else{
      B[i]=B[i-1]-A[i-1];
      C[i]=C[i-1]+A[i-1];
    }
  }
  REP(i,1,N+1){
    int ans=0;
    if(i%2==0){
      ans=C[i-1]+B[N]-B[i-1];
    }else{
      ans=B[i-1]+C[N]-C[i-1];
    }
    print(-ans)
  }

}


Measured memory_bytes: 3712
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define ll long long int
#define sp ' '
#define intmax 2147483647
#define intmin -2147483647
#define llmax 9223372036854775807
using namespace std;

string s, t;

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	ll g = gcd(x, y);
	return x / g * y;
}

int main(){
	cin >> s >> t;
	lp(s.size()) {
		if (s.substr(0, i+1) == t.substr(s.size() - i - 1, i+1) && s.substr(i + 1, s.size() - i - 1) == t.substr(0, s.size() - i - 1)) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

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

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

	int cnt = 0;
	rep(i, n) {
		if (p[i] != i + 1) cnt++;
	}

	puts(cnt < 3 ? "YES" : "NO");

	return 0;
}

Measured memory_bytes: 256
import sys
from functools import reduce
from operator import mul
from collections import Counter

input = sys.stdin.readline


def cmb(n, r):
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


def main():
    n = int(input())
    lines = ["".join(sorted(input().strip())) for _ in range(n)]
    count = 0
    for _, v in Counter(lines).most_common():
        if v == 1:
            break
        count += cmb(v, 2)
    print(count)


if __name__ == "__main__":
    main()


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

int main(){
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    auto it = lower_bound(a.begin(), a.end(), a[n-1]/2);
    int idx1 = it - a.begin();
    int idx2 = idx1 - 1;
    int m1 = (a[n-1]+1)/2;
    int m2 = a[n-1]/2;
    if(min(abs(a[idx1] - m1), abs(a[idx1] - m2)) < abs(a[idx2] - m2)) cout << a[n-1] << " " << a[idx1] << endl;
    else cout << a[n-1] << " " << a[idx2] << endl;

}

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

int main(){
    int A, B, C, X, Y, ans = 0;
    scanf("%d %d %d %d %d", &A, &B, &C, &X, &Y);
    if(C + C <= A + B) {
        int Z = min(X, Y);
        X -= Z, Y -= Z;
        ans += 2 * C * Z;
    }
    if(C + C <= A) ans += 2 * C * X, X = 0;
    if(C + C <= B) ans += 2 * C * Y, Y = 0;
    ans += A * X + B * Y;
    printf("%d\n", ans);
    return 0;
}

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

int main(void){
	string s;
	cin>>s;
	int N=(int)s.size(),cnt=0;
	rep(i,N){
		if(i<=(N-1)/2){
			if(s[i]=='p')cnt--;
		}else if(s[i]=='g')cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


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

using namespace std;
using ll = long long;

int main(){
    int n;
    cin>>n;
    for (int i = 0; i < n; ++i) {
        int a;
        cin>>a;
        if(a%2==0){
            if(a%3!=0&&a%5!=0){
                cout<<"DENIED"<<endl;
                return 0;
            }
        }
    }
    cout<<"APPROVED"<<endl;
    return 0;
}

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

using namespace std;
typedef long long LL;

int main() {
	string s;
	cin >> s;
	int l1 = s.length();
	bool bad = 0;
	for (int i = 0; i < l1 - 1; i++) {
		if (s[i] == s[i + 1]) bad = 1;
	}	
	if (bad) printf("Bad\n");
	else printf("Good\n");
}

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

int n, W, w, v;
long long mn[100005];

int main() {
    cin >> n >> W;
    for (int i = 1; i <= 100000; i++){
        mn[i] = 1e18;
    }
    for (int i = 0; i < n; i++){
        cin >> w >> v;
        for (int j = 100000; j >= v; j--){
            mn[j] = min(mn[j], mn[j-v]+w);
        }
    }
    for (int i = 100000; i >= 0; i--){
        if (mn[i] <= W){
            cout << i << "\n";
            break;
        }
    }
}


Measured memory_bytes: 4384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

ll solve(ll a, ll b, ll c, ll d) {
    chmax(a, 0LL);
    chmax(b, 0LL);
    chmax(c, 0LL);
    return 3 * min({a % 2, c % 2, d % 2}) + a / 2 * 2 + c / 2 * 2 + d / 2 * 2 + b;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a, b, c, d, e, f, g;
    cin >> a >> b >> c >> d >> e >> f >> g;
    ll ans = 0;
    REP(i, 0, 2) {
        REP(j, 0, 2) {
            REP(k, 0, 2) {
                chmax(ans, solve(a - i, b, d - j, e - k));
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
ans = {}
for x in sys.stdin.readlines():
    word, page = x.rstrip().split()
    ans.setdefault(word,[])
    ans[word].append(page)

for k in sorted(ans.keys()):
    print k
    print " ".join(sorted(ans[k], cmp=lambda a,b: int(a)-int(b)))

Measured memory_bytes: 4220
#include<iostream>
#include<cmath>
using namespace std;
int maxtime(int a)
{
	return (a+9)/10 * 10;
}
int rem(int a)
{
	return maxtime(a) - a;
}
int main()
{
	//using namespace std;
	ios_base:: sync_with_stdio(false);
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	int sum = maxtime(a) + maxtime(b) + maxtime(c) + maxtime(d) + maxtime(e);
	sum -= max(rem(a), max(rem(b), max(rem(c), max(rem(d), rem(e)))));
	cout << sum << endl;
	return 0;
}
	


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

int A[100];
int main() {
  A[0] = 1;
  A[1] = 1;
  A[2] = 2;

  for(int i = 3; i <= 30; i++) {
    A[i] = A[i-1] + A[i-2]+ A[i-3];
  }
  
  int N;
  while(cin >> N && N)
    cout << A[N]/3650 + 1 << endl;
}

Measured memory_bytes: 3032
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;

const int N = 1e5 + 200 ;
const ll inf = 1e14;
int n , k;
ll a[N] , mem[N];

ll dp(int i){
	if(i == n-1) return 0;
	if(i >= n) return inf;
	ll &ret = mem[i];
	if(ret != -1)
		return ret;
	ret = inf;
	for (int j=1 ; j<=k ; j++) ret = min(ret , abs(a[i] - a[i+j]) + dp(i+j));
	return ret;
}

int main(){
	memset(mem , -1 , sizeof mem);
	scanf("%d%d"  ,&n , &k);
	for(int i=0 ; i<n ; i++)
		scanf("%lld"  ,a+i);
	printf("%lld" , dp(0));
}


Measured memory_bytes: 6528
implicit none
integer:: n, i, j, a, b, count_1, count_2, count_3
integer,allocatable,dimension(:):: p

read(5,*) n

if (n == 25) then
    write(6,*) "Christmas"
else if (n == 24) then
    write(6,*) "Christmas Eve"
else if (n == 23) then
    write(6,*) "Christmas Eve Eve"
else 
    write(6,*) "Christmas Eve Eve Eve"
endif

end

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//size_t f = string::npos
//make pair

int main(){
      string s;cin >> s;
      int ans = 0;
      int n = s.length();
      for(int i = 2;i < n;i += 2){
            if(s.substr(0, i / 2) == s.substr(i / 2,i / 2))ans = i;
      }
      cout << ans;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;    
const int N = 2e5 + 5;



signed main(){
    IOS;
    unsigned int a;
    double b;
    cin >> a >> b;
    b = b * 100;
    cout << a * (unsigned int)round(b) / 100 << endl;
    return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) static_cast<int>((x).size())

using LL = long long;
template<class T, size_t D>
struct vec : vector<vec<T, D - 1>> {
  template<class... Args>
  vec(size_t n = 0, Args... args)
    : vector<vec<T, D - 1>>(n, vec<T, D - 1>(args...)) {}
};
template<class T>
struct vec<T, 1> : vector<T> {
  template<class... Args>
  vec(Args... args)
    : vector<T>(args...) {}
};

template<class T>
inline bool asMn(T& a, const T& b) { return a > b ? a = b, true : false; }
template<class T>
inline bool asMx(T& a, const T& b) { return a < b ? a = b, true : false; }
inline int nex(int i, int n) { return i == n - 1 ? 0 : i + 1; }
inline int pre(int i, int n) { return !i ? n - 1 : i - 1; }

mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

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

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

  vec<char, 2> ans(100, 100);
  for (int i = 0; i < 100; ++i) {
    for (int j = 0; j < 100; ++j) {
      ans[i][j] = (i < 50 ? '#' : '.');
    }
  }
  --a; --b;
  for (int x = 0, y = 0; a--; y += 2) {
    if (y == 100) {
      x += 2;
      y = 0;
    }
    ans[x][y] = '.';
  }
  for (int x = 99, y = 0; b--; y += 2) {
    if (y == 100) {
      x -= 2;
      y = 0;
    }
    ans[x][y] = '#';
  }

  cout << sz(ans) << ' ' << sz(ans[0]) << '\n';
  for (auto& i : ans) {
    for (auto& j : i) {
      cout << j;
    }
    cout << '\n';
  }

  return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<ll,ll>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
#define F first
#define S second
const int INF = 1 << 20;
const int MOD = 1e9+7;





int main(){
    ll n;
    cin >> n;
    ll a[n],b[n];
    ll asum = 0,bsum = 0;
    REP(i,n){
        cin >> a[i];
        asum += a[i];
    }
    REP(i,n){
        cin >> b[i];
        bsum += b[i];
    }
    if(bsum > asum){
        cout << -1 << endl;
        return 0;
    }
    P d[n];
    ll res = 0,f = 0,fsum = 0;
    REP(i,n){
        P p = mk(a[i]-b[i],a[i]);
        if(a[i]-b[i] < 0){
            f++;
            fsum += (a[i]-b[i])*(-1);
        }
        d[i] = p;
    }
    sort(d,d+n);
    /*
    REP(i,n)
        cout << d[i].first << "     " << d[i].second << endl;
        */
    int x = n-1;
    while(fsum > 0){
        fsum -= d[x].first;
        res++;
        x--;
    }
    res += f;
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3328
def check(limit, max_training, costs, volumes):
    from math import floor
    remain_training = max_training
    for id, (cost, volume) in enumerate(zip(costs, volumes)):
        if cost * volume <= limit:
            continue
        else:
            lowest_cost = floor(limit / volume)
            remain_training -= (cost - lowest_cost)
        if remain_training < 0:
            return False
    return True


def main():
    n, k = map(int, input().rstrip("\n").split(" "))
    costs = list(map(int, input().rstrip("\n").split(" ")))
    volumes = list(map(int, input().rstrip("\n").split(" ")))

    costs.sort()
    volumes.sort(reverse=True)
    queue = []
    total_cost = 0

    success = False

    max_cost = max([cost * volume for cost, volume in zip(costs, volumes)])
    min_cost = 0

    while (min_cost + 1) < max_cost:
        center_cost = (min_cost + max_cost) // 2
        success = check(center_cost, k, costs, volumes)
        if success:
            max_cost = center_cost
        else:
            min_cost = center_cost
    if check(min_cost, k, costs, volumes):
        print(min_cost)
    else:
        print(max_cost)


if __name__ == '__main__':
    main()

Measured memory_bytes: 119388
#include<iostream>
int main()
{
  int N = 0;
  scanf("%d",&N);
  long long abc = 1;
  for(int a = 0; a < N; a++)
  {
    abc = abc * 10;
    abc = abc % 1000000007;
  }
  long long def = 1;
  for(int a = 0; a < N; a++)
  {
    def = def * 8;
    def = def % 1000000007;
  }
  long long ghi = 1;
  for(int a = 0; a < N; a++)
  {
    ghi = ghi * 9;
    ghi = ghi % 1000000007;
  }
  long long A = 0;
  if(ghi >= def)
    A = ghi - def;
  else
    A = 1000000007 + ghi - def;
  A = ((A * 2) + def) % 1000000007;
  if(abc >= A)
  {
    long long ans = abc - A;
    printf("%lld",ans);
  }
  else
  {
    long long ans = (abc + 1000000007) - A;
    printf("%lld",ans);
  }
}


Measured memory_bytes: 3180
#include <iostream>
#include <string>
int a[105][105];
bool tf[105][105];
int w , h;
int dirc[4][2] = {{-1 , 0} , {1 , 0} , {0 , -1} , {0 , 1}};
void dfs(int x , int y){
    tf[y][x] = true;
    for(int i = 0;i < 4;i++){
        int nx = x + dirc[i][0] , ny = y + dirc[i][1];
        if(nx >= 0 && nx < w && ny >= 0 && ny < h && tf[ny][nx] == false && a[ny][nx] == a[y][x]){
            dfs(nx , ny);
        }
    }
}
int main(){
    while(std::cin >> h >> w){
        if(h == 0 && w == 0){
            break;
        }
        std::string s;
        for(int i = 0;i < h;i++){
            std::cin >> s;
            for(int j = 0;j < w;j++){
                a[i][j] = (s[j] == '#')? 1 :
                          (s[j] == '*')? 2 : 3; 
                tf[i][j] = false;
            }
        }
        int ans = 0;
        for(int i = 0;i < h;i++){
            for(int j = 0;j < w;j++){
                if(tf[i][j] == false){
                    ans++;
                    dfs(j , i);
                }
            }
        }
        std::cout << ans << "\n";
    }
}


Measured memory_bytes: 3816
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		for (int turtle = 0; turtle <= x; turtle++) {
		    if (turtle * 4 + (x - turtle) * 2 == y) {
		        System.out.println("Yes");
		        return;
		    }
		}
	    System.out.println("No");
	}
}


Measured memory_bytes: 35624
/*input
5
1 1 2 2 2
*/
#include<iostream>
using namespace std;

#define int long long 
#define double long double

#define f first
#define s second
#define mp make_pair
#define pb push_back

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int fast_ex(int a,int n,int m){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= fast_ex(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  int n;
  int pref = 1;
  int ans = 0;
  int prev;
  cin >> n;n--;
  cin >> prev;
  while(n--){
      int now;cin >> now;
      if(now == prev)pref++;
      else { 
      	ans += (pref)/2;
      	pref = 1;
      }
      prev = now;
  }
  ans += pref/2;
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
ll int large=(ll int)1e13+7;
ll int mod=(ll int)1e5;
ll int const N=(ll int)1e5+10;

ll int mod_exp(ll int x,ll int n)
{
    ll int result=1;
    while(n>0)
    {
        if(n%2==1)
            result=(result*x)%mod;
        x=(x*x)%mod;
        n=n/2;
    }
    return result;
}

ll int mod_inverse(ll int a)
{
    return mod_exp(a,mod-2);
}




int main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
ll int T,i,j,ij,k1,k2;
T=1;
//cin>>T;
while(T--)
{
   ll int h,w,k;
   cin>>h>>w>>k;
   char a[h][w];


   ll int num=0;
   rep(i,0,h)
   rep(j,0,w)
   {
   cin>>a[i][j];
   if(a[i][j]=='#')
    num++;
   }

   ll int ans=0;

  for(ll int i=0;i<mod_exp(2,h);i++)
    for(ll int j=0;j<mod_exp(2,w);j++)
  {
      ll int var=0;
      rep(k1,0,h)
      rep(k2,0,w)
      {
        //  cout<<i<<" "<<j<<" "<<k1<<" "<<k2<<endl;
         if(( (i& (1<<k1))!=0 && (j&(1<<k2))!=0 ) && a[k1][k2]=='#')
             var++;
      }
    //  cout<<var<<endl;
      if(var==k)
        ans++;
  }



   cout<<ans;

}
return 0;
}
















Measured memory_bytes: 3652
// Header {{{
#include <bits/stdc++.h>

using namespace std;
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;
typedef unsigned long long int ull;
typedef long long int ll;
#define rep(i,a,b) for (ll i=(a); i<(b); i++)
typedef pair<ll,ll> PLL;
// }}}

signed main() {
    bool ans=true;
    ll c[3][3];
    rep(y,0,3){
        rep(x,0,3){
            cin>>c[y][x];
        }
    }

    set<ll> s;
    rep(x,0,3) s.insert(c[1][x]-c[0][x]);
    if (s.size()!=1) ans=false;

    s={};
    rep(x,0,3) s.insert(c[2][x]-c[1][x]);
    if (s.size()!=1) ans=false;

    s={};
    rep(y,0,3) s.insert(c[y][0]-c[y][1]);
    if (s.size()!=1) ans=false;

    s={};
    rep(y,0,3) s.insert(c[y][2]-c[y][1]);
    if (s.size()!=1) ans=false;

    cout<<(ans?"Yes":"No")<<endl;

    return 0;
}


Measured memory_bytes: 256
n, x = (int(i) for i in input().split())
l_array = [int(i) for i in input().split()]

counter = 0
coordinate = 0

while counter < n+1 and coordinate<=x:
    counter+=1
    if counter == n+1:
        break
    else:
        coordinate += l_array[counter-1]


print(counter)


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

//{ SFT
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, a) for (auto &&i : (a))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builitin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end());
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
#define F first
#define S second
#define cauto (const auto &)
template <class A, class B>
using pii = vector<pair<A, B>>;
//昇順
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;
//降順
template <class T>
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr long long mod1 = 1e9 + 7;
constexpr long long mod2 = 998244353;
//} END

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

    int n,cnt=0;
    cin>>n;
    umap<string,int> x;
    string s;

    rep(i,0,n){
        cin>>s;
        x[s]++;
    }

    cout<<x.size()<<'\n';
    return 0;
}

Measured memory_bytes: 17700
from operator import itemgetter
import itertools
def inpl(): return list(map(int, input().split()))
def cost(x, y):
    if x == y:
        return float('inf')
    return D * abs(x - y) + A[x] + A[y]
N, D = inpl()
A = inpl()
Right = [(v - i*D, i) for i, v in enumerate(A)]
Left = [(v + i*D, i) for i, v in enumerate(A)][::-1]
Right = list(map(itemgetter(1), itertools.accumulate(Right, min)))
Left = list(map(itemgetter(1), itertools.accumulate(Left, min)))[::-1]
ans = 0
hub = []
for i, (l, r) in enumerate(zip(Left, Right)) :
    if i == l == r:
        hub.append(i)
    else:
        ans += min(cost(i, r), cost(i, l))
print(ans + sum([cost(i, j) for i, j in zip(hub, hub[1:])]))


Measured memory_bytes: 72976
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
// #define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    int n;
    cin >> n;
    int d[9] = {};
    rep(i, 0, n){
        int a;
        cin >> a;
        d[min(8, a / 400)]++;
    }
    int MIN = 0, MAX = 0;
    rep(i, 0, 8) if(d[i]) MIN++;
    MAX = MIN;
    if(d[8]){
        MAX = MIN + d[8];
    }
    if(MIN == 0 && d[8]) MIN = 1;
    cout << MIN << " " << MAX << endl;
}

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

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

LL N, ans;

void dfs(string s){
	int seven=0, five=0, three=0;
	int n=s.size();
	if(n>9) return;
	LL num=0;
	rep(i,n){
		if(s[i]=='7') seven++, num+=7*pow(10,n-1-i);
		if(s[i]=='5') five++, num+=5*pow(10,n-1-i);
		if(s[i]=='3') three++, num+=3*pow(10,n-1-i);
	}
	if(seven and five and three and num<=N) ans++;
	dfs(s+"3");
	dfs(s+"5");
	dfs(s+"7");
}

int main(){
	cin >> N;
	dfs("");
	cout << ans << endl;

	return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll, int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const int N = 100005;

int see[1000005];

void solve(){
	int n;
	cin >> n;
	vi v(n);
	for(int i = 0; i < n; i++){
		cin >> v[i];
		see[v[i]]++;
	}
	int sum = 0;
	for(auto i:v){
		for(int j = 1; j <= sqrt(i); j++){
			if((i%j) == 0){
				int a = i/j, b = j;
				if((a != i and see[a]) or (a == i and see[a] > 1)){
					sum++;
					break;
				}
				if(a == b)continue;
				if((b != i and see[b]) or (b == i and see[b] > 1)){
					sum++;
					break;
				}
			}
		}
	}
	cout << n-sum << '\n';
}

int main(){
	fastio;
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 7760
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

int main(void)
{
    char w[101];
    char tmp;
    int i, j;
    bool flag = false;
    scanf("%s", w);
    for (i=strlen(w)-2; i>=0; i--)
    {
        for (j=0; j<=i; j++)
        {
            if (w[j] > w[j+1]) {
                tmp = w[j+1];
                w[j+1] = w[j];
                w[j] = tmp;
            }
        }
    }
    for (i=0; i<=strlen(w)-2; i++)
    {
        if (w[i] != w[i+1] && (i+1)%2 != 0) {
            flag = true;
            break;
        }
    }
    if (flag) {
        printf("No\n");
    } else {
        printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 128
//この問題は、N個の頂点に1～Kの番号を割り振り、同じ番号どうしはすでに結ばれてるとしたときのMSTを求める問題。
//とりあえず、同じ色番号で縮約しておく(色0同士は縮約しない)。縮約後のグラフをG2とする。G2について問題を解けばよい。
//ここで、どの辺が全域木に使われるかを考える。これは、G2上のK-1辺であって閉路のできないもの。
//逆に、閉路ができないようK-1辺を選ぶと、グラフが連結になるようにK彩色できる。辺が一つ増えるごとに色を一つ増やせるイメージ。
//
//よってこの問題は, 同じ色番号で縮約したのち連結成分数がN-K+1になるまでクラスカルをすると解ける。縮約はi=1,2,…,Kについて
//vec[i] = 色番号がiの頂点の集合
//とおいて、頂点vec[i][0],…,vec[i][k-1] (kはvec[i]の大きさ)をマージしていけばOK. 連結成分はUnionFind（木）で表現しておけば高速.
//
//ポイント：
//各頂点に何を塗るかではなく、どの辺を選ぶかを先に考える。
//コメント1行目のように問題を要約できると、この発想に至りやすい。

#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(i = 0; i < n; i++)
#define REP(i, a, b) for(i = a; i < b; i++)
#define int long long
using namespace std;

struct Edge {
	int from, to, cost;
	Edge() {}
	Edge(int from, int to, int cost) {
		this->from = from; this->to = to; this->cost = cost;
	}
	bool operator<(Edge &r) { return cost < r.cost; }
};

struct UF {
	int par[100000];
	UF() { int i; rep(i, 100000) par[i] = i; }
	int root(int x) { if (par[x] == x) return x; return par[x] = root(par[x]); }
	void unit(int x, int y) { x = root(x); y = root(y); par[x] = y; }
	bool same(int x, int y) { return root(x) == root(y); }
};

int n, m, k;
int c[100000];
vector<int> vec[100001];
Edge edges[100000];

signed main() {
	int i, j;
	
	cin >> n >> m >> k;
	rep(i, n) {
		cin >> c[i];
		vec[c[i]].push_back(i);
	}
	rep(i, m) {
		int a, b, w;
		cin >> a >> b >> w;
		a--; b--;
		edges[i] = Edge(a, b, w);
	}
	
	static UF uf;
	REP(i, 1, k + 1) {
		rep(j, (int)vec[i].size() - 1) {
			uf.unit(vec[i][j], vec[i][j + 1]);
		}
	}
	sort(edges, edges + m);
	
	int cnt = 0;
	int ans = 0;
	rep(i, m) {
		int u = edges[i].from;
		int v = edges[i].to;
		if (uf.same(u, v)) continue;
		uf.unit(u, v);
		cnt++;
		ans += edges[i].cost;
		if (cnt >= k - 1) break;
	}
	
	if (cnt < k - 1) { cout << -1 << endl; }
	else { cout << ans << endl; }
	return 0;
}

Measured memory_bytes: 9600
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 19 22:03:19 2020

@author: liang
"""

N, X, M = map(int,input().split())
mod_set = {X}
mod_lis = [X]
A = [0]*(10**6+1)
A[0] = X
flag = False
#for i in range(1,N):
"""
【for文のループ用の変数を、
　●for文外で使ったり
 ●for文内で書き換えたり
 してはいけない】
 (理由)
●for文外で使うとき、for文に入らない入力値の場合
　　【未定義】
　となり、エラーが出る。　
 ⇒　【for文外で定義済み】の他の変数に保存する
●for文内で書き換えると、ループが壊れてしまう
 ⇒　一旦別の変数に保存し、その変数を書き換える

【整数の切り捨て演算は計算順序に注意】
*ans += T_sum * (N-j)//T
　⇒T_sum * (N-j)　を Tで割っているのでダメ
<対策 1: 切り捨て演算は括弧で囲む>
 ⇒ans += T_sum * ( (N-j)//T )
<対策 2: 切り捨て演算は予め計算しておく>
 ●divmod(a,b) => return (a//b,a%b)

"""
l = 1
for i in range(1,min(10**6,N)):
    l = i
    tmp = A[i-1]**2%M
    if tmp in mod_set:
        flag = True
        break
    A[i] = tmp
    mod_set.add(tmp)
    mod_lis.append(tmp)

if flag:
    j = mod_lis.index(tmp)
else:
    j = l
T = l - j
ans = 0
if T != 0:  
    #print("A")
    ans += sum(mod_lis[:j])
    T_sum = sum(mod_lis[j:])
    q, r = divmod(N-j,T)
    ans += T_sum * q
    #print((N-j)//T, T_sum)
    T_lis = mod_lis[j:]   
    ans += sum(T_lis[:r])
else:
    #print("B")
    ans = sum(mod_lis)
   # print(mod_lis)
#print(T_lis)
#print((N-j)%T)
#print(T_lis[:10])
print(ans)
#print(T_sum)
#print(sum(T_lis))

Measured memory_bytes: 21288
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int n;
    scanf("%d", &n);

    ll count = 0;
    for (int i = 1; i < n; i++) {
        if(n % i == 0) count += n / i - 1;
        else count += n / i;
    }

    printf("%lld\n", count);
    return 0;
}

Measured memory_bytes: 3824
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define _ << " _ " <<
#define TRACE(x) cerr << #x << " = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define debug
#define TRACE(x)

using namespace std;

typedef long long llint;

const int MAXN = 200010;
const int MAXLG = 22;
const int MAXMASK = (1 << MAXLG) + 10;

int n, maxv, x[MAXN], r[MAXN][MAXLG], l[MAXN][MAXLG];
int dpL[MAXMASK], dpR[MAXMASK], p[MAXN];

int main(void) {
  scanf("%d %d",&n,&maxv);
  REP(i, n) scanf("%d",&x[i]);

  int lg = 0;
  for (int v = maxv; v >= 0; v /= 2, ++lg) {
    for (int i = n - 1; i >= 0; --i) {
      r[i][lg] = i;
      if (i < n - 1 && x[i+1] - x[i] <= v)
	r[i][lg] = r[i+1][lg];
    }
    for (int i = 0; i < n; ++i) {
      l[i][lg] = i;
      if (i > 0 && x[i] - x[i-1] <= v)
	l[i][lg] = l[i-1][lg];
    }

    REP(i, n)
      TRACE(i _ lg _ l[i][lg] _ r[i][lg]);
    if (v == 0) break;
  }

  REP(mask, (1 << (lg + 1)) - 1) {
    if (mask & 1) continue;

    dpL[mask] = -1;
    dpR[mask] = n;

    REP(j, lg + 1)
      if (mask & (1 << j)) {
	TRACE(j _ dpL[mask & ~(1 << j)]);
	if (dpL[mask & ~(1 << j)] == n - 1)
	  dpL[mask] = n - 1;
	else
	  dpL[mask] = max(dpL[mask], r[dpL[mask & ~(1 << j)] + 1][j]);

	if (dpR[mask & ~(1 << j)] == 0)
	  dpR[mask] = 0;
	else
	  dpR[mask] = min(dpR[mask], l[dpR[mask & ~(1 << j)] - 1][j]);
      }
  }

  REP(mask1, (1 << (lg + 1)) - 1) {
    if (mask1 & 1) continue;
    int mask2 = ((1 << (lg + 1)) - 1) ^ mask1;
    if (mask2 & 1) mask2 ^= 1;
    
    TRACE(mask1 _ mask2 _ dpL[mask1] _ dpR[mask2]);

    int lo = dpL[mask1] + 1;
    int hi = dpR[mask2] - 1;
    if (lo > hi) {
      ++p[0];
      --p[n];
      continue;
    }

    int from = l[lo][0];
    int to = r[lo][0];

    if (from <= lo && to >= hi) {
      ++p[from];
      --p[to+1];
    }
  }

  int curr = 0;
  REP(i, n) {
    curr += p[i];
    if (curr > 0)
      printf("Possible\n");
    else
      printf("Impossible\n");
  }
  
  return 0;
}


Measured memory_bytes: 45696
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)++)
#define p(...) printf(__VA_ARGS__); cout << endl;
#define in(...) __VA_ARGS__; input__(__VA_ARGS__);
#define input(...) in(__VA_ARGS__)
#define out(...) output__(__VA_ARGS__);
#define output(...) out(__VA_ARGS__)
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](const a, const b){ return c ;}
#define key(t, x, compare) [](const t& a, const t& b){ return a x compare b x ;}

using namespace std;

using pii = pair<int, int>;

template <class... T>
void input__(T &...a) {
  for(auto v: {&a...}) {
    cin >> *v;
  }
}

template <class... T>
void output__(T ...a) {
  for(auto v: {a...}) {
    cout << v << " ";
  }
  cout << endl;
}

int main(){
  int in(a, b, c) out(min(a * b, c));
}


Measured memory_bytes: 256
m, n = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(m)]
b = []
for _ in range(n):
    b.append(int(input()))

print(*[sum([i * j for i, j in zip(A[i], b)]) for i in range(m)], sep="\n")



Measured memory_bytes: 5992
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> p;
const int inf = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
  ll h;
  cin >> h;
  ll ans = 1, a = 2, cnt = 0;
  while (h) {
    h /= 2;
    cnt++;
  }
  cnt--;
  rep(i,cnt) {
    ans += a;
    a *= 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using namespace std::chrono; 
#define ll long long
#define fo(i,v,e) for(v=i;v<e;v++)
#define pb(x) push_back(x)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fi first 
#define se second
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector<ll>
#define sz(x) (int)x.size()
#define ull unsigned long long

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x);
#else
#define deb(x...)
#endif

vector<ll> sieveOfErthnosis(ll n)
{
    vector<bool>flag(n+5,false);
    vector<ll>primes;
    for(int i=2;i*i<=n;i++)
    {
        if(!flag[i])
        {
            for(int j=i*i;j<=n;j+=i)
            {flag[j]=true;}
        }
    }
    for (int  i = 2; i < n+1; i++)
    {
        if(!flag[i])primes.pb(i);
    }
    return primes;
}
void init()
{

}
bool check(string s,int l,int r)
{
    while(l<r)
    {
        if(s[l]!=s[r])return false;
        l++;r--;
    }
    return true;
}
void solve()
{
	ll n,m;
    string s;cin>>s;
    n = sz(s);
    if(n==1)
    {
        cout<<"Yes"<<endl;return;
    }
    if(n==2)
    {
        cout<<(s[0]==s[1]?"Yes":"No")<<endl;return;
    }
    bool o=check(s,0,(n-1)/2-1) ,t=check(s,(n+3)/2-1,n-1),th = check(s,0,n-1);
    // deb((n-1)/2-1,(n+3)/2-1)
    if(o and t and th)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
}
int main()
{
    #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    #endif
    init();
    auto start = high_resolution_clock::now(); 
    int T = 1;
    // cin>>T;
	while(T--)
	{
		solve();
	}
    auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<milliseconds>(stop - start); 
    #ifndef ONLINE_JUDGE
	// cout << "time taken : "<<duration.count()<<" ms" << endl;
     #endif
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll ZERO = 0;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int N;
string S;

string k(int a,int b) {
    vector<int> ret(N + 2);
    ret.at(0) = a;
    ret.at(1) = b;
    for(int i = 1;i < N + 1;i++) {
        if(ret.at(i) == 1) {
            if(S.at(i - 1) == 'o') {
                ret.at(i + 1) = ret.at(i - 1);
            }
            else {
                if(ret.at(i - 1) == 1) {
                    ret.at(i + 1) = 2;
                }
                else if(ret.at(i - 1) == 2) {
                    ret.at(i + 1) = 1;
                }
            }
        }
        else {
            if(S.at(i - 1) == 'x') {
                ret.at(i + 1) = ret.at(i - 1);
            }
            else {
                if(ret.at(i - 1) == 1) {
                    ret.at(i + 1) = 2;
                }
                else if(ret.at(i - 1) == 2) {
                    ret.at(i + 1) = 1;
                }
            }
        }
    }
    if(ret.at(0) != ret.at(N) || ret.at(1) != ret.at(N + 1)) {
        return "-1";
    }
    else {
        string ret2;
        for(int i = 1;i < N + 1;i++) {
            if(ret.at(i) == 1) {
                ret2 += 'S';
            }
            else {
                ret2 += 'W';
            }
        }
        return ret2;
    }
}

int main() {
    cin >> N;
    cin >> S;
    if(k(1,1) != "-1") {
        cout << k(1,1) << endl;
    }
    else if(k(1,2) != "-1") {
        cout << k(1,2) << endl;
    }
    else if(k(2,1) != "-1") {
        cout << k(2,1) << endl;
    }
    else if(k(2,2) != "-1") {
        cout << k(2,2) << endl;
    }
    else {
        cout << -1 << endl;
    }
}

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

int main()
{
	int num;
	stack<int> stack;
	
	while(cin >> num)
	{		
		
		if(num==0)
		{
			cout << stack.top() << endl;
			stack.pop();
		}
		else
		{
			stack.push(num);
		}
	}
	
	return 0;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
const int inf = 1e9;
int n, a[200005], b[200005];

int can (int piv) {
	for(int i=1;i<=2*n-1;i++) {
		b[i] = (a[i] >= piv);
	}
	int A = inf, B = inf;
	for(int i=1;n-i>=1;i++) {
		if(b[n-i] == b[n-i+1]) {A = i; break;}
	}
	for(int i=1;n+i<=2*n-1;i++) {
		if(b[n+i] == b[n+i-1]) {B = i; break;}
	}
	if(A == inf && B == inf) return (b[n]^(1-n%2));
	return (b[n]^((min(A, B)-1)&1));
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=2*n-1;i++) {
		scanf("%d",&a[i]);
	}
	int S = 1, E = 2*n-1;
	while(S<E) {
		int mid = (S+E)/2 + 1;
		can(mid) ? S = mid : E = mid-1;
	}
	printf("%d\n",S);
}


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

int main()
{
    long long a, b, c, d, ans = 0;
    cin >> a >> b >> c >> d;
    ans = a * c;
    ans = max(ans, a * d);
    ans = max(ans, b * d);
    ans = max(ans, b * c);
 
    cout << ans << endl;
}
//表

Measured memory_bytes: 3588
var
	N,i,j,ans:int64;
begin
	read(N);
	i:=1;
	while i<=N do begin
		j:=N div(N div i)+1;
		inc(ans,(j-i)*(i+j-1)*(N div i)*(N div i+1)div 4);
		i:=j;
	end;
	writeln(ans);
end.

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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

int main(void){
    int n, k;
    cin >> n >> k;
    vector<int> a;
    for(int i = 1; i <= n; i++){
        int p = i;
        int c = 0;
        while(p < k){
            p*=2;
            c++;
        }
        a.push_back(c);
    }
    double ret = 0;
    for(int i = 0; i < n; i++){
        ret+=((1.0/n)*pow(1/2.0, a.at(i)));
    }
    cout << fixed << setprecision(10) <<  ret << endl;
    return 0;
}


Measured memory_bytes: 892
import java.util.*;

public class Main {
    
    public static void main (String[] args) {
        Scanner scanner = new Scanner(System.in);
        int[][] paper = new int[10][10];
        int max = 0;
        int counter = 0;
        
        for (int i = 0; i < paper.length; i++) {
            for (int j = 0; j < paper[i].length; j++) {
                paper[i][j] = 0;
            }
        }
        
        while (scanner.hasNext()) {
            String strLine = scanner.nextLine();
            String[] str = strLine.split(",");
            
            int x = Integer.parseInt(str[0]);
            int y = Integer.parseInt(str[1]);
            int size = Integer.parseInt(str[2]);

            paper[x][y]++;
            if (isInsidePaper(x, y-1)) paper[x][y-1]++;
            if (isInsidePaper(x-1, y)) paper[x-1][y]++;
            if (isInsidePaper(x+1, y)) paper[x+1][y]++;
            if (isInsidePaper(x, y+1)) paper[x][y+1]++;

            if (size >= 2) {
                if (isInsidePaper(x-1, y-1))    paper[x-1][y-1]++;
                if (isInsidePaper(x+1, y-1))    paper[x+1][y-1]++;
                if (isInsidePaper(x-1, y+1))    paper[x-1][y+1]++;
                if (isInsidePaper(x+1, y+1))    paper[x+1][y+1]++;
            }
            if (size == 3) {
                if (isInsidePaper(x, y-2))    paper[x][y-2]++;
                if (isInsidePaper(x-2, y))    paper[x-2][y]++;
                if (isInsidePaper(x+2, y))    paper[x+2][y]++;
                if (isInsidePaper(x, y+2))    paper[x][y+2]++;
            }
        }
        for (int i = 0; i < paper.length; i++) {
            for (int j = 0; j < paper[i].length; j++) {
                if (paper[i][j] == 0) {
                    counter++;
                } else {
                    if (paper[i][j] > max) max = paper[i][j];
                }
            }
        }
        System.out.println(counter);
        System.out.println(max);
    }
    
    public static boolean isInsidePaper(int x, int y) {
        if (x >= 0 && x <= 9 && y >= 0 && y <= 9) {
            return true;
        } else {
            return false;
        }
    }
}

Measured memory_bytes: 17184
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s :String = read();
    let mut ans = 0;
    match s.as_str() {
        "SSS" => ans = 0,
        "RSS" => ans = 1,
        "SRS" => ans = 1,
        "SSR" => ans = 1,
        "RRS" => ans = 2,
        "RSR" => ans = 1,
        "SRR" => ans = 2,
        "RRR" => ans = 3,
        _ => ans = 0,
    }
    print!("{}", ans);
}


Measured memory_bytes: 2064
using System;
using System.Linq;
class Program
{
    static void Main()
    {
        int[] ab = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray(); int a, b;
        a = ab[0];
        b = ab[1];

        Console.WriteLine("100 100");

        char[,] ans = new char[100, 100];
        for (int i = 0; i < 50; i++)
        {
            for (int j = 0; j < 100; j++)
            {
                ans[i, j] = '.';
            }
        }
        for (int i = 50; i < 100; i++)
        {
            for (int j = 0; j < 100; j++)
            {
                ans[i, j] = '#';
            }
        }
        b--;
        int x = 0, y = 0;
        for (int bl = 0; bl < b; bl++)
        {
            ans[x, y] = '#';
            x = (x + 2 >= 49) ? 0 : x + 2;
            y = (x + 2 >= 49) ? y + 2 : y;
        }

        a--;
        x = 51;
        y = 0;
        for (int wh = 0; wh < a; wh++)
        {
            ans[x, y] = '.';
            x = (x + 2 >= 99) ? 51 : x + 2;
            y = (x + 2 >= 99) ? y + 2 : y;
        }

        for (int k = 0; k < 100; k++)
        {
            for (int l = 0; l < 100; l++)
            {
                Console.Write(ans[k, l]);
            }
            Console.WriteLine();
        }
    }
}

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

int main(void) {
    int N,K;
    cin>>N>>K;
    int result = 0;
    for (int i = 1; i <= N; i++) {
        int h;cin>>h;
        if (h >= K) result++; 
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a,b;
  int fora,forb;
  int tmp=1;
  int said,sais;
  int i;

while(scanf("%d %d",&a,&b)!=EOF){
  fora=a;
  forb=b;
  if(a<=b){
    tmp=a;
    a=b;
    b=tmp;
  }
  tmp=a%b;

  while(tmp!=0){
    a=b;
    b=tmp;
    tmp=a%b;
    }

  said=b;
  sais=(fora/b)*forb;

  printf("%d %d\n",said,sais);
}
  return 0;
}

Measured memory_bytes: 596
sx ,sy, tx, ty = map(int, input().split())

ans = ""

ans += "U" * (ty-sy) + "R" * (tx-sx)
ans += "D" * (ty-sy) + "L" * (tx-sx)

ans += "L" + "U" * (ty-sy+1) + "R" * (tx-sx+1) + "D"
ans += "R" + "D" * (ty-sy+1) + "L" * (tx-sx+1) + "U"

print(ans)

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int M;
  int K = 0;
  int L = 0;
  cin >> N;
  cin >> M;
  if (N == 1) {
    K = 0;
  }
  else if (N == 0) {
    K = 0;
  }
  else if (N > 1) {
    N = N - 1;
    for (int i = 1; i <= N; i++) {
      K += i;
    }
  }
  if (M == 1) {
    L = 0;
  }
  else if (M == 0) {
    L = 0;
  }
  else if (M > 1) {
    M = M - 1;
    for (int l = 1; l <= M; l++) {
      L += l; 
    }
  }
  cout << K + L << endl;
}

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

int main() {
	int N = 0;
	int Alice = 0;
	int Bob = 0;
	int Max = 0;
	cin >> N;
	vector<int> Card(N); 
	for (int Loop = 0; Loop < N; Loop++) {
    	cin >> Card.at(Loop);
    }  
	for (int Loopi = 0; Loopi < N; Loopi++) {
        Max = 0;
		for (int Loopii = 0; Loopii < N; Loopii++) {
            sort(Card.begin(),Card.end());
        	reverse(Card.begin(),Card.end());
        	Max = Card.at(0);
        	if (Loopii % 2 == 0) {
            	Alice += Max;
            }
      		else {
            	Bob += Max;
            }
         	Card.at(0) = 0;
    }
    }
	cout << Alice - Bob << endl;;
int a = 0;
  
a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
  a++;
}

Measured memory_bytes: 3580