akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

#define POS(i,j) ((i)*(m+1)+(j))

void run(void){
  const int m=100000;
  int n;
  scanf("%d",&n);
  int *cnt=(int *)calloc(2*(m+1),sizeof(int));
  int i;
  for(i=0;i<n;i++){
    int a;
    scanf("%d",&a);
    cnt[POS(i%2,a)]++;
  }
  int a=0;
  for(i=1;i<=m;i++) if(cnt[POS(0,i)]>cnt[POS(0,a)]) a=i;
  int b=0;
  for(i=1;i<=m;i++) if(cnt[POS(1,i)]>cnt[POS(1,b)]) b=i;
  if(a!=b){
    printf("%d\n",n-cnt[POS(0,a)]-cnt[POS(1,b)]);
    return;
  } else if(cnt[POS(0,a)]==cnt[POS(1,b)]){
    int c=0;
    for(i=1;i<=m;i++) if(i!=a && cnt[POS(0,i)]>cnt[POS(0,c)]) c=i;
    int d=0;
    for(i=1;i<=m;i++) if(i!=b && cnt[POS(1,i)]>cnt[POS(1,d)]) d=i;
    printf("%d\n",cnt[POS(0,c)]>=cnt[POS(1,d)]?n-cnt[POS(0,c)]-cnt[POS(1,b)]:n-cnt[POS(0,a)]-cnt[POS(1,d)]);
    return;
  }
}

int main(void){
  run();
  return 0;
}


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

int main() {
    unsigned int a,b,m;
    double k;
    cin>>a>>b;
    string ans="IMPOSSIBLE";

    m = (a+b)/2;
    k = (double)(a+b)/(double)2;
    if (m == k) cout<<m<<endl;
    else cout<<ans<<endl;
}


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

int main(){
  bool water[10][10];
  bool frog[10][10];
  int x,y;
  int sp[10][2];
  int n;

  while(1){
    cin >> x >> y;
    if(!x && !y)break;

    cin >> n;
    for(int i=0;i<n;i++)cin >> sp[i][0] >> sp[i][1];

    vector<pair<int,int> > pyon[11];
    pyon[0].push_back(make_pair(x,y));

    for(int i=0;i<n;i++){
      if(pyon[i].size()){
	for(int j=0;j<10;j++){
	  for(int k=0;k<10;k++){
	    water[j][k] = false;
	    frog[j][k] = false;
	  }
	}

	for(int j=sp[i][1]-1;j<=sp[i][1]+1;j++){
	  for(int k=sp[i][0]-1;k<=sp[i][0]+1;k++){
	    if(k<0 || k>=10 || j<0 || j>=10)continue;
	    water[j][k] = true;
	  }
	}

	for(int k=0;k<(int)pyon[i].size();k++){
	  int dx = pyon[i][k].first,dy = pyon[i][k].second;
	  for(int j=dy-1;j<=dy+1;j++){
	    if(j < 0 || j >= 10)continue;
	    if(dx-2 >= 0)frog[j][dx-2] = true;
	    if(dx+2 < 10)frog[j][dx+2] = true;
	  }
	  for(int j=dx-1;j<=dx+1;j++){
	    if(j < 0 || j >= 10)continue;
	    if(dy-2 >= 0)frog[dy-2][j] = true;
	    if(dy+2 < 10)frog[dy+2][j] = true;
	  }
	}

	for(int j=0;j<10;j++){
	  for(int k=0;k<10;k++){
	    if(water[j][k] && frog[j][k])pyon[i+1].push_back(make_pair(k,j));
	  }
	}
      }
    }

    if(pyon[n].size())cout << "OK" << endl;
    else cout << "NA" << endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<long long>
#define vii vector<int>
#define vll vector<long long>
using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    int ans = n*n*n;
    printf("%d",ans);
    return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
float round_n(float number, int n)
{
    number = number * pow(10,n-1);
    number = round(number);
    number /= pow(10, n-1);
    return number;
}
int main(int argc, const char * argv[]) {
    int datasetCount;
    float x1,x2,x3,y1,y2,y3;
    float result[20][3];
    float a,b,c;
    
    scanf("%d", &datasetCount);
    
    for(int i=0;i<datasetCount;i++) {
        scanf("%f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3);
        
               a = hypot(x2 - x1,y2 - y1);
               b = hypot(x3 - x1,y3 - y1);
               c = hypot(x3 - x2,y3 - y2);
        
               result[i][2] = (a*b*c) / (sqrt((a+b+c)*(b+c-a)*(a-b+c)*(a+b-c)));
               result[i][0] = (((x1*x1)+(y1*y1))*(y2-y3)+((x2*x2)+(y2*y2))*(y3-y1)+((x3*x3)+(y3*y3))*(y1-y2))/(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2))/2;
               result[i][1] = (((x1*x1)+(y1*y1))*(x2-x3)+((x2*x2)+(y2*y2))*(x3-x1)+((x3*x3)+(y3*y3))*(x1-x2))/(y1*(x2-x3)+y2*(x3-x1)+y3*(x1-x2))/2;
    }
    
    for(int i=0;i<datasetCount;i++) {
        printf("%.3f %.3f %.3f\n", round_n(result[i][0], 4) , round_n(result[i][1], 4), round_n(result[i][2], 4));
    }
    
    return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  ll a[n], b[n];
  fi(0, n) {
    cin >> a[i] >> b[i];
  }
  for(int i = n - 1; i >= 0; i--) {
    a[i] += ans;
    ll mul = (a[i] + b[i] - 1) / b[i];
    ans += mul * b[i] - a[i];
  }
  cout << ans << endl;
  return 0;
}



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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;

int main() {
    lli a, b;
    cin2(a, b);

    b++;
    lli div = 2;
    lli ans = 0;
    while (true) {
        lli half = div/2;
        lli ap = a/div;
        lli aq = a%div;
        lli a_count = ap * (div/2);
        if (half < aq)
            a_count += aq- half;

        lli bp = b/div;
        lli bq = b%div;
        lli b_count = bp * (div/2);
        if (half < bq)
            b_count += bq- half;
        if ((b_count - a_count) % 2 == 1)
            ans += half;
        div *= 2;
        if (half > b)
            break;
    }
    cout << ans << endl;

}


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

int h, w;
vector<vector<string>> grid, hashes;
vector<string> grids;
vector<vector<int>> lens;
vector<int> len;
vector<string> rows, hashh;
string s;

/*
int solve(int x, int y, int c) {
  if (x<0 || y<0 || x>=h || y>=w) return 2501;
  if (grid[x][y]=="#") return 2501;
  if (x==h-1 && y==w-1) return c;
  grid[x][y]="#";
  return min(min(solve(x,y+1,c+1), solve(x,y-1,c+1)), min(solve(x+1,y,c+1), solve(x-1,y,c+1)));
}
*/

void solve(int x, int y, int c) {
  if (x<0 || y<0 || x>=h || y>=w) return;
  if (grids[x][y]=='#') {
    //cout << "#";
    return;
  }
  if (lens[x][y]<=c) return;
  /*
  if (lens[x+1][y]>c+1) solve(x+1,y,c+1);
  if (lens[x-1][y]>c+1) solve(x-1,y,c+1);
  if (lens[x][y+1]>c+1) solve(x,y+1,c+1);
  if (lens[x][y-1]>c+1) solve(x,y-1,c+1);
  */
  lens[x][y]=c;
  solve(x+1,y,c+1);
  solve(x-1,y,c+1);
  solve(x,y+1,c+1);
  solve(x,y-1,c+1);
}

int main() {
  int count=0;
  cin >> h >> w;
  for (int i=0; i<h; i++) {
    cin >> s;
    len.clear();
    rows.clear();
    hashh.clear();
    for (int j=0; j<w; j++) {
      //cin >> s;
      rows.push_back(s);
      len.push_back(2501);
      hashh.push_back("#");
    }
    grids.push_back(s);
    grid.push_back(rows);
    lens.push_back(len);
    hashes.push_back(hashh);
  }
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) if (grid[i][j]=="#") lens[i][j]=0;
  }
  for (auto i : grids) for (auto j : i) if (j=='#') count++;
  //for (auto i : grid) for (auto j : i) for (auto k : j) if (k=='#') count++;
  solve(0,0,1);
  //cout << grid[0][2];
  if (lens[h-1][w-1]==2501) cout << -1;
  else cout << h*w-lens[h-1][w-1]-count;
  //cout << lens[h-1][w-1];
  //for (auto i : lens) for (auto j : i) cout << j;
  return 0;
}


Measured memory_bytes: 640
N = int(input())
Z = list(map(int, input().split()))

ans = -1
flg = 1

while(flg):
    ans += 1
    for i in range(N):
        if list(Z)[i] % 2 != 0:
            flg = 0
        else:
            Z[i] /= 2


print(ans)    


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

#define N 400
#define W 400

#define max(a,b) (a>b?a:b)

int main() {
  int n, m, s[N], l[N], p[N];
  int dp[N+1][W+1], w[N];
  bool f = false;
  cin >> n;
  for(int i=0; i<n; ++i) cin >> s[i] >> l[i] >> p[i];
  for(int i=0; i<=n; ++i) dp[i][0] = 0;
  for(int i=0; i<=W; ++i) dp[0][i] = 0;
  for(int i=0; i<n; ++i) {
    for(int j=1; j<=W; ++j) {
      dp[i+1][j] = dp[i][j];
      for(int t=s[i]; t<=l[i]; ++t) {
        if(j-t<0) break;
        dp[i+1][j] = max(dp[i+1][j], dp[i+1][j-t] + p[i]);
      }
    }
  }
  cin >> m;
  for(int i=0; i<m; ++i) {
    cin >> w[i];
    if(dp[n][w[i]]==0) f = true;
  }
  if(f) cout << "-1" << endl;
  else for(int i=0; i<m; ++i) {
      cout << dp[n][w[i]] << endl;
    }
  return 0;
}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define sd second

using namespace std;

const int maxn = 100010;
const int inf = 1000000000;

int n,sz[maxn],mid=0,ano;
ll ans=0;
vector<pair<int,int> > g[maxn];

void visit(int u,int pa) {
    bool ok=true;
    sz[u]=1;
    for (int j=0;j<g[u].size();j++) {
        int v=g[u][j].fi,c=g[u][j].sd;
        if (v!=pa) {
            visit(v,u);
            sz[u]+=sz[v];
            ans+=1ll * 2 * min(sz[v],n-sz[v]) * c;
            if (2*sz[v]==n) mid=c;
            ok&=(2*sz[v]<=n);
        }
    }
    ok&=(2*(n-sz[u])<=n);
    if (ok) ano=u;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
//    freopen("in.txt","r",stdin);
    cin>>n;
    for (int i=1;i<n;i++) {
        int u,v,c;
        cin>>u>>v>>c;
        g[u].push_back(make_pair(v,c));
        g[v].push_back(make_pair(u,c));
    }
    visit(1,-1);
    if (mid!=0) ans-=mid;
    else {
        int best=inf;
        for (int j=0;j<g[ano].size();j++) {
            int v = g[ano][j].sd;
            best=min(best,v);
        }
        ans-=best;
    }
    cout<<ans;
}



Measured memory_bytes: 12800
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    cin >> N;
    ll power = 1;
    rep(i, 0, N)
    {
        power *= (i + 1);
        power %= 1000000007;
    }
    cout << power << endl;
}


Measured memory_bytes: 256
//Compiler optimization
#pragma GCC optimize("Ofast")

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

//typedef
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<vl> mat;

//macro
#define reverse(a) reverse(a.begin(),a.end())
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define each(x, v) for (auto &x : v)

//abbreviation
#define pb push_back
#define elif else if
#define mp make_pair
#define endl '\n'

//debug
#define debug(x) cerr << #x << ": " << x << endl
#define v_debug(v) cerr << #v << endl;fr(i,v.size()) cerr << i << ": " << v[i] << endl

//const
const  ll INF = 1e18;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(20);
    ll n;cin >> n;
    ll ans = 0;
    ll tmp;
    for(ll k = 1;k<=n;k++){
        tmp = (n/k)*(n/k+1)/2;
        ans += k*tmp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  while (true) {
    int n, mn, mx; cin >> n >> mn >> mx;
    if (!n) break;
    V<> p(n); for (auto&& e : p) cin >> e;
    int res = -1, g = -1;
    for (int i = mn; i <= mx; ++i) {
      if (p[i - 1] - p[i] >= g) {
        g = p[i - 1] - p[i];
        res = i;
      }
    }
    cout << res << '\n';
  }
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
#define all(a) a.begin(),a.end()
using namespace std;
int main(void){
	string s;
	cin>>s;
	if(s=="RRR")cout<<3;
	else if(s=="RRS"||s=="SRR")cout<<2;
	else if(s=="SSS")cout<<0;
	else cout<<1;
	return 0;
}

Measured memory_bytes: 3612
from collections import deque


def main():
    n, m = map(int, input().split())
    is_checked = [False for _ in range(n+1)]
    edges = [[] for _ in range(n+1)]
    ans = 0

    for _ in range(m):
        a, b = map(int, input().split())
        edges[a].append(b)
        edges[b].append(a)

    for ni in range(n):
        if is_checked[ni]:
            continue
        is_checked[ni] = True
        q = deque([ni])
        depth = 0
        while len(q) > 0:
            p = q.popleft()
            for e in edges[p]:
                if not is_checked[e]:
                    is_checked[e] = True
                    q.append(e)
            depth += 1

        ans = max(ans, depth)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 106656
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = sc.nextLong();
        long count = 0;
        while (y >= x) {
            count++;
            x = x << 1;
        }
        System.out.println(count);
        sc.close();
    }
}


Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <iomanip>
#include <math.h>
#include <vector>
#include <map>

using namespace std;

int main()
{
  int P, Q, R;
  cin >> P >> Q >> R;

  int min_flight = P+Q;
  if (min_flight > Q + R) min_flight = Q + R;
  if (min_flight > R + P) min_flight = R + P;

  cout << min_flight << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define init ios::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL);
using namespace std;

//  =========     /\       /|    |====/|
//      |        /  \       |    |   / |
//      |       /____\      |    |  /  |
//      |      /      \     |    | /   |
//  ========= /        \  =====  |/====|  
//  code

int main(){
    init;
    long long int W,N,i,j,k,l;
    cin>>N>>W;

    long long int dp[W+1][N+1];
    memset(dp,0,sizeof(dp));

    long long int w[N+1],v[N+1];
    for(i=1;i<=N;i++){
        cin>>w[i]>>v[i];
    }

    for(i=1;i<=W;i++){
        for(j=1;j<=N;j++){
            if(i >= w[j]){
                dp[i][j] = max(dp[i-w[j]][j-1] + v[j] , dp[i][j-1]);
            }
            else dp[i][j] = dp[i][j-1];
        }
    }
    cout<<dp[W][N]<<endl;
    return 0;
}

Measured memory_bytes: 79232
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <utility>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <iterator>
#include <random>
#include <fstream>
#include <chrono>
#include <math.h>
#include <cctype>
using namespace std;
#define int long long
#define forn(i, n) for (int i = 0; i < n; ++i)

#define sqr(x) ((x) * (x))

const int mod = 1e9 + 7;


int32_t main() {
    ios::sync_with_stdio(false);
    int n, c;
    cin >> n >> c;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> dp(n);
    vector<pair<int, int>> st;
    st.push_back({a[0], 0});
    for (int i = 1; i < n; i++) {
        int j = upper_bound(st.begin(), st.end(), make_pair(a[i], (int)(1e9))) - st.begin() - 1;
        j = st[j].second;
        dp[i] = dp[j] + c + sqr(a[i] - a[j]);
        while (!st.empty()) {
            int x = st.back().first;
            j = st.back().second;
            if (dp[i] + sqr(x - a[i]) > dp[j] + sqr(x - a[j])) {
                break;
            }
            st.pop_back();
        }
        j = st.back().second;
        int x = (dp[i] + sqr(a[i]) - dp[j] - sqr(a[j]) + 2 * a[i] - 2 * a[j] - 1) / (2 * a[i] - 2 * a[j]);
        st.push_back({x, i});
    }
    cout << dp.back() << endl;
    return 0;
}

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

int main() {
    ll n, m;
    cin >> n >> m;
    int ans = 0;
    for(int i=pow(m, 0.5)+1; i>=1; i--){
        if(m%i==0){
            int tmp = m/i;
            if(tmp*n<=m){
                ans = max(ans, tmp);
            }
            if(i*n<=m){
                ans = max(ans, i);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
const lines: string[] = [];
const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});
reader.on("line", function (line: string) {
  lines.push(line);
});

reader.on("close", function () {
  const inputSize = lines[0];

  //数字の配列
  const input = lines[1].split(" ").map(Number);

  const dp: any = [input.length];
  for (let i = 0; i < input.length; i++)
    dp[i] = {
      value: Infinity,
    };

  dp[0] = { value: 0 };

  for (let i = 1; i < dp.length; i++) {
    chmin(dp[i], { value: dp[i - 1].value + abs(input[i] - input[i - 1]) });
    if (i > 1)
      chmin(dp[i], { value: dp[i - 2].value + abs(input[i] - input[i - 2]) });
  }

  console.log(dp[Number(inputSize) - 1].value);
});

function chmin(a: any, b: any): boolean {
  if (a.value > b.value) {
    a.value = b.value;
    return true;
  }
  return false;
}

function chmax(a: any, b: any): boolean {
  if (a.value < b.value) {
    a = b;
    return true;
  }
  return false;
}

function abs(value: number) {
  return Math.abs(value);
}


Measured memory_bytes: 34380
import sys
import math

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    H = int(readline())
    W = int(readline())
    N = int(readline())
    print(math.ceil(N/max(H,W)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9076
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
char s[233333]; int n,c[2333],p[23333];
string L,R,M;
string rev(string x)
{
	reverse(x.begin(),x.end());
	return x;
}
vector<int> vs[233]; int ps[233333],sm[233333]; ll ans=1e18;
void work(string x)
{
	memset(sm,0,sizeof sm);
	for(int i=0;i<=200;++i) vs[i].clear();
	for(int i=int(x.size())-1;i>=0;--i)
		vs[x[i]].pb(i+1);
	for(int i=1;s[i];++i)
		ps[i]=n+1-vs[s[i]].back(),
		vs[s[i]].pop_back();
	ll ca=0;
	for(int i=1;i<=n;++i)
	{
		for(int j=ps[i];j>=1;j-=j&-j) ca+=sm[j];
		for(int j=ps[i];j<=n;j+=j&-j) ++sm[j];
	}
	ans=min(ans,ca);
}
int main()
{
	scanf("%s",s+1); n=strlen(s+1);
	for(int i=1;i<=n;++i) ++c[s[i]];
	int odd=0;
	for(int i=0;i<=200;++i)
		if(c[i]&1) ++odd;
	if(odd>1)
	{
		puts("-1");
		return 0;
	}
	for(int i=1;i<=n;++i)
	{
		++p[s[i]];
		if(c[s[i]]%2==1&&p[s[i]]==(c[s[i]]+1)/2)
			M=s[i];
		else if(p[s[i]]<=c[s[i]]/2) L.pb(s[i]);
		else R.pb(s[i]);
	}
	work(L+M+rev(L));
	work(rev(R)+M+R);
	printf("%lld\n",ans);
}


Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef unsigned long long ll;

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

int main(){
  int N, X;
  vector<int>x(100001);

  cin >> N >> X;
  for(int i=0; i < N; ++i){
    cin >> x[i];
    x[i]-=X;
    if(x[i] < 0){
      x[i]*=-1;
    }
  }

  int max_ans = x[0];

  for(int i=1; i < N; ++i){
    if(max_ans > x[i]){
      max_ans = gcd(max_ans, x[i]);
    }
    else{
      max_ans = gcd(x[i], max_ans);
    }
  }

  cout << max_ans << endl;





  return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
using namespace std;

int N, A, B;

int main() {
	cin >> N >> A >> B;
	if (N * A <= B) {
		cout << N * A;
	}
	else {
		cout << B;
	}
		return 0;
}


Measured memory_bytes: 256
#n=int(input())
n,Y=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
x,y,z=-1,-1,-1
for i in range(n+1):
    for j in range(n+1):
        k=max(0,n-(i+j))
        if i+j+k==n:
            if i*1000+j*5000+k*10000 == Y:
                x,y,z=k,j,i
                #break
print("{0} {1} {2}".format(x,y,z))


Measured memory_bytes: 73416
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define pdump(p) cout<<" "<<#p<<"=("<<p.fst<<","<<p.snd<<")"
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std; using lint = long long; using ld = long double;
using pii = pair<int, int>; using pll = pair<lint, lint>;

int main(void) {
    int n, m;
    cin >> n >> m;
    
    vector<int> divs;
    for (int i = 1; i * i <= m; ++i) {
        if (m % i == 0) {
            divs.push_back(i);
            if (i != m/i) divs.push_back(m/i);
        }
    }
    sort(divs.begin(), divs.end(), greater<int>());
    //vdump(divs);
    
    for (auto d: divs) {
        if (m/d >= n) {
            cout << d << endl;
            return 0;
        }
    }
}

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

namespace _0112
{
    public class Program

    {
        public static void Main(string[] args)
        {
            while (true)
            {
                int n = RInt();
                if (n == 0) break;

                long[] items = new long[n];
                for (int i = 0 ; i < n ; i++) items[i] = RInt();

                Console.WriteLine(items.OrderBy(x => x).Select((x, i) => x * ((n - 1) - i)).Sum());
            }
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 16536
#include<cstdio>
#include<iostream>
#include<string>

using namespace std;

int main(void){

	string W;
	string T;
	string ko("qwertyuiopasdfghjklzxcvbnm");
	string oo("QWERTYUIOPASDFGHJKLZXCVBNM");
	int lon;
	int cnt=0;
	int flag;

	cin>>W;
	while(1){
		cin>>T;
		if(T=="END_OF_TEXT") break;
		if(W.length()==T.length()){
			flag=1;
			for(int i=0;i<W.length();i++){
				if(oo.find(W[i])!=-1) W[i]=ko[oo.find(W[i])];
				if(oo.find(T[i])!=-1) T[i]=ko[oo.find(T[i])];
				if(W[i]!=T[i]) flag=0;
			}
			if(flag==1) cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 1196
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

#define N 4
#define LIM 46


int ans[N][N]={
    {1,2,3,4},
    {5,6,7,8},
    {9,10,11,12},
    {13,14,15,0}};

int x[N*N]={3,0,1,2,3,0,1,2,3,0,1,2,3,0,1,2},y[N*N]={3,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3};

int min = LIM;



void dfs(int p[N][N], int pr[N][N], int n)
{
    int i,j,i0,j0,d=0;
    int f=0;
    int tmp[N][N];
    
    for(i=0;i<N;i++)
    {
        for(j=0;j<N;j++)
        {
            if(ans[i][j]!=p[i][j])f++;
            if(p[i][j]==0)
            {
                i0=i;
                j0=j;
            }
            else
                d+=abs(j-x[p[i][j]])+abs(i-y[p[i][j]]);

        }
    }
    
    if(f==0)
    {
        if(min>n)
        {
            min=n;
        }
        return;
    }
    if(d+n>min) return;
    
    
    if(i0>0 && i0<N)
    {
        memcpy(tmp,p,sizeof(int)*N*N);
        f=tmp[i0][j0];
        tmp[i0][j0]=tmp[i0-1][j0];
        tmp[i0-1][j0]=f;
        if(memcmp(tmp,pr,sizeof(int)*N*N)!=0)
            dfs(tmp, p, n+1);
    }
    if(j0>0 && j0<N)
    {
        memcpy(tmp,p,sizeof(int)*N*N);
        f=tmp[i0][j0];
        tmp[i0][j0]=tmp[i0][j0-1];
        tmp[i0][j0-1]=f;
        if(memcmp(tmp,pr,sizeof(int)*N*N)!=0)
            dfs(tmp, p, n+1);
    }
    
    if(i0>=0 && i0<N-1)
    {
        memcpy(tmp,p,sizeof(int)*N*N);
        f=tmp[i0][j0];
        tmp[i0][j0]=tmp[i0+1][j0];
        tmp[i0+1][j0]=f;
        if(memcmp(tmp,pr,sizeof(int)*N*N)!=0)
            dfs(tmp, p, n+1);
    }
    if(j0>=0 && j0<N-1)
    {
        memcpy(tmp,p,sizeof(int)*N*N);
        f=tmp[i0][j0];
        tmp[i0][j0]=tmp[i0][j0+1];
        tmp[i0][j0+1]=f;
        if(memcmp(tmp,pr,sizeof(int)*N*N)!=0)
            dfs(tmp, p, n+1);
    }
    
}

int main()
{
    int i,j;
    int p[N][N];
    
    for(i=0;i<N;i++)
    {
        for(j=0;j<N;j++)
        {
            scanf("%d",&p[i][j]);
        }
    }
    dfs(p,p,0);
    
    printf("%d\n",min);
    
    return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    int count = 0;
    for (int num=a; num<=b; num++) {
        int x = num / 1000;
        int y = num % 100;

        if (x / 10 == y % 10 && x % 10 == y / 10) count++;
    }

    cout << count << endl;

    return 0;
}


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

using namespace std;
const int N = 110;
int _w;

int n, m, f[N][N];
char s[N][N];

int main() {
	cin >> n >> m;
	for( int i = 1; i <= n; ++i )
		cin >> (s[i] + 1);
	memset(f, 0x3f, sizeof f);
	if( s[1][1] == '#' ) {
		f[1][1] = 1;
	} else {
		f[1][1] = 0;
	}
	for( int i = 1; i <= n; ++i )
		for( int j = 1; j <= m; ++j ) {
			if( i != n ) {
				int w = (s[i][j] == s[i+1][j] || s[i+1][j] == '.') ? 0 : 1;
				f[i+1][j] = min( f[i+1][j], f[i][j] + w );
			}
			if( j != m ) {
				int w = (s[i][j] == s[i][j+1] || s[i][j+1] == '.') ? 0 : 1;
				f[i][j+1] = min( f[i][j+1], f[i][j] + w );
			}
		}
	cout << f[n][m] << endl;
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int N;
    cin >> N;
    
    cout << (N>=1000?"ABD":"ABC") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;
const long long INF = 1LL << 60;
using Graph = vector<vector<ll>>;

int main()
{
    ll n;
    cin >> n;
    vector<ll> T(n), A(n);
    rep(i, n) cin >> T[i] >> A[i];
    ll sumT = T[0];
    ll sumA = A[0];
    for (int i = 1; i < n; i++)
    {
        ll nt1, na1, nt2, na2;
        //Tを基準にした新しい値1
        if (sumT % T[i] == 0)
        {
            nt1 = sumT;
            na1 = (sumT / T[i]) * A[i];
        }
        else
        {
            nt1 = ((sumT / T[i]) + 1) * T[i];
            na1 = ((sumT / T[i]) + 1) * A[i];
        }
        //Aを基準にした新しい値2
        if (sumA % A[i] == 0)
        {
            na2 = sumA;
            nt2 = (sumA / A[i]) * T[i];
        }
        else
        {
            na2 = ((sumA / A[i]) + 1) * A[i];
            nt2 = ((sumA / A[i]) + 1) * T[i];
        }

        if (nt1 < sumT || na1 < sumA)
        {
            sumT = nt2;
            sumA = na2;
        }
        else
        {
            sumT = nt1;
            sumA = na1;
        }
    }
    cout << sumT + sumA << endl;
}

Measured memory_bytes: 3612
import math
import collections
from operator import mul
from functools import reduce



n=int(input())
v=list(map(int,input().split()))
v1=sorted(v[::2])
v2=sorted(v[1::2])

c1 = collections.Counter(v1).most_common(2)
c2 = collections.Counter(v2).most_common(2)

m1=10000000000000000000000


for ci1 in c1:
    for ci2 in c2:
        if ci1[0]!=ci2[0]:
            m1=min(m1,(len(v1)-ci1[1])+(len(v2)-ci2[1]))
        else:
            m1=min(m1,(len(v1)-ci1[1])+(len(v2)))
            m1=min(m1,(len(v2)-ci2[1])+(len(v1)))
print(m1)

Measured memory_bytes: 63724
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <tuple> 
#include <random>
#include <cassert>
#include <limits>

using namespace std;

#define mp make_pair
#define pb push_back
#define repi(i, p, q) for (long i = p; i < q; i++)
#define repd(i, p, q) for (long i = p; i >= q; i--)
#define sz(x) x.size()
#define INF 2000000000
#define MOD 1000000007

typedef map<int, int> MI;
typedef pair<int, int> PI;
typedef long long int LLI;
typedef long int LI;
typedef int I;

int main() {
    int a,b;
    cin >> a >> b;
    cout << a*b - 1*1 - 1*(a-1) - 1*(b-1);
    return 0;
}

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

#define ll long long
#define ld long double
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

struct cake
{
    ll d;
    int candle;
};

bool asc(const cake &left, const cake &right)
{
    return left.d == right.d ? left.candle < right.candle : left.d > right.d;
}

int main()
{
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> a;
    vector<ll> b;
    vector<ll> c;

    ll deli;
    rep(i, x)
    {
        cin >> deli;
        a.push_back(deli);
    }
    sort(a.begin(), a.end(), greater<ll>());
    rep(i, y)
    {
        cin >> deli;
        b.push_back(deli);
    }
    sort(b.begin(), b.end(), greater<ll>());

    rep(i, z)
    {
        cin >> deli;
        c.push_back(deli);
    }
    sort(c.begin(), c.end(), greater<ll>());

    vector<ll> ans;

    rep(i, x)
    {
        rep(j, y)
        {
            rep(l, z)
            {
                if ((i + 1) * (j + 1) * (l + 1) <= k)
                {
                    ans.push_back(a[i] + b[j] + c[l]);
                }
                else
                {
                    break;
                }
            }
        }
    }
    sort(ans.begin(), ans.end(), greater<ll>());
    rep(i, k)
    {
        cout << ans[i] << endl;
    }
}

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

int main(){
  int N;
  cin >> N;
  
  set<int> d;
  
  rep(i,N){
    int a;
    cin >> a;
    d.insert(a);
  }
  
  cout << d.size() << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
                #define ll long long
                #define f   first
                #define s   second
                #define pb          push_back
                #define mod        1000000007
                #define mod1       1000000009
                #define hell        998244353
                #define inf         1000000000000000000LL
                #define pi          3.14159265358979323
                //#define N           100005 
                const int N=200005;
                using namespace std;
                ll n,k,sum,q,res,m,val,ans;
                ll x,y;
                ll xx[]={1,0,-1,0};
                ll yy[]={0,1,0,-1};
                ll cnt[1000005];  
                void solve()    
                {   
                    cin>>n>>m;
                    cout<<(n-1)+(m>=n);


                }   
                int main()
                {   ios_base::sync_with_stdio(false);
                    cin.tie(0);cout.tie(0);
                    ll t=1; 
                   //cin>>t;
                     for(ll i=1;i<=t;i++)
                        solve();
                }            

Measured memory_bytes: 3632
using System;
using System.Linq;

class E
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var h = Read();
		int x = h[0], y = h[1];
		var a = Read();
		var b = Read();
		var c = Read();
		Console.WriteLine(a.OrderBy(v => -v).Take(x).Concat(b.OrderBy(v => -v).Take(y)).Concat(c).OrderBy(v => -v).Take(x + y).Sum(v => (long)v));
	}
}


Measured memory_bytes: 48392
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def lcm(a, b):
    return a * b / fractions.gcd(a, b)


def main():


    n = int(input())
    if n % 2 == 1:
        print(0)
        exit()
    ans = 0
    n//=2
    while n > 0:
        ans += n // 5
        n//=5
    print(ans)




if __name__ == '__main__':
    main()


Measured memory_bytes: 5084
//CODEFORCES:-
//coded by AMAN BHARTI NIT PATNA
//ALL RIGHTS RESERVED
//ECE 2K18

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

//#define home
#define TASK "soln"
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define pb push_back
#define ll long long int
#define br cout<<endl;
#define fo for(int i=0;i<n;i++)
#define foo for(int i=1;i<=n;i++)
#define mod 1000000007

int dp[1000000];

int cal(int a[],int n){
    if(n==0||n==1)return 0;

    if(dp[n]!=-1)return dp[n];

    int ans =0;
    ans+= abs(a[n]-a[n-1])+cal(a,n-1);

    if(n>=3){
        ans = min(ans,abs(a[n]-a[n-2])+cal(a,n-2));
    }

    return dp[n] = ans;
}

void solve(){
    memset(dp,-1,sizeof(dp));
    int n;
    cin>>n;
    int a[n+1];
    foo{cin>>a[i];}

    cout<<cal(a,n);
    br;    
}

int main(){
	#ifdef home
        assert(freopen(TASK".in","r",stdin));
        assert(freopen(TASK".out","w",stdout));
    #endif

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

    // int t;
    // cin>>t;
    // while(t-->0)
    solve();

    #ifdef home
        eprintf("Time: %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
    #endif

    return 0;
}

Measured memory_bytes: 15692
# coding: utf-8
#a, b, c, d = map(int,input().split())
n=int(input())
ans=1
MOD=10**9+7
a=1
b=1
c=1
for i in range(n):
    a*=10
    a%=MOD
    c*=8
    c%=MOD
for i in range(n):
    b*=9
    b%=MOD
print((a-b*2+c)%MOD)

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

int main(){
	int a, b, c, d, e, f;
	double x, y;
	double p;

	while(cin >> a >> b >> c >> d >> e >> f){
		p = (double)e/(double)b;
		x = (p*(double)c-(double)f)/(p*(double)a-(double)d);
		y = ((double)c-(double)a*x)/(double)b;

		if(abs(x)<0.005){
			x = 0.0;
		}
		if(abs(y)<0.005){
			y = 0.0;
		}


		printf("%.3f %.3f\n", x, y);
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string>
using namespace std;

struct Node
{
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

Node * treeMinimum(Node *x){
  while(x->left != NIL) x=x->left;
  return x;
}

Node * find(Node *u, int k){
  while(u != NIL && k != u->key)
  {
    if(k < u->key)
      u=u->left;
    else
      u=u->right;
  }
  return u;
}

Node * treeSuccessr(Node *x)
{
  if(x->right != NIL)
    return treeMinimum(x->right);

  Node *y=x->parent;

  while(y != NIL && x == y->right)
  {
    x=y;
    y=y->parent;
  }
  return y;
}

void treeDelete(Node *z)
{
  Node *y;
  Node *x;

  if(z->left == NIL || z->right == NIL)
    y=z;
  else
    y=treeSuccessr(z);

  if(y->left != NIL)
  {
    x=y->left;
  }
  else
  {
    x=y->right;
  }

  if(x != NIL)
  {
    x->parent=y->parent;
  }

  if(y->parent == NIL)
  {
    root=x;
  }
  else
  {
    if(y == y->parent->left)
    {
      y->parent->left=x;
    }
    else
    {
      y->parent->right=x;
    }
  }

  if(y != z)
  {
    z->key=y->key;
  }

  free(y);
}

void insert(int k){
  Node *y=NIL;
  Node *x=root;
  Node *z;

  z=(Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL)
    {
      y=x;
      if(z->key < x->key)
        {
          x = x->left;
        }
      else
        {
          x = x->right;
        }
    }

  z->parent = y;

  if(y == NIL)
    {
      root=z;
    }
  else
    {
      if(z->key < y->key)
        {
          y->left = z;
        }
      else
        {
          y->right = z;
        }
    }

}

void inoder(Node *u){
  if(u == NIL)
    return;
  inoder(u->left);
  printf(" %d", u->key);
  inoder(u->right);
}

void preoder(Node *u){
  if(u == NIL)
    return;
  printf(" %d", u->key);
  preoder(u->left);
  preoder(u->right);
}

int main(){
  int n, i, x;
  string com;

  scanf("%d", &n);

  for(i=0; i<n; i++)
  {
    cin >> com;

    if(com[0] == 'f')
    {
      scanf("%d", &x);
      Node *t=find(root, x);
      if(t != NIL)
        printf("yes\n");
      else
        printf("no\n");
    }
    else if(com == "insert")
    {
      scanf("%d", &x);
      insert(x);
    }
    else if(com == "print")
    {
      inoder(root);
      printf("\n");
      preoder(root);
      printf("\n");
    }
    else if(com == "delete")
    {
      scanf("%d", &x);
      treeDelete(find(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 21996
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<int, int, int> T;
// get<K>(tuple型の変数)

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}


int N, Q;
string s;
vector<char> t(200005), d(200005);

bool check1(int x){
    if(x==-1) return true;
    if(x==N) return false;

    char c=s[x];
    rep(i, Q) if(c==t[i]) {
        if(d[i]=='L') --x;
        else ++x;

        if(x==-1) return true;
        if(x==N) return false;
        c = s[x];
    }
    return false;
}

bool check2(int x){
    if(x==N) return true;
    if(x==-1) return false;

    char c=s[x];
    rep(i, Q) if(c==t[i]) {
        if(d[i]=='L') --x;
        else ++x;

        if(x==-1) return false;
        if(x==N) return true;
        c = s[x];
    }
    return false;
}

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

    string S; cin >> S;
    ll K; cin >> K;

    if(S == string(S.size(), S[0])){
        cout << ((ll)S.size() * K)/2 << endl;
    }
    else if(S[0] != S.back()){
        string T=S;
        ll cnt=0;
        repr(i, 1, T.size()){
            if(T[i]==T[i-1]) ++cnt, T[i]='0';
        }
        cout << cnt * K << endl;
    }
    else{
        ll a=0, b=0;
        ll cnt=0;
        string T=S;
        repr(i, 1, T.size()){
            if(T[i]==T[i-1]) ++cnt, T[i]='0';
        }
        rep(i, S.size()){
            if(S[i]==S[0]) ++a;
            else break;
        }
        reprev(i, S.size()){
            if(S[i]==S.back()) ++b;
            else break;
        }

        cout << cnt*K - (K-1) * (a/2 + b/2 - (a+b)/2) << endl;

    }

    return 0;
} 

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int X,A,B;
  cin>>X>>A>>B; 
    if(A-B>=0) cout<<"delicious";
    else{
      if(B-A<=X) cout<<"safe";
      else cout<<"dangerous";
    }
 
}

  
  


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

int N;
int x[10], y[10];

double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}

void solve() {
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> x[i] >> y[i];
    double sum = 0.0;
    vector<int> v(N);
    for(int i = 0; i < N; i++) v[i] = i + 1;
    do {
        for(int i = 0; i < N - 1; i++) sum += dist(v[i], v[i+1]);
    } while(next_permutation(v.begin(), v.end()));
    int Factorial = 1;
    for(int i = 2; i <= N; i++) Factorial *= i;
    cout << fixed << setprecision(10) << sum / Factorial << endl;
    return;
}

int main() {
    solve();
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    cout << s[0] << s[1] << s[2] << endl;


}


Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

template<class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}



ll N, a;
vector<ll> v;

int main () {
  cin >> N;
  Rep(i, 5) {
    cin >> a;
    v.push_back(a);
  }

  auto iter = min_element(All(v));
  ll n;
  if (N % *iter == 0) {
    n = N / *iter;
  } else {
    n = N / *iter + 1;
  }
  cout << 4 + n << "\n";
}

Measured memory_bytes: 256