akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}



int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	vector<double> e(n);
	rep(i, n) e[i] = (1.0 * a[i] + 1) / 2;
	vector<double> se(n + 1,0);
	rep(i, n) se[i + 1] = se[i] + e[i];
	double ans = 0;
	rep(i,n-k+1){
		ans = max(se[i + k] - se[i], ans);
	}
	cout << fixed << setprecision(10) <<ans << endl;
	return 0;
}

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

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

  int ans = 0;
  int cnt = 0;
  for (int i = 0; i < N.size(); ++i) {
    int x = N[i] - '0';
    if (x) ans = max(ans, cnt + x - 1 + ((int)N.size() - i - 1) * 9);
    cnt += x;
  }

  ans = max(ans, cnt);

  cout << ans << endl;
}


Measured memory_bytes: 256
//#pragma GCC optimize("O2")
//#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
using vpi = vector<pi>;
const int maxn = 2e2 + 55;
const int mod = 1e9 + 7;
ll h, n, dp[2][10100];
vpi a;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> h >> n;
	for(ll x, y, i = 0; i < n; i++) {
		cin >> x >> y;
		for(int j = 0; j < 14; j++) {
			a.pb({x*(1<<j), y*(1<<j)});
		}
	}
	memset(dp, 0x3f, sizeof dp);
	dp[0][h] = 0;
	for(int it = 0; it < a.size(); it++) {
		int i = it&1;
		memset(dp[i^1], 0x3f, sizeof dp[i^1]);
		for(ll j = 0; j <= 10000; j++) {
			if(dp[i][j]==dp[i^1][10001]) continue;
			dp[i^1][j] = min(dp[i^1][j], dp[i][j]);
			dp[i^1][max(0ll, j-a[it].first)] = min(dp[i^1][max(0ll, j-a[it].first)], dp[i][j] + a[it].second);
		}
	}
	cout << dp[a.size()&1][0];
}


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

ll fun(ll A, ll B, ll x) {
	return A * x / B - A * (x / B);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll A, B, N;
	cin >> A >> B >> N;
	ll ans = fun(A, B, N);
	ans = max(ans, fun(A, B, N / B * B - 1));
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
using namespace std;
#define int long long
#define mn 55
#define inf 777777777777777777
#define ZLA "test"
#define mod 1000000007

int n,A,a[mn],b[mn],kq,DP[mn][4905][mn];

int dp(int x,int y,int z)
{
	if (x==0)
	{
		if ((y==2450) && (z>0)) return 1;
		return 0;
	}
	if (DP[x][y][z]!=inf) return DP[x][y][z];
	DP[x][y][z]=dp(x-1,y,z)+dp(x-1,y+b[x],z+1);
	return DP[x][y][z];
}

void input()
{
	cin >> n >> A;
	for (int i=1;i<=n;i++)
	{
		cin >> a[i];
		b[i]=a[i]-A;
	}
}

void output()
{
	cout << dp(n,2450,0);
}

signed main()
{
//	freopen(ZLA".inp", "r", stdin);
//	freopen(ZLA".out", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	input();
	for (int i=1;i<=n;i++)
	{
		for (int j=0;j<=4900;j++)
		{
			for (int k=0;k<=n;k++)
			{
				DP[i][j][k]=inf;
			}
		}
	}
	output();
	return 0;
}


Measured memory_bytes: 106752
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n;cin>>n;
    vector<int> ret = {0,1,2,4,6,16,12,64,24,36,48,1024,60};
    cout << ret[n] << endl;
}



Measured memory_bytes: 3160
n,k,q = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
ans = 10**9
for i in a:
	p,s,f = [],0,1
	for j in range(n):
		if a[j]>=i and f:
			s,f = j,0
		elif a[j]<i and f-1:
			if j-s>=k:
				for j2 in sorted(a[s:j])[:j-s-k+1]: p.append(j2)
			f = 1
	if f-1 and n-s>=k:
		for j2 in sorted(a[s:n])[:n-s-k+1]: p.append(j2)
	if len(p)>=q: ans = min(ans,sorted(p)[q-1]-i)
print(ans)

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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var A = Console.ReadLine().Split().Select(double.Parse).ToArray();
            Console.WriteLine(1 / A.Select(s => 1 / s).Sum());
        }
    }
}

Measured memory_bytes: 13396
// Problem : A - Number of Multiples
// Contest : AtCoder - AIsing Programming Contest 2020
// URL : https://atcoder.jp/contests/aising2020/tasks/aising2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
int main() 
{
	// && has higher precedence than ||
	ios_base::sync_with_stdio(0); cin.tie(0);    
	int L,R,d;
	cin>>L>>R>>d;
	int c=1,ans=0;
	while(true)
	{
		if(c*d<=R)
		{
			if(c*d>=L)
				ans++;
		}
		else
			break;
		c++;
	}
	cout<<ans<<endl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3616
s = input()
N = len(s)
if N == 2:
    if s[0] == s[1]:
        print('1 2')
        quit()
    else:
        print('-1 -1')
        quit()
for i in range(N-2):
    if s[i] == s[i+1] or s[i] == s[i+2]:
        print(i+1, i+3)
        quit()
if s[-1] == s[-2]:
    print(N-2, N)
    quit()
print('-1 -1')


Measured memory_bytes: 9184
#include <stdio.h>

int main(void)
{
	int W;
	int H;
	int x;
	int y;
	int r;

	scanf("%d", &W); scanf("%d", &H);
	scanf("%d", &x); scanf("%d", &y); scanf("%d", &r);

	if (x >= W && y >= H)
		printf("No\n");
	else if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H)
		printf("Yes\n");
	else printf("No\n");
	       
	return 0;
}


Measured memory_bytes: 2140
N = int(input())
K = int(input())
X = int(input())
Y = int(input())

ac_fee = 0

if (N - K) > 0:
    for i in range(1, K+1):
        ac_fee += X
    for j in range(K+1, N+1):
        ac_fee += Y
else:
    for k in range(1, N+1):
        ac_fee += X
    
print(ac_fee)

Measured memory_bytes: 3064
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

ll hoge[1000000];
int main()
{
  ll n, a, ans = 0;
  scanf("%lld", &n);
  for (int i = 0; i < n; i++)
  {
    scanf("%lld", &a);
    hoge[i] = a - i;
  }
  sortup(hoge, n);
  for (int i = 0; i < n; i++)
  {
    ans += llabs(hoge[i] - hoge[n / 2]);
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 3324
n = int(input())
H = list(map(int,input().split()))

Dp = [0] * n

Dp[1] = abs(H[1] - H[0])     

for i in range(2, n):
    Dp[i] = min(Dp[i-1] + abs(H[i] - H[i-1]), Dp[i-2] + abs(H[i] - H[i-2]))
    
print(Dp[-1])


Measured memory_bytes: 13980
#include<stdio.h>

int main(void){
  char S[100001];
  int n;
  long long int ans = 1,mod = 1000000007,c[26] = {0};
  
  scanf("%d",&n);
  scanf("%s",S);
  
  for(int i = 0;i<n;i++){
    c[S[i] - 'a']++;
  }
  
  for(int i = 0;i<26;i++){
    ans = ans * (c[i] + 1) % mod;
  }
  printf("%lld",ans - 1);
}


Measured memory_bytes: 256
#include<cstdio>
#include<cctype>

int main(){
    char ch;
    
    while(1){
        scanf("%c",&ch);
        if(isalpha(ch)){
            if(islower(ch))printf("%c",toupper(ch));
            else printf("%c",tolower(ch));
            
        }else printf("%c",ch);
        if(ch=='\n')break;
    }
    return 0;
}


Measured memory_bytes: 2568
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fr(i,j,n)   for(long long i=j;i<(n);++i)
#define bk(i,j,n)   for(long long i=j;i>=n;--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define MOD 1000000007
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define srt(x) sort(x.begin(),x.end());
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>

typedef long long ll;

//std::cout << std::setprecision(12) << s << '\n';
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}

ll n;
ll a[305];
double dp[301][301][301];
typedef double ld;

ld fun(ll on,ll tw,ll th)
{
    ld s=1.0*(on+tw+th);

    if(dp[on][tw][th]!=-1)
        return dp[on][tw][th];

    ld a=0,b=0,c=0;

    if(on)
    {
        a=(fun(on-1,tw,th)+1.0)*on/s;
    }
    if(tw)
    {
        b=(fun(on+1,tw-1,th)+1.0)*tw/s;
    }
    if(th)
    {
        c=(fun(on,tw+1,th-1)+1.0)*th/s;
    }
    ld nn=1.0*n;
    return dp[on][tw][th]=a+b+c+(nn-s)/s;





}


int main()
{
    run;
    cin>>n;
    ll c1=0,c2=0,c3=0;
    fr(i,0,n)
    {
        cin>>a[i];
        if(a[i]==1)
        {
            c1++;
        }else if(a[i]==2)
        {
            c2++;
        }else{
        c3++;}
    }

    fr(i,0,301)
    {
        fr(j,0,301)
        {
            fr(k,0,301)
            {
                dp[i][j][k]=-1;
            }
        }
    }
    dp[0][0][0]=0;

    cout<<setprecision(12)<<fun(c1,c2,c3)<<endl;

    


}


Measured memory_bytes: 213504
// BWOTSHEWCHB

#include <bits/stdc++.h>

using namespace std ;

#define int long long
#define pb push_back
#define in insert
#define X first
#define Y second

const int MAXN = 1e6 + 69 , MOD = 1e9 + 7 ;

int n , ans , arr[MAXN] ;

int32_t main() {
	ios::sync_with_stdio(false) ;
	cin.tie(0) ; cout.tie(0) ;
	cin >> n ;
	int parity = 0 , Min = 1e10 ;
	for ( int i = 1 ; i <= n ; i ++ ) {
		cin >> arr[i] ;
		if ( arr[i] <= 0 )
			parity ^= 1 ;
		Min = min(Min , abs(arr[i])) ;
		ans += abs(arr[i]) ;
	}
	if ( parity )
		cout << ans - 2 * Min << "\n" ;
	else
		cout << ans << "\n" ;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

constexpr ll inf = INT64_MAX / 4;
constexpr ll mod = 1000000007;

int main() {
    int n, k;
    string s;
    cin >> n >> k >> s;
    vector<pair<int, int>> h;
    int d = 0;
    char v = s[0];
    for (int i = 0; i < n; i++) {
        if (s[i] != v) {
            h.emplace_back(v, d);
            d = 0;
            v = s[i];
        }
        d++;
    }
    if (d != 0)h.emplace_back(v, d);
    int ret = 0, l = 0, r = 0, c = k, maxr = 0;
    for (int i = 0; r < h.size() && (i < k || h[r].first == '1'); r++) {
        ret += h[r].second;
        if (h[r].first == '0') i++;
    }
    maxr = ret;
    while (r != h.size()) {
        ret -= h[l].second;
        if (h[l].first == '0') c--;
        l++;
        while (r < h.size() && (c < k || h[r].first == '1')) {
            ret += h[r].second;
            if (h[r].first == '0') c++;
            r++;
        }
        maxr = max(maxr, ret);
    }
    cout << maxr << endl;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  string s;
  cin >> s;
  int N = s.size();
  vector<char> S(N);
  for (int i = 0; i < N; i++) S.at(i) = s.at(i);
  
  sort(S.begin(), S.end());
  
  string ans = "yes";
  for (int i = 1; i < N; i++)
  {
    if (S.at(i - 1) == S.at(i))
    {
      ans = "no";
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 764
#include <stdio.h>
int main(void)
{
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);
    if((1 <= n)&&(n <= 20)&&(1 <= a)&&(a <= 50)&&(1 <= b)&&(b <= 50))
    {
        int train, taxi;
        train = n * a;
        taxi = b;
        if(train < taxi) printf("%d", train);
        else             printf("%d", taxi);
    }
}


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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 2 ** 31 - 1
MOD = 10 ** 9 + 7

class SegTreeLazy:
    """ 遅延評価セグメント木(区間更新・区間最小値取得) """

    def __init__(self, N, func, intv):
        self.intv = intv
        self.func = func
        LV = (N-1).bit_length()
        self.N0 = 2**LV
        self.data = [intv]*(2*self.N0)
        self.lazy = [None]*(2*self.N0)

    # 伝搬される区間のインデックス(1-indexed)を全て列挙するgenerator
    def gindex(self, l, r):
        L = l + self.N0; R = r + self.N0
        lm = (L // (L & -L)) >> 1
        rm = (R // (R & -R)) >> 1
        while L < R:
            if R <= rm:
                yield R
            if L <= lm:
                yield L
            L >>= 1; R >>= 1
        while L:
            yield L
            L >>= 1

    # 遅延評価の伝搬処理
    def propagates(self, *ids):
        # 1-indexedで単調増加のインデックスリスト
        for i in reversed(ids):
            v = self.lazy[i-1]
            if v is None:
                continue
            self.lazy[2*i-1] = self.data[2*i-1] = self.lazy[2*i] = self.data[2*i] = v
            self.lazy[i-1] = None

    def update(self, l, r, x):
        """ 区間[l,r)の値をxに更新 """

        *ids, = self.gindex(l, r)
        # 1. トップダウンにlazyの値を伝搬
        self.propagates(*ids)
        # 2. 区間[l,r)のdata, lazyの値を更新
        L = self.N0 + l; R = self.N0 + r
        while L < R:
            if R & 1:
                R -= 1
                self.lazy[R-1] = self.data[R-1] = x
            if L & 1:
                self.lazy[L-1] = self.data[L-1] = x
                L += 1
            L >>= 1; R >>= 1
        # 3. 伝搬させた区間について、ボトムアップにdataの値を伝搬する
        for i in ids:
            self.data[i-1] = self.func(self.data[2*i-1], self.data[2*i])

    def query(self, l, r):
        """ 区間[l,r)の最小値を取得 """

        # 1. トップダウンにlazyの値を伝搬
        self.propagates(*self.gindex(l, r))
        L = self.N0 + l; R = self.N0 + r

        # 2. 区間[l, r)の最小値を求める
        s = self.intv
        while L < R:
            if R & 1:
                R -= 1
                s = self.func(s, self.data[R-1])
            if L & 1:
                s = self.func(s, self.data[L-1])
                L += 1
            L >>= 1; R >>= 1
        return s

N, Q = MAP()
stl = SegTreeLazy(N+1, min, INF)

ans = []
for i in range(Q):
    cmd, *arg = MAP()
    if cmd == 0:
        s, t, x = arg
        stl.update(s, t+1, x)
    else:
        i, = arg
        ans.append(str(stl.query(i, i+1)))
print('\n'.join(ans))



Measured memory_bytes: 17832
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;
int main(){
    int A,B,C;
    cin >> A >> B >> C;
    cout << C << " " << A << " " << B << endl;
    return 0;
}

Measured memory_bytes: 256
/*
 *  連立方程式
        ax + by = c
        dx + ey = f
    の解、x, y を出力して終了するプログラムを作成して下さい。
    a, b, c, d, e, f はそれぞれ、 -1000 以上 1000 以下の実数とし、連立方程式の解が一意に存在するように与えれれるものとします。
     
    Input
    複数のデータセットが与えられます。入力の最後まで処理して下さい。１つのデータセットが１行に与えられます。
    １つのデータセットに a, b, c, d, e, f が１つのスペースで区切られて与えられます。
     
    Output
    各データセットに対して、x, y を１つのスペースで区切って１行に出力して下さい。
    各値は小数点以下第３位まで出力して下さい。小数点以下第４位を四捨五入して下さい。
     
    x，yは以下の解法で求める
    x = (ce - fb) / (ae -bd)
    y = (cd - fa) / (bd - ae)
 
 */
#include <stdio.h>
#include <stdlib.h>
 
int main(void) {
    char buff[1000];
    int a, b, c, d, e, f;
    double x, y;
 
    while(fgets(buff, sizeof(buff), stdin) != NULL){
        if(sscanf(buff,("%d %d %d %d %d %d"),
            &a, &b, &c, &d, &e, &f) != 6) exit(-1);
 
        if( a < -1000 || a > 1000 ||
            b < -1000 || b > 1000 ||
            c < -1000 || d > 1000 ||
            d < -1000 || d > 1000 ||
            e < -1000 || e > 1000 ||
            f < -1000 || f > 1000
            ) exit(-1);
 
        x = (double)(c*e - f*b) / (a*e - b*d);
        y = (double)(c*d - f*a) / (b*d - a*e);
 
        printf("%.3f %.3f\n",x  + 0.00001,y  + 0.00001);
    }
    return 0;
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define repx(i, a, b) for(int i = a; i <= b; i++)
int cake[333][333], piece[333][333];

int main(){

    // 1. 入力情報.
    int H, W, K;
    scanf("%d %d %d", &H, &W, &K);
    char c[333];
    rep(i, H){
        scanf("%s", c);
        rep(j, W) cake[i][j] = c[j];
    }
    // rep(i, H){
    //     rep(j, W) printf("%c ", cake[i][j]);
    //     printf("\n");
    // }
    
    // 2. K個の長方形ピースに分割.
    // 行ごとに見ていく方針で, とりあえず対応.
    int strawberry = 1;
    rep(i, H){
        int bef = 0;
        int sharp = 0;
        rep(j, W){
            if(cake[i][j] == '#'){
                repx(k, bef, j) if(piece[i][k] == 0) piece[i][k] = strawberry;
                strawberry++;
                bef = j + 1;
                sharp++;
            }
            if(j == W - 1 && piece[i][j] == 0 && sharp > 0){
                repx(k, bef, j) piece[i][k] = strawberry - 1;
            }
        }
    }
    
    // 3. ピースに分割出来てない部分を処理.
    // 0 が 並んでいる筈なので, 0以上の値が入るように修正.
    int zero = 0;
    rep(i, H){
        if(piece[i][0] != 0){
            repx(x, i - zero, i - 1) rep(y, W) piece[x][y] = piece[i][y];
            zero = 0;
        }else{
            zero++;
        }
    }
    // 最終行に, 0 が並んでいる場合も考慮.
    if(zero > 0) repx(x, H - zero, H - 1) rep(y, W) piece[x][y] = piece[H - 1 - zero][y];
    
    // 4. 出力
    rep(i, H){
        rep(j, W){
            printf("%d", piece[i][j]);
            if(j < W - 1) printf(" ");
            else          printf("\n");
        }
    }
    return 0;
    
}

Measured memory_bytes: 1536
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#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 <queue>

 
using namespace std;
 
#define INF 1000000000
#define EPS 1e-9
#define PI acos(-1)
 
typedef long long ll;

#define MAX_N 100
#define MAX_M 1000
#define MAX_H 1000

int N, M, A;

struct ame{
  int h,p,q;
};

bool comp(const ame& e1, const ame& e2){
  return e1.h > e2.h;
}

vector<int> ans_list;



int main(){

  while(true){

    cin >> N >> M >> A;
    if(N == 0)
      break;
    
    struct ame P[MAX_M];

    for(int i = 0; i < M; i++){
      cin >> P[i].h >> P[i].p >> P[i].q;
    }

    sort(P, P+M, comp);

    int height = MAX_H;
    int num = 0;

    while(num < M){
      
      if(P[num].h < height){
	height = P[num].h;
	continue;
      }

      else{
	if(P[num].p == A){
	  A = P[num].q;
	  num++;
	  continue;
	}
	else if(P[num].q == A){
	  A = P[num].p;
	  num++;
	  continue;
	}
      }

      num++;

    }

    ans_list.push_back(A);
   

  }

  for(int i = 0; i < ans_list.size(); i++){
    cout << ans_list[i] << endl;
  }

  return 0;

}

Measured memory_bytes: 1236
#include <stdio.h>

int main(void)
{
	char str1[2],str2[2];
	scanf("%s%s",str1,str2);
	if(str1[0] == 'H')
		{
		if(str2[0] == 'H')
			{printf("H");}
		else
			{printf("D");}
		}
	else
		{
		if(str2[0] == 'H')
			{printf("D");}
		else
			{printf("H");}
		}
			
	return 0;
}


Measured memory_bytes: 128
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	nl := strings.Split(sc.Text(), " ")
	n, _ := strconv.Atoi(nl[0])
	// l, _ := strconv.Atoi(nl[1])

	var s []string
	for i := 0; i < n; i++ {
		sc.Scan()
		s = append(s, sc.Text())
	}

	sort.Strings(s)

	var result string

	for _, str := range s {
		result += str
	}
	fmt.Println(result)
}


Measured memory_bytes: 2408
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define fr(i,l,r) for(int i=l;i<=r;i++)
int m[401][401];
int a[401],sum[401];
int fun(int i,int j)
{
    if(m[i][j]!=-1)return m[i][j];
    if(i==j)return m[i][j]=0;
      m[i][j]=1e18;
    for(int k=i;k<j;k++)
    {   
          int cost=fun(i,k)+fun(k+1,j)-sum[i-1]+sum[j];
          if(cost<m[i][j])m[i][j]=cost;
    }
    return m[i][j];
}
signed main()
{  // freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
  
  for(int i=1;i<=n;i++)
  { cin>>a[i];
    if(i==1)sum[i]=a[i];
    else sum[i]=sum[i-1]+a[i];
  }
  for(int i=0;i<=n;i++)
  {
    for(int j=0;j<=n;j++)
        m[i][j]=-1;
  }
  cout<<fun(1,n)<<endl;


    return 0;
}

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

int main(){
  ll n,m,ans,i,sum;
  cin >> n >> m;
  ll a[n];
  sum=0;
  ans=0;
  for(i=0;i<n;i++){
    cin >> a[i];
    sum+=a[i];
  }
  for(i=0;i<n;i++){
    if(4*m*a[i]>=sum){
      ans+=1;
    }
  }
  if(ans>=m){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 384
n = int(input())
a_s = list(map(int, input().split()))
b_s = list(map(int, input().split()))

count = 0
next_b1_minus = 0
for a, b1, b2 in zip(a_s, [0]+b_s, b_s+[0]):
    b1 -= next_b1_minus
    if b1 >= a:
        count += a
        next_b1_minus = 0
    elif b1+b2 >= a:
        count += a
        next_b1_minus = a-b1
    else:
        count += b1+b2
        next_b1_minus = b2

print(count)


Measured memory_bytes: 19116
#include <iostream>
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int H, W;
while (cin >> H >> W && (H > 0 || W > 0)) {
for (int i = 0; i < H; i++) {
 for (int j = 0; j < W; j++) {
     if ((i+j)%2==0)
         cout << "#";
     else
         cout << ".";
 }
 cout << "\n";
}
cout << "\n";
}
}

Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int n,k;
    cin >> n >> k;
    long long int ans=0;
    for(long long int i=k+1;i<=n;i++){
        if(k==0){
            ans += n/i;
            long long int mod = min((n+i-1)%i+1,i-1);
            if(i>1)ans += (((n+i-1)/i)*mod+(((n+i-1)/i-1)*(i-mod-1)));
        }
        else{
            int mod = min((n+i-k)%i+1,i-k);
            ans += ((n+i-k)/i)*(mod)+(((n+i-k)/i-1)*(i-k-mod));            
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def loadIcicle():
	icicles = []
	line = input().strip().split(" ")
	N, L = int(line[0]), int(line[1])
	while True:
		icicles.append(int(input().strip()))
		if len(icicles) == N: break
	return icicles, N, L
icicles, N, L = loadIcicle()

def calcDiff(icicles, N):
	diff_2times = [0]*N

	for idx in range(N):
		dif_right = icicles[idx+1] - icicles[idx] if idx != N-1 else -icicles[idx]
		dif_left = icicles[idx] - icicles[idx-1] if idx != 0 else icicles[idx]

		dif_right = 1 if dif_right > 0 else -1
		dif_left = 1 if dif_left > 0 else -1

		if dif_right - dif_left < 0: diff_2times[idx] = -1
		elif dif_right - dif_left > 0: diff_2times[idx] = 1
		else: diff_2times[idx] = 0

	return diff_2times

diff_2times = calcDiff(icicles, N)

time = [-1]*N
peakX = [i for i in range(N) if diff_2times[i]==-1]
for i in peakX:
	time[i] = L - icicles[i]

	isLocalMinL, isLocalMinR = False, False
	posL, posR = i, i
	while not (isLocalMinL and isLocalMinR):
		posL -= 1
		if posL < 0:
			isLocalMinL = True
		if not isLocalMinL:
			if time[posL] == -1:
				time[posL] = (L-icicles[posL]) + time[posL+1]
			else:
				time[posL] = (L-icicles[posL]) + max(time[posL-1], time[posL+1])

			if diff_2times[posL] == 1:
				isLocalMinL = True

		posR += 1
		if posR >= N:
			isLocalMinR = True
		if not isLocalMinR:
			if time[posR] == -1:
				time[posR] = (L-icicles[posR]) + time[posR-1]
			else:
				time[posR] = (L-icicles[posR]) + max(time[posR-1], time[posR+1])

			if diff_2times[posR] == 1:
				isLocalMinR = True
print(max(time))

Measured memory_bytes: 17756
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> P;
struct pos {
  int row;
  int column;
};
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1 << 30;
const ll MOD = 1000000007;
int main(void) {
  string s1, s2;
  cin >> s1 >> s2;
  int dp[1001][1001];
  rep(i, 1001) {
    rep(j, 1001) { dp[i][j] = INF; }
  }

  dp[0][0] = 0;
  for (int i = 0; i <= s2.size(); i++) {
    dp[0][i] = i;
  }

  for (int j = 0; j <= s1.size(); j++) {
    dp[j][0] = j;
  }

  for (int i = 0; i < s1.size(); i++) {
    for (int j = 0; j < s2.size(); j++) {
      if (s1[i] == s2[j]) {
        dp[i + 1][j + 1] = min(dp[i][j], dp[i + 1][j + 1]);
      } else {
        dp[i + 1][j + 1] =
            min(dp[i][j] + 1, min(dp[i][j + 1] + 1, dp[i + 1][j] + 1));
      }
    }
  }

  cout << dp[s1.size()][s2.size()] << endl;
  return 0;
}


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

#define rep(i, n) for(int i=0; i<n; i++)

inline string max(const string& a, const string& b)
{
  if(a.length() < b.length()) return b;
  if(a.length() > b.length()) return a;
  return a < b ? b : a;
}

int W, H;
char C[77][77];
string dp[77][77];

int main(int argc, char *argv[])
{

  while(cin >> W >> H, W){
    rep(i, H) rep(j, W) cin >> C[i][j];
    rep(i, H) rep(j, W) dp[i][j] = "";
    if(C[0][0] > '0' && C[0][0] <= '9') dp[0][0] = C[0][0];
    rep(i, H) rep(j, W) if(i || j){
      if(C[i][j] >= '0' && C[i][j] <= '9'){
        if(i && (C[i][j] > '0' || dp[i - 1][j] != "")) dp[i][j] = max(dp[i][j], string(dp[i - 1][j] + C[i][j]));
        if(j && (C[i][j] > '0' || dp[i][j - 1] != "")) dp[i][j] = max(dp[i][j], string(dp[i][j - 1] + C[i][j]));
      }
    }
    string res = "";
    rep(i, H) rep(j, W) res = max(res, dp[i][j]);
    cout << (res == "" ? "0" : res) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1400
from collections import deque
n,m=map(int,input().split())
edge=[[] for _ in range(n)]
for i in range(m):
    x,y=map(int,input().split())
    edge[x-1].append(y-1)
    edge[y-1].append(x-1)
dist=[-1]*n
d=deque()
d.append(0)
now=0
while d:
    x=d.popleft()
    for i in range(len(edge[x])):
        if dist[edge[x][i]]==-1:
            dist[edge[x][i]]=x+1
            d.append(edge[x][i])
print("Yes")
for i in range(n-1):
    print(dist[i+1])

Measured memory_bytes: 36836
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
int main()
{
	int n;
	string s, s1, s2;
	cin >> n >> s;
	if(n % 2 == 1){
		printf("No");
		return 0;
	}
	int m = n / 2, flg = 0;
	for(int i = 0; i < m; i++){
		if(s[i] != s[i + m]){
			flg = 1;
			printf("No");
		}
	}
	if(flg == 0)	printf("Yes");
	return 0;
 } 

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

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

    ll d;
    cin >> d;

    vector<vector<vector<ll>>> dp(str.size()+1,vector<vector<ll>>(d,vector<ll>(2,0)));

    dp[str.size()][0][1] = 1;

    for(int i = str.size()-1; i >= 0; i--){
        for(int j = 0; j < d; j++){
            for(int k = 0; k <= 9; k++){
                if(k < str[str.size() - i - 1] - '0' ){
                    dp[i][(j+k)%d][0] += (dp[i+1][j][0] + dp[i+1][j][1])%MOD;
                    dp[i][(j+k)%d][0] %= MOD;
                }else if(k > str[str.size() - i - 1] - '0'){
                    dp[i][(j+k)%d][0] += dp[i+1][j][0];
                    dp[i][(j+k)%d][0] %= MOD;
                }else{
                    dp[i][(j+(str[str.size() - i - 1] - '0'))%d][0] += dp[i+1][j][0];
                    dp[i][(j+(str[str.size() - i - 1] - '0'))%d][0] %= MOD;
                    dp[i][(j+(str[str.size() - i - 1] - '0'))%d][1] += dp[i+1][j][1];
                    dp[i][(j+(str[str.size() - i - 1] - '0'))%d][1] %= MOD;
                }
            }
        }
    }

    ll ans;

    cout << ((ans = dp[0][0][0] + dp[0][0][1] - 1) < 0 ? ans + MOD : ans)%MOD << endl;
    
    return 0;
}

Measured memory_bytes: 55424
import numpy as np

N, M = map(int, input().split())
H_list = [int(x) for x in input().split()]
np_H_list = np.array(H_list)
H_days = np.sum(np_H_list)

if N - H_days >= 0:
    print(N - H_days)

else:
    print(-1)


Measured memory_bytes: 27616
#include <queue>
#include <string>
#include <vector>
#include <iostream>
using namespace std;

bool searched[2][1009][1009], dp[2][1009][1009];
bool solve(int p, int zero, int one) {
	if (zero + one == 1) return true;
	if (searched[p][zero][one]) return dp[p][zero][one];
	bool ret = false;
	if (p == 1) {
		if (!solve(0, zero, one)) ret = true;
	}
	if (zero >= 2) {
		if (!solve(p ^ 1, zero - 1, one)) ret = true;
	}
	if (zero >= 1 && one >= 1) {
		if (!solve(p ^ 1, zero - 1, one)) ret = true;
	}
	if (one >= 2) {
		if (!solve(p, zero + 1, one - 2)) ret = true;
	}
	searched[p][zero][one] = true;
	return dp[p][zero][one] = ret;
}

int n, x; string s;
int main() {
	cin >> n;
	vector<vector<int> > G(n);
	for (int i = 0; i < n; i++) {
		cin >> s;
		for (int j = 0; j < n; j++) {
			if (s[j] == 'Y') G[i].push_back(j);
		}
	}
	int zero = 0, one = 0;
	vector<bool> vis(n);
	for (int i = 0; i < n; i++) {
		if (vis[i]) continue;
		queue<int> que; que.push(i); vis[i] = true;
		int cnt = 0, pile = 1;
		while (!que.empty()) {
			int u = que.front(); que.pop();
			for (int i : G[u]) {
				cnt++;
				if (!vis[i]) {
					vis[i] = true;
					pile++;
					que.push(i);
				}
			}
		}
		cnt /= 2;
		x ^= (pile * (pile - 1) / 2 - cnt) % 2;
		if (pile % 2 == 0) zero++;
		else one++;
	}
	cout << (solve(x, zero, one) ? "Taro" : "Hanako") << endl;
	return 0;
}

Measured memory_bytes: 5176
package main
 
import (
  "fmt"
  "math"
)
 
const inf = math.MaxInt32
 
type edge struct {
  from int
  to   int
  cost int
}
 
func main() {
  var n,m int
  fmt.Scan(&n,&m)
  
  edges := make([]edge ,m)
  for i := range edges {
    fmt.Scan(&edges[i].from)
    fmt.Scan(&edges[i].to)
    fmt.Scan(&edges[i].cost)
  }
  
  //ノードi,j間の最短経路を定義
  dist := make([][]int, n)
  for i := 0; i < n; i++ {
    dist[i] = make([]int, n)
    for j := 0; j < n; j++ {
      if i == j {
        dist[i][j] = 0
      } else {
        dist[i][j] = inf
      }
    }
  }
  
  //既知の経路
  for i := 0; i < m; i++ {
    dist[edges[i].from-1][edges[i].to-1] = edges[i].cost
    dist[edges[i].to-1][edges[i].from-1] = edges[i].cost
  }
  
  //最短経路を更新
  for k := 0; k < n; k++ {
    for i := 0; i < n; i++ {
      for j := 0; j < n; j++ {

        //経由した方が低コストの場合、最短経路を更新
        if dist[i][k]+dist[k][j] < dist[i][j] {
          dist[i][j] = dist[i][k] + dist[k][j]
          dist[j][i] = dist[i][k] + dist[k][j]
        }
      }
    }
  }
  
  //最短経路に含まれていない辺をカウント
  ans := 0
  for i := 0; i < m; i++ {
    if dist[edges[i].from-1][edges[i].to-1] < edges[i].cost {
      ans++
    }
  }
  fmt.Println(ans)
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <chrono> 
 
using namespace std;
using namespace std::chrono; 
 
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
// #pragma optimization_level 3
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define f0r(a, b) for (long long a = 0; a < (b); ++a)
#define f1r(a, b, c) for (long long a = (b); a < (c); ++a)
#define f0rd(a, b) for (long long a = (b); a >= 0; --a)
#define f1rd(a, b, c) for (long long a = (b); a >= (c); --a)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define pb push_back
#define send {ios_base::sync_with_stdio(false);}
#define help {cin.tie(NULL); cout.tie(NULL);}
#define fix(prec) {cout << setprecision(prec) << fixed;}
#define mp make_pair
#define f first
#define s second
#define presum(p, a, n) {p[0] = a[0]; for (int i = 1; i < (n); i++) p[i] = a[i] + p[i-1];}
#define all(v) v.begin(), v.end()
#define getunique(v) {sort(all(v)); v.erase(unique(all(v)), v.end());}
#define readgraph(list, edges) for (int i = 0; i < edges; i++) {int a, b; cin >> a >> b; a--; b--; list[a].pb(b); list[b].pb(a);}
#define ai(a, n) for (int ele = 0; ele < n; ele++) cin >> a[ele];
#define ain(a, lb, rb) for (int ele = lb; ele <= rb; ele++) cin >> a[ele];
#define ao(a, n) {for (int ele = 0; ele < (n); ele++) { if (ele) cout << " "; cout << a[ele]; } cout << '\n';}
#define aout(a, lb, rb) {for (int ele = (lb); ele <= (rb); ele++) { if (ele > (lb)) cout << " "; cout << a[ele]; } cout << '\n';}
typedef long long ll;
typedef double ld;
typedef long double lld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
 
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
  cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
  cin >> p.first;
  return cin >> p.second;
}
 
mt19937 rng(steady_clock::now().time_since_epoch().count());
// mt19937 rng(61378913);
/* usage - just do rng() */
 
void usaco(string filename) {
  // #pragma message("be careful, freopen may be wrong")
	freopen((filename + ".in").c_str(), "r", stdin);
	freopen((filename + ".out").c_str(), "w", stdout);
}
 
const lld pi = 3.14159265358979323846;
// const ll mod = 1000000007;
// const ll mod = 998244353;
// ll mod;
 


ll n, m, k, q, l, r, x, y, z;
ll a[1000005];
ll b[1000005];
ll c[1000005];
string s, t;
ll ans = 0;

string rr[2] = {"ABC", "ARC"};

void solve(int tc) {
  cin >> s;
  cout << rr[s == rr[0]] << '\n';
}
 
int main() {
  send help
 
  // usaco("file");
 
  int tc;
  tc = 1;
  // cin >> tc;
  for (int t = 0; t < tc; t++) solve(t);
} 

Measured memory_bytes: 3664
#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;
struct Card{ char suit,value; };

void BubbleSort(struct Card C[],int n){
	Card tmp;
	for (int i = 0; i < n; i++){
		for (int j = n - 1; j >= i; j--){
			if (C[j].value < C[j - 1].value){
				tmp = C[j]; C[j] = C[j - 1]; C[j - 1] = tmp;
			}
		}
	}
}

void SelectionSort(struct Card C[],int n){
	Card tmp;
	for (int i = 0; i < n; i++){
		int min = i;
		for (int j = i; j < n; j++){
			if (C[j].value < C[min].value){
				min = j;
			}
		}
		tmp = C[i]; C[i] = C[min]; C[min] = tmp;
	}
}

void print(struct Card C[],int n){
	for (int i = 0; i < n; i++){
		if (i != 0)
			cout << " ";
		cout << C[i].suit << C[i].value;
	}
	cout << endl;
}

bool isStable(struct Card C1[],struct Card C2[],int n){
	for (int i = 0; i < n; i++){
		if (C1[i].suit != C2[i].suit){
			return false;
		}
	}
	return true;
}

int main(){
	Card C1[100], C2[100];
	int n;
	char ch;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> C1[i].suit >> C1[i].value;
	}
	for (int i = 0; i < n; i++)
		C2[i] = C1[i];
	BubbleSort(C1, n);
	SelectionSort(C2, n);
	print(C1, n);
	cout << "Stable" << endl;
	print(C2, n);
	if (isStable(C1, C2, n)){
		cout << "Stable" << endl;
	}
	else{
		cout << "Not stable" << endl;
	}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;

const int INF=1<<30;
const ll LINF = 1e18+5;

int main() {
    int N;
    cin >> N;
    ld ans1 = (ld)(N)/1.08;
    int ans = (int)ans1;
    while(1) {
        if((int)((ld)ans*1.08) <N) ans++;
        else if((int)((ld)ans*1.08) ==N) break;
        else {
            cout << ":(" << endl;
            return 0;
        }
    } 
    cout << ans << endl;
    return 0;
}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    int x, t;
    cin >> x >> t;
    if (x - t < 0)
        cout << 0 << endl;
    else
        cout << x - t << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n,k;
	cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++)
	cin>>arr[i];
	int dp[n];
	dp[0]=0;
	dp[1] = abs(arr[1]-arr[0]);
	if(n<3){
	cout<< dp[n-1];
	return 0;
	}
	for(int i=2;i<n;i++)
	{
		int mx = INT_MAX;
		if(i<k)
		{
			for(int j=i-1;j>=0;j--)
			{
				mx = min(mx,dp[j]+abs(arr[i]-arr[j]));
			}
		}
		else
		{
			for(int j=i-1;j>=i-k;j--)
			{
				mx = min(mx,dp[j]+abs(arr[i]-arr[j]));
			}
		}
		
		dp[i]=mx;
	}
	/*for(int i=0;i<n;i++)
	cout<<dp[i]<<" ";*/
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
from itertools import groupby

a = ['_','.,!? ','abc','def','ghi','jkl','mno','pqrs','tuv','wxyz']
for i in xrange(input()):
	b = [[i for i in j] for i,j in groupby(raw_input())]
	c = []
	d = ''
	for i in b:
		index = int(i[0])
		s = a[index][(len(i))%len(a[index])-1]
		if s == '_':
			d = d + ''.join(c)
			c = []
		else:
			c.append(s)
	if d != '':
		print d

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    double pi = 3.1415926535897932384626;
    li r;
    cin >> r;
    printf("%.12f\n", 2 * r * pi);

    return 0;
}

Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
int main() {
  int a, b, c, d ;
  cin >> a >> b >> c >> d;
  int ab, cd;
  if (a > b) ab = b;
  else ab = a;
  if (c > d) cd = d;
  else cd = c;
  cout << ab+cd << endl;
  return 0;
}

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

#define FOR(i,a,b)    for (int i=(a)  ;i<(b) ;i++)
#define RFOR(i,a,b)   for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)      for (int i=0    ;i<(n) ;i++)
#define RREP(i,n)     for (int i=(n)-1;i>=0  ;i--)
#define EACH(i,a,b)   for (int i=(a)  ;i<=(b);i++)
#define REACH(i,a,b)  for (int i=(b)  ;i>=(a);i--)
#define ALL(a)        (a).begin(),  (a).end()
#define RALL(a)       (a).rbegin(), (a).rend()
#define YES()         printf("YES\n")
#define NO()          printf("NO\n")
#define Yes()         printf("Yes\n")
#define No()          printf("No\n")
#define in(a,x,b)     ((a) <= (x) && (x) < (b))

const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const double EPS = 1e-10;

using ll = long long;
using P = pair<int,int>;
template<class T = int> using V = vector<T>;

template<class T> bool inline chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool inline chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T = int> T inline input() { T x; cin >> x; return (x); }
template<class T> void inline print(T& x) { cout << x << '\n'; }
#define debug(x) cerr << #x << ": " << x << endl;

const int dxs[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dys[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

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

  int N;
  cin >> N;
  ll T[N];
  REP(i,N) cin >> T[i];

  ll ans = 1;
  REP(i,N) ans = lcm(ans,T[i]);

  cout << ans << endl;
}



Measured memory_bytes: 3652
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Long n = sc.nextLong();
        Long k = sc.nextLong();

        List<Long> l = new ArrayList<Long>();
        Long ansMin = 0L, ansMax = 0L;

        for (int i = 0; i < n; i++) {
            Long now = sc.nextLong();
            l.add(now);
            ansMin = Math.max(ansMin, now - 1);
            ansMax += now;
        }


        while (ansMin + 1 < ansMax) {
            Long ansMid = (ansMin + ansMax) / 2;

            Long x = 0L;
            Long count = 0L;
            for (int i = 0; i < n; i++) {
                if (x + l.get(i) > ansMid) {
                    x = 0L;
                    count++;
                }
                x += l.get(i);
            }
            if (x != 0) {
                count++;
            }
            if (count <= k) {
                ansMax = ansMid;
            } else {
                ansMin = ansMid;
            }
        }
        System.out.println(ansMin + 1);
    }
}



Measured memory_bytes: 105812