akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ck cout<<(id++)<<endl
typedef long long ll;
const int maxn=1e6+100;
const int maxc=26;
const int mod=998244353;
char s[20][1100];
int a[20][1100];
int id;
int main()
{
    int h,w,k;
    scanf("%d%d%d",&h,&k,&w);
    for(int i=1;i<=h;i++)
    scanf("%s",s[i]);
    for(int i=1;i<=h;i++){
        for(int j=0;j<k;j++){
            a[i][j+1]=s[i][j]-'0';
        }
    }
    int mine=2000;
    for(int i=0;i<(1<<(h-1));i++){
        //ck;
        int e=0,dp[12]={},cnt=0,vis=1;
        for(int j=1;j<=k;j++){
            int now[12]={},flag=1;
            e=0;
            for(int u=1;u<=h;u++){
                now[e]+=a[u][j];
                if((i>>(u-1))&1)
                    e++;
            }
            for(int u=0;u<=e;u++){
                if(dp[u]+now[u]>w)
                    flag=0;
                if(now[u]>w)
                    vis=0;
            }
            if(flag){
                for(int u=0;u<=e;u++)
                    dp[u]+=now[u];
            }else {
                for(int u=0;u<=e;u++)
                    dp[u]=now[u];
                cnt++;
            }

        }
        e=__builtin_popcount(i);
        if(vis) mine=min(mine,cnt+e);
    }
    cout<<mine<<endl;
    return 0;
}
/*

*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> g[100005];
vector<int> h(100005);
int main(){
  int n, m; cin >> n >> m;
  bool flag;
  int ans = 0;
  for(int i = 0; i < n; ++i) cin >> h[i];
  for(int i = 0, x, y; i < m; ++i){
    cin >> x >> y;
    x--;
    y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for(int i = 0; i < n; ++i){
    flag = true;
    for(auto a: g[i]){
      if(h[a] < h[i])continue; 
      flag = false;
      break;
    }
    if(flag) ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 8776
program scoring
    implicit none
    integer(8)::D,C(26),last(26,365),last_sim(26),i,j,k,l,vmax,tbest,dadd,i_calc,vbest,add_best,score
    integer(8),allocatable::S(:,:),T(:),Tans(:),V(:)

    !入力
    read*,D,C
    allocate(S(26,D))
    allocate(T(D))
    allocate(Tans(D))
    allocate(V(D))
    read*,S
    T=0
    V=0
    last=0
    last_sim=0

    !貪欲法
    do dadd=0,26
        T=0
        V=0
        last=0
        last_sim=0
        !今日の日付+dadd日目のパラメータを使用して満足度を計算する
        do i=1,D
            i_calc=min(i+dadd,D)
            do j=1,26
                !得点の初期化
                if(i==1)V(i)=0
                if(i>1)V(i)=V(i-1)

                !lastの初期化
                if(i==1)last(:,i)=0
                if(i>1)last(:,i)=last(:,i-1)

                last(j,i)=i
                V(i)=V(i)+S(j,i)
                
                do k=1,26
                    do l=i,i_calc
                        V(i)=V(i)-C(k)*(l-last(k,i))
                    end do
                end do

                if(j==1)then
                    vmax=V(i)
                    tbest=j
                else if(V(i)>=vmax)then
                    vmax=V(i)
                    tbest=j
                end if
            end do
            if(i==1)last(:,i)=0
            if(i>1)last(:,i)=last(:,i-1)
            T(i)=tbest
            last(tbest,i)=i
        end do
        !print'(i0)',V(D)

        !得点の再計算
        score=0
        last_sim=0
        do i=1,D
            score=score+S(T(i),i)
            last_sim(T(i))=i
            do j=1,26
                score=score-C(j)*(i-last_sim(j))
            end do
        end do

        !print'(i0)',score
        if(dadd==0.or.score>vbest)then
            add_best=dadd
            vbest=score
            Tans(:)=T(:)
        end if
    end do
    !print'(i0)',vbest
    !print'(i0)',add_best
    !print'(A)',""

    do i=1,D
        print'(i0)',Tans(i)
    end do
end program scoring

Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define LL long long
#define fr(i,x,y) for(int i=(x);i<=(y);i++)
#define rf(i,x,y) for(int i=(x);i>=(y);i--)
#define frl(i,x,y) for(int i=(x);i<(y);i++)
using namespace std;
const int N=1002;
LL S;

void read(LL &x){ scanf("%lld",&x); }

int main(){
	read(S);
	LL x=sqrt(S)+0.0001,y=S/x;
	if (x*y<S) x++;
	LL v=x*y-S;
	LL a=x-1,b=y-v;
	printf("%lld %lld %lld %lld %lld %lld\n",a,0,0,b,x,y);
	return 0;
}


Measured memory_bytes: 3776
// Written by newbiechd
#include <iostream>
#include <string>
using namespace std;

const int maxN = 1003;
string s[maxN];
int t[maxN];

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i)
    cin >> s[i] >> t[i];
  string tmp;
  cin >> tmp;
  for (int i = 1; i <= n; ++i)
    if (s[i] == tmp) {
      int ans = 0;
      for (int j = i + 1; j <= n; ++j)
        ans += t[j];
      cout << ans << endl;
      return 0;
    }
  return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    DE = [list(map(int, input().split())) for _ in range(N)]
    for i in range(N - 3 + 1):
        if DE[i][0] == DE[i][1] and DE[i+1][0] == DE[i+1][1] and DE[i+2][0] == DE[i+2][1]:
            return "Yes"
    return "No"

if __name__ == '__main__':
    print(main())

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

int main()
{
    int n;
    cin >> n;
    string s;
    if(n < 1200){
        s = "ABC";
    }else if(n < 2800){
        s = "ARC";
    }else{
        s = "AGC";
    }
    
    cout << s << endl;
    return 0;
}

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


int main() {

    int n;
    while (cin >> n && n) {

        int p=1;
        int sum=0, ans=0;

        for (int i=1; i<n; ++i) {
            sum += i;
            if (sum >= n) {
                for (; sum>n && p<i; ++p) sum -= p;
                if (sum == n) ans++;
            }
        }

        cout << ans << endl;

    }

    return 0;

}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D;cin>>A>>B>>C>>D;
  if(A+B==C+D)cout<<"Balanced"<<endl;
  else if(A+B>C+D)cout<<"Left"<<endl;
  else cout<<"Right"<<endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define MAX(a, b) ((a)>(b)?(a):(b))
#define MIN(a, b) ((a)<(b)?(a):(b))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define _BFS 1
// #define _DFS 1

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

ll cost[100010];
vector< pair<int, ll> > v[100010];

void bfs(int k){
  queue< pil > q;
  q.push(pil(k, 0));

  pil p;
  int x, y;
  while(!q.empty()){
    p = q.front();
    q.pop();

    x = p.first;
    REP(i, v[x].size()){
      y = v[x][i].first;
      if(cost[y] != -1) continue;
      cost[y] = p.second + v[x][i].second;
      q.push(pil(y, cost[y]));
    }

  }
}

void dfs(int x, ll c){
  // dump(x);
  // if(cost[x] != -1) {cout << "exit" << endl; return;}
  if(cost[x] != -1) return;
  cost[x] = c;

  REP(i, v[x].size()){
    dfs(v[x][i].first, c + v[x][i].second);
  }
}

#ifdef _BFS
int main(){
  int n;
  cin >> n;

  int x, y, z;
  pair<int, ll> p;
  REP(i, n-1){
    cin >> x >> y >> z;
    p.first = y;
    p.second = z;
    v[x].push_back(p);
    p.first = x;
    v[y].push_back(p);
  }

  int q, k;
  cin >> q >> k;

  REP(i, n+1) cost[i] = -1;
  bfs(k);

  REP(i, q){
    cin >> x >> y;
    cout << cost[x] + cost[y] << endl;
  }

  return 0;
}
#endif

#ifdef _DFS
int main(){
  int n;
  cin >> n;

  int x, y, z;
  pair<int, ll> p;
  REP(i, n-1){
    cin >> x >> y >> z;
    p.first = y;
    p.second = z;
    v[x].push_back(p);
    p.first = x;
    v[y].push_back(p);
  }

  int q, k;
  cin >> q >> k;

  REP(i, n+1) cost[i] = -1;
  dfs(k);

  REP(i, q){
    cin >> x >> y;
    cout << cost[x] + cost[y] << endl;
  }

  // FOR(i, 1, n+1) cout << cost[i] << endl;
  
  return 0;
}
#endif

Measured memory_bytes: 10736
#include <stdio.h>

int main(void)
{
    int a, b, c, tmp;
    scanf("%d %d %d", &a, &b, &c);

    if (b > c) {
        tmp = c;
        c = b; 
        b = tmp;
    }

    if (a > b) {
        tmp = a;
        a = b; 
        b = tmp;
    }

    if (b > c) {
        tmp = c;
        c = b; 
        b = tmp;
    }

    printf("%d %d %d\n", a, b, c);

    return 0;
}

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

int N;
int A[200005];
queue <int> q;
long long ans;

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++) scanf("%d", &A[i]);
	sort(A, A + N, greater <int>());
	if (N == 2) {
        printf("%d\n", A[0]);
        return 0;
	}
	ans += A[0] + A[1];
	q.push(A[1]);
	q.push(A[2]);
	q.push(A[2]);
	for (int i = 3; i < N; i++) {
		ans += q.front(); q.pop();
		q.push(A[i]);
		q.push(A[i]);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 5148
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define f(i,n) for(int i=0; i<n; ++i)
#define fi(i,st,n) for(int i=st; i<=n; ++i)
#define veci vector<int>
#define vecp vector<pair<int,int> >
#define vecl vector<ll>
int prime[100000+10];

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

ll power(ll a, ll n, ll mod) {
	ll res = 1;
	while(n > 0) {
		if(n&1) {
			res = (res*a)%mod;
		}
		a = (a*a)%mod;
		n = n/2;
	}
	return res;
}

ll sum(int arr[], int n) {
	ll res = 0;
	f(i,n) {
		res += arr[i];
	}
	return res;
}

void seive() {
	prime[1] = 0;
	for(int i=2; i<=100000; i++) {
		prime[i] = 1;
	}
	for(ll i=2; i<=100000; i++) {
		if(prime[i]) {
			for(ll j=i*i; j<=100000; j+=i) {
				prime[j] = 0;
			}
		}
	}
}

bool check(int arr[], int mid, int n, int k) {
	int ans = 0;
	for(int i=0; i<n; i++) {
		if(arr[i]%mid == 0)
			ans += (arr[i])/mid - 1;
		else ans += arr[i]/mid;
	}
	return ans <= k;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--){
		int n,k;
		cin>>n>>k;
		int arr[n];
		f(i,n) cin>>arr[i];
		int ans;
		int start = 1;
		int end = 1000000000;
		while(start <= end) {
			int mid = (start + end)/2;
			if(check(arr,mid,n,k)) {
				ans = mid;
				end = mid - 1;
			}
			else {
				start = mid + 1;
			}
		}
		cout<<ans<<"\n";
 	}
 	return 0;
}


Measured memory_bytes: 4384
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define SUBL freopen("/home/ajinkya/Desktop/input.txt","r",stdin); freopen("/home/ajinkya/Desktop/output.txt","w",stdout); 
#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 
	// SUBL
	int n, l, ans=INT_MAX, sum=0;
	cin >> n >> l;
	FI(i,1,n)
	{
		sum+=(l+i-1);
		if(abs(l+i-1)<abs(ans))
		{
			ans = l+i-1;
		}
	}
	cout << sum - ans;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define p(p) cout<<(p)<<" ";
#define pb push_back
#define mp make_pair
#define INF 1<<25

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pi;
typedef long long ll;

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

struct S{
	int a,b,c;
};
bool asc(const S& left,const S& right){
	return left.c > right.c;
}
#define int ll
int N,M,Z,W;
vector<ll> a,b,c,d;
vector<vector<ll>> dp;

void input(){
	cin>>N>>Z>>W;
	a.resize(N+1);
	rep(i,N)cin>>a[i];
	dp.resize(N+1,vector<ll>(2,-1));
}

int dfs(int now,int turn){
	if(dp[now][turn]!=-1)return dp[now][turn];
	int other;
	if(now!=0) other=a[now-1];
	else other = W;
	if(now==N-1)return abs(a[N-1]-other);
	int res;
	if(turn){
		int mx=abs(other-a[N-1]);
		REP(i,now,N-1){
			int tmp=dfs(i+1,0);
			mx=max(mx,tmp);
		}
		res=mx;
	}
	else{
		int mn=abs(other-a[N-1]);
		REP(i,now,N-1){
			int tmp=dfs(i+1,1);
			mn=min(mn,tmp);
		}
		res=mn;
	}
	return dp[now][turn]=res;
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	input();
	P(dfs(0,1))
	return 0;
}



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

#define mp make_pair
#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 < n; i++)
#define for1(i,n) for(int i = 1; i <= n; i++)
#define ford(i,n) for(int i = n-1; i >= 0; i--)
#define fore(i,a,b) for(int i = a; i <= b; i++)

using namespace std;

typedef long long ll;
typedef double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;


const  int MAXn= 3e5+5;
const  long long INF= 1e18;
const long long mod= 1e9+7;


int main(){
        int n; cin>>n;
        vector<pll> v;
        
		forn(i,n){
			ll a,b;
			cin>>a>>b;
			v.emplace_back(b,a);
		}
		sort(all(v));
		
		bool flag = true;
		ll count=0;
		for(auto x : v){
			if(count + x.se > x.fi) {
				flag=false;
				break;
			}
			count += x.se;
		}
		if(flag) cout<<"Yes";
		else cout<<"No";
	}
    


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

int main()
{
	int64_t n, k;
	cin >> n >> k;
	vector<int64_t> vs(n);
	for (auto &v : vs)
	{
		cin >> v;
	}

	int64_t ans = -(1LL << 60);

	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; i + j <= n; j++)
		{
			if (k < i + j)
			{
				continue;
			}
			vector<int64_t> tmp;
			for (int l = 0; l < i; l++)
			{
				tmp.emplace_back(vs[l]);
			}
			for (int l = 0; l < j; l++)
			{
				tmp.emplace_back(vs[n - l - 1]);
			}
			sort(tmp.begin(), tmp.end());
			int64_t s = accumulate(tmp.begin(), tmp.end(), int64_t(0));
			for (int l = 0; l < tmp.size() && l < k - (i + j); l++)
			{
				if (0 <= tmp[l])
				{
					break;
				}
				s -= tmp[l];
			}
			ans = max(ans, s);
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  
  int ans = 0; //ans通り
  rep(i,a){
    rep(j,b){
      rep(k,c){
        int sum = 500*i + 100*j + 50*k;
        if(sum == x) ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll N,W;
ll w[105],v[105];
vector<vector<ll>> dp(105,vector<ll>(100005,0));
void knapsack(){
    rep(i,N) rep(j,W){
        if (j+w[i] <= W){
            chmax(dp[i+1][j+w[i]],dp[i][j]+v[i]);
        }
        chmax(dp[i+1][j],dp[i][j]);
    }
}
int main(){
    cin >> N >> W;
    rep(i,N) cin >> w[i] >> v[i];
    knapsack();
    ll ans = 0;
    rep(i,W+1) chmax(ans,dp[N][i]);
    PRINT(ans);
}


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

int main(){
  int h, w;
  std::cin >> h >> w;
  vector<vector<int> > a(h, vector<int>(w));
  vector<vector<int> > c(10, vector<int>(10));
  for (int i = 0; i < 10; i++) 
    for (int j = 0; j < 10; j++)
      std::cin >> c[i][j];
  for (int i = 0; i < h; i++) 
    for (int j = 0; j < w; j++) 
      std::cin >> a[i][j];
  int ans = 0;
  int n = 10;
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
      }
    }
  }
  
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if(a[i][j] == -1)continue;
      ans += c[a[i][j]][1];
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 384
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())
    seq = [False] * 100000

    for _ in range(N):
        l, r = map(int, readline().split())
        l -= 1
        for i in range(l, r):
            seq[i] = True

    print(seq.count(True))


if __name__ == '__main__':
    main()


Measured memory_bytes: 69288
n,m = map(int, input().split())
a_s = list(map(int, input().split()))
a_s.sort(reverse=True)

cb_s = []
for i in range(m):
    b,c = map(int, input().split())
    cb_s.append((c,b))
cb_s.sort(reverse=True)

cnt = 0
total = 0
head = 0
for i in range(m):
    c,b = cb_s[i]
    while cnt < n and a_s[head] >= c:
        cnt += 1
        total += a_s[head]
        head += 1
    if cnt == n:
        print(total)
        exit()
    for j in range(min(b, n-cnt)):
        cnt += 1
        total += c
while cnt < n:
    cnt += 1
    total += a_s[head]
    head += 1
print(total)



Measured memory_bytes: 71320
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a>b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
using namespace std;
typedef long long ll;


int main(){
	int n;
	cin>>n;
	ll c=1;
	int d[101010];
	int war=998244353;
	cin>>d[1];
	if(d[1]!=0){cout<<0<<endl;return 0;}
	ll v[101010]={};
	int ma=0;
	v[0]=1;
	rep(i,n-1){
		cin>>d[i+2];
		if(d[i+2]==0){cout<<0<<endl;return 0;}
		v[d[i+2]]++;
		MAX(ma,d[i+2]);
	}
	int w=0;
	REP(i,1,ma+1){
		if(v[i]==0){cout<<0<<endl;return 0;}
		rep(j,v[i]){
			c=(c*v[i-1])%war;
			// c*=v[i-1];
		}
	}
	cout<<c<<endl;
}

Measured memory_bytes: 1408
package main

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

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	arr := scanArrayInt()
	t := (arr[0]*100 + arr[1]*10 + arr[2]) % 4
	var o = "NO"
	if t == 0 {
		o = "YES"
	}
	fmt.Println(o)
}
func scanArrayInt() []int {
	var ret = []int{}
	stdin.Scan()
	for _, s := range strings.Split(stdin.Text(), " ") {
		i, _ := strconv.Atoi(s)
		ret = append(ret, i)
	}
	return ret
}


Measured memory_bytes: 640
#include <stdio.h>

int main()
{
	float a, b, c, d, e, f, x, y;
	while(scanf("%f %f %f %f %f %f", &a, &b, &c, &d, &e, &f) != EOF) {
		y = (a*f - c*d) / (a*e - b*d);
		x = (c - b*y) / a;
		printf("%.3f %.3f\n", x, y);
	}
	return 0;
}

Measured memory_bytes: 644
n=int(input())
A=list(map(int,input().split()))
N=((n)*(n+1))//2

if sum(A)%N!=0:
    print("NO")
    exit()
elif n==1:
    print("YES")
elif n==2:
    if sum(A)%3==0 and max(A)<=2*min(A):
        print("YES")
    else:
        print("NO")
else:
    T=(sum(A)//N)
    A+=[A[0]]
    cnt=0
    for i in range(1,len(A)):
        if (A[i]-A[i-1])==T:
            #print(A[i],A[i-1])
            continue
        else:
            if A[i-1]>A[i]-T:
                B=((A[i-1]-A[i])//n)+1
                cnt+=B
                #print(A[i],A[i-1],n*B)
                if (A[i]-A[i-1]+n*B)==T:
                    continue
                else:
                    print("NO")
                    exit()
            else:
                print("NO")
                exit()
    if T==cnt:
        print("YES")
    else:
        print("NO")
    


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

signed main() {
  string S;
  cin >> S;
  
  for( int i = 0; i < S.size(); i++ ){
    if( i % 2 == 0 ){ //奇数の時
      if( S.at(i) != 'R' && S.at(i) != 'U' && S.at(i) != 'D' ){
        cout << "No" << endl;
        return 0;
      }
    }else{ //偶数の時
      if( S.at(i) != 'L' && S.at(i) != 'U' && S.at(i) != 'D' ){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
/* https://atcoder.jp/contests/abc103/tasks/abc103_c */

#include <iostream>
#include <vector>
#include <string>

int solve(const int N, const std::vector<int> a)
{
  int y = 0;
  for (auto e: a)
  {
    y += e-1;
  }

  return y;
}

int main(int argc, char **argv)
{
  // Input
  int N;

  std::cin >> N;

  std::vector<int> a(N);

  for (auto& e: a)
  {
    std::cin >> e;
  }

  // Output
  std::cout << solve(N, a) << std::endl;

  return 0;
}


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

int main() {
  string N, S;
  cin >> N >> S;
  int count = 0;
  for(int i = 0; i < 3; i++){
  if(N.at(i) == S.at(i)){
  count += 1;
  }
  }
  cout << count;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef vector<bool> vb;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

ll k;
void solve(){
 cin >> k;
 vll que;
 rep(i,1,10) que.emplace_back(i);
 ll index=0;
 while(index<k){
  ll x=que[index]; 
  ll y=x%10; 
  if(y!=0) que.emplace_back(x*10+(y-1));
  que.emplace_back(x*10+y); 
  if(y!=9) que.emplace_back(x*10+(y+1)); 
  index++;
 }
 cout << que[k-1] << endl; 
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}  

Measured memory_bytes: 6512
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <cmath>
using namespace std;
#define pi M_PI

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

  if(a + b + c == 17){
    if((a == 5 && b == 5) || (b == 5 && c == 5) || (c == 5 && a == 5)){
      cout << "YES" << endl;
    }
  }
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
import heapq

INF = 1000000000
class Edge:
	def __init__(self, to, cost):
		self.to = to
		self.cost = cost


def dijkstra(graph, start):
	V = len(graph)
	d = [INF for _ in xrange(V)]
	d[start] = 0

	pq = []
	heapq.heappush(pq, (d[start], start))

	while len(pq) != 0:
		done = heapq.heappop(pq)
		node = graph[done[1]]
		for edge in node:
			if done[0] + edge.cost < d[edge.to]:
				d[edge.to] = done[0]+ edge.cost
				heapq.heappush(pq, (d[edge.to], edge.to))

	return d

def main():
	V, E, r = map(int, raw_input().split())

	graph = [[] for _ in xrange(V)]
	for i in xrange(E):
		_s, _t, _c = map(int, raw_input().split())
		graph[_s].append(Edge(_t, _c))


	distance = dijkstra(graph, r)
	for d in distance:
		if d == INF:
			print "INF"
		else:
			print d




if __name__ == '__main__':
	main()

Measured memory_bytes: 224624
#!/usr/bin/env python3
#
# Author: Tetsuya Ishikawa <tiskw111@gmail.com>
# Date  : June 30, 2020
##################################################### SOURCE START #####################################################

cs = ["dream", "dreamer", "erase", "eraser"]
S = input().strip()

while True:

    changed = False

    for c in cs:
        if S.endswith(c):
            S = S[:-len(c)]
            changed = True
            break
    
    if len(S) == 0:
        print("YES")
        break

    if not changed:
        print("NO")
        break

##################################################### SOURCE FINISH ####################################################
# vim: expandtab tabstop=4 shiftwidth=4 fdm=marker


Measured memory_bytes: 9080
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <bitset>
#include <list>
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rrep(i,a,n) for(ll i=n;i>=a;i--)
#define elif else if
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF = 1e+17;
const ll MODcdf = 998244353;
bool pairCompare(const P& firstElof,const P& secondElof){
    return firstElof.first<secondElof.first;
}
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string a;cin>>a;
    string s=a;
    s.push_back('0');
    ll ans0=0;
    rrep(i,0,s.size()-2){
        if(s[i]==s[i+1]){
            if(s[i]=='0')s[i]='1';
            else s[i]='0';
            ans0++;
        }
    }
    a.push_back('1');
    ll ans1=0;
    rrep(i,0,a.size()-2){
        if(a[i]==a[i+1]){
            if(a[i]=='0')a[i]='1';
            else a[i]='0';
            ans1++;
        }
    }
    cout<<min(ans1,ans0)<<endl;
}


Measured memory_bytes: 576
a,f;c(char*v){return(*v-*1[&v])*f;}main(n,s){for(scanf("%d",&n);n--;printf("%d\n",atoi(s)-a))scanf("%s",s),f=1,qsort(s,8,1,c),a=atoi(s),f=-1,qsort(s,8,1,c);exit(0);}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPS(i,n) for(int i=1;i<=(int)(n);i++)
using namespace std;
using ll = long long;
using ld = long double;

int main(void) {
    ll n;
    cin >> n;
    ll a[n];
    REP (i, n) {
        cin >> a[i];
    }

    for (int i = n-1; i >= 0; i -= 2) {
        cout << a[i] << " ";
    }
    if (n % 2 == 0) {
        for (int i = 0; i < n; i += 2) {
            cout << a[i] << " ";
        }
    } else {
        for (int i = 1; i < n; i += 2) {
            cout << a[i] << " ";
        }
    }
    cout << endl;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 6000;
vector <int> bi[N];
int xi[N];
int dfs(int t)
{
    int s = 0;
    bitset <N> X;
    X[0] = 1;
    for (int i = 0; i < bi[t].size(); ++ i)
    {
        int v = dfs(bi[t][i]);
        s += v + xi[bi[t][i]];
        X = (X << xi[bi[t][i]]) | (X << v);
    }
    int v = xi[t];
    while (v && !X[v]) v --;
    if (!X[v])
    {
        puts("IMPOSSIBLE");
        exit(0);
    }
    return s - v;
}
int main()
{
    cin >> n;
    for (int i = 2; i <= n; ++ i)
    {
        int p;
        cin >> p;
        bi[p].push_back(i);
    }
    for (int i = 1; i <= n; ++ i) cin >> xi[i];
    dfs(1);
    puts("POSSIBLE");
}


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

typedef deque <int> DI;

DI boxes;

void solve( int n, int m )
{
	if ( n == 0 )
	{
		for ( DI::iterator it = boxes.begin(); it != boxes.end(); it++ )
		{
			cout << *it;
			if ( it+1 != boxes.end() ) cout << " ";
			else cout << endl;
		}
		return;
	}

	for ( int i = m; i > 0; i-- )
	{
		if ( n-i >= 0 )
		{
			boxes.push_back( i );
			solve( n-i, i );
			boxes.pop_back();
		}
	}
}

int main( void )
{
	int n;
	while ( cin >> n && n )
	{
		boxes.clear();
		solve( n, n );
	}
}

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

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

    ll N, A, B;
    cin >> N >> A >> B;

    if (A > B || (N == 1 && A != B)) {
        cout << 0 << endl;
        exit(0);
    }
    if (N <= 2) {
        cout << 1 << endl;
        exit(0);
    }
    ll maxsum = B * (N - 1) + A;
    ll minsum = A * (N - 1) + B;
    cout << maxsum - minsum + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[5];
int main(){
    for(int i=1;i<5;i++){
        scanf("%d",&a[i]);
    }
    sort(a+1,a+5);
    int flag=0;
    if(a[1]==1){
        if(a[2]==4){
            if(a[3]==7){
                if(a[4]==9){
                    flag=1;
                }
            }
        }
    }
    if(!flag)
        printf("NO");
    else
        printf("YES");
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> hen(N);
  for(int i = 0;i < N;i++){
    cin >> hen.at(i);
  }
  
  sort(hen.begin(), hen.end());
  
  int a = hen.at(N - 1);
  
  int sum = 0;
  
  for(int i = 0;i < N - 1;i++){
    sum += hen.at(i);
    
  }
  
  if(a < sum){
    cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl;
  }
  
 
  
}


Measured memory_bytes: 256
from heapq import heappush, heappop
N, K = map(int, input().split())
TD = [list(map(int, input().split())) for _ in range(N)]
TD.sort(key=lambda x:x[1], reverse=True)
muptiple = set()
for i in range(len(TD)):
    flg = 0
    if TD[i][0] not in muptiple:
        muptiple.add(TD[i][0])
        flg = 1
    TD[i][0] = flg
TD.reverse()
ret = []
point = 0
vari = 0
total = 0
for i in range(K):
    v = TD.pop()
    vari += v[0]
    point += v[1]
    if not v[0]:
        heappush(ret, v[1])

total = vari ** 2 + point

while len(TD) > 0 and len(ret) > 0:
    v = TD.pop()
    if v[0] == 0:
        continue
    pre_t = heappop(ret)
    point -= pre_t - v[1]
    vari += 1
    tmp = vari ** 2 + point
    total = max(total, tmp)

print(total)

Measured memory_bytes: 34288
/*input

*/


// assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll          long long int
#define pb          push_back
#define pii         pair<ll ,ll >
#define vpii        vector< pii >
#define vi          vector<ll >
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define debug(x)     cout << #x << " " << x << endl;
#define debug_p(x)   cout << #x << " " << x.F << " " << x.S << endl;
#define debug_v(x)   {cout << #x << " "; for (auto ioi : x) cout << ioi << " "; cout << endl;}
#define debug_vp(x)  {cout << #x << " "; for (auto ioi : x) cout << '[' << ioi.F << " " << ioi.S << ']'; cout << endl;}
#define debug_v_v(x) {cout << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cout << ioi2 << " "; cout << '\n';} cout << "*/" << #x << endl;}

int solve()
{
	ll n;cin>>n;
	string s;cin>>s;
	ll ans=0;
	ll l = 0,r = n-1;
	while(l<r)
	{
		if(s[l]=='W' && s[r]=='R') ans++,l++,r--;
		else if(s[l]=='R') l++;
		else if(s[r]=='W') r--;
	}

	cout<<ans<<"\n";

	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	//cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

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

int main()
{
    int n;
    scanf("%d", &n);
    int c[10000];
    for(int i = 0; i < n; ++i){
        scanf("%d", &c[i]);
    }
    int min = c[0];
    int max = c[0];
    for(int i = 1; i < n; ++i){
        if(min > c[i]) min = c[i];
        if(max < c[i]) max = c[i];
    }
    long long int sum = 0;
    for(int i = 0; i < n; ++i){
        sum += c[i];
    }
    printf("%d %d %lld\n", min, max, sum);
    return 0;
}

Measured memory_bytes: 1064
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <string>
#include <sstream>
int fix()
{
    //example to format floating point numbers.
    double pi = 3.141592653589793;
    double r = 3.141592653589793 * 128;
    std::ios_base::fmtflags f(std::cout.flags()); //[1]
    std::cout << "default:\n  " << pi << " " << r << "\n";
    std::cout << std::setprecision(4) << "setprecision(4):\n  " //[2]
              << pi << " " << r << "\n";
    std::cout << std::setiosflags(std::ios::fixed) << "setiosflags(std::ios::fixed):\n  " //[2]
              << pi << " " << r << "\n";
    std::cout << std::setprecision(5) << "setprecision(5):\n  " //[2]
              << pi << " " << r << "\n";
    std::cout.flags(f);
    std::cout << "reset:\n  " << pi << " " << r << "\n";
    //[1] https://stackoverflow.com/questions/2273330/restore-the-state-of-stdcout-after-manipulating-it
    //[2] https://stackoverflow.com/questions/4217510/how-to-cout-the-correct-number-of-decimal-places-of-a-double-value
    return 0;
}
void multipleLines()
{
    //example to parse multiple lines input.
    std::istringstream isin("1 2 3\n3 2 4\n0 0 0");

    for (std::string str; std::getline(isin, str);)
    {
        std::istringstream tisin(str);
        int a, b, c;
        tisin >> a >> b >> c;
        std::cout << a << " " << b << " " << c << "\n";
    }
    //[1]  https://stackoverflow.com/questions/19767644/c-parsing-input-string-to-variables
}
#include <vector>
#include <set>
#include <map>

int main()
{
    while(true)
    {
        std::string str;
        std::cin >> str;
        int64_t a = 0;
        for(auto c :str)
        {
            a += std::stoi(std::string(1, c));
        }
        if(a == 0)
            return 0;

        std::cout << a << "\n";
    }
}


Measured memory_bytes: 3148
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

long long int gcd(long long int a,long long int b){
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b,a%b);
    }
}
long long int fac(long long int n){
    if(n==0){
        return 1;
    }
    else{
        return n*(fac(n-1))%1000000007;
    } 
}

int main(){
    long long int a,b;
    cin>>a>>b;
    if(a-b>1||a-b<-1){
        cout<<0<<endl;
    }
    if(a-b==1||a-b==-1){
        cout<<(fac(a)*fac(b))%1000000007<<endl;
    }
    if(a==b){
        cout<<(2*fac(a)*fac(b))%1000000007<<endl;
    }


    return 0;
}

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

using namespace std;
const int N=1e5+10,mod=1e9+7;
long long a[N];
long long b[N];
long long dp[N];
int main()
{

    long long n,ans=0,w;
    scanf("%lld%lld",&n,&w);

    for(int i=0;i<n;i++)
        scanf("%lld%lld",&a[i],&b[i]);

        for(long long i=0;i<n;i++){
            for(long long j=w-a[i];j>=0;j--){

            dp[a[i]+j]=max(dp[a[i]+j],dp[j]+b[i]);
            }
        }
        for(int i=0;i<=w;i++)
            ans=max(ans,dp[i]);

    printf("%lld",ans);
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());

        long tmp10 = 1;
        long tmp9 = 1;
        long tmp8 = 1;
        long cut = 1000000000 + 7;

        long ans = 0;

        for(int i = 0; i < N; i++) {
            tmp10 = (tmp10 * 10) % cut ;
            tmp9 = (tmp9 * 9) % cut ;
            tmp8 = (tmp8 * 8) % cut ;
        }

        ans = (tmp10 - tmp9 * 2 + tmp8) % cut;

        if(ans < 0) ans += cut;
        
        pw.println(ans);
        br.close();
        pw.close();
    }
}

Measured memory_bytes: 32860
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	var h int
	p, cnt := 0, 0
	for i := 0; i < n; i++ {
		fmt.Scan(&h)
		if v := h - p; v >= 0 {
			cnt += v
		}
		p = h
	}
	fmt.Println(cnt)
}


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

int main() {
  int N;
  cin >> N;
  
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    sum += r - l + 1;
  }

  cout << sum << endl;
}


Measured memory_bytes: 256
from collections import deque
S = deque(input())
Q = int(input())
x = 1
l=[]
for i in range(Q):
    a, *b = input().split()
    if a == "1":
        x *= -1
    elif a == "2":
        c, d = b
        if (c == "2" and x == -1) or  (c == "1" and x == 1):
            S.appendleft(d)
        else:
            S.append(d)
if x == -1:
    S.reverse()
print(*S, sep="")

Measured memory_bytes: 82992
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#define inf 2147483640
#define IL inline
#define RG register
#define LL long long
#define db long double
#define N 200005
using namespace std;
const db pi=acos(-1.0);
IL int gi()
{
	RG int res=0,s=1;RG char ch;
	for(ch=getchar(); (ch<'0'||ch>'9')&&ch!='-' ;ch=getchar());
	if(ch=='-') s=-1,ch=getchar();
	for(;ch>='0'&&ch<='9';ch=getchar()) res=10*res+ch-48;
	return res*s;
}
LL n;
struct node{LL x,y;} d[N],s,t;
db ans; LL dp[N],tr[N],mmax; 
IL int cmp(RG node a,RG node b){return a.x<b.x;}
IL int cmp1(RG node a,RG node b){return a.y<b.y;}
IL int lb(RG int x){return x&-x;}
IL LL ask(RG int x)
{
	RG LL res=0;
	for(;x;x-=lb(x))
		res=max(res,tr[x]);
	return res;
}
IL void add(RG int x,RG LL v)
{
	for(;x<=n;x+=lb(x))
		tr[x]=max(tr[x],v);
}
int main()
{
	//freopen("3.in","r",stdin);
	//freopen("3.out","w",stdout);
	s.x=gi(),s.y=gi(),t.x=gi(),t.y=gi();
	if(s.x>t.x) swap(s,t);
	if(s.x==t.x&&s.y>t.y) swap(s,t);
	n=gi();
	for(RG int i=1;i<=n;++i)
		{
			d[i].x=gi(),d[i].y=gi();
			if(d[i].x<s.x||d[i].x>t.x) {i-=1,n-=1;continue;}
			if(d[i].y<min(s.y,t.y)||d[i].y>max(s.y,t.y))
				{i-=1,n-=1;continue;}
		}
	ans=(abs(s.x-t.x)+abs(t.y-s.y))*100;
	if(s.y<=t.y&&n)
		{
			sort(d+1,d+n+1,cmp1);
			for(RG int i=1;i<=n;++i)
				d[i].y=i;
			sort(d+1,d+n+1,cmp);
			dp[1]=1; mmax=1; add(d[1].y,dp[1]);
			for(RG int i=2;i<=n;++i)
				{
					dp[i]=ask(d[i].y)+1;
					add(d[i].y,dp[i]);
					mmax=max(mmax,dp[i]);
				}
			ans=ans-(db)20*mmax + (db)mmax*5*pi;
		}
	else if(s.y>t.y&&n)
		{
			sort(d+1,d+n+1,cmp1);
			for(RG int i=1;i<=n;++i)
				d[i].y=i;
			sort(d+1,d+n+1,cmp);
			dp[1]=1; mmax=1; add(n+1-d[1].y,dp[1]);
			for(RG int i=2;i<=n;++i)
				{
					dp[i]=ask(n+1-d[i].y)+1;
					add(n+1-d[i].y,dp[i]);
					mmax=max(mmax,dp[i]);
				}
			ans=ans-(db)20*mmax + (db)mmax*5*pi;
		}
	if(mmax==min(abs(s.x-t.x),abs(s.y-t.y))+1) ans+=5*pi;
	printf("%.15Lf",ans);
	//fclose(stdin);fclose(stdout);
	return 0;
}

Measured memory_bytes: 6528
#if 0
(0,0)???????????????(1,1)?????????(=???????¶????)=?§?????????´??????(gx+1,gy+1)???
#endif

#include <iostream>
using namespace std;

int main(){
	int n,gx,gy,p,x1,y1,x2,y2;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> gx >> gy >> p;
		int Vert[gx+10][gy+10]; //????????????????????????????????????????????????T/F??§??¨???
		int Horiz[gx+10][gy+10]; //?????????
		long long T[gx+10][gy+10]; //?????????????????????????????????????????°
		for(int a=1; a<gx+2; a++){
			for(int b=1; b<gy+2; b++){ 
				Vert[a][b]=true;
				Horiz[a][b]=true;
			}
		}
		for(int k=0; k<p; k++){  //?????????????????????????¨????
			cin >> x1 >> y1 >> x2 >> y2;
			if (x1==x2)//????????????(=false)???????¨????
				Vert[x1+1][max(y1+1,y2+1)]=false;
			if (y1==y2)//?????¨????§?
				Horiz[max(x1+1,x2+1)][y1+1]=false;
		}

		for(int a=0; a<gx+2; a++) //?????????
			for(int b=0; b<gy+2; b++)
				T[a][b]=0;

		for(int a=1; a<gx+2; a++){ 
			for(int b=1; b<gy+2; b++){
				if(a==1&&b==1)
					T[a][b]=1;
				else if(Vert[a][b]==false && Horiz[a][b]==false)//??????????????????
					T[a][b]=0;
				else if(Vert[a][b]==true && Horiz[a][b]==false)
					T[a][b]=T[a][b-1];
				else if(Vert[a][b]==false && Horiz[a][b]==true)
					T[a][b]=T[a-1][b];
				else if(Vert[a][b]==true && Horiz[a][b]==true)
					T[a][b]=T[a-1][b]+T[a][b-1];
			}
		}
		if(T[gx+1][gy+1]==0)
			cout << "Miserable Hokusai!" << endl;
		else cout << T[gx+1][gy+1] <<endl;
	}
}

Measured memory_bytes: 3068
{-# LANGUAGE FlexibleInstances #-}

import Data.List

-- stdin
class In a where stdin :: IO a
instance In [Int] where stdin = map read . words <$> getLine

type N = Int
type ChunkCount = Int

getIndex :: [Int] -> Int
getIndex ns = treeBottom (search ns []) [1..(product ns)]
  where
    -- [3, 2, 1, 4] []                       -> [(2, 4)]
    -- [2, 1, 4]    [(2, 4)]                 -> [(2, 4), (1, 3)]
    -- [1, 4]       [(2, 4), (1, 3)]         -> [(2, 4), (1, 3), (0, 2)]
    -- [4]          [(2, 4), (1, 3), (0, 2)] -> [(2, 4), (1, 3), (0, 2), (0, 1)]
    search :: [Int] -> [(N, ChunkCount)] -> [(N, ChunkCount)]
    search [] acc = acc
    search all@(n:ns) acc = search ns $ acc ++ [(indexOf n all, length all)]

    indexOf x xs = length $ takeWhile (/=x) $ sort xs

    -- [(2, 4), (1, 3), (0, 2), (0, 1)] [1..24] -> 15
    treeBottom :: [(N, ChunkCount)] -> [Int] -> Int
    treeBottom [] [n] = n
    treeBottom ((n,cc):remains) ns = treeBottom remains $ chunk ns cc !! n
      where
        -- [1, 2, 3, 4, 5, 6] -> [[1, 2], [3, 4], [5, 6]]
        chunk :: [Int] -> ChunkCount -> [[Int]]
        chunk ns n = chunk_ ns (length ns `div` n) []
          where
            chunk_ [] _ acc = acc
            chunk_ ns len acc = chunk_ (drop len ns) len (acc ++ [take len ns])

main = do
    _ <- getLine
    a <- stdin
    b <- stdin

    print $ abs (getIndex a - getIndex b)


Measured memory_bytes: 3452
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int l,r;
  cin >> l >> r;
  if(l%2019>=r%2019 || r-l>2019){
    cout << 0 << endl;
    return 0;
  }
  l %= 2019;
  r %= 2019;
  int mod = 2019 - 1;
  for(int i=l;i<r;i++){
    for(int j=i+1;j<r+1;j++){
      mod = min(mod,(i*j)%2019);
    }
  }
  cout << mod << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
bool calc(int i,int A,int B)
{
	int a,b;
	a = (int)(i*(0.08));
	b = (int)(i*(0.1));
	if((a == A) && (b == B)) return true;
	else return false;
}
int main()
{
	long long A,B;
	long long i;
	cin >> A >> B;
	for(i=0;i<100000;i++)
	{
		if(calc(i,A,B)) 
		{
			cout << i << endl;
			break;
		}
		if(i == 99999) cout << "-1" << endl;
	}
	return 0;
}
	

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

int N, K, p;
vector<int> P;
vector<int> SP;  //K連続サイコロの目の和
double E = 0.0;
int MAX = 0; int idx;

int main(){
  cin >> N >> K;

  for(int i = 0; i < N; i++){
    cin >> p; P.push_back(p); SP.push_back(p);
  }

  for(int i = 0; i < N-1; i++) SP[i+1] = SP[i]+P[i+1];
  MAX = SP[K-1]; idx = 0;
  for(int i = K; i < N; i++){
    if(MAX < (SP[i]-SP[i-K])){ 
      MAX = (SP[i]-SP[i-K]);
      idx = i-K+1;  //連続の始まり
    }
  }

  /*n目は1/2*(n+1)と 期待値の線形性*/
  for(int i = idx; i < idx+K; i++){ 
    E += (P[i]+1) / 2.0;
  }
  printf("%.12f\n", E);
  return 0;
}



    

Measured memory_bytes: 2036
# -*- coding: utf-8 -*-

n = int(raw_input())

t = [0 for i in range(n)]
x = [0 for i in range(n)]
y = [0 for i in range(n)]

for i in range(n):
	t[i], x[i], y[i] = map(int, raw_input().split())

flag = True

for i in range(n):
	if i == 0:
		dt = t[i]
		dx = x[i]
		dy = y[i]
	else:
		dt = t[i] - t[i-1]
		dx = abs(x[i] - x[i-1])
		dy = abs(y[i] - y[i-1])

	if dt < dx + dy:
		flag = False
		break
	else:
		if (dt - (dx + dy)) % 2 == 1:
			flag = False
			break

if flag:
	print "Yes"
else:
	print "No"


Measured memory_bytes: 12908
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]

taka = l[0][0]
ao = l[0][1]

for i in range(1,n):
    rt = (taka+l[i][0]-1) // l[i][0]
    ra = (ao+l[i][1]-1) // l[i][1]
    r = max(rt,ra)
    taka = r * l[i][0]
    ao = r * l[i][1]

print(taka+ao)


Measured memory_bytes: 39280
#include <stdio.h>

const int kDiffLowerAndUpper = 'a'-'A';

int main(void) { 
  char ch;
  while(1){
    scanf( "%c" , &ch );
    if( 'a' <= ch && ch <= 'z' ) ch -= kDiffLowerAndUpper;
    else if( 'A' <= ch && ch <= 'Z' ) ch += kDiffLowerAndUpper;
    printf( "%c" , ch);
    if( ch == '\n' ) break;
  }
  return 0;
}


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

int main() {
 int n,m;
 cin >> n >> m;
 vector<int> v(m);
  
  for(int i=0;i<n;i++){
    int k;
    cin >> k;
    for(int j=0;j<k;j++){
      int a;
      cin >>a;
      v.at(a-1)++;
    }
  }
  
  int ans=0;
   for(int i=0;i<m;i++){

     if (v.at(i)==n){

       ans ++ ;
     }
   }
 
  cout << ans ;
  
      
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#include <bitset>
#include <math.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 10007;
const int INF = LLONG_MAX/3;
const int MAX = 710000;

/*-----Library-----*/

struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
    vector<int> sizeuf; //要素数
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); rank.resize(n); sizeuf.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
            sizeuf[i]=1;
        }
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

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

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        sizeuf[x]+=sizeuf[y];
        return true;
    }

    int size(int x){
        return sizeuf[root(x)];
    }
};

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

long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

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;
}
/*-----Library-----*/
signed main(){
    string s;
    cin>>s;
    if(s=="SUN")cout<<7<<endl;
    else if(s=="MON")cout<<6<<endl;
    else if(s=="TUE")cout<<5<<endl;
    else if(s=="WED")cout<<4<<endl;
    else if(s=="THU")cout<<3<<endl;
    else if(s=="FRI")cout<<2<<endl;
    else cout<<1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
 int h1,h2,k1,k2,a,b,c,d;
 cin >> h1 >> h2;
 cin >> k1 >> k2;
 cin >> a >> b >> c >> d;
 int H = h1*a+(h1/10)*c+h2*b+(h2/20)*d;
 int K = k1*a+(k1/10)*c+k2*b+(k2/20)*d;
 
  if(H > K){
   cout << "hiroshi" << endl;
  }
  else if(K > H){
   cout << "kenjiro" << endl;
  }
  else{
    cout << "even" << endl;  
  }
} 


Measured memory_bytes: 3088
/*
    ->->->->-> Vora Mahammasasim <-<-<-<-<-
*/
#include<bits/stdc++.h>
#include<stdio.h>
#define Quick std :: ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define pb emplace_back
#define Mod 1000000007
#define all(a) a.begin(),a.end()
#define ps(a) partial_sum(all(a),a.begin())
using namespace std;

signed main(){

    Quick;
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    int ans = 0;
    for(int i=1;i<n;i++){
        if(a[i] < a[i-1]){
            ans += (a[i-1] - a[i]);
            a[i] = a[i-1];
        }
    }
    cout<<ans;
}


Measured memory_bytes: 5216