akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define REP(k, n) for (ll k = 0; k < (ll)(n); ++k)
#define REPREV(k, n) for (ll k = (ll)(n)-1; k >= 0; --k)
#define FOR(k, a, b) for (ll k = (ll)(a); k < (ll)(b); ++k)
#define FORREV(k, a, b) for (ll k = (ll)(b)-1; k >= (ll)(a); --k)
#define FOREACH(e, v) for (auto& e : v)

#define TGET(t, i) get<i>(t)
#define TSET(t, i, a) get<i>(t) = a
// MinHeap - priority_queue<ll, vll, greater<ll>> pq;

#define EVEN(n) ((n)&1) == 0
#define ODD(n) ((n)&1) == 1

#define SORT(v) sort(v.begin(), v.end())
#define SORTREV(v) sort(v.rbegin(), v.rend())
#define SHUFFLE(v) random_shuffle(v.begin(), v.end())
//srand(unsigned(time(0)));

#define REMOVEAT(v, i) v.erase(v.begin() + i)
#define REVERSE(v) reverse(v.begin(), v.end())

ll MOD(ll x, ll m) {
    ll r = x % m;
    if (r < 0) {
        r += m;
    }
    return r;
}

ostream& operator<<(ostream& str, const pll& p) {
    str << p.first << " " << p.second;
    return str;
}

template <typename T>
void join(T& arr, string sep) {
    bool first = true;
    for (auto t : arr) {
        if (first) {
            first = false;
            cout << t;
        } else {
            cout << sep << t;
        }
    }
    cout << "\n";
}

#define POS "POSSIBLE"
#define IMPOS "IMPOSSIBLE"

// #define INF LLONG_MAX
// #define MINF LLONG_MIN
#define INF 9e18
#define MINF -INF

void solve() {
    ll n, m, k;
    cin >> n >> m >> k;
    vll a(n);
    vll b(m);
    REP(i, n) {
        cin >> a[i];
    }
    vll agg;
    ll cur = 0;
    REP(i, m) {
        cin >> b[i];
        agg.push_back(cur + b[i]);
        cur += b[i];
    }
    
    ll res = distance(agg.begin(), upper_bound(agg.begin(), agg.end(), k));
    cur = 0;
    REP(i, n) {
        cur += a[i];
        if (cur > k)
            break;
        ll left = k - cur;
        auto it = upper_bound(agg.begin(), agg.end(), left);
        ll res2 = i + 1;
        res2 += distance(agg.begin(), it);
        res = max(res, res2);
    }

    // cout << fixed << setprecision(6);
    cout << res << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt = 1;
    // cin >> tt;
    for (int t = 1; t <= tt; t++) {
        // cout << "Case #" << t << ": ";
        solve();
    }

    return 0;
}

Measured memory_bytes: 8456
#include<stdio.h>
int A[1000000],n;

int binarySearch(int key)
{
	int left=0;
	int right = n;
	int mid;
	while(left<right)
	{
		mid = (left+right)/2;
		if(key==A[mid])
		{
			return 1;
		}
		if(key>A[mid])
		{
			left=mid+1;
		}
		else if(key<A[mid])
		{
			right = mid;
		}
	}
	return 0;
}

int main()
{
	int i,q,k,sum=0;

	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&A[i]);
	}
	
	scanf("%d",&q);
	for(i=0;i<q;i++)
	{
		scanf("%d",&k);
		if(binarySearch(k))
		{
			sum++;
		}
		
	}
	printf("%d\n",sum);
	return 0;
}


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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int cf = c / b;
  if (c % b) {
    cf++;
  }

  int cl = a / d;
  if (a % d) {
    cl++;
  }

  if (cf > cl) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }

  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
char a[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
int cnt =0;

void t(int n,int k);

int main()
{
    int n,k;
    cin>>n>>k;
    t(n,k);
    cout<<cnt<<endl;
}

void t(int n,int k){
    int r = n%k;
    n /= k;
    if(n!=0) t(n,k);
    cnt++;
}


Measured memory_bytes: 256
# N, D = [int(i) for i in input().split()]
# K = int(input())
S = input()
if S == 'RRR':
  print(3)
elif S == 'RRS' or S == 'SRR':
  print(2)
elif 'R' in S:
  print(1)
else:
  print(0)


Measured memory_bytes: 61784
import sys
N, M, *PS = sys.stdin.read().strip().split()
N = int(N)
ac = [0] * N
wa = [0] * N
for p, s in zip(*[iter(PS)] * 2):
  p = int(p) - 1
  if s == "AC":
    ac[p] = 1
  elif ac[p] == 0:
    wa[p] += 1
penalties = sum([w * a for a, w in zip(ac, wa)])
print("{} {}".format(sum(ac), penalties))

Measured memory_bytes: 17992
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
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;
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++)
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;

void debug(vec &v) {
	int n = v.size();
	rep(i, n) {
		if (i > 0)cout << " ";
		cout << v[i];
	}
	cout << endl;
}

int trans(char t) {
	if (t == 'r') {
		return 2;
	}
	else if (t == 's')return 0;
	else return 1;
}
void solve() {
	int n, k, s[3];
	cin >> n >> k;
	rep(i, 3)cin >> s[i];
	string t; cin >> t;
	int sum = 0;
	rep(i, k) {
		P score = { 0,0 };
		score.second = s[trans(t[i])];
		for (int j = i + k; j < n; j += k) {
			P nex = { 0,0 };
			nex.first = max(score.first,score.second);
			nex.second = score.first + s[trans(t[j])];
			if (t[j] != t[j - k]) {
				nex.second = max(nex.second, score.second + s[trans(t[j])]);
			}
			score = nex;
		}
		//cout << max(score.first, score.second) << endl;
		sum += max(score.first, score.second);
	}
	cout << sum << endl;
}


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

Measured memory_bytes: 512
import java.io.*;
import java.util.*;

public class Main{
	
	public static void main(String[] args) throws Exception{
		pw=new PrintWriter(System.out);
		sc = new MScanner(System.in);
		HashSet<Integer>hs=new HashSet<>();
		int n=sc.nextInt(),k=sc.nextInt();
		for(int i=1;i<=n;i++)hs.add(i);
		
		while(k-->0) {
			int len=sc.nextInt();
			while(len-->0) {
				hs.remove(sc.nextInt());
			}
		}
		pw.println(hs.size());
		pw.flush();
	}
	static PrintWriter pw;
	static MScanner  sc;
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
}


Measured memory_bytes: 35140
#include <bits/stdc++.h>
#include <cmath>
#include <vector>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
#define PI 3.141592653589793
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};


using namespace std;
using Graph = vector< vector<int> > ;


int main(){
    int n;
    cin >> n;
    int last;
    if (n <10){
        last = n;
    }else if (n < 100){
        last = n%10;
    }else{
        n %= 10;
        last = n %= 10;
    }
    if (last == 2 || last == 4 || last == 5 || last == 7 || last == 9){
        cout << "hon" << endl;
    }else if (last == 3){
        cout << "bon" << endl;
    }else{
        cout << "pon" << endl;
    }
}

Measured memory_bytes: 3572
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

vector<int> factors(int x) {
  vector<int> result;
  for (int d = 1; d * d <= x; d++) {
    if (x % d == 0) {
      result.push_back(d);
      result.push_back(x / d);
    }
  }
  sort(result.begin(), result.end());
  result.push_back(x);
  result.erase(unique(result.begin(), result.end()), result.end());
  return result;
}

int main() {
  int64_t X;
  cin >> X;

  int L = 0, R = 0;
  while (pow(L, 5) - pow(L - 1, 5) < X) {
    L--;
  }
  while (pow(R, 5) - pow(R - 1, 5) < X) {
    R++;
  }

  for (int i = L; i <= R; i++) {
    for (int j = L - 1; j <= R - 1; j++) {
      if (pow(i, 5) - pow(j, 5) == X) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 4024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		String s = scanner.next();
		String ans = "Yes";

		if(s.charAt(0) == s.charAt(1) && s.charAt(1) == s.charAt(2)) {
			ans = "No";
		}

		System.out.println(ans);

		scanner.close();

	}

}


Measured memory_bytes: 35664
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define all(x) x.begin(),x.end()
#define ld long double
#define fast  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
signed main(){
    fast;
    int x,k,d;
    cin>>x>>k>>d;
    int dis = abs(x);
    int steps = dis/d;
    if(k<=steps){
    	cout<<dis-(k*d);
    }
    else{
    	int val = (dis - d) + (steps-1ll)*(-d);
    	k-=steps;
    	int a1 = abs(val-d);
    	int a2 = val;
    	int a3 = abs(val + d);
    	if(k%2 == 0){
    		cout<<a2;
    	}
    	else{
    		cout<<min(a1,a3);
    	}
    }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

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

    vvi a(3, vi(3));
    rep(i, 3) rep(j, 3) cin >> a[i][j];
    bool ok = true;
    rep(i, 2) rep(j, 2) {
        if (a[i][j] - a[i+1][j] == a[i][j+1] - a[i+1][j+1]) continue;
        ok = false;
    }
    cout << (ok ? "Yes" : "No") << endl;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x,  k;
string s, t;

// <------------- Implement Functions Here ----------> //

// <------------- Start of main() -------------------> //

void MAIN() {
	ll h,w;
	cin >> n >> h >> w ;
	ll ans = 0;
	for(ll i=0;i<n;i++) {
		cin>>x>>k;
		if(x>=h && k>=w) ans++;
	}
	cout<<ans;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

#define PB(N) push_back(N)

using namespace std;

using Graph = vector<vector<int>>;

int main(){
  int N;cin >> N;
  cout << N+pow(N,2)+pow(N,3);
  return 0;
}


Measured memory_bytes: 4288
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const long long int inf = 1e18+7;
const int mod = 998244353;

using namespace std;

inline ll int max(ll int a,ll int b) { return a>b?a:b; }
inline ll int min(ll int a,ll int b) { return a<b?a:b; }

//const int maxn=

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int n;
	while(cin>>n)
	{
		int cnt=0;
		for(int i=1,x;i<=n;i++)
		{
			cin>>x;
			if(i&1 && x&1)
			{
				cnt++;
			}
		}
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 3484
#pragma GCC optimize ("Ofast")
#pragma GCC target(*sse4.2*)
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define PB push_back
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define vvii vector<vii>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define read(x) long long x;cin>>x;
#define FOR(a,b,c,d) for(int a=b;a<=c;a+=d)
#define MP make_pair
#define F first
#define S second
#define debug(x) cout<<("#x)<<": "<<(x)<<"\n"
#define SZ(x) x.size()
#define mod 1000000007
#define lg2(x) 63-(__builtin_ctzll(x))
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
typedef unsigned long long ull;
typedef long double d64;




int main(){
    fast
   read(n);

        if(n>=400&&n<=599)cout<<8;
   else if(n>=600&&n<=799)cout<<7;
   else if(n>=800&&n<=999)cout<<6;
   else if(n>=1000&&n<=1199)cout<<5;
   else if(n>=1200&&n<=1399)cout<<4;
   else if(n>=1400&&n<=1599)cout<<3;
   else if(n>=1600&&n<=1799)cout<<2;
   else if(n>=1800&&n<=1999)cout<<1;


return 0;
}


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

int main(){
  while(true){
    int n, l;
    cin >> n >> l;
    if(n == 0) break;

    vector<char> dirs(n);
    vector<int> pos(n);
    for(int i=0;i<n;i++){
      cin >> dirs[i] >> pos[i];
    }
    int cnt = 0;
    for(int t=1;t<=l+2;t++){
      vector<pair<int, int>> deads;
      for(int i=n-1;i>=0;i--){
        pos[i] += dirs[i] == 'L' ? -1 : 1;
        if(pos[i] == 0 || pos[i] == l){
          cnt++;
          deads.emplace_back(pos[i], i);
        }
      }
      for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
          if(pos[i] == pos[j]){
            swap(dirs[i], dirs[j]);
          }
        }
      }
      if(cnt == n){
        assert(deads.size() <= 2);
        if(deads.size() == 1){
          cout << t << " " << deads[0].second + 1 << endl;
        }else{
          cout << t << " " << min(deads[0], deads[1]).second + 1 << endl;
        }
        break;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 3008
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<iomanip>
#include<cmath>
using namespace std;

int main(){
    long long N;
    cin >> N;
    
    cout << (N + 1) / 2;
}


Measured memory_bytes: 256
#include <stdio.h>
#define len 100005
typedef struct q{
    char name[100];
    int time;
}q;
q pro[len];
int head,tail,n;
q enqueue(q x){
    pro[tail]=x;
    tail=(tail+1)%len;
}
q dequeue(void){
    q x=pro[head];
    head=(head+1)%len;
    return x;
}
int main(void){
    int n,max,total=0,i;
    q x;
    scanf("%d %d",&n,&max);
    for(i=0;i<n;i++)
        scanf("%s %d",pro[i].name,&pro[i].time);
    head=0,tail=n;
    while(head != tail){
        x=dequeue();
        if(x.time <= max){
            total+=x.time;
            printf("%s %d\n",x.name,total);
        }
        else{
            total+=max;
            x.time-=max;
            enqueue(x);
        }
    }
    return 0;
}

Measured memory_bytes: 10752
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
#define N 100
const double PI = acos(0) * 2;
int x[N], y[N];

pair<double, int> in[N];
int main(void) {
	//solve 
	
		int n; scanf("%d", &n);
		for (int i = 0; i < n; ++i) {
			scanf("%d %d", &x[i], &y[i]);
			in[i] = make_pair(atan2(x[i], y[i]), i);
		}
		sort(in, in + n);
		long long ret = 0;
		for (int i = 0; i < n; ++i) {
			long long X = 0, Y = 0;
			for (int j = i; j < i + n; ++j) {
				int ind = j % n, id = in[ind].second;
				X += x[id], Y += y[id];
				ret = max(ret, X*X + Y * Y);
			}
		}
		printf("%0.10lf\n", sqrt(ret));
	
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
  int N,K[20]={0};
  cin >> N >> K[0];
  long long a=0,b=N;
  for(int i=0;K[i]>1;i++){
    K[i+1]=(K[i]+1)/2;
  }
  for(int n=N,id;n>0;n--){
    while(n<K[id]){
      id++;b*=2;a*=2;
    }
    a++;
  }
  if(a<b){
   cout << "0.";
    for(int i=0;i<12;i++){
      a*=10;
      cout << a/b;
      a-=(a/b)*b;
    }
  }else cout << 1 << endl;
  return 0;
}

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

long a[1200000], b[1200000];

int main(){
	while(1){
		int n, m;
		long h[1501], w[1501];
		
		scanf(" %d %d", &n, &m);
		if(n==0) break;
		
		h[0]=0;
		for(int i=0; i<n; ++i){
			int t;
			scanf(" %d", &t);	
			h[i+1]=h[i]+t;
		}
	
		w[0]=0;
		for(int i=0; i<m; ++i){
			int t;
			scanf(" %d", &t);	
			w[i+1]=w[i]+t;
		}
		
		
		long aa=0, bb=0;
		for(int i=0; i<n; ++i){
			for(int j=i+1; j<=n; ++j){
				a[aa++]=h[j]-h[i];		
			}
		}
		sort(a, a+aa);
		
		for(int i=0; i<m; ++i){
			for(int j=i+1; j<=m; ++j){
				b[bb++]=w[j]-w[i];		
			}
		}
		sort(b, b+bb);
		
		long ans=0;
		for(long i=0; i<aa; ++i){
			//2?????¢?´¢	
			long left=0, right=bb-1;
			long center;
			bool found=false;
			while(left<=right){
				center=(left+right)/2;
				
				if(b[center]==a[i]){
					found=true;
					break;
				}
				else if(b[center]<a[i]) left=center+1;
				else if(b[center]>a[i]) right=center-1;		
			}
			
			if(found){
				long p, q;
				p=q=center;
				
				while(b[p]==a[i]) p--;
				while(b[q]==a[i]) q++;
				ans+=q-p-1;
			}
			
		}
		printf("%ld\n", ans);
	}	
}

Measured memory_bytes: 19648
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main (int argc, char * const argv[]) {
    // insert code here...
    string str;
	cin >> str;
	reverse(str.begin(), str.end());
	cout<<str<<endl;
	
	return 0;
}

Measured memory_bytes: 1172
#include<iostream>
#include<vector>
#include<string>
#include <queue>
#include<map>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include<set>

using namespace std;
#define _USE_MATH_DEFINES
# define M_PI 3.14159265358979323846
# define MOD 1000000007
#define ll long long int
#define pii pair<ll, ll>
#define pb push_back
#define MIN -9,223,372,036,854,775
#define N 100005
#define all(v) v.begin(),v.end()


ll help( vector<set<ll> > &g,vector<ll> &vis, ll x ){
    queue<ll> q;
    ll ans=0;
    q.push(x);
    vis[x]=(ll)1;
    
    while(!q.empty()){
        x = q.front();
        q.pop();
        ans++;
        set<ll> cur = g[x];
        for(auto it:cur){
            if( vis[it]==0 ){
                q.push(it);
                vis[it]=(ll)1;
            }
        }
    }
    return ans;
}

void solve(){
    ll i,n,ans=1,m,x,y;
    cin>>n>>m;
    vector<set<ll> > g(n+1);
    for(i=0;i<m;i++){
        cin>>x>>y;
        g[x].insert(y);
        g[y].insert(x);
    }
    vector<ll> vis(n+1);
    for(i=1;i<=n;i++){
        if( vis[i]==0 ){
            ll c = help( g, vis, i );
            ans = max(ans,c);
        }
    }
    cout<<ans;
}

int main() {
    ll t=1;
	//cin>>t;
	while( t-- ){
	    solve();
	    cout<<"\n";
	}
	return 0;
}


Measured memory_bytes: 28332
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define MOD 1000000007LL

using namespace std;
using llong = long long;

int main()
{
	IOS;

	int n;
	cin >> n;
	if (n % 10 == 3) cout << "bon";
	else if (n % 10 == 0 || n % 10 == 6 || n % 10 == 1 || n % 10 == 8) cout << "pon";
	else cout << "hon";

	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;

void dfs(vvi& g,vi& vis,int i)
{
	if(vis[i]) return;
	vis[i]=1;
	for(int j:g[i])
		dfs(g,vis,j);
}

string solve(int n)
{
	vvi g(26);
	rep(i,n){
		string s; cin>>s;
		int l=s[0]-'a',r=s.back()-'a';
		g[l].push_back(r);
	}
	
	vi vis(26);
	rep(i,26)
		vis[i]=g[i].empty();
	rep(i,26)
		if(g[i].size()){
			dfs(g,vis,i);
			break;
		}
	if(count(vis.begin(),vis.end(),0))
		return "NG";
	
	vi deg(26);
	rep(i,26) rep(j,g[i].size())
		deg[i]++,deg[g[i][j]]--;
	if(count(deg.begin(),deg.end(),0)!=26)
		return "NG";
	
	return "OK";
}

int main()
{
	for(int n;cin>>n,n;)
		cout<<solve(n)<<endl;
	
	return 0;
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
//#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
 
 
int main(){
   
  int n;
  cin>>n;
  
  string s;
  cin>>s;
  
  rep(i,s.size()){
      
      if(int(s.at(i))+n>int('Z')){
         cout<<char((s.at(i)+n)%int('Z')+int('A')-1);
      }
      else cout<<char(s.at(i)+n);
  }
  cout<<endl;
}

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

int main(){
    int w,n;
    cin>>w>>n;
    int vec[30];
    for(int i=0;i<w;i++)
        vec[i]=i+1;
    for(int i=0;i<n;i++){
        int x,y;char m;
        cin>>x>>m>>y;
        swap(vec[x-1],vec[y-1]);
    }
    for(int i=0;i<w;i++)
        cout<<vec[i]<<endl;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cctype>
#include <queue>
#include <map>
#include <set> 
#include <bitset>
#include <cmath>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)

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


    if(n % 2 == 0) {
        cout << n << endl;
    } else if (n != 1) {
        cout << n*2 << endl;
    } else {
        cout << 2 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
//typedef pair<int, int> P;
struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
};

/** Problem0155 : Spider Jin **/
int cost[1000][1000];
int d[1000];
bool used[1000];
int V;

int prev[1000];

void dijkstra(int s)
{
	fill(d, d+V, INF);
	fill(used, used+V, false);
	fill(prev, prev+V, -1);
	d[s]=0;
	
	while (true) {
		int v=-1;
		
		for (int u=0; u<V; u++) {
			if (!used[u] && (v==-1 || d[u]<d[v]))
				v=u;
		}
		if (v==-1) break;
		used[v] = true;
		
		for (int u=0; u<V; u++) {
			if (d[u]>d[v]+cost[v][u]) {
				d[u] = d[v]+cost[v][u];
				prev[u] = v;
			}
		}
	}
}

int main()
{
	while (cin>>V, V) {
		vector<P> p;
		rep(i, V) {
			int a, b, c;
			cin>>a>>b>>c;
			p.push_back(P(a-1, b, c));
		}
		
		fill(cost[0], cost[0]+1000*1000, INF);
		rep(i, V) {
			rep(j, V) {
				if (i!=j) {
					int a = p[i].n, b=p[j].n;
					double d = sqrt((p[i].x-p[j].x)*(p[i].x-p[j].x)+(p[i].y-p[j].y)*(p[i].y-p[j].y));
					if (d<=50)
						cost[a][b] = cost[b][a] = d;
				}
			}
		}
		
		int N; cin>>N;
		while (N--) {
			int s, t;
			cin>>s>>t;
			s--, t--;
			
			dijkstra(s);
			vector<int> path;
			for (; t!=-1; t=prev[t]) path.push_back(t);
			reverse(path.begin(), path.end());
		
			if (path.size()>1) {
				rep(i, path.size()) {
					if (i!=0) cout << " ";
					cout << path[i]+1;
				}
				cout << endl;
			} else {
				cout << "NA" << endl;
			}
		}
	}
}

Measured memory_bytes: 5136
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)
 
inline ll ii(){ ll x; cin >> x; return x; }
inline string is(){ string x; cin >> x; return x; }
inline ld id(){ ld x; cin >> x; return x; }
inline void oi(ll x){ cout << x; }
inline void od(ld x){ cout << fixed << setprecision(10) << x; }
inline void os(string x){ cout << x; }
inline void oe(){ cout << endl; }
inline void oie(ll x){ oi(x); oe(); }
inline void ode(ld x){ od(x); oe(); }
inline void ose(string x){ os(x); oe(); }
inline void maxin(ll &a, ll b){ a=max(a,b); }
inline void minin(ll &a, ll b){ a=min(a,b); }

int main(){
    string S=is(), T=is();
    ll Slen=S.length(), Tlen=T.length();
    ll ret=LLONG_MAX;
    REP(i,0,Slen-Tlen+1){
        ll r=0;
        REP(j,0,Tlen){
            if(S[i+j]!=T[j]){
                r++;
            }
        }
        minin(ret,r);
    }
    oie(ret);

    return 0;
}

Measured memory_bytes: 3632
//author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 	first
#define s 	second
#define ll 	int
#define int 	long long
#define ld 	long double
#define pb 	push_back
#define eb 	emplace_back
#define mk 	make_pair
#define vi 	vector<int>
#define pii 	pair<int,int>
#define vpi 	vector<pii>
#define fori(a,b,c) for(register int i=a;i<b;i+=c)
#define ford(a,b,c) for(register int i=a;i>=b;i-=c)
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); } 
#define test4(x,y,z,a) 		cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl()
{
	cout<<"Control\n";
}
signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
    cin>>n;
    int A[n],B[n],C[n];

    fori(0,n,1)cin>>A[i];

    fori(0,n,1)cin>>B[i];

    fori(0,n-1,1)cin>>C[i];

    int s=0;

    fori(0,n,1)
    {
        s+=B[A[i]-1];

        if(i)
        {
            if(A[i]==A[i-1]+1)
            s+=C[A[i-1]-1];
        }
    }
    cout<<s;

return 0;
}

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

int N, M;
vector<int> A, sum;

bool C(int mid) {
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    cnt += N - (lower_bound(A.begin(), A.end(), mid - A[i]) - A.begin());
  }

  if (cnt < M) {
    return false;
  }

  return true;
}

signed main() {
  cin >> N >> M;
  A.resize(N, 0);
  sum.resize(N + 1, 0);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  sort(A.begin(), A.end());

  for (int i = 0; i < N; i++) {
    sum[i + 1] = sum[i] + A[N - 1 - i];
  }

  int ok = 0, ng = 1e12;
  while (abs(ok - ng) > 1) {
    int mid = (ok + ng) / 2;
    if (C(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }

  int ans = 0, cnt = 0;
  for (int i = N - 1; i >= 0; i--) {
    int dist = N - (lower_bound(A.begin(), A.end(), ok - A[i]) - A.begin());
    cnt += dist;
    ans += A[i] * dist + sum[dist];
  }

  ans -= (cnt - M) * ok;

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

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(LL)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat 
using namespace std;
typedef long long LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
const int INF=1<<30;
const int BITSIZE=1<<17;
const LL p=7+1e9;
const int SIZE=2001;
LL N,C;
LL A[SIZE],B[SIZE];
LL DP[SIZE][SIZE];
LL timer[SIZE][SIZE];
LL power(LL x,LL r){
	if(r&1) return x*power(x,r-1)%p;
	if(r==0) return 1;
	LL ans=power(x,r/2);
	return ans*ans%p; 
}
LL timesSum(int n,int c){
	if(timer[n][c]) return timer[n][c];
	if(n==0) return 0;
	return timer[n][c]=(power(n,c)+timesSum(n-1,c))%p;
}
LL gets(int x,int c){
	return (timesSum(B[x],c)-timesSum(A[x]-1,c)+p)%p;
}
LL solve(int n,int c){
	if(DP[n][c]) return DP[n][c];
	if(n==0) return c==0;
	REP(i,c+1)
		DP[n][c]+=(solve(n-1,c-i)*gets(n,i))%p;
	DP[n][c]%=p;
	return DP[n][c]%p;
}
int main(){
	cin >> N >> C;
	FOR(i,1,N+1) cin >> A[i];
	FOR(j,1,N+1) cin >> B[j];
	cout << solve(N,C) << endl;
	return 0;
}

Measured memory_bytes: 6016
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

bool hoge2(char a, char b) {
  // cout << a << b << endl;
  // cout << (a=='(') << " " << (b==')') << endl;
  if (a==')')
    return b=='(';
  if (a=='(')
    return b==')';
  if (a==']')
    return b=='[';
  if (a=='[')
    return b==']';
  if (a=='{')
    return b=='}';
  if (a=='}')
    return b=='{';
  return a==b;
}
bool hoge(string s) {
  if (s.length() <3) return false;
  for (int i=0, j=s.size()-1; i<=j; ++i, --j) {
    if (!hoge2(s[i],s[j])) {
      return false;
    }
  }
  if (s.substr(s.size()/2-1,3) != "iwi") return false;
  if (count(ALL(s), 'i') == 2 && count(ALL(s), 'w') == 1) return true;
  return false;
}

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int res = 0;
  bool f = 0;
  for (int S=0; S<(1<<n); ++S) {
    string sub;
    REP(i,n) {
      if ((S>>i) & 1)
        sub += s[i];
    }
   
    if (hoge(sub)) {
      res = max(res,(int)sub.length());
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 880
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i < n; i ++)
#define rep1(i, n) for (int i=1; i <= n; i ++)
#define _min(x, y) x = min(x, y)
#define _max(x, y) x = max(x, y)
using namespace std;

long long INF = 1000000005;
const int MSIZE = 305;
long long d[MSIZE][MSIZE] = {INF};
long long d2[MSIZE][MSIZE] = {INF};

int main() {
  rep(i, MSIZE) {
    rep(j, MSIZE) {
      d[i][j] = INF;
      d2[i][j] = INF;
    }
  }
  int N, M, L; cin >> N >> M >> L;
  rep1(i, M) {
    int A, B, C; cin >> A >> B >> C;
    d[A][B] = C;
    d[B][A] = C;
  }


  rep1(k, N) {
    rep1(i, N) {
      rep1(j, N) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }

  rep1(i, N) {
    rep1(j, N) {
      if (d[i][j] <= L) {
        d2[i][j] = 1;
      }
    }
  }

  rep1(k, N) {
    rep1(i, N) {
      rep1(j, N) {
        d2[i][j] = min(d2[i][j], d2[i][k] + d2[k][j]);
      }
    }
  }

  int Q; cin >> Q;
  rep1(i, Q) {
    int s, t; cin >> s >> t;
    if (d2[s][t] == INF) {
      cout << -1 << endl;
    } else {
      cout << d2[s][t] - 1 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1920
N, K = map(int, input().split())
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

print(len(Base_10_to_n(N, K)))

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sax(x) cout << "!!!!!!!!!!! " << #x << " = " << x << '\n'
#define inf (sizeof(int) == 4 ? (int)1E9 : (int)1E18)
#define one(x) x.insert(x.begin(), 0);
#define TCT template <class T>
#define TCT12 template <class T1, class T2>
#define IS istream
#define OS ostream
#define OP operator

//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,
//tree_order_statistics_node_update> imsi;

TCT IS& OP>>(IS &I, vector<T>& v) {for (T &e: v) I >> e; return I;}
TCT OS& OP<<(OS &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, const unordered_set<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, const set<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, const unordered_multiset<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, const multiset<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT IS& OP>>(IS &I, deque<T>& v) {for (T &e: v) I >> e; return I;}
TCT OS& OP<<(OS &O, const deque<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, priority_queue<T> v) {while (!v.empty()) {O << v.top() << ' '; v.pop();} return O;}
TCT OS& OP<<(OS &O, stack<T> v) {while (!v.empty()) {O << v.top() << '\n'; v.pop();} return O;}
TCT OS& OP<<(OS &O, queue<T> v) {while (!v.empty()) {O << v.front() << ' '; v.pop();} return O;}
TCT12 IS& OP>>(IS &I, pair<T1,T2>& p) {return I >> p.first >> p.second;}
TCT12 OS& OP<<(OS &O, const pair<T1,T2>& p) {return O << '(' << p.first << ' ' << p.second << ')';}
TCT12 OS& OP<<(OS &O, const unordered_map<T1,T2>& v) {for (const auto &e: v) O << e << ' '; return O;}
TCT12 OS& OP<<(OS &O, const map<T1,T2>& v) {for (const auto &e: v) O << e << ' '; return O;}
typedef pair<int,int> pii;
typedef vector<int> vi;





void _main() {
        int a, b; cin >> a >> b;
        cout << (1 ^ 2 ^ 3 ^ a ^ b);
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int n;
vector<double> p;

double dp[3100][3100];

int main(){
    cin >> n;
    p.resize(n);
    rep(i,n){
        cin >> p[i];
    }
    dp[0][0] = 1.0;

    for(int i=0; i<n; i++){
        for(int j=0; j<=i; j++){

            dp[i+1][j+1] +=  dp[i][j] * p[i];
            dp[i+1][j] += dp[i][j] * (1-p[i]);

        }
    }

    double ans=0;

    for(int i= (n+1)/2; i<=n; i++){
        ans += dp[n][i];
    }

    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 72320
#include<iostream>
#include<algorithm>
using namespace std;
int dp1[1000001],dp2[1000001];
int main(){
  int c1[100000],c2[100000],i,m,p=0,k;
  for(i=0;i*(i+1)*(i+2)/6<=1000000;i++){
    c1[i]=i*(i+1)*(i+2)/6;
    if(c1[i]%2==1){
      c2[p]=c1[i]; 
      p++; 
    }
  }
  for(int j=0;j<=1000000;j++){
    dp1[j]=j;
    dp2[j]=j;
    for(int k=0;k<i;k++){
      if(j-c1[k]>=0)dp1[j]=min(dp1[j],dp1[j-c1[k]]+1);
      if(k<p){
	if(j-c2[k]>=0){
	dp2[j]=min(dp2[j],dp2[j-c2[k]]+1);
       }
      }
    }
  }

  while(1){
  cin >>m;
  if(m==0)break;

  cout << dp1[m]<<" "<<dp2[m]<<endl;
  }
 return 0;
}

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

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  int ans = 0;
  for(int i = 1; i <= n; i++){
    int sum = 0;
    int x = i;
    for(int i = 0; i < 5; i++){
      sum += x % 10;
      x /= 10;
    }
    if(a <= sum && sum <= b){
      ans += i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdlib.h>
#include<stdio.h>
#include<vector>
#include<utility>
#include<queue>
#include<stdbool.h>
#include<math.h>
typedef long long ll;
#define N (1000000000+7)
using namespace std;
typedef pair<int, int> P;

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

ll prime[100010];
ll kaijo[200010];
void init() {
	kaijo[0] = 1;
	for (ll i = 1;i <= 200000;i++)kaijo[i] = (kaijo[i - 1] * i) % N;
}

ll inv(ll x) {
	ll res = 1;
	ll k = N - 2;
	ll y = x;
	while (k) {
		if (k & 1)res = (res*y) % N;
		y = (y%N*y%N) % N;
		k /= 2;
	}
	return res;
}

ll Comb(ll n, ll k) {
	ll b = kaijo[n];
	ll c = kaijo[n - k];
	ll d = kaijo[k];
	ll cd = (c*d) % N;
	return ((b%N)*(inv(cd)%N) + N) % N;
}

int a[3], b[3];
int main(void) {
	int n, k;
	cin >> n >> k;
	int e = n / 2;
	int o = n - e;
	int ans = max(o, e);
	if (ans >= k)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int i,j=0,N,A[1000],v=0,k;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&A[i]);
		if(i>0){
			printf(" ");
		}
		printf("%d",A[i]);
	}
	printf("\n");
	for(i=1;i<N;i++){
		v=A[i];
		j=i-1;
		while(j>=0&&A[j]>v){
			A[j+1]=A[j];
			j--;
		}
		A[j+1]=v;
		for(k=0;k<N;k++){
			if(k>0){
				printf(" ");
			}
			printf("%d",A[k]);
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2088
import java.util.*;

/*
問題文


*/

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

        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int n = sc.nextInt();
        int a[] = new int[n];

        for (int i = 0; i < n; i ++) {
            a[i] = sc.nextInt();
        }

        int max = a[0] - a[n - 1] + k;

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

        System.out.println(k-max);
    }
}

Measured memory_bytes: 85648
/*
ID: arunesh2
TASK: ride
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) 
{ 
    while (a != b) { 
        if (a > b)         
            a = a - b;         
        else        
            b = b - a;         
    } 
    return a; 
} 
   
// Function to return LCM of two numbers  
  ll lcm(ll a, ll b)  
 {  
    return (a*b)/gcd(a, b);  
 }  

int main() {
    /*ofstream fout ("ride.out");
    ifstream fin ("ride.in");*/
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;ll c1=a;ll c2=b;
    ll n1=b/c;ll n2=(a-1)/c;ll n3=b/d;ll n4=(a-1)/d;ll n5=lcm(c,d);ll n6=(b/n5)-((a-1)/n5);
    cout<<((b-a+1)-((n1-n2)+(n3-n4)-n6))<<"\n";
    return 0;
    
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int x  = sc.nextInt();

        int left = x;
        int coin = 0;

        while(true){
        	if(left>=500){
        		left -= 500;
        		coin += 1000;
        	} else if(left>=5){
        		left -= 5;
        		coin += 5;
        	} else{
        		break;
        	}
        }
      	System.out.println(coin);
        sc.close();
    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main()
{
    map <long long int, long long int> m;
    vector <long long int> v;
    long long int n, x, i, j, c=0;
    cin >> n;
    for(i=1; i<=n; i++)
    {
        cin >> x;
        //if(m[x]==0)
        v.push_back(x);
        m[x]++;
    }
    int len = v.size();
    for(i=0; i<len; i++)
    {
        if(m[v[i]] != v[i])
        {
            m[v[i]]--;
            c++;
        }
    }

    cout << c << endl;
}


Measured memory_bytes: 7028
s = input()
if s[0]==s[1] and s[0]!=s[2] and s[2]==s[3]:
    print("Yes")
elif s[0]==s[2] and s[0]!=s[1] and s[1]==s[3]:
    print("Yes")
elif s[0]==s[3] and s[0]!=s[1] and s[1]==s[2]:
    print("Yes")
else:
    print("No")

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

int main()
{
	int s[8], count, f;
	while(cin >> s[0]){
		count = 0;
		for (int i = 1; i < 8; i++){
			cin >> s[i];
		}

		for (int i = 0; i < 8; i++){
			if (s[i] > 0) count++;
		}
	
		if (count == 4) cout << "B" << endl;
		else if (count == 1) cout << "C" << endl;
		else if (count == 3) {
			for (int i = 0; i < 8; i++){
				if (s[i] > 0){
					if (s[i] < s[i + 2]) cout << "D" << endl;
					else cout << "F" << endl;
					i = 9;
				}
			}
		}
		else if (count == 2){
			for (int i = 0; i < 8; i++){
				if (s[i] > 0){
					if (s[i] == s[i + 1]) cout << "A" << endl;
					else if (s[i] > s[i + 1]) cout << "E" << endl;
					else cout << "G" << endl;
					i = 9;
				}
			}
		}
	}
	return (0);
}

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

struct Block {
  Block() : xl(0), xr(0), m(0), mg(0) {}

  int xl, xr;
  int m, mg;

  vector<Block> children;
};

void MakeTree(Block &b, int y, int x, char n,
	      vector<vector<char> > &q, int ly) {
  if (q[y][x] == '.') {
    return;
  }

  if ((q[y][x] & 191) != n && ly == y + 1) {
    b.xl = min(x, b.xl);
    b.xr = max(x, b.xr);
    return;
  }

  if (q[y][x] & 64) {
    return;
  }

  if (q[y][x] != n && ly == y - 1) {
    Block child;
    child.xl = child.xr = x;
    MakeTree(child, y, x, q[y][x], q, y);
    b.children.push_back(child);
    return;
  }

  if (q[y][x] != n) {
    return;
  }

  b.m++;
  b.mg += x;
  q[y][x] |= 64;

  MakeTree(b, y, x - 1, n, q, y);
  MakeTree(b, y, x + 1, n, q, y);
  MakeTree(b, y - 1, x, n, q, y);
  MakeTree(b, y + 1, x, n, q, y);
}

bool Stable(Block &b) {
  bool stable = true;
  for (int i = 0; i < b.children.size(); i++) {
    stable = stable && Stable(b.children[i]);

    b.m += b.children[i].m;
    b.mg += b.children[i].mg;
  }

  double g = (double)b.mg / b.m - 0.5;

  return stable && g > b.xl - 1 && g < b.xr;
}

int main() {
  int w, h;
  while (cin >> w >> h, w != 0) {
    vector<vector<char> > q(h + 2);
    for (int i = 0; i < h + 2; i++) {
      q[i].resize(w + 2);
      fill(q[i].begin(), q[i].end(), '.');
    }

    for (int y = h; y >= 1; y--) {
      for (int x = 1; x <= w; x++) {
        cin >> q[y][x];
      }
    }

    Block root;
    for (int x = w; x >= 1; x--) {
      if (q[1][x] != '.') {
        root.xr = x;
        break;
      }
    }

    for (int x = 1; x <= w; x++) {
      if (q[1][x] != '.') {
        root.xl = x;
        MakeTree(root, 1, x, q[1][x], q, 1);
        break;
      }
    }

    cout << (Stable(root) ? "STABLE" : "UNSTABLE") << endl;
  }

  return 0;
}

Measured memory_bytes: 3132
text = input()
q = int(input())

for _ in range(q):
    ops = input().split()

    if len(ops) == 3:
        op, a, b = ops
    else:
        op, a, b, p = ops

    a = int(a)
    b = int(b)

    if op == 'print':
        print(text[a:b+1])
    elif op == 'reverse':
        text = text[:a] + ''.join(reversed(text[a:b+1])) + text[b + 1:]
    else:
        text = text[:a] + p + text[b + 1:]

Measured memory_bytes: 7688