akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define INF (1e9)
#define S second
#define F first
#define N 105
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> P1;
typedef pair<P,P1> P2;
int n,m,a,d[N][N],sy,sx;
string s[N];
int dy[4]={-1,0,1,0};
int dx[4]={0,1,0,-1};

int dijkstra(){
  priority_queue<P2,vector<P2>,greater<P2> > q;
  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++)
      d[i][j]=INF;
  d[sy][sx]=0;
  q.push(P2(P(0,2),P1(P(0,0),P(sy,sx))));
  while(!q.empty()){
    P2 t=q.top(); q.pop();
    int cost=t.F.F,dir=t.F.S;
    int pcnt=t.S.F.F,qcnt=t.S.F.S;
    int y=t.S.S.F,x=t.S.S.S;
    if(s[y][x]=='G')return cost;
    if(d[y][x]<cost)continue;
    for(int i=0;i<4;i++){
      int ny=y+dy[i],nx=x+dx[i],ncost=cost;
      int npcnt=pcnt,nqcnt=qcnt;
      if(ny<0||nx<0||n<=ny||m<=nx)continue;
      if(s[ny][nx]=='#')continue;
      if(i!=dir){
	if(s[y][x]=='S')continue;
	ncost++;
	int mindir=min(i,dir),maxdir=max(i,dir);
	if((mindir==0&&maxdir==1)||(mindir==2&&maxdir==3))npcnt++;
	else if((mindir==0&&maxdir==3)||(mindir==1&&maxdir==2)) nqcnt++;
	else continue;
      }
      if(a<npcnt||a<nqcnt)continue;
      while(1){
	if(ny<0||nx<0||n<=ny||m<=nx)break;
	if(s[ny][nx]=='#')break;
	if(d[ny][nx]>ncost){
	  d[ny][nx]=ncost;
	  q.push(P2(P(ncost,i),P1(P(npcnt,nqcnt),P(ny,nx))));
	}
	ny+=dy[i],nx+=dx[i];
      }
    }
  }
  return -1;
}

int main(){
  cin>>n>>m>>a;
  for(int i=0;i<n;i++){
    cin>>s[i];
    for(int j=0;j<m;j++)
      if(s[i][j]=='S')
	sy=i,sx=j;
  }
  cout<<dijkstra()<<endl;
  return 0;
}

Measured memory_bytes: 3320
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

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

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    int n;
    cin >> n;
    vector<ll> z(n);
    for (int i = 0; i < n; i++) {
        cin >> z.at(i);
    }
    sort(z.begin(), z.end());
    ll ans = -334;
    for (int i = 0; i < n-1; i++) {
        if (abs(z.at(n - 1) - ans * 2) > abs(z.at(n - 1) - z.at(i) * 2))ans = z.at(i);
    }
    cout << z.at(n - 1) << " " << ans << endl;
}

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

int main(){
  int n,i,p,b,c,min;
  int a = 0;
  int goke = 0;
  int omori[100] = {};
  int sa[100] = {};

  cin >> n;

  for (i = 0; i < n; i++){
    cin >> omori[i];
    goke = goke + omori[i];
  }

  for (i = 0; i < n; i++){
     a = 0;
     b = 0;
    for (p = 0; p < i; p++){
      a = a + omori[p];
    }
    b = goke - a;

    c = a - b;
    sa[i] = abs(c);
  }

  min = sa[0];
  for(i = 1; i < n; i++){
    if(sa[i] <= min) min = sa[i];
  }

  cout << min;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1; 
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	string s, t;
	int sum = 0;
	cin >> s >> t;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[i]) {
			sum++;
		}
	}
	cout << sum;
}

Measured memory_bytes: 3924
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int ans = -INF;
	int  N;
	vector<vector<int>> p, cum1, cum2;
	
	cin>>N;
	
	p.resize(N,vector<int>(N));
	cum1.resize(N+1,vector<int>(N+1,0));
	// cum2.resize(N,vector<int>(N+1,0));
	
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			cin>>p[i][j];
			cum1[i][j+1] += cum1[i][j] + p[i][j];
		}
	}
	// for(int i = 0; i < N; i++){
		// for(int j = 0; j < N; j++){
			// cum2[i+1][j] += cum2[i][j] + p[i][j];
		// }
	// }
	
	for(int i = 0; i < N; i++){
		for(int j = i+1; j < N; j++){
			int sum = -INF;
			for(int k = 0; k < N; k++){
				// bool flag = false;
				if(sum + p[k][i] + p[k][j] < cum1[k][j+1]-cum1[k][i]){
					sum = cum1[k][j+1]-cum1[k][i];
					ans = max(sum, ans);
				} else {
					sum += p[k][i] + p[k][j];
					ans = max(ans, sum + cum1[k][j] - cum1[k][i+1]);
				}
				
				// cout<<i<<" "<<j<<" "<<k<<" ans = "<<ans<<" sum = "<<sum<<endl;
			}
		}
	}
	for(int i = 0; i < N; i++){
		int sum = -INF;
		for(int k = 0; k < N; k++){
			sum = max(sum + p[k][i], p[k][i]);
			ans = max(sum, ans);
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 4484
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define ar array
 
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
 
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) cin >> p[i];
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (p[i] != i + 1) cnt++;
    }
    cout << (cnt <= 2 ? "YES" : "NO") << '\n';
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from collections import Counter
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
A = list(map(int,readline().split()))
cnt = Counter(A)
sum = 0
for n in cnt.values():
    sum += n*(n-1)//2
for a in A:
    print(sum-cnt[a]+1)

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

using namespace std;

const double EPS = 1e-7;
const int N = 1e5+5, M = 1e5+5, OO = 0x3f3f3f3f;
typedef long long ll;

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

ll fixMod(ll a, ll b){
    return (a%b + b)%b;
}

void pushBack(ll& h, ll base, ll mod, char c){
    h = ((h*base)%mod + c)%mod;
}

void pushFront(ll& h, ll p, ll mod, char c){
    h = (h + (c*p)%mod)%mod;
}

void popFront(ll& h, ll p, ll mod, char c){
    h = fixMod((h - (p*c)%mod), mod);
}

void popBack(ll& h, ll inv, ll mod, char c){
    h = (fixMod(h-c, mod)*inv)%mod;
}

ll power(ll a, ll b, ll m){
    if(!b)  return 1;
    ll t = power(a, b>>1, m);
    return ((t*t)%m * (b&1 ? a : 1))%m;
}


int n, k,x,c=0;
int main(){
//    freopen("araf_bara.txt", "wt", stdout);
cin>>n>>k;
for(int i=0; i<n; i++){
    cin>>x;
    if(x>=k)c++;
}
cout<<c<<endl;

}


Measured memory_bytes: 256
def area(p,q):return p[0]*q[1]-p[1]*q[0]
 
n=int(input())
point=[]
x_1,y_1=[int(i) for i in input().split(" ")]
 
for i in range(n-1):
    x,y=[int(k) for k in input().split(" ")]
    point.append([x-x_1,y-y_1])
a=0
for i in range(n-2):a+=area(point[i],point[i+1])
print(a*0.5)

Measured memory_bytes: 7760
#include <bits/stdc++.h>
using namespace std;
int n;
long long dp[2005][2005];
vector<pair<long long,int> > v;
long long solve(int l,int r)
{
	if (r<l)
	return 0;
	if (dp[l][r]!=-1)
	return dp[l][r];
	int i=l+n-r-1;
	return dp[l][r]=max(v[i].first*abs(v[i].second-l)+solve(l+1,r),v[i].first*abs(v[i].second-r)+solve(l,r-1));
}
int main()
{
	scanf("%d",&n);
	for (int i=0;i<n;i++)
	{
		int a;
		scanf("%d",&a);
		v.push_back({a,i});
	}
	sort(v.rbegin(),v.rend());
	memset(dp,-1,sizeof(dp));
	printf("%lld",solve(0,n-1));
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main(void){
	int r,g;
	cin >> r >> g;
	cout <<  2*g-r << endl;
	return 0;
}

Measured memory_bytes: 256
# 配るDP、もらうDP

n, k = map(int, input().split())
mod = 998244353

kukan = []
for _ in range(k):
    # 区間の問題は扱いやすいように[ )　の形に直せるなら直す
    l, r = map(int, input().split())
    l -= 1
    kukan.append([l, r])

dp = [0 for i in range(n)]
dp[0] = 1

# 区間のL, Rは数字が大きいため、その差一つ一つを考えると時間がない！
# それゆえにL, Rの端を考えればいいようにするためにそこまでの累和を考える
ruiseki = [0 for i in range(n + 1)]
ruiseki[1] = 1
for i in range(1, n):
    for l, r in kukan:
        l = i - l
        r = i - r
        l, r = r, l
        # print(l, r)
        if r < 0:
            continue
        elif l >= 0:
            dp[i] += (ruiseki[r] - ruiseki[l]) % mod
        else:
            dp[i] += (ruiseki[r]) % mod
    ruiseki[i + 1] = (ruiseki[i] + dp[i])
    # print(ruiseki, dp)

print(dp[-1] % mod)


Measured memory_bytes: 30216
#include <stdio.h>
int main(void)
{
  int h, w, i, j=0;
  char p[102][102];
  scanf("%d %d", &h, &w);
  
  for(i = 0; i < h; i++)
    scanf("%s", p[i]);
 
  for(i = 0; i < h; i++){
    do{
      printf("%s\n", p[i]);
      j++;
    }while(j%2 != 0);
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define ull unsigned long long
#define FI(i,a,n) for(int i=a; i<=n; i++)
#define RFI(i,n,a) for(int i=n; i>=a; i--)
#define FLL(i,a,n) for(ll i=a; i<=n; i++)
#define RFLL(i,n,a) for(ll i=n; i>=a; i--)
#define vi vector<int>
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>
#define pi pair<int, int>
#define GCD(a,b) __gcd(a,b)
#define MP make_pair
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define debug(x) cout << x << endl
#define MOD 1000000007
#define INF LLONG_MAX
#define PI 3.14159265359
using namespace std;


int main()
{
  fastio
  int n;
  cin >> n;
  int a[n];
  for(int i=0; i<n; i++) cin >> a[i];
  sort(a, a+n);
  int ans = 0;
  for(int i=2; i<n; i++)
  {
    for(int j=1; j<i; j++)
    {
      for(int k=0; k<j; k++)
      {
        if(a[k]+a[j]>a[i] && a[k]!=a[j] && a[j]!=a[i]) ans++;
      }
    }
  }
  cout << ans;
	return 0;
}





Measured memory_bytes: 3652
import numpy as np
import sys
input = sys.stdin.readline


def main():
    N,M = map(int, input().split())
    A = np.array(sorted([int(i) for i in input().split()]))

    left = 0
    right = A[-1] * 2 + 5
    while right - left > 1:
        x = (left + right) // 2

        count = N**2 - np.searchsorted(A, x-A).sum()

        if count >= M:
            left = x
        else:
            right = x

    bound = np.searchsorted(A, left-A)
    count = N**2 - bound.sum()
    diff = count - M
    ans = ((N - bound) * A * 2).sum() - diff * left

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 23460
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  int d = 0;
  map<int,int> D;
  vector<int> K;
  for(int k = 0; k < N; ++k){
    d -= abs(D[A[k]]);
    ++D[A[k]];
    d += abs(D[A[k]]);
    d -= abs(D[A[N-1-k]]);
    --D[A[N-1-k]];
    d += abs(D[A[N-1-k]]);
    if(!d) K.push_back(k+1);
    // cerr << k << " " << d << endl;
  }
  for(size_t i = 0; i < K.size(); ++i)
    cout << K[i] << (i+1 < K.size() ? " " : "\n");
}



Measured memory_bytes: 5488
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
#define equals(a,b) (fabs((a)-(b))<EPS)
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};

//幾何学テンプレート

//点
class Point{
public:
  double x,y;

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

  Point operator + (Point p) {return Point (x+p.x, y+p.y);}
  Point operator - (Point p) {return Point (x-p.x, y-p.y);}
  Point operator * (double a) {return Point(a*x, a*y);}
  Point operator / (double a) {return Point(x/a,y/a);}

  double abs(){return (norm());}
  double norm(){return x*x+y*y;}

  bool operator < (const Point &p)const{
    return x!=p.x ? x<p.x:y<p.y;
  }
  bool operator > (const Point &p)const{
    return x!=p.x ? x>p.x:y>p.y;
  }
  bool operator == (const Point &p)const{
    return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
  }
};

//ベクトル
typedef Point Vector;

//内積
double dot(Vector a,Vector b){
  return a.x*b.x+a.y*b.y;
}

//外積
double cross(Vector a,Vector b){
  return a.x*b.y-a.y*b.x;
}

//線分
struct Segment{Point p1,p2;};

//直線
typedef Segment Line;

//円
class Circle{
public:
  Point c;   //中心
  double r;  //半径
  Circle(Point c=Point(),double r=0.0):c(c),r(r){}
};

//多角形
typedef vector<Point> Polygon;


//直交判定
bool isOrthogonal(Vector a,Vector b){
  return equals(dot(a,b),0.0);
}

bool isOrthogonal(Point a1,Point a2,Point b1, Point b2){
  return isOrthogonal(a1-a2,b1-b2);
}

bool isOrthogonal(Segment s1,Segment s2){
  return equals(dot(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}

//平行判定
bool isParallel(Vector a,Vector b){
  return equals(cross(a,b),0.0);
}

bool isParallel(Point a1,Point a2,Point b1,Point b2){
  return isParallel(a1-a2,b1-b2);
}

bool isParallel(Segment s1,Segment s2){
  return equals(cross(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}


signed main(){
  int a;cin>>a;
  queue<int>q;
  for(int i=0;i<a;i++){
    double x0,y0,x1,y1,x2,y2,x3,y3;
    cin>>x0>>y0>>x1>>y1>>x2>>y2>>x3>>y3;
    Point p0,p1,p2,p3;
    p0={x0,y0};p1={x1,y1};
    p2={x2,y2};p3={x3,y3};
    Segment s1={p0,p1};
    Segment s2={p2,p3};

    if(isParallel(s1,s2)){
      q.push(2);
    }else if(isOrthogonal(s1,s2)){
      q.push(1);
    }else{
      q.push(0);
    }
  }

  while(!q.empty()){
    cout<<q.front()<<endl;
    q.pop();
  }
  return 0;
}



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

int main() {
	int n,m;
	cin>>n>>m;
	long a[n][2];
	for(int i=0;i<n;i++)
	{
	    cin>>a[i][0]>>a[i][1];
	   
	}
	long b[n+1][m+1];
	for(int i=0;i<=n;i++)
	{
	    b[i][0]=0;
	    
	}
	for(int i=0;i<=m;i++)
	{
	    b[0][i]=0;
	}
	long k=0;
	for(int i=1;i<=n;i++)
	{
	    for(int j=1;j<=m;j++)
	    {   if(j-a[i-1][0]>=0)
	    {  // cout<<b[i-1][j-a[i-1][0]]+a[i-1][1]<<"    ";
	        b[i][j]=max(b[i-1][j],b[i-1][j-a[i-1][0]]+a[i-1][1]);
	    }
	    else
	    {b[i][j]=b[i-1][j];
	   
	    }
	       //cout<<b[i][j]<<" ";
	    }
	  // cout<<endl;
	    }
	
	cout<<b[n][m];
	
	return 0;
}


Measured memory_bytes: 79104
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	s := wordScanner()
	_, h := scanNAndIntSlice(s)

	pre := 0
	for _, cur := range h {
		if pre > cur {
			fmt.Println("No")
			return
		} else if pre < cur {
			pre = cur - 1
		}
	}
	fmt.Println("Yes")
}

func wordScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func scanNAndIntSlice(s *bufio.Scanner) (int, []int) {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n, scanIntSlice(s, n)
}

func scanIntSlice(s *bufio.Scanner, n int) []int {
	vals := make([]int, n)
	for i := range vals {
		s.Scan()
		m, _ := strconv.Atoi(s.Text())
		vals[i] = m
	}
	return vals
}


Measured memory_bytes: 3072
import math
def p(d): print(d)
def i(): return input()

def LI():  # Line Integer
    # 1行 1つの数字
    return int(input())
def LIS():  # Line IntegerS
    # 1行 mつの数字
    return [int(x) for x in input().split()]
def MLIS(n):  # Multi Line IntegerS
    # n行 mつの数字
    return [[int(x) for x in input().split()] for y in range(n)]
def LC():  # Line Character
    # 1行 1つの文字
    return input()
def LCS(): # Line CharacterS
    # 1行 nつの文字
    return [x for x in input().split()]
def MLCS(n): # Multi Line CharacterS
    # n行 mつの数字
    return [[x for x in input().split()] for y in range(n)]

def alp2int(alphabet):
    # アルファベットの番号を返す
    return ord(alphabet) - ord('a')
def int2alp(num):
    # 番号からアルファベットを返す
    return chr(num + ord('a'))
def cnt2dic(lst, dic={}):
    # 同じものをカウントして辞書型にする
    for x in lst:
        key = str(x)
        if key in dic:
            dic[key] += 1
        else:
            dic[key] = 1
    return dic
def dic2lst(dic, key=lambda x:x[1]):
    # 辞書をタプルの配列にする
    return sorted(list(dic.items()), key=key);

def A():
    a = LC()
    if a[0] == a[2]:
        print('Yes')
    else:
        print('No')

def B():
    pass

def C():
    pass

def D():
    pass

def E():
    pass

def F():
    pass

def G():
    pass

def H():
    pass

A()


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <functional>

using namespace std;

class State{
public:
  double E;
  string name;
  bool operator < (const State& s) const {
    if(E < s.E){
      return true;
    }else if(E > s.E){
      return false;
    }else{
      return name > s.name;
    }
  }
};

int n, p, a, b, c, d, e, f, s, m;
State ans[50];

double calc(){
  int time = a + b + c + (d + e) * m;
  int income = f * s * m - p;
  return (double)income / time;
}

main(){
  while(cin >> n && n){
    for(int i=0;i<n;i++){
      cin >> ans[i].name;
      cin >> p >> a >> b >> c >> d >> e >> f >> s >> m;
      ans[i].E = calc();
    }
    sort(ans, ans+n);
    reverse(ans, ans+n);
    for(int i=0;i<n;i++){
      cout << ans[i].name << endl;
    }
    cout << "#" << endl;
  }
  return 0;
}

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


int main(){
  int n;cin>>n;
  int a[3*n];
  for(int i=0;i<3*n;i++){
    cin>>a[i];
  }

  sort(a,a+3*n);
  long long int ans=0;

  for(int i=3*n-2;i>=n;i-=2){
    ans+=a[i];
  }

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


Measured memory_bytes: 1536
import java.util.*;

class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        final String[] ss = {"dream", "dreamer", "erase", "eraser"};

        int r = s.length();
        while (r > 0) {

            boolean isFound = false;
            for (String x : ss) {
                if (r - x.length() < 0) {
                    // System.out.println(s);
                    continue;
                }
                String subs = s.substring((r - x.length()), r);
                // System.out.println(subs);
                if (x.equals(subs)) {
                    r -= x.length();
                    isFound = true;
                    break;
                }
            }
            if (!isFound) {
                System.out.println("NO");
                return;
            }
        }


        System.out.println("YES");
        sc.close();
    }
}


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

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

  vector<int> r(n);
  ll sum = 0;
  rep(i, n) {
    if (i % 2 == 0) sum += a[i];
    else sum -= a[i];
  }
  r[0] = sum;
  for (int i = 1; i < n; ++i) {
    sum = -sum + 2 * a[i-1];
    r[i] = sum;
  }
  rep(i, n-1) printf("%d ", r[i]);
  printf("%d\n", r[n-1]);
  return 0;
}

Measured memory_bytes: 4060
#include<bits/stdc++.h>
#define sz(x) ((int)(x).size())
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
 
typedef long long lld;
typedef vector<lld> vlld;
typedef pair<lld,lld> pi;
typedef tuple<lld,lld,lld> tup;
const lld mod=(lld)1e9+7;
 
lld solve(lld a[],lld n,lld k)
 {
    
    lld dp[n]={0};
    for(lld i=1;i<n;i++)
    {
    	lld l1=mod,l2;
    	for(lld j=i-1;j>=max(i-k,0ll);j--)
    	{
            l2=abs(a[i]-a[j])+dp[j];
            l1=min(l2,l1);
    	}
    	dp[i]=l1;
    }

   return dp[n-1];

 }
    	
 

int main() {

	lld n,k;
	cin>>n>>k;
	lld a[n];

	forn(i,n)
	cin>>a[i];

	cout<<solve(a,n,k);
  
  return 0;
}

Measured memory_bytes: 5184
#include <iostream>
using namespace std;
bool In(int x,int g[],int size){
	int i;
	for (i=0;i<size;i++){
		if (x==g[i]){
			return true;
		}
	}

	return false;
}
int main(int argc, char* argv[])
{
	int g1[]={1,3,5,7,8,10,12};
	int g2[]={4,6,9,11};
	int g3[]={2};
	int x,y;
	cin>>x>>y;

	if (In(x,g1,7) && In(y,g1,7)){
		cout<<"Yes"<<endl;
		return 0;
	}
	if (In(x,g2,4) && In(y,g2,4)){
		cout<<"Yes"<<endl;
		return 0;
	}
	if (In(x,g3,1) && In(y,g3,1)){
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}

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

using namespace std;

int main()
{
	int a[100];
	int flag=1,ans=0,n;
	cin>>n;
	int t;
	for(int i=0;i<n;i++)
		cin>>a[i];
	while(flag)
	{
		flag=0;
		for(int i=n-1;i>0;i--)
			if(a[i]<a[i-1])
			{
				t=a[i];
				a[i]=a[i-1];
				a[i-1]=t;
				flag=1;
				ans++;
			}
	}
	for(int i=0;i<n-1;i++)
		cout<<a[i]<<' ';
	cout<<a[n-1]<<endl;
	cout<<ans<<endl;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sct(tc) scanf("%lld",&tc)
#define scl(n) scanf("%lld",&n)
#define scll(n,m) scanf("%lld%lld",&n,&m)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
ll ar[100000]={0};
int main()
{
	ll n,i,b,c,q,j,x,sum=0;
	scanf("%lld",&n);
	for(i=0;i<n;i++)
	{
		scanf("%lld",&x);
		ar[x]++;
		sum+=x;
	}
	scanf("%lld",&q);
	for(i=0;i<q;i++)
	{
		scanf("%lld %lld",&b,&c);
		{
			sum=sum-ar[b]*b+c*ar[b];
			ar[c]+=ar[b];
			ar[b]=0;
		}
		printf("%lld\n",sum);
	}
}


Measured memory_bytes: 4580
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
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;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  FOR(i,0,1500000000){
    if(i%2==0){
      n*=3;
    }
    else{
      n/=3;
    }
  }
  co(3*n*n)
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MAXN = 300 + 7;

int main()
{
    int k, x;
    cin>>k>>x;
    for(int i = x-k+1; i<= x+k-1;i++)
    {
        cout<<i;
        if(i != x+k-1)
            cout<<' ';
        else cout<<endl;
    }


    return 0;
}


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

#include <chrono>

template <typename T>
inline bool is_prime(T n)
{
    if(n <= 1) {
        return false ;
    }

    if(n == 2) {
        return true ;
    }

    if(n % 2 == 0) {
        return false ;
    }

    for(T i = 3 ; i * i <= n ; i += 2) {
        if(n % i == 0) {
            return false ;
        }
    }
    return true ;
}

template <typename T>
inline auto compute_z_list(T n)
{
    std::vector<T> vec ;
    for(T i = 2 ; i * i <= n ; i ++) {
        if(n % i != 0 || !is_prime(i)) {
            continue ;
        }

        auto elem = i ;
        while(n % i == 0) {
            vec.push_back(elem) ;

            if(is_prime(n / elem)) {
                vec.push_back(n / elem) ;
            }

            n /= i ;
            elem *= i ;
        }
    }

    return vec ;
}

template <typename T>
inline size_t func(T num)
{
    static const auto z_list = compute_z_list(num) ;

    static std::vector<T> vec ;
    if(num == 1) return vec.size() ;

    for(auto z : z_list) {
        if(num % z != 0) {
            continue ;
        }

        if(std::find(vec.cbegin(), vec.cend(), z) == vec.cend()) {
            vec.push_back(z) ;
            return func(num / z) ;
        }
    }

    return vec.size() ; //not reached
}


int main()
{
    unsigned long long num ;
    std::cin >> num ;

    if(is_prime(num)) {
        std::cout << 1 << std::endl ;
        return 0 ;
    }

    std::cout << func(num) << std::endl ;
    return 0 ;
}

Measured memory_bytes: 3604
#include <cstdio>
#include <vector>
using namespace std;

vector<int> a;

int main(){
	int n;
	scanf("%d", &n);
	for(int i=0; i<n; ++i){
		int t;
		scanf("%d", &t);
		a.push_back(t);
	}

	int s = 0;
	int t = a[0];
	int ans = 1;
	for(int i=1; i<n; ++i){
		if(a[i-1] < a[i]){
			if(s == 0){
				s = 1;
			}else if(s < 0){
				s = 0;
				++ans;
			}
		}else if(a[i-1] > a[i]){
			if(s == 0){
				s = -1;
			}else if(s > 0){
				s = 0;
				++ans;
			}
		}
		t = a[i];
	}
	printf("%d\n", ans);
}

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

int main(void){
    
    int k;
    int tmp=0;
    ll ans=0;
    
    cin >> k;
    
    for(int a=1; a<=k; a++){
        
        for(int b=1; b<=k; b++){
            
            for(int c=1; c<=k; c++){
                
                tmp = gcd(a, b);
                ans += gcd(tmp, c);
                
            }
            
        }
        
    }
    
    cout << ans << endl;
    
    return 0;
    
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n, m, p, a[100], c, d, dp[5500][700];
vector<pair<int, int> >x[100];
int main() {
	while (cin >> n >> m >> p) {
		for (int i = 0; i < 5500; i++) {
			x[i].clear();
			for (int j = 0; j < 700; j++)dp[i][j] = 0;
		}
		for (int i = 0; i < n; i++) {
			cin >> a[i];
			for (int j = 0; j < a[i]; j++) {
				cin >> c >> d;
				x[i].push_back(make_pair(c, d));
			}
		}
		int cnt = 0;
		for (int i = 0; i < m; i++) {
			cin >> c;
			for (int j = 0; j < x[c].size(); j++) {
				for (int k = 0; k <= p; k++) {
					dp[cnt + 1][k] = max(dp[cnt + 1][k], dp[cnt][k]);
					dp[cnt + 1][k + x[c][j].second] = max(dp[cnt + 1][k + x[c][j].second], dp[cnt][k] + x[c][j].first);
				}
				cnt++;
			}
		}
		int maxn = 0, maxid = 0;
		for (int i = 0; i <= p; i++) {
			if (maxn < dp[cnt][i]) {
				maxn = dp[cnt][i];
				maxid = i;
			}
		}
		cout << maxn << ' ' << maxid << endl;
	}
	return 0;
}

Measured memory_bytes: 16292
"use strict";
const Main = (input) =>{
   let xs = input.trim().split('\n');
   let a = xs[0].split(''); 
   let b = xs[1].split('');
   let ans = 0;
   for(let i =0; i < 3; i++){
   	if(a[i] == b[i]){
     	ans += 1;
    }
   }
   console.log(ans);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 21064
#include <iostream>
#include <vector>

using namespace std;

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

	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) cout << "Possible" << endl;
	else cout << "Impossible" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
#define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() 
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    ll n;
    cin>>n;
    ll a[n][3];
    ll dp[n][3];
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < 3; ++j)
        {
            cin>>a[i][j];
            dp[i][j]=0;
        }
    }

    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    
    for (int i = 1; i < n; ++i)
    {
        dp[i][0] = a[i][0]+max(dp[i-1][2], dp[i-1][1]);
        dp[i][2] = a[i][2]+max(dp[i-1][0], dp[i-1][1]);
        dp[i][1] = a[i][1]+max(dp[i-1][0], dp[i-1][2]);
    }
    cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));

    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VII;
typedef pair<int,int> PII;

int A[200010]={};
int ans[200010]={};
VII T(200010,VI(1));

void dfs(int s){
  A[s]++;
  rep(i,T[s].size()){
    if(i){
      if(A[T[s][i]]==0){
        ans[T[s][i]]+=ans[s];
        dfs(T[s][i]);
      }
    }
  }
}

int main(){
  int N,Q;
  cin>>N>>Q;
  VI A(N-1),B(N-1),P(Q),X(Q);
  rep(i,N-1) cin>>A[i]>>B[i];
  rep(i,Q) cin>>P[i]>>X[i];
  rep(i,N-1){
    T[A[i]-1].push_back(B[i]-1);
    T[B[i]-1].push_back(A[i]-1);
  }
  rep(i,Q) ans[P[i]-1]+=X[i];
  A[0]++;
  dfs(0);
  rep(i,N){
    if(i) cout<<" ";
    cout<<ans[i];
  }
  cout<<endl;
}


Measured memory_bytes: 24320
n, k = map(int, input().split())
candle_list = list(map(int, input().split()))


right_candle = [0] + [i for i in candle_list if i>0] + [float('inf')] * k
left_candle = [-float('inf')] * k + [i for i in candle_list if i<=0] + [0]


print(min([-left_candle[-i-1] * 2 + right_candle[k-i] for i in range(k+1)] + \
          [-left_candle[-i-1] + right_candle[k-i] * 2 for i in range(k+1)]))

Measured memory_bytes: 80792
#include "bits/stdc++.h"
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = 1e9;
const LL LLINF   = 1e18;
#define pow10(n) int(1e##n + n)

void solve()
{
    int A, B, C;
    cin >> A >> B >> C;
    if ((A == B and B == C) or (A != B and B != C and A != C))
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
    return;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 256
import operator

n = input()
operator_list = [operator.add, operator.sub]
operator_list2 = ["+", "-"]
flag = False
for i in range(2):
    for j in range(2):
        for k in range(2):
            if operator_list[i](operator_list[j](operator_list[k](int(n[0]), int(n[1])), int(n[2])), int(n[3])) == 7:
                flag = True
                break
        if flag == True:
            break
    if flag == True:
        break
print(n[0] + operator_list2[k] + n[1] + operator_list2[j] + n[2] + operator_list2[i] + n[3] + "=7")

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>

using namespace std;

int main(void){

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

  int a_num=0;
  int b_num=0;
  int c_num=0;

  vector<int> p(n);

  for(int i=0;i<n;i++){
    cin>>p[i];
    if(p[i]<=a){
      a_num++;
    }
    else if(p[i]>a && p[i]<=b){
      b_num++;
    }
    else{
      c_num++;
    }
  }

  cout << min({a_num,b_num,c_num}) << endl;


  return 0;
}


Measured memory_bytes: 256
program magic_2
  implicit none
  integer :: a, b, c, k, n = 0
  read(*,*) a, b, c
  read(*,*) k
  do while (b <= a)
    b = 2 * b
    n = n + 1
  end do
  do while (c <= b)
    c = 2 * c
    n = n + 1
  end do
  write(*,'(a)') trim(merge('No ', 'Yes', n > k))
end program magic_2

Measured memory_bytes: 2860
def solve():
    N, M = map(int, input().split())
    
    c = 0
    l = 0
    r = 10 ** 9
    for _ in range(M):
        a, b = list(map(int, input().split()))
        l = max(l, a)
        r = min(r, b)
        
    if r < l:
        return 0
    if r == l:
        if r <= N:
            return 1
        else:
            return 0
    
    if N < l:
        return 0
    elif N == l:
        return 1
    elif l < N < r:
        return N-l+1
    elif N == r:
        return r-l+1
    elif r < N:
        return r-l+1

print(solve())

Measured memory_bytes: 3064
// ------------------------------------
// Date:2018/ 2/13
// Problem:0004 : SimulataneousEquation 4.cpp
//
// ------------------------------------
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define REP(i,n) FOR(i,0,n)
 
int main()
{
  double a,b,c,d,e,f;
  while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f) != EOF) {
    printf("%.3lf %.3lf\n",((c*e-b*f)/(a*e-b*d))==0?0.000:(c*e-b*f)/(a*e-b*d), ((c*d-a*f)/(b*d-a*e))==0?0.000:(c*d-a*f)/(b*d-a*e));
  }
  return 0;
}


Measured memory_bytes: 3140
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll M =1e9+7;
const int N = 1e6+7;


ll ME(ll x,ll n)
{
    ll res=1;
    
    while(n)
    {
        if(n&1)
        res=(res*x)%M;
        
        n/=2;
        
        x=(x*x)%M;
    }
    
    return res;

    
}



void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

    
int main()
{

    ll x,k,d;
    lscf(x),lscf(k),lscf(d);
    
    x=abs(x);
    
    ll v=(x+d-1)/d;
    
    if(d>=x)
    {
        
        ll w=0;
        
        if(k%2==0)
        w=x;
        
        else
        w=abs(d-x);
        
        lprin(abs(w));
    
    }
    
    
    else
    {
        if(v>=k)
        {
          ll a=x-d*k;
            lprin(abs(a));
        }

        else
        {
            ll a=x-d*v;
            
            a=abs(a);
        
            ll e=0;
        
            k-=v;
            
            if(d>=a)
            {
                if(k%2==0)
                e=a;
        
                else
                e=abs(d-a);
        
                lprin(abs(e));
                
            }
            
            else
            {
        
                ll b=(a+d-1)/d;
                
                if(b>=k)
                a=a-d*k;
                
                else
                a=a-b*d;
                
                a=abs(a);
                
                lprin(a);
    
            }

        }
    }
    

    
    
    
        
    
            
}

Measured memory_bytes: 3808
#include <stdio.h>
#include <math.h>

int main(void)
{
    double minvel, y, v, time;
    int floor;

    while(scanf("%lf", &minvel) != EOF){
        floor = 1;

        while (1){
            y = 5 * floor - 5;
            time = sqrt(y / 4.9);
            v = 9.8 * time;
            if (v >= minvel)    break;
            floor++;
        }
        printf("%d\n", floor);

    }
    return (0);
}


Measured memory_bytes: 2032
#abc064 c
n=int(input())
a=list(map(int,input().split()))
color=[False]*8
strongman=0
for i in a:
    x=i//400
    if x<8:
        color[x]=True
    else:
        strongman+=1
human=0
for i in color:
    if i==True:
        human+=1
color_min=max(human,1)
color_max=human+strongman
print(color_min,color_max)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int n,ans;
string s;
bool OK(int m) {
    map<string,int> d;
    for(int i=1;i<=n+1-m;i++) {
        string str=s.substr(i-1,m);
        if(d[str]) {
            if(i-d[str]>=m) return true;
        } else
            d[str]=i;
    }
    return false;
}
int main() {
    cin>>n>>s;
    int l=0,r=n/2;
    while(l<=r) {
        int mid=l+(r-l)/2;
        if(OK(mid))
            l=mid+1,ans=mid;
        else r=mid-1;
    }
    cout<<ans<<endl;
    return 0;
}

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

int n, m, X;
int c[13];
int lv[13][13];

int ans = 987654321;

void bf(int x) {
    int curr[13] = {0, };  // 현재 레벨 상태
    int cost = 0;
    for (int i = 0; i < n; i++) {
        if (x & (1 << i)) {
            for (int j = 0; j < m; j++) {
                curr[j] += lv[i][j];
            }
            cost += c[i];
        }
    }

    bool succeed = true;
    for (int i = 0; i < m; i++) {
        // cout << curr[i] << ' ';
        if (curr[i] < X) {
            succeed = false;
            break;
        }
    }
    // cout << '\n';
    if (succeed) {
        ans = min(ans, cost);
    }
}

int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    cin >> n >> m >> X;
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j = 0; j < m; j++) {
            cin >> lv[i][j];
        }
    }

    for (int i = 0; i < (1 << n); i++) {
        bf(i);
    }

    cout << (ans == 987654321 ? -1 : ans) << '\n';

    return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>

long long int gcd(long long int number_a, long long int number_b) {
  long long int temp;
  if(number_a == 0 || number_b == 0) {
    return number_a + number_b;
  }
  if(number_a < number_b) {
    temp = number_a;
    number_a = number_b;
    number_b = temp;
  }
  temp = number_a % number_b;
  while(temp != 0) {
    number_a = number_b;
    number_b = temp;
    temp = number_a % number_b;
  }
  return number_b;
}

int main() {
  long long int number_n, i, max_value = 0;
  scanf("%lld", &number_n);
  long long int value[number_n], gcd_number[number_n], gcd_left[number_n], gcd_right[number_n];
  gcd_left[0] = 0;
  gcd_right[number_n-1] = 0;
  for(i = 0; i < number_n; i++) {
    scanf("%lld", &value[i]);
  }
  for(i = 1; i < number_n; i++) {
    gcd_left[i] = gcd(gcd_left[i-1], value[i-1]);
  }
  for(i = number_n - 2; i >= 0; i--) {
    gcd_right[i] = gcd(gcd_right[i+1], value[i+1]);
  }
  for(i = 0; i < number_n; i++) {
    gcd_number[i] = gcd(gcd_left[i], gcd_right[i]);
    if(max_value < gcd_number[i]) {
      max_value = gcd_number[i];
    }
  }
  printf("%lld\n", max_value);
  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int x, n;
    cin >> x >> n;
    vector<int> p(n);
    rep(i, n)cin >> p[i];
    map<int, int> mp;
    rep(i, n)mp[p[i]]++;
    int i = 0;
    if(mp[x] == 0)cout << x << endl;
    else{
        while(true){
            i++;
            if(mp[x-i] == 0){
                cout << x-i << endl;
                return 0;
            }
            if(mp[x+i] == 0){
                cout << x+i << endl;
                return 0;
            }
        }
    }
}


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)

using namespace std;


struct Node{
    ll pos;
    vector<bool> used;
    ll cost;
    bool operator< (const Node &r) const{
        return cost > r.cost;
    }
};

ll solve(ll n, ll c, vector<vector<ll>> d, vector<vector<ll>> f){
    rep(hx, n){
        rep(wx, n) f[hx][wx]--;
    }

    vector<map<ll, ll>> v(3, map<ll, ll>());
    rep(hx, n){
        rep(wx, n){
            ll idx = (hx+wx)%3;
            v[idx][f[hx][wx]]++;
        }
    }

    vector<vector<ll>> list(3, vector<ll>(c, 1e10));
    rep(i, 3){
        auto m = v[i];
        rep(to, c){
            ll sum = 0;
            for(auto from = m.begin(); from != m.end(); from++){
                sum += from->second * d[from->first][to];
            }
            list[i][to] = sum;
        }
    }

    priority_queue<Node> que;
    que.push({0, vector<bool>(c, false), 0});

    while(!que.empty()){
        Node node = que.top(); que.pop();

        if(node.pos == 3) return node.cost;
        
        rep(i, c){
            if(node.used[i]) continue;
            vector<bool> v = node.used;
            v[i] = true;
            que.push({node.pos+1, v, node.cost+list[node.pos][i]});
        }
    }

    return 1e10;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    ll n, c;
    cin >> n >> c;
    vector<vector<ll>> d(c, vector<ll>(c));
    rep(hx, c){
        rep(wx, c) cin >> d[hx][wx];
    }
    vector<vector<ll>> f(n, vector<ll>(n));
    rep(hx, n){
        rep(wx, n) cin >> f[hx][wx];
    }

    cout << solve(n, c, d, f) << endl;
    
    
    return 0;
}


Measured memory_bytes: 6584
#include <iostream>

const bool is_vowel(const char& given)
{
  return given == 'a' ||
         given == 'e' ||
         given == 'i' ||
         given == 'o' ||
         given == 'u';
}

int main()
{
  char c;

  std::cin >> c;
  std::cout << (is_vowel(c) ? "vowel" : "consonant") << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
multiset <int> s;
int n,ans;
int main()
{
    scanf("%d",&n);
    while(n--)
    {
        int a;
        scanf("%d",&a);
        s.insert(a);
    }
    while(!s.empty())
    {
        int t = *(--s.end()),k;
        for(k=1;k<=t;k*=2);
        s.erase(--s.end());
        if(s.find(k-t)!=s.end())
        {
            ans++;
            s.erase(s.find(k-t));
        }
    }
    printf("%d",ans);
}


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

int gcd(int a, int b) //returns gcd of two numbers
{
	if (b == 0)
		return a;
	return gcd(b, a%b); //recursively call on itself
}

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

	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			for (int k = 1; k <= n; k++)
			{
				ans += gcd(i, gcd(j, k));
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 3568