akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define repc(i, s, t) for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(ios_base::fixed);
    cout.precision(12);

    var(int, a, b, H, M);

    const double argMin = 360. * (M / 60.0);
    const double argHour = 360. * ((60 * H + M) / (60.0 * 12));
    const double argDiff =
        min(360 - abs(argHour - argMin), abs(argHour - argMin));

    dump(argHour);
    dump(argMin);
    dump(argDiff);

    const double rad = argDiff * M_PI / 180;
    print(sqrt(a * a + b * b - 2 * a * b * cos(rad)));

    return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false);	
    cin.tie(0);
	int n, cnt = 0;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		if (p[i] != i + 1) cnt++;
	}
	if (cnt <= 2) cout << "YES" << "\n";
	else cout << "NO" << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;

using namespace std;
int a[205];
int main()
{
    int n;
    cin >> n;
    FOR(i,1,n)
    cin >> a[i];
    bool ok = true;
    int ans = 0;
    while(ok)
    {
        FOR(i,1,n)
        {
            if(a[i]%2 == 0)a[i] /= 2;
            else ok = false;
        }
        if(!ok)break;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
using ll = long long;
using ii = pair < int , int >;
using i3 = pair < int , ii >;
using vi = vector < int >;
using vii = vector < ii >;
using vi3 = vector < i3 >;

const int N = 1e5 + 5;
const ll INF = 1e12 , mod = 1e9 + 7;
const double eps = 1e-9 , PI = acos(-1);

int n;
char s[N];

ll mem[N][15];

ll dp(int i , int rem){
    if(i == n){
        return rem == 5;
    }

    ll &ret = mem[i][rem];
    if(ret != -1)return ret;
    ret = 0;

    if(s[i] == '?'){
        for(int j = 0 ; j <= 9 ; j ++){
            ret += dp(i + 1 , (rem*10 + j)%13);
            ret %= mod;
        }
    }
    else {
        ret += dp(i+1 , (rem*10 + int(s[i] - '0'))%13);
        ret %= mod;
    }

    return ret;
}

void solve(){
    scanf("%s" , s);
    n = strlen(s);

    memset(mem , -1 , sizeof mem);
    printf("%lld\n" , dp(0 , 0));
}

main(){

    int t = 1;
    //scanf("%d" , &t);

    while( t -- ){
        solve();
    }

    return 0;
}




Measured memory_bytes: 18304
#include <stdio.h>
#include <string.h>
#define MAX_N 100
#define MAX_X 297


int mem[MAX_N + 1][MAX_X + 1][3];

int dfs(int n,int x,int i,int s,int p){
	int ret = 0, j;
	if(s == x && p == 3){
		return 1;
	}else if(n < i || x < s || p == 3){
		return 0;
	}
	if(mem[i][s][p] != -1){
		return mem[i][s][p];
	}
	for(j = i;j <= n;j++){
		ret += dfs(n,x,j + 1,s + j,p + 1);
	}
	return mem[i][s][p] = ret;
}


int main(void){
	int n, x;
	while(1){
		scanf("%d%d",&n,&x);
		if((n | x) == 0){
			break;
		}
		memset(mem,-1,sizeof(mem));
		if(x <= MAX_X){
			printf("%d\n",dfs(n,x,1,0,0));
		}else{
			printf("0\n");
		}
	}
	return 0;
}

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

int ck[200005];
int arr[200005];

int main(){
  ios::sync_with_stdio(0); cin.tie(0), cout.tie(0);
  int n, x; cin >> n >> x;
  if(x==1||x==2*n-1){
    cout << "No";
    return 0;
  }
  cout << "Yes\n";
  int flag = 1;
  if(x==2*n-2){
    arr[n-1] = x-1;
    arr[n] = x;
    arr[n+1] = x+1;
    arr[n+2] = x-2;
    ck[x-2] = ck[x-1] = ck[x] = ck[x+1] = 1;

  }
  else{
    arr[n-1] = x+1;
    arr[n] = x;
    arr[n+1] = x-1;
    arr[n+2] = x+2;
    ck[x-1] = ck[x] = ck[x+1] = ck[x+2] = 1;
  }
  for(int i = 1 ; i <= 2*n-1; i++){
    if(arr[i]){
        cout << arr[i] << '\n';
        continue;
    }
    while(ck[flag]){
      flag++;
    }
    cout << flag << '\n';
    ck[flag] = 1;
  }
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define ll long long
#define all(x) begin(x), end(x)
#define range(x) begin(x), begin(x)
#define what(x) cout << #x << ": " << x << '\n'
#define print(x) for (auto &el: x) cout << el << ' '; cout << '\n'
using namespace std;
 
template<typename S, typename T>
ostream& operator <<(ostream &os, pair<S, T> &m) { 
    os << '[' << m.first << " " << m.second << ']'; 
    return os; 
}

int count_digits(ll n) {
    int cnt = 0;
    while(n > 0) {
        cnt++;
        n /= 10;
    }
    return cnt;
}

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

    
    int n;
    cin >> n;

    vector<ll> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        if (v[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    ll prod = 1;
    for (int i = 0; i < n; ++i) {
        if ( ((long double) prod / 1e18) * v[i] > 1.00 ) {
            cout << -1 << endl;
            return 0;
        }
        prod *= v[i];
    }

    cout << prod << endl;


    return 0;
}

Measured memory_bytes: 3988
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define EB emplace_back
#define MP make_pair
#define all(o) (o).begin(), (o).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define fr(i,n) for(lli i=0;i<n;++i)
#define rep(i,a,b) for(lli i=a;i<=b;++i)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b)))
#define endl '\n'
typedef long long int lli;
typedef long double ld;
typedef pair< lli,lli > ii;
typedef vector<lli> vi;
typedef vector<ii> vii;
typedef vector<vi> graph;
lli MOD=1000000007;long double EPS=1e-9;


void pre(){

}

int n;
lli arr[3030];


void solve(){
	cin>>n;
	fr(i,n)cin>>arr[i];
	lli ans=0;
	fr(i,n)ans+=arr[i]-1;
	cout<<ans<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	pre();
	int t=1;
	//cin>>t;
	for(int i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
		solve();
	}
}

Measured memory_bytes: 256
use std::io::{BufRead, Write};
use std::io;
use std::iter;

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut buf = String::new();
    input.read_line(&mut buf).unwrap();
    let n: usize = buf.trim_right().parse().unwrap();
    buf.clear();
    input.read_line(&mut buf).unwrap();
    let t: Vec<usize> = buf.split_whitespace().map(|x| x.parse().unwrap()).chain(iter::once(0)).collect();
    buf.clear();
    input.read_line(&mut buf).unwrap();
    let v: Vec<usize> = buf.split_whitespace().map(|x| x.parse().unwrap()).chain(iter::once(0)).collect();
    assert!(n == t.len() - 1 && n == v.len() - 1);
    let mut result = 0.;
    let mut current_speed = 0.;
    for i in 0..n {
        let mut accu = 0;
        let target_speed = (i + 1..n + 1).map(|j| {
            let ret = v[j] + accu;
            accu += t[j];
            ret
        }).min().unwrap();
        let max_speed = (v[i] as f64).min((t[i] as f64 + current_speed + target_speed as f64) / 2.).min(current_speed + t[i] as f64);
        let goal_speed = max_speed.min(target_speed as f64);
        let accel = max_speed - current_speed;
        let decel = max_speed - goal_speed;
        let keep = t[i] as f64 - accel - decel;
            assert!(accel >= 0.);
            assert!(decel >= 0.);
            assert!(keep >= 0.);
        result += (current_speed + max_speed) * accel / 2. + keep * max_speed + (goal_speed + max_speed) * decel / 2.;
        current_speed = goal_speed;
    }
    writeln!(output, "{}", result).unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }

    #[test]
    fn case1() {
        test(
            "1
100
30\n",
            "2100.000000000000000\n",
        );
    }

    #[test]
    fn case2() {
        test(
            "2
60 50
34 38\n",
            "2632.000000000000000\n",
        );
    }

    #[test]
    fn case3() {
        test(
            "3
12 14 2
6 2 7\n",
            "76.000000000000000\n",
        );
    }

    #[test]
    fn case4() {
        test(
            "1
9
10\n",
            "20.250000000000000\n",
        );
    }

    #[test]
    fn case5() {
        test(
            "10
64 55 27 35 76 119 7 18 49 100
29 19 31 39 27 48 41 87 55 70\n",
            "20291.000000000000000\n",
        );
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
namespace April
{
	inline void check_min(int a,int &b){if(a<b)b=a;}
	inline void check_max(int a,int &b){if(a>b)b=a;}
	const int N=2050,M=N*2,INF=2147483647;
	int begin[N],next[M],to[M];
	int n,m,e,ans;
	void add(int x,int y,bool k=1)
	{
		to[++e]=y;
		next[e]=begin[x];
		begin[x]=e;
		if(k)add(y,x,0);
	}
	int dfs(int p,int h=0,int dis=0)
	{
		if(dis>m/2)return 0;
		int ret=1;
		for(int i=begin[p],q;i;i=next[i])
			if((q=to[i])!=h)ret+=dfs(q,p,dis+1);
		return ret;
	}
	void work(int p)
	{
		int ret=dfs(p);
		check_min(n-ret,ans);
	}
	void cao(int i)
	{
		int u=to[i*2],v=to[i*2-1];
		int ret=dfs(u,v)+dfs(v,u);
		check_min(n-ret,ans);
	}
	void initialize()
	{
		scanf("%d%d",&n,&m);
		for(int i=1,u,v;i<n;i++)
			scanf("%d%d",&u,&v),add(u,v);
	}
	void solve()
	{
		initialize();
		ans=n;
		if(m&1)for(int i=1;i<=n;i++)cao(i);
		else for(int i=1;i<n;i++)work(i);
		printf("%d\n",ans);
	}
}
int main()
{
	April::solve();
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
    ll n;
    cin>>n;
for(int i=1;i<=9;i++){
    if(i*100+i*10+i>=n){
        cout<<i*100+i*10+i<<endl;
        break;
    }
}
}












Measured memory_bytes: 256
N = int(input())
a = [int(input()) for i in range(N)]

if 2 in a:
	l = 1
	count = 0
	while 1:
		if l==2:
			print(count)
			break
		elif a[l-1]==0:
			print(-1)
			break
		temp = l-1
		l = a[l-1]
		a[temp] = 0 
		count += 1
else:
	print(-1)

Measured memory_bytes: 7084
#include <cstdio>
#include <iostream>
typedef long long ll;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)

using namespace std;

int main() {
	int n;
	int a[15][15];	
	while(scanf("%d", &n), n) {
		rep(i,15) {
			rep(j,15) {
				a[i][j] = 0;
			}
		}
		rep(i,n) {
			rep(j,n) {
				cin >> a[i][j];
			}
		}
		rep(i,n) {
			rep(j,n) {
				a[i][n] += a[i][j];
			}
		}
		rep(i,n+1) {
			rep(j,n) {
				a[n][i] += a[j][i];
			}
		}
		
		rep(i,n+1) {
			rep(j,n+1) {
				printf("%5d", a[i][j]);
			}
			cout << endl;
		}
	}
	return 0;
}

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

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//------------------------------------------------------------------

int main(void){
	double n, m, d;
	cin >> n >> m >> d;
	if(d==0) prtd(10, (m-1)/n);
	else prtd(10, 2*(m-1)*(n-d)/n/n);
}


Measured memory_bytes: 3724
import math
N, K = map(int, input().split())
if K%2 == 1:
    n = math.floor(N/K)
    print(n**3)
else:
    n1 = math.floor(N/K)
    k = K/2
    n2 = (math.floor(N/k)+1)//2
    print(n1**3 + n2**3)

Measured memory_bytes: 3060
s = input()
flag = "NO"
s = s[::-1]
for i in range(len(s)//5+1):
    if s[0:5] == "maerd":
        s = s[5:]
    if s[0:7] == "remaerd":
        s = s[7:]
    if s[0:5] == "esare":
        s = s[5:]
    if s[0:6] == "resare":
        s = s[6:]
            
    if s == '':
        flag = "YES"
        
print(flag)

Measured memory_bytes: 133896
#include <stdio.h>
#include <string.h>

int main(){
	int L, R, d;
	int sum = 0;
	scanf ("%d %d %d", &L, &R, &d);
	
	for(int i = L; i <= R; i++){
		if (i % d == 0){
			sum++;
		}
	}
	printf ("%d", sum);
	
	return 0;
}

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

int main() {
	ll n;cin >> n;
  	ll rtn = sqrt(n);
  	if (n==1) {cout<<0;return 0;}

	vector<int> x(rtn + 1, 0);
	ll num = n;

	for (int i = 2; i <= rtn; i++) {
		while (num%i == 0) {
			x.at(i)++;
			num /= i;
		}
	}

	int ans = 0;
	for (int i = 2; i <= rtn; i++)
	{	
      int cnt=1;
      while (x[i] > 0) {
        x[i] -= cnt;
        cnt++;
        if (x[i] >= 0) ans++;
      }
	}
    if (num != 1) ans++;
  	cout << ans << endl;
}

Measured memory_bytes: 7248
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define x first
#define y second
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ve vector
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define sz(a) (int)(a.size())
//using namespace __gnu_pbds;
using namespace std;

// // // functions: find_by_order  & order_of_key
// typedef tree<
// int,
// null_type,
// less<int>,
// rb_tree_tag,
// tree_order_statistics_node_update>
// ordered_set;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

const int inf=(int)2e9;
const long long mod=1000000007; //1E9+7
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

ll powmod(ll a,ll p){
	ll ans=1;
	while(p){
		if(p&1) ans*=a;
		p/=2;a*=a; ans%=mod;a%=mod;
	}
	return ans;
}
ll mdinv(ll a){return powmod(a,mod-2); }

signed main(){
	IOS
	int n;cin>>n;
	int w;cin>>w;
	vi DP(w+1,0);
	for(int i=0;i<n;i++){
		int a,b;cin>>a>>b;
		for(int x=w;x>=a;x--){
			DP[x]=max(DP[x],b+DP[x-a]);
		}
	}
	cout<<DP[w];
}


Measured memory_bytes: 1024
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

s = rr()
t = rr()
for i in range(len(s)+3):
    if s == t:
        print('Yes')
        exit()
    else:
        s = s[-1] + s[:-1]
print('No')
        












Measured memory_bytes: 27144
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
const Int MOD = 1000000007;
const Int MAX = 2000100;
Int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = finv[0] = finv[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;
    }
}
Int COM(int n, int k) {
    if (n < k || n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
Int POW(Int n, Int m) {
    if (m == 0) return 1;
    if (m % 2 == 0) return POW(n*n%MOD, m/2);
    return n*POW(n, m-1)%MOD;
}
int main() {
    COMinit();
    int K; cin >> K;
    string S; cin >> S;
    int N = S.size();
    vector<Int> A(K + 1), B(K + 1);
    for (int i = 0; i <= K; i++) {
        A[i] = COM(N - 1 + i, i) * POW(25, i) % MOD;
    }
    for (int i = 0; i <= K; i++) {
        B[i] = A[i] + (i > 0 ? B[i - 1] * 26 : 0);
        B[i] %= MOD;
    }
    cout << B[K] << endl;
    return 0;
}


Measured memory_bytes: 66832
n=int(input())
s = [input().split() for i in range(n)]
c=0
for x in s:
    c+=1
    x.append(c)
    x[1]=str(100-int(x[1])).zfill(3)
s.sort(key=lambda x:(x[0],x[1]))
for x in s:
    print(x[2])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef pair< int,int > point;
int main(){
    int n,a;
    scanf("%d",&n);
    map< int,int > mp;
    int cnt=0;
    for(int i=0;i<n;++i){
        scanf("%d",&a);
        if(mp.find(a)==mp.end()) mp.insert(point(a,1));
        else mp[a]++;
        if(mp[a]==a) cnt-=a-1;
        else if(mp[a]>a) cnt++;
        else cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}



Measured memory_bytes: 4736
using static System.Math;
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            getAns(n);
        }
    }
    static void getAns(int n)
    {
        var dif = int.MaxValue;
        for (int i = 0; i * i * i <= n; i++)
            for (int j = 0; j * (j + 1) * (j + 2) / 6 <= n; j++)
            {
                var w = i * i * i + j * (j + 1) * (j + 2) / 6;
                if (w > n) break;
                dif = Min(dif, n - w);
            }
        Console.WriteLine(n - dif);
    }
}



Measured memory_bytes: 13728
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt
from fractions import gcd
from itertools import permutations, combinations

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

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas



# N = intinput()
# S = input()
H, A = mulinputs()
# datas = list(mulinputs())
# datas = lineinputs(input)

# 出力
ans = H//A
if H - (ans * A) > 0:
    ans += 1
print(ans)




Measured memory_bytes: 5532
#include<bits/stdc++.h>
#define mod 1000000007
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
int main()
{
	IOS
	long long int a,b,c,d;
	cin >> a >> b >> c >> d;
	long long int ans1 = a * c;
	long long int ans2 = a * d;
	long long int ans3 = b * c;
	long long int ans4 = b * d;
	cout << max({ans1,ans2,ans3,ans4});
}

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

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)　//通らない
            {
                int[] data = new int[2];
                data = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                int h = data[0];
                int w = data[1];

                if (h == 0 && w == 0) break;
                else
                for (int i = 0; i < h; i++)
                {
                    for (int j = 0; j < w; j++)
                    {
                        Console.Write("#");
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }

        }
    }
}


Measured memory_bytes: 18340
#include <stdio.h>

int main(void) {
	int K, A, B;
	int asumi, iguti;
	if (scanf("%d", &K) != 1) return 1;
	if (scanf("%d%d", &A, &B) != 2) return 1;
	asumi = A / K;
	iguti = B / K;
	if (asumi < iguti) {
		puts("OK");
	} else {
		puts(A % K == 0 ? "OK" : "NG");
	}
	return 0;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
// #define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int n; cin >> n;
    vec a(n), b(n), c(n-1);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n-1) cin >> c[i];
    int res = 0;
    int cur = -1;
    rep(i, n){
        res += b[a[i]-1];
        if(cur+1 == a[i]-1) res += c[cur];
        cur = a[i]-1;
    }
    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7624
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto rd = readln.split.to!(int[]), a = rd[0], b = rd[1];
  auto s = readln.chomp;

  foreach (i, c; s) {
    if (i == a) {
      if (c != '-') {
        writeln("No");
        return;
      }
    } else {
      if (c < '0' || c > '9') {
        writeln("No");
        return;
      }
    }
  }

  writeln("Yes");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1010;
int n,k,a[maxn];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	int sum=0;
	for(int i=0;i<k;i++)
		sum+=a[i];
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3668
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int[] ingredients = new int[N];
        for (int i = 0; i < N; i++) ingredients[i] = in.nextInt();
        Arrays.sort(ingredients);

        float res = (float) (ingredients[0] + ingredients[1]) / 2;
        for (int i = 2; i < N; i++) res = (res + (float)ingredients[i]) / 2;
        System.out.println(res);
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t a,b,c,d;cin>>a>>b>>c>>d;
  int64_t ans=-1000000000000000000;
  int64_t tmp;
  tmp=a*c;
  ans=max(ans,tmp);
  tmp=a*d;
  ans=max(ans,tmp);
  tmp=b*c;
  ans=max(ans,tmp);
  tmp=b*d;
  ans=max(ans,tmp);
  if(a*b<=0||c*d<=0){tmp=0;ans=max(ans,tmp);}
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
	int a,f, b;
	cin >> a >>f>> b;
	if (a + f < b){
		cout << "NA" << endl;
	}
	else if(a==b|a>b){
		cout <<"0" << endl;
	}
	else{
		cout << b - a << endl;
	}
	return 0;

}


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

int main(){
  int t[5];
  rep(i,5) cin >> t[i];
  
  int total=0,rem=10;
  rep(i,5){
    if(t[i]%10==0){
      total += t[i];
    }else{
      if(t[i]%10 < rem) rem = t[i]%10;
      total += (t[i]/10 + 1)*10;
    }
  }
  
  total = total - 10 + rem;
  
  cout << total << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
	static NODE node;
	static NODE root;
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));	
		int n=Integer.parseInt(br.readLine());
		
		for(int i=0;i<n;i++){
			String[] str=br.readLine().split(" ");
		
			if("print".equals(str[0])) {
				inorder(root);
				System.out.println("");	
				preorder(root);
				System.out.println("");	
			}
			else if("insert".equals(str[0])){
				int key=Integer.parseInt(str[1]);
				NODE newnode=new NODE();
				newnode.key=key;
				insert(newnode);
			}
			
			else if("find".equals(str[0])){
				int key=Integer.parseInt(str[1]);
				findnum(root,key);
			}

		}
	}
	
	static void findnum(NODE node,int key){
		boolean flag=false;
		while(node!=null){
			if(node.key==key){
				flag=true;
				break;
			}
			else{
				if(key<node.key) node=node.left;
				else node=node.right;
			}
		}
		if (flag) System.out.println("yes");
		else System.out.println("no");
	}

	static void inorder(NODE node){
		if(node==null) return;
		inorder(node.left);
		System.out.print(" " + node.key);
		inorder(node.right);
	}
	
	static void preorder(NODE node){		
		if(node==null) return;
		System.out.print(" " + node.key);
		preorder(node.left);
		preorder(node.right);	
	}
	
	static void insert(NODE node){
        if(root==null){
            root = node;
            return;
        }
        NODE tnode = root;
        NODE parent = null;
        while(tnode != null) {
            parent = tnode;
            if(tnode.key > node.key)
                tnode = tnode.left;
            else
                tnode = tnode.right;
        }
        if(parent.key > node.key)
            parent.left = node;
        else
            parent.right = node;
		
	}
}

class NODE{
	int key;
	NODE left;
	NODE right;;
	NODE(){
		key=-1;
		left=null;
		right=null;
	}
}

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

using namespace std;

int main()
{
    string S;
    cin >> S;
    string s1 = {S.at(0),S.at(1)};
    string s2 = {S.at(2),S.at(3)};

    int n1 = stoi(s1);
    int n2 = stoi(s2);
    
    if(n1 < 13 && 0 < n1) // n1が月
    {
        if(!(n2 < 13 && 0 < n2)) // n2が年
        {
            cout << "MMYY" << endl;
        }
        else // n2も月
        {
            cout << "AMBIGUOUS" << endl;
        }
    }
    else // n1が月でない
    {
        if(!(n2 < 13 && 0 < n2)) // n2も月でない
        {
            cout << "NA" << endl;
        }
        else // n2が月
        {
            cout << "YYMM" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<cstdint>
#include<climits>
#include<cstdbool>
#include<iostream>
#include<vector>
#include<array>
#include<string>
#include<strstream>

int main(){
	int N;
	std::cin>>N;
	if(N == 1)
		std::cout<<1;
	else if(N < 4)
		std::cout<<2;
	else if(N < 8)
		std::cout<<4;
	else if(N < 16)
		std::cout<<8;
	else if(N < 32)
		std::cout<<16;
	else if(N < 64)
		std::cout<<32;
	else
		std::cout<<64;
}


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

int main(void)
{
    vector<vector<int>> A(3, vector<int>(3));
    for (int i = 0; i < 3; i++)
        for (int j = 0; j < 3; j++)
            cin >> A[i][j];

    int N;
    cin >> N;

    vector<int> b(N);
    for (int i = 0; i < N; i++)
        cin >> b[i];

    vector<vector<bool>> bingo(3, vector<bool>(3, false));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (A[j][k] == b[i])
                    bingo[j][k] = true;
            }
        }
    }
    //for (int i = 0; i < 3; i++) {
    //    for (int j = 0; j < 3; j++)
    //        cout << bingo[i][j] << " ";
    //    cout << endl;
    //}

    bool ans = false;
    for (int i = 0; i < 3; i++) {
        bool line = true;
        for (int j = 0; j < 3; j++)
            line &= bingo[i][j];

        ans |= line;
    }

    for (int i = 0; i < 3; i++) {
        bool line = true;
        for (int j = 0; j < 3; j++)
            line &= bingo[j][i];

        ans |= line;
    }

    ans |= (bingo[0][0] & bingo[1][1] & bingo[2][2]);
    ans |= (bingo[0][2] & bingo[1][1] & bingo[2][0]);

    if (ans == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


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

namespace cswork
{
    class Program
    {
        class Scanner
        {
            string[] s;
            int i;

            char[] cs = new char[] { ' ' };

            public Scanner()
            {
                s = new string[0];
                i = 0;
            }

            public string next()
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();

                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next();
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

            public long nextLong()
            {
                return long.Parse(next());
            }

            public double nextDouble()
            {
                return double.Parse(next());
            }
        }

        public Program() { }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        public static List<long> GeneratePrime(long max)
        {
            long prime;
            double sqrtMax = Math.Sqrt(max);
            var primeList = new List<long>();

            List<long> searchList = new List<long>();
            for (long i = 2; i <= max - 1; i++)
            {
                searchList.Add(i);
            }

            do
            {
                prime = searchList.First();
                primeList.Add(prime);
                searchList.RemoveAll(n => n % prime == 0);
            } while (prime < sqrtMax);

            primeList.AddRange(searchList);

            return primeList;
        }

        void Omame()
        {
            cin = new Scanner();
            long A = cin.nextLong();
            long B = cin.nextLong();

            long ans = 0;
            for (int i = 0; i < B; i++)
            {
                ans += A;
                if(ans % B == 0)
                {
                    Console.WriteLine(ans);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 11220
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N, T, A;
ll heights[1005];
std::vector<pair<double, int>> temps;

int main() {
	scanf("%lld %lld %lld", &N, &T, &A);
	for(int i = 0; i < N; i++) {
		scanf("%lld", &heights[i]);
	}
	for(int i = 0; i < N; i++) {
		temps.push_back(make_pair(T - heights[i] * 0.006, i));
	}
	int ansInd = 0;
	double ans = 1e10;
	for(int i = 0; i < temps.size(); i++) {
		if(abs(A - temps[i].first) <= ans) {
			ans = abs(A - temps[i].first);
			ansInd = temps[i].second;
		}
	}
	printf("%d\n", ansInd + 1);

	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;

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

	if (q == 1) cout << "Hello World" << endl;
	else if (q == 2)
	{
		int a, b;
		cin >> a;
		cin >> b;
		cout << a + b << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main() {
	string A, B, C;	cin >> A >> B >> C;

	if (A[A.size() - 1] == B[0] && B[B.size() - 1] == C[0]) cout << "YES" << endl;
	else cout << "NO" << endl;
	cin >> A;
	return 0;
}

Measured memory_bytes: 256
S = input()
one = S[0]
two = S[1]
ans = "-1 -1"
l = len(S)
for i in range(2,l):
    s = S[i]
    if s == one:
        ans = str(i-1) + " " + str(i+1)
        break
    elif s == two:
        ans = str(i) + " " + str(i+1)
        break
    one, two = two, s
if l == 2:
    if one == two:
        ans = "1 2"
print( ans)

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define LL long long
#define PI 3.14159265359
template<class T> inline void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

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

	cout << N / 3 << endl;

	return 0;
}

Measured memory_bytes: 256
def g(a,b,c,d,e,f):
	A=2*(c-a)
	B=2*(d-b)
	C=a*a-c*c+b*b-d*d
	D=2*(e-a)
	E=2*(f-b)
	F=a*a-e*e+b*b-f*f
	N=(A*E-D*B)
	X=(B*F-E*C)/N
	Y=(C*D-F*A)/N
	return tuple(map(round,[X,Y,((X-a)**2+(Y-b)**2)**0.5],[3]*3))
for k in [map(float,raw_input().split())for i in range(input())]:print"%.3f %.3f %.3f"%(g(*k))

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

int main()
{
  string s, t;
  cin >> s >> t;
  string ans = "Yes";
  map<char, char> map1, map2;
  for (auto i = 0; i < s.size(); i++) {
    if (map1[s[i]] || map2[t[i]]) {
      if (map1[s[i]] != t[i] || map2[t[i]] != s[i]) {
	ans = "No";
      }
    }
    map1[s[i]] = t[i];
    map2[t[i]] = s[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 1020
#include<stdio.h>
#define m(a,b)(a<b?a:b)
#define INF 999999999
int A,B,D,i,j;

int main()
{
	
	for(;scanf("%d%d%d",&A,&B,&D),A+B+D;)
	{
		int b1=INF,b2=INF,b3=INF,Ra=INF,Rb=INF,x;
		for(i=0;i<10000;i++)
		{
			b1=(i*A+D)%B==0?m((i*A+D)/B,b1):b1;
			b2=i*A-D>=0&&(i*A-D)%B==0?m((i*A-D)/B,b2):b2;
			b3=D-i*A>=0&&(D-A*i)%B==0?m((D-A*i)/B,b3):b3;
			x=m(b1,m(b2,b3));
			if(Ra+Rb>x+i||(Ra+Rb==x+i&&Ra*A+Rb*B>i*A+x*B))
			{
				Ra=i;
				Rb=x;
			}
		}
		printf("%d %d\n",Ra,Rb);
	}
	return 0;
}

Measured memory_bytes: 600
//
//  main.cpp
//  ITP1_4-B
//
//  Created by Saicj on 2015/07/14.
//  Copyright (c) 2015??´ saicj. All rights reserved.
//

#include <iostream>
#include <stdio.h>
using namespace std;

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

    double t = 3.141592653589;
    double r;
    cin >> r;
    
    double are = t * r * r;
    double cirle = 2 * t * r;
    
    printf("%.5f %.5f\n",are, cirle );
    
    

    
    return 0;
}

Measured memory_bytes: 1236
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Map;
import java.util.TreeMap;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		Map<Integer, Long> map = new TreeMap<>();

		for (int i = 0; i < n; i++) {
			String str[] = br.readLine().split(" ");

			int a = Integer.parseInt(str[0]);
			int b = Integer.parseInt(str[1]);

			if (map.containsKey(b))
				map.put(b, map.get(b) + a);
			else
				map.put(b, (long) a);
		}

		Object key[] = map.keySet().toArray();

		int count = 0;
		long left = 0;
		for (long i : map.values()) {
			if ((int) key[count] < i) {
				System.out.println("No");
				return;
			}

			long dist = (int) key[count] - left;

			if (map.get((int) key[count]) > dist) {
				System.out.println("No");
				return;
			}
			left += map.get((int) key[count]);
			count++;
		}

		System.out.println("Yes");
	}
}


Measured memory_bytes: 78444
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int x = sc.nextInt();
    int a = 500 * k;
    if(a >= x){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 22740
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
int h,w,imap[400][400],d[400][400];
static const int dx[4] = {0,1,0,-1};
static const int dy[4] = {1,0,-1,0};

void solve(){
  queue<P> que;
  que.push(P(0,0));
  d[0][0] = 1;
  while(!que.empty()){
    P p = que.front(); que.pop();
    //cout << "p = "<< p.F << "," <<  p.S << endl;
    rep(i,4){
      int limx = p.S%2==0?w-1:w;
      if(imap[p.S+dy[i]][p.F+dx[i]] == 1)continue;
      int nx = p.F+dx[i]*2,ny = p.S+dy[i]*2;
      if(0<= nx && nx < w*2-1 && 0<= ny && ny < h*2-1 && d[ny][nx] > d[p.S][p.F]+1){
	d[ny][nx] = d[p.S][p.F]+1;
	//	cout << "nx = " << nx << ", ny = "<< ny << ",d["<<ny<<"]["<<nx<<"] = " << d[ny][nx] << endl;
	que.push(P(nx,ny));
      }
    }
  }
    
  if(d[h*2-2][w*2-2] == INF)cout << 0 << endl;
  else cout << d[h*2-2][w*2-2] << endl;
}

bool input(){
  cin >> w >> h;
  if(h+w == 0)return false;
    rep(i,h*2-1){
    for(int j=0;j<w*2-1;j++){
      if((i%2==0 && j%2==0) || (i%2!=0 && j%2!=0)){
	imap[i][j] = 8;
	d[i][j] = INF;
	continue;
      }
      cin >> imap[i][j];
      d[i][j] = INF;
    }
  }
  return true;
}

int main()
{
  while(input())solve();
  
return 0;
}

Measured memory_bytes: 1404
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N,anis[100009];
string s;

bool ck(int l,int m,int r){
    if(anis[m]==0){
        if(s[m]=='o'){
            if(anis[l]!=anis[r]) return false;
        }else{
            if(anis[l]==anis[r]) return false;
        }
    }else{
        if(s[m]=='o'){
            if(anis[l]==anis[r]) return false;
        }else{
            if(anis[l]!=anis[r]) return false;
        }
    }
    return true;
}

bool solve(){
    for(int i=1;i<N-1;i++){
        if(anis[i]==0){
            if(s[i]=='o') anis[i+1]=anis[i-1];
            else anis[i+1]=anis[i-1]^1;
        }else{
            if(s[i]=='o') anis[i+1]=anis[i-1]^1;
            else anis[i+1]=anis[i-1];
        }
    }
    if(!ck(N-1,0,1)) return false;
    if(!ck(N-2,N-1,0)) return false;
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>s;
    
    rep(bit,4){
        mem(anis,0);
        if(1&bit) anis[0]=1;
        if(2&bit) anis[1]=1;
        if(solve()){
            rep(i,N){
                cout<<(anis[i]?"W":"S");
            }
            cout<<endl;
            return 0;
        }
    }
    cout1(-1);
}

Measured memory_bytes: 976
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int N = S.length();
		String S1 = S.substring(0,N/2);
		String S2 = S.substring((N+1)/2);
		int ans = 0;
		for(int i = 0; i < N/2; i++)
			if(S1.charAt(i) != S2.charAt(N/2-1-i))
				ans++;
		System.out.println(ans);

	}

}

Measured memory_bytes: 23124