akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define EPS ((ld)(1e-9))
 
#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define rep(i, e) for (int i = 0, _##i = (e); i < _##i; i++)
#define repp(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)
#define repr(i, s, e) for (int i = (s)-1, _##i = (e); i >= _##i; i--)
#define repi(i, x) for (auto &i : (x))
#define ARR(...) vector<int>({__VA_ARGS__})
#define ARS(...) vector<string>({__VA_ARGS__})
 
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef complex<double> base;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << '(' << pai.first << ' ' << pai.second << ')';
}
 
template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    cout << '[';
    for (auto p : v) cout << p << ",";
    cout << "]";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const set<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
#ifndef __DJKIM613
#define debug(...) 0
#define endl '\n'
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif
 
template<typename T> void get_max(T &a, T b) {a = max(a, b);}
template<typename T> void get_min(T &a, T b) {a = min(a, b);}

const ll MAXN = 1e5 + 10;
const ll INFF = 1e15;

ll N, W;
ll DP[MAXN];
map<ll, ll> M;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    cin >> N >> W;

    rep(i, MAXN) DP[i] = INFF;
    DP[0] = 0;

    rep(xxx, N){
        ll a, b;
        cin >> a >> b;
        repr(i, MAXN, b) get_min(DP[i], DP[i - b] + a);
    }

    ll ans = 0;
    rep(i, MAXN) if(DP[i] <= W) get_max(ans, (ll)i);
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> iP;
int w,h,c,b[35][35][4];
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int bfs(){
  bool used[35][35]={};
  queue<iP> q;
  q.push(iP(1,P(1,1)));
  while(!q.empty()){
    iP t=q.front();
    q.pop();
    int x=t.s.s,y=t.s.f;
    if(x==w&&y==h)return t.f;
    if(used[y][x])continue;
    used[y][x]=1;
    for(int i=0;i<4;i++)
      if(!b[y][x][i])q.push(iP(t.f+1,P(y+dy[i],x+dx[i])));
  }
  return 0;
}

int main(){
  while(cin>>w>>h,w){
    memset(b,-1,sizeof(b));
    for(int i=2;i<=2*h;i++)
      if(i%2)
	for(int j=1;j<=w&&cin>>c;j++)
	  b[i/2][j][3]=b[i/2+1][j][1]=c;
      else
	for(int j=1;j<w&&cin>>c;j++)
	  b[i/2][j][2]=b[i/2][j+1][0]=c;
    cout<<bfs()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1244
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int [] a = new int [N+1];
        int count = 0;
        
        for(int i=1; i<N+1; i++){
            a[i] = sc.nextInt();
        }
        
        for(int i=1; i<N+1; i++){
            if(i%2 == 1 && a[i]%2 == 1){
                count++;
            }
        }
        
        System.out.println(count);
    }
}

Measured memory_bytes: 36068
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;

public class Main
{
  static long t[];
  static long l[];
  static long h[];

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

    String s;
    String sl[];

    s = r.readLine();
    int n = Integer.parseInt(s);

    HashMap<Long, Long> m = new HashMap<>();
    m.put(0L, 1L);

    long a = 0;
    long v = 0;
    s = r.readLine();
    sl = s.split(" ");
    for(int i = 0; i < n; i++)
    {
      v += Long.parseLong(sl[i]);
      Long z = m.get(v);
      if(z != null && z > 0)
      {
        a += z;
      }
      z = m.getOrDefault(v, 0L);
      m.put(v, z + 1);
    }

    System.out.println(a);
  }

}

Measured memory_bytes: 101548
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	public static void main(String[] args) {
		int i, j, k;
		int n, m = 0;
		Py[] py0 = null;
		Py[] py1 = null;
		String[] inn = null;
		try(BufferedReader br = new BufferedReader(new InputStreamReader(in))) {
			inn = br.readLine().split(" ");
			n = parseInt(inn[0]);
			m = parseInt(inn[1]);
			py0 = new Py[m];
			py1 = new Py[m];
			for(i = 0; i < m; i++) {
				inn = br.readLine().split(" ");
				py0[i] = new Py(parseInt(inn[0]), parseInt(inn[1]));
				py1[i] = py0[i];
			}
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
		Arrays.sort(py1, (a, b) -> {if(a.p != b.p) {
			return a.p - b.p;
		} else {
			return a.y - b.y;
		}
		});
		int prep = -1;
		int xx = 0;
		for(i = 0; i < m; i++) {
			if(prep == py1[i].p) {
				xx++;
			} else {
				prep = py1[i].p;
				xx=1;
			}
			py1[i].y = xx;
		}
		PrintWriter out = new PrintWriter(System.out);
		for(i = 0; i < m; i++) {
			out.printf("%06d%06d%n", py0[i].p, py0[i].y);
		}
		out.flush();
	}
}
class Py {
	int p;
	int y;
	Py(int p, int y){
		this.p = p;
		this.y = y;
	}
}


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

using namespace std;

int main(){
  int n;
  string s1,s2;
  int a=0,b=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s1>>s2;
    if(s1>s2) a +=3;
    else if(s1<s2) b +=3;
    else {
      a++;
      b++;
    }
  }
  cout<<a<<" "<<b<<endl;

  return 0;
}
    



Measured memory_bytes: 3144
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<list>
#include<map>
#include<iomanip>
#include<iostream>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
#include<memory.h>
using namespace std;
int i,n,a[52];
long long x;
string s,t;
int main(){
	cin>>n>>s>>t;
	if(s[0]==s[1])i=2,x=6;
	else i=1,x=3;
	for(;i<s.size();){
    	if(s[i]==s[i+1]){
			if(s[i-2]==s[i-1])
				x=x*3%1000000007;
			else 
				x=x*2%1000000007;
			i+=2;
    	}
	    else if(s[i-1]==t[i-1]){
	    	x=x*2%1000000007;
			i++;
		}
	    else 
			i++;
	}
	cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
cli = {}
for i in range(-1,10**5+1):
  cli[i] = 0
for j in a:
  cli[j - 1] += 1
  cli[j] += 1
  cli[j + 1] += 1
print(max(cli.values()))

Measured memory_bytes: 20704
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a,b,sum=0;
        for(int i=0;i<n;i++){
            a = sc.nextInt();
            b = sc.nextInt();
            sum+=b-a;
        }
        sum +=n;
        System.out.println(sum);
    }
}


Measured memory_bytes: 26192
#include "bits/stdc++.h"
#include <set>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

int dp[110000];

signed main(void) {
	int W;
	cin >> W;
	vector<int>weight;
	for (int i = 1; i <= W; i *= 6)weight.pb(i);
	for (int i = 9; i <= W; i *= 9)weight.pb(i);
	int n = weight.size();
	rep(i, 100001) {
		dp[i] = 1<<29;
	}
	dp[0] = 0;

	rep(i, n) {
		FOR(j,weight[i], W+1) {
			dp[j] = min(dp[j],dp[j-weight[i]]+1);
		}
	}
	
	print(dp[W]);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	for(int i = 0; i <= 9; ++i){
		for(int j = 0; j <= 9; ++j){
			if(i * j == n){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=520,inf=1e18;
map <int,int> mp;
ll a,b,c,d;
void solve(ll n){
//cout << n << endl;
    if (n==0) return ;
    if (n==1){
        mp[1]=d;
        return ;
    }
    if (mp[n]) return;
    ///2
    ll mi=(ll)1e18;
    if (inf/d>n){
        mi=min(mi,n*d);
    }
    ll z=n%2;
    ll t=n-(n%2);
    solve(t/2);
    mi=min(mi,mp[t/2]+(n%2)*d+a);
    z=n%2;
    t=n+(n%2);
    solve(t/2);
    mi=min(mi,mp[t/2]+(n%2)*d+a);

    z=n%3;
    t=n-(n%3);
    solve(t/3);
    mi=min(mi,mp[t/3]+(n%3)*d+b);
    z=3-(n%3);
    t=n+z;
    solve(t/3);
    mi=min(mi,mp[t/3]+z*d+b);

    z=n%5;
    t=n-(n%5);
    solve(t/5);
    mi=min(mi,mp[t/5]+(n%5)*d+c);
    z=n%5;
    t=n+(5-z);
    solve(t/5);
    mi=min(mi,mp[t/5]+(5-z)*d+c);
    mp[n]=mi;
    return ;


}
void Main(){
    ll n;
    cin >> n >> a >> b >> c >> d;
    mp.clear();
    solve(n);
    cout << mp[n] << endl;
}
int32_t main(){
    sync;
    ll t;
    cin >> t;
    while(t--) Main();
}



Measured memory_bytes: 4628
import sys
input_line = [int(i) for i in input().split(" ")]
n = input_line[0]
m = input_line[1]

ans = ["1"] + ["0"] * (n - 1)
flag = 0
for i in range(m):
    input_line = input().split(" ")
    if int(input_line[0]) == 1 and flag == 0:
        ans[int(input_line[0]) - 1] = input_line[1]
        flag = 1
        continue
    elif int(input_line[0]) == 1 and flag == 1:
        if input_line[1] != ans[0]:
            print(-1)
            sys.exit()

    if ans[int(input_line[0]) - 1] == "0" or ans[int(input_line[0]) - 1] == input_line[1]:
        ans[int(input_line[0]) - 1] = input_line[1]
    else:
        print(-1)
        sys.exit()

if m == 0 and n == 1:
    ans[0] = "0"

ans_num = int("".join(ans))
if n == len(str(ans_num)):
    print(ans_num)
else:
    print(-1)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
#define pll pair<ll,ll>
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

ll c[20][20],a[220][220];
int main(){
    ll h,w;
    cin>>h>>w;
    rep(i,0,10){
        rep(j,0,10){
            cin>>c[i][j];
        }
    }

	rep(k,0,10){
		rep(i,0,10){
		    rep(j,0,10){
		    	c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
		    }
	    }
    }
    ll ans=0;
    rep(i,0,h){
        rep(j,0,w){
            cin>>a[i][j];
            if(a[i][j]>=0)ans+=c[a[i][j]][1];
        }
    }
    cout<<ans;
}



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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	string s;
	cin >> s;
	for(int i = 1; i < 4; ++i){
		if(s[i] == s[i - 1]){
			cout << "Bad";
			return 0;
		}
	}
	cout << "Good";

	return 0;
}



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

int gcd(int a, int b, int c) {
	if (a > b) swap(a, b);
	while (b % a != 0) {
		int k = b % a;
		b = a;
		a = k;
	}
	if (a > c) swap(a, c);
	while (c % a != 0) {
		int k = c % a;
		c = a;
		a = k;
	}
	return a;
}
int main() {
	int k;
	int sum = 0;
	cin >> k;
	for (int i = 1;i <= k; i++) {
		for (int j = 1; j <= k; j++) {
			for (int l = 1;l <= k;l++) {
				sum += gcd(i, j, l);
			}
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long
using namespace std;
int n, m, v, res = 1, f[1007];
pair<int, pair<int, int> >e[2007];
int read()
{
	int num = 0;
	char c = getchar();
	while (c < '0' || c>'9')c = getchar();
	while (c >= '0' && c <= '9')num = num * 10 + c - '0', c = getchar();
	return num;
}
int find(int x)
{
	if (f[x] == x)return x;
	return f[x] = find(f[x]);
}
int merge(pair<int, int>x)
{
	int a = find(x.first), b = find(x.second);
	if (f[a] == f[b])return 0;
	f[a] = b;
	return 1;
}
int kruskal(int x)
{
	for (int i = 1; i <= n; i++)
		f[i] = i;
	int res = 0;
	if (x)res += merge(e[x].second) * e[x].first;
	for (int i = 1; i <= m; i++)
		res += merge(e[i].second) * e[i].first;
	return res;
}
int fpow(int a, int x)
{
	int res = 1;
	while (x)
	{
		if (x & 1)res = 1LL * res * a % mod;
		a = 1LL * a * a % mod;
		x >>= 1;
	}
	return res;
}
signed main()
{
	n = read();
	m = read();
	v = read();
	for (int i = 1; i <= m; i++)
	{
		e[i].second.first = read();
		e[i].second.second = read();
		e[i].first = read();
	}
	sort(e + 1, e + m + 1);
	int ans = kruskal(0);
	if (ans > v)cout << 0 << endl;
	else if (ans == v)
	{
		int cnt1 = 0, cnt2 = 0;
		for (int i = 1; i <= m; i++)
			if (kruskal(i) == ans)cnt1++;
			else cnt2++;
		res = 1LL * ((fpow(2, cnt1) - 2 + mod) % mod) * fpow(2, cnt2) % mod;
		cout << res << endl;
	}
	else
	{
		int cnt1 = 0, cnt2 = 0;
		for (int i = 1; i <= m; i++)
		{
			int ch = kruskal(i);
			if (ch == v)cnt1++;
			if (ch > v)cnt2++;
		}
		res = 2LL * ((fpow(2, cnt1) - 1 + mod) % mod) * fpow(2, cnt2) % mod;
		cout << res << endl;
	}
	return 0;
}

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

#define mp make_pair
#define pb push_back
#define all(v) (v).begin(),(v).end()

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int MAX_N = 100000;
int n,m;
vi g[MAX_N];
bool vis[MAX_N];

int main()
{
  cin >> n >> m;
  int a,b;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    a--;b--;
    g[a].pb(b);
    g[b].pb(a);
  }

  fill_n(vis, n, false);

  deque<int> path({a});
  vis[a] = true;

  while (any_of(all(g[path.back()]), [](int n){ return !vis[n]; })) {
    int i = 0;
    while (vis[g[path.back()][i]]) i++;
    vis[g[path.back()][i]] = true;
    path.pb(g[path.back()][i]);
  }

  while (any_of(all(g[path.front()]), [](int n){ return !vis[n]; })) {
    int i = 0;
    while (vis[g[path.front()][i]]) i++;
    vis[g[path.front()][i]] = true;
    path.push_front(g[path.front()][i]);
  }

  cout << path.size() << endl;
  for (int i = 0; i < path.size(); i++) {
    cout << path[i]+1 << (i+1==path.size() ? '\n' : ' ');
  }

  return 0;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
vector<double> Dijkstra(int s, vector<vector<pair<int, double>>> &g) {
    priority_queue<pair<double, int>, vector<pair<double, int>>,
                   greater<pair<double, int>>>
        que;
    int n = sz(g);
    vector<double> d(n);
    for (double &x : d) x = 1e18;
    d[s] = 0;
    que.push(make_pair(0, s));
    while (!que.empty()) {
        pair<double, int> p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (auto e : g[v]) {
            if (chmin(d[e.first], d[v] + e.second)) {
                que.push(make_pair(d[e.first], e.first));
            }
        }
    }
    return d;
}
double dist(pair<double, double> a, pair<double, double> b) {
    double ax, ay, bx, by;
    tie(ax, ay) = a;
    tie(bx, by) = b;
    return sqrt((ax - bx) * (ax - bx) + (ay - by) * (ay - by));
}
int main() {
    double sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int n;
    cin >> n;
    vector<double> x(n), y(n), r(n);
    vector<vector<pair<int, double>>> g(n + 2);
    rep(i, n) cin >> x[i] >> y[i] >> r[i];
    rep(i, n) {
        rep(j, i) {
            g[i].emplace_back(
                j, max(0.0, dist({x[i], y[i]}, {x[j], y[j]}) - r[i] - r[j]));
            g[j].emplace_back(
                i, max(0.0, dist({x[i], y[i]}, {x[j], y[j]}) - r[i] - r[j]));
        }
    }
    rep(i, n) {
        g[i].emplace_back(n, max(0.0, dist({x[i], y[i]}, {sx, sy}) - r[i]));
        g[i].emplace_back(n + 1, max(0.0, dist({x[i], y[i]}, {tx, ty}) - r[i]));
        g[n].emplace_back(i, max(0.0, dist({x[i], y[i]}, {sx, sy}) - r[i]));
        g[n + 1].emplace_back(i, max(0.0, dist({x[i], y[i]}, {tx, ty}) - r[i]));
    }
    g[n].emplace_back(n + 1, dist({sx, sy}, {tx, ty}));
    g[n + 1].emplace_back(n, dist({sx, sy}, {tx, ty}));
    auto d = Dijkstra(n, g);
    cout << fixed << setprecision(20) << d[n + 1] << endl;
}


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

int main()
{
int a,b;
cin>>a>>b;
if((a==1&&b==3)||(a==3&&b==1))
{
    cout<<"2";
}
else if((a==1&&b==2)||(a==2&&b==1))
{
    cout<<"3";
}
else if((a==2&&b==3)||(a==3&&b==2))
{
    cout<<"1";
}

}


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

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
clock_t startTime;
long double getTime(){
	return (long double)(clock()-startTime)/CLOCKS_PER_SEC;
}
string s;
int solve(){
	int i=0;
	int n=s.length();
	int j=n-1;
	int count=0;
	while(i <=j){
		if(s[i]!=s[j]){
			if(s[i]=='x'){ count++; i++;}
			else if(s[j]=='x'){count++;j--;}
			else return -1;
		}	
		else {
			i++;
			j--;
		}
	}
	return count;
}
int main(){
	startTime=clock();
	cin >> s;
	cout << solve();

	return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, k;
    cin >> n >> m >> k;
    bool ans = false;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            int hoge = i * m + j * n - i * j * 2;
            if (hoge == k) {
                ans = true;
            }
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007
int k, t;
int a[105];

void eat(int yesterday){
    int i = 1;
    if(yesterday == 1){
        i = 2;
    }
    for(int j = 1; j <= t; j++){
        if(j == yesterday){
            continue;
        }
        if(a[j] > a[i]){
            i = j;
        }
    }
    if(a[i] <= 0){
        return;
    }
    a[i]--;
    eat(i);
}

int main() {
    //cout.precision(10);
    cin >> k >> t;
    for(int i = 1; i <= t; i++){
        cin >> a[i];
    }
    if(t == 1){
        cout << k - 1 << endl;
        return 0;
    }
    eat(0);
    int ans = 0;
    for(int i = 1; i <= t; i++){
        if(a[i] > 0){
            ans = a[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define NMAX 100000
using namespace std;
int dp[NMAX];
 
 
int frogSolver(int n, int h[]){
 dp[0] = 0;
 dp[1] = abs(h[0]-h[1]);
 dp[2] = abs(h[0]-h[2]);
 for(int i = 3; i<=n;i++){
   dp[i] = min(abs(h[i-1]-h[i])+dp[i-1],abs(h[i-2]-h[i])+dp[i-2]);     
 }
 
 return dp[n]; 
 
}
 
int main(void) {
  int n,t;
  int h[NMAX];
  cin >> n;
  for(int i =0;i<n;i++){
    cin >> t;
    h[i] = t;
  }
 
 
  printf("%d \n",frogSolver(n-1,h));
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
 
int main(){
   int i,j,n,s,m;
    
   scanf("%d",&n);
   scanf("%d",&s);
   m=s;
   for (i=1;i<n;i++) {
      scanf("%d",&j);
      if (j>m) m=j;
      s+=j;
   }
   if (m>=s-m) puts("No");
   else       puts("Yes");
   return 0;
}


Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Scanner;

class Main{



	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int H = sc.nextInt();
		int W = sc.nextInt();
		int[][] a = new int[H][W];
		for(int i = 0;i < H ;i++){
			for(int j = 0;j < W;j++){
				a[i][j] = sc.nextInt();
			}
		}
		ArrayList<Pair> pairs = new ArrayList<Pair>();
		int count = 0;
		for(int i = 0;i < H ;i++){
			for(int j = 0;j < W;j++){
				if(a[i][j]%2 == 1){

					if(j+1 < W){
						Pair pair1 = new Pair();
						pair1.from = i+1;
						pair1.end = j+1;
						pairs.add(pair1);

						
						Pair pair2 = new Pair();
						pair2.from = i+1;
						pair2.end = j+2;
						pairs.add(pair2);


						
						a[i][j+1]++;
						a[i][j]--;
						count++;

					}else if(i+1<H ){
						Pair pair1 = new Pair();
						pair1.from = i+1;
						pair1.end = j+1;
						pairs.add(pair1);

						
						Pair pair2 = new Pair();
						pair2.from = i+2;
						pair2.end = j+1;
						pairs.add(pair2);
						a[i+1][j]++;
						a[i][j]--;
						count++;
					}
				}
			}
		}
//				for(int i = 0;i < H ;i++){
//					for(int j = 0;j < W;j++){
//						System.out.print(a[i][j] + " ");	
//					}
//					System.out.println();	
//				}
		System.out.println(count);
		for(int i = 0;i < pairs.size();i=i+2){
			System.out.print(pairs.get(i).from + " " + pairs.get(i).end);
			System.out.println(" "+pairs.get(i+1).from + " " + pairs.get(i+1).end);

		}

	}

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



}




class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}



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

// マクロ //
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vpii = vector<pii>;
using msi = map<string, int>;

// 関数 //
template<class T> lint gcd(T a, T b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T> lint lcm(T a, T b) {
    return a * b / gcd(a, b);
}

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

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

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

// 定数 //
#define pi acos(-1)
#define mod 1000000007
#define MOD 998244353
#define inf ((1LL << 62) - 1 + (1LL << 62))

// キーワード //
#define elif else if

// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
        
    int N;
    cin >> N;
    vi L(N);
    rep(i, N) cin >> L[i];
    sort(L);
    int tori = 0;

    rep(i, N - 2) {
        for (int j = i + 1; j < N - 1; j++) {
            int wa = L[i] + L[j];
            int min = j + 1, max = N - 1;
            if (wa <= L[min]) continue;
            if (wa > L[max]) {
                tori += max - j;
                continue;
            }
            int mid = (min + max) / 2;
            
            while (1) {
                if (L[mid] < wa) {
                    if (L[mid + 1] >= wa) {
                        tori += mid - j;
                        goto end;
                    }
                    min = mid;
                    mid = (min + max) / 2;
                }
                else {
                    if (L[mid - 1] < wa) {
                        tori += mid - 1 - j;
                        goto end;
                    }
                    max = mid;
                    mid = (min + max) / 2;
                }
            }
        end:{}
        }
    }
    cou(tori);

}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author EDGE
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BBattle solver = new BBattle();
        solver.solve(1, in, out);
        out.close();
    }

    static class BBattle {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int a[] = in.nextIntArray(4);
            boolean flag = true;
            while (a[0] > 0 && a[2] > 0) {
                if (!flag)
                    a[0] = a[0] - a[3];
                else
                    a[2] = a[2] - a[1];
                //out.println(a[0]+" "+a[2]);
                flag = !flag;
            }
            if (a[0] <= 0)
                out.print("No");
            else
                out.print("Yes");
        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] nextIntArray(int n) {
            int[] array = new int[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextInt();
            }
            return array;
        }

    }
}



Measured memory_bytes: 25616
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  int N, A, B; std::cin >> N >> A >> B;
  std::cout << std::min(N*A, B) << std::endl;  

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp setprecision(12)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)
#define forx(v) for(ll x=0; x<v; x++)
#define ll long long
#define double long double
#define MAX (int)(2*pow(10,5) + 10)
#define N 100000
#define pb(a) push_back(a)
// #define cout out
// #define cin in
ll inf = pow(10,18);
ll modulo = inf;
double eps = 1e-10;
ifstream in;
ofstream out;

ll get_MAX(vector<ll>& involved, vector<vector<ll> >& rate, ll money){
	ll n = involved.size();
	if(n == 0)
		return money;
	if(n==1)
		return money/ rate[involved[0]][0]   * rate[involved[0]][1] + money % rate[involved[0]][0];
	if(n==2){
		ll mx =  0;
		ll a = involved[0],b = involved[1];
		for(ll i = 0; i<=money; i++){
			ll left = money - i;
			mx = max(mx, i/ rate[a][0] * rate[a][1] + i%rate[a][0]  + left / rate[b][0] * rate[b][1]  + left%rate[b][0]);
		}
		return mx;
	}
	ll mx =  0;
	ll a = involved[0],b = involved[1], c = involved[2];
	for(ll i = 0; i<=money; i++){
		for(ll j = 0; j<=money-i; j++){
			ll k = money - i - j;
			mx = max(mx, i / rate[a][0]*rate[a][1] + j/ rate[b][0]*rate[b][1]  + k/ rate[c][0]*rate[c][1] + i%rate[a][0] + j%rate[b][0] + k%rate[c][0]);
		}
	}
	return mx;
}

void deal(){
	vector<vector<ll> > th(3, vector<ll> (2,0));
	ll n;
	cin>>n;
	fori(2)
		forj(3)
			cin>>th[j][i];
	vector<vector<ll> > when(2,vector<ll>());
	fori(3){
		if(th[i][0] < th[i][1])
			when[0].pb(i);
		else 
			when[1].pb(i);
		sort(th[i].begin(), th[i].end());
	}
/*	cout<<"0s "<<endl;
	for(auto& el : when[0])
		cout<<el<<" ";
	cout<<endl;
*/	// we have n now
	n = get_MAX(when[0],th,n);
//	cout<<n<<endl;
	n = get_MAX(when[1],th,n);
	cout<<n;
}


int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}

/*

5
-3 -2 -6 -1 -5

*/

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

using namespace std;

int main(){
	int n;
	cin>>n;
	string a;
	cin>>a;
	int i=0,ans=0;
	while(i<n){
		int j=i;
		while(j<n && a[j]==a[i]){
			j++;
		}
		i=j;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> s(n);
  for (int i=0;i<n;++i) {
    cin >> s[i];
  }
  int h = n/2;
  sort(s.begin(), s.end());
  int p = s[h]-s[h-1];
  cout << p << endl;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int N;
LL need;
int as[114514];

struct Set {
  int base;
  int r;
  map<int, int> mp;

  Set() : base(0), r(0), mp() {}

  void Add() {
    ++base;
    if (mp.count(-base)) {
      r += mp[-base];
    }
  }

  void Dec() {
    if (mp.count(-base)) {
      r -= mp[-base];
    }
    --base;
  }

  void Push(int k) {
    if (k >= 0) r++;
    k -= base;
    mp[k]++;
  }

  int Count() {
    return r;
  }
};

bool check(int x) {
  LL cnt = 0;
  Set st[2];
  int odd = 0;
  int even = 1;
  
  for (int i=0; i<N; i++) {

    if (as[i] <= x) {
      st[odd].Add();
      st[even].Add();
    }
    st[even].Dec();
    st[odd].Push(- (as[i] > x));

    cnt += st[odd].Count();
    //printf("%d: odd - %d even - %d\n", i, st[odd].Count(), st[even].Count());
    cnt += st[even].Count();

    swap(odd, even);
  }

  //printf("%d: need - %lld cnt - %lld\n", x, need, cnt);
  return cnt >= need;
}

int main(){
  scanf("%d", &N);
  for (int i=0; i<N; i++) {
    scanf("%d", &as[i]);
  }

  need = (LL(N+1)*N/2)/2 + 1;

  int low = 0;
  int high = 1e9+1;
  while (high - low > 1) {
    int mid = (low+high)/2;
    if (check(mid)) high = mid;
    else low = mid;
  }
  printf("%d\n", high);

  return 0;
}


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

int main() {
	// your code goes here
	int l,r,k;
	cin>>l>>r>>k;
	l-=1;
	int c1 = l/k;
	int c2 = r/k;
	int ans = c2-c1;
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<string>
#include<map>
using namespace std;

int dp[1145][1145];

int main(){
    int n;
    cin>>n;
    while(n--){
        string s,t;
        cin>>s>>t;
        for(int i=0;i<s.size();i++){
            for(int j=0;j<t.size();j++){
                if(s[i]==t[j])dp[i+1][j+1]=dp[i][j]+1;
                else dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
            }
        }
        cout<<dp[s.size()][t.size()]<<endl;
    }
    return 0;
}


Measured memory_bytes: 7596
using AtCoderBeginnerContest132.Questions;
using AtCoderBeginnerContest132.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest132.Questions
{
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var s = inputStream.ReadLine().OrderBy(c => c).ToArray();

            yield return s[0] == s[1] && s[1] != s[2] && s[2] == s[3] ? "Yes" : "No";
        }
    }
}


namespace AtCoderBeginnerContest132
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest132.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest132.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

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

int main(){
     int N;
     string s;
     int r = 0; //red_flag
  
     cin >> N;
     cin >> s;
              
     for(int i;i<N;i++){
       if(s[i]=='R') r++;
       else r--;
     }
    
    if(r>0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

namespace geometry {
	using Real = double;
	using Point = complex<Real>;
	const Real EPS = 1e-9;
	const Real PI = acos(-1);
	struct Circle {
		Point p;
		Real r;
	};
	// 内積
	inline Real dot(const Point& lhs, const Point& rhs) {
		return (conj(lhs) * rhs).real();
	}
	// 外積
	inline Real cross(const Point& lhs, const Point& rhs) {
		return (conj(lhs) * rhs).imag();
	}
	// 円の交点
	vector<Point> intersect(const Circle& c1, const Circle& c2) {
		const Real dist = abs(c1.p - c2.p);
		vector<Point> ret;
		if(dist > c1.r + c2.r) return ret;
		if(dist < abs(c1.r - c2.r)) return ret;
		const Real rc = (dist * dist + c1.r * c1.r - c2.r * c2.r) / (2 * dist);
		const Real rs = sqrt(c1.r * c1.r - rc * rc);
		const Point vec = (c2.p - c1.p) / dist;
		ret.emplace_back(c1.p + vec * Point(rc, rs));
		ret.emplace_back(c1.p + vec * Point(rc, -rs));
		return ret;
	}

	inline istream& operator>>(istream& is, Point& p) {
		Real x, y;
		is >> x >> y;
		p = Point(x, y);
		return is;
	}
	inline ostream& operator<<(ostream& os, const Point &p) {
		return os << fixed << setprecision(10) << "(" << p.real() << ", " << p.imag() << ")";
	}
}


using namespace geometry;

int n, k;
Circle ci[60];
Real c[60];

bool bisearch(const Real d) {
	for(int i = 0; i < n; ++i) {
		ci[i].r = d / c[i];
	}
	vector<Point> pt;
	for(int i = 0; i < n; ++i) {
		pt.emplace_back(ci[i].p);
		for(int j = i + 1; j < n; ++j) {
			for(Point p : intersect(ci[i], ci[j])) {
				pt.emplace_back(p);
			}
		}
	}
	for(const Point& p : pt) {
		int cnt = 0;
		for(int i = 0; i < n; ++i) {
			if(c[i] * abs(p - ci[i].p) <= d + EPS) {
				++cnt;
			}
		}
		if(cnt >= k) return true;
	}
	return false;
}

int main() {
	cin >> n >> k;
	for(int i = 0; i < n; ++i) {
		cin >> ci[i].p >> c[i];
	}
	if(k == 1) {
		cout << 0 << '\n';
		return 0;
	}
	Real ok = 1e18, ng = -1e-18;
	int cnt = 100;
	while(cnt--) {
		const Real mid = (ok + ng) / 2;
		if(bisearch(mid)) {
			ok = mid;
		} else {
			ng = mid;
		}
	}
	printf("%.15f\n", ok);
	return 0;
}

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

using namespace std;

int main() {
    vector<int> a(5);
    for (int i = 0; i < 5; i++)cin >> a[i];
    int ret = 0;
    int ma = 0;
    for (int i = 0; i < 5; i++) {
        ret += (a[i] + 9) / 10 * 10;
        if (a[i] % 10 != 0) ma = max(ma, 10 - (a[i] % 10));
    }

    cout << ret - ma << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,x[65],y[65],c,i,j,t,r;
  char m[15][15];
  int X[4]={0,1,0,-1};
  int Y[4]={1,0,-1,0};
  scanf("%d",&n);
  for(c=0;c<n;c++){
    for(i=0;i<8;i++)scanf(" %s",m[i+3]+3);
    scanf(" %d %d",&x[0],&y[t=0]);
    x[0]+=2;
    y[0]+=2;
    m[y[0]][x[0]]='0';
    for(r=1;t!=r;t++){
      for(i=1;i<4;i++){
	for(j=0;j<4;j++){
	  if(m[y[t]+Y[j]*i][x[t]+X[j]*i]=='1'){
	    x[r]=x[t]+X[j]*i;
	    y[r]=y[t]+Y[j]*i;
	    m[y[r  ]][x[r++]]='0';
	  }
	}
      }
    }
    printf("Data %d:\n",c+1);
    for(i=0;i<8;i++){
      printf("%s\n",m[i+3]+3);
    }
  }
  return 0;
}
	

Measured memory_bytes: 608
#include <utility>
#include <stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define YES(b) std::cout<< (b ? "Yes" : "No")
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	int m, sum = 0;
	cin >>n>>m;
	REP(i, m - n) {
		sum += i + 1;
	}
	cout << sum - m;
}


Measured memory_bytes: 256
/*
* Author:sam51305
*/
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define endl '\n'
#define f first
#define s second
#define mp make_pair
#define ll long long
#define pii pair <int, int>
#define pll paiar <ll, ll>
#define pb push_back
#define ary array

#define Yes cout << "Yes" <<endl;
#define No cout << "No" << endl;
int main() {
    fastio
    int n, m, k;
    cin >> n >> m >> k;
    vector<ll> A(n+1),B(m+1);
    for(int i=1; i<=n; i++){
        cin >> A[i];
        A[i] += A[i-1];
    }
    for(int i=1; i<=m; i++){
        cin >> B[i];
        B[i] += B[i-1];
    }
    /*利用累加數列，讓A[i]與B[j]的值是遞增的，再來判斷A[i]+B[j]有沒有超過限制K，
    * 沒有的話，將目前的i和j加起來，就會是本數
    */
    int j = m, ans = 0;
    for(int i=0;i<=n;i++){
        if(A[i] > k) break;
        while(j>=0 && A[i]+B[j]>k)
            j--;
        //找到j
        ans = max(ans, i+j);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6348
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<ll,pair<ll,ll>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

ll n, k;
vector<ll> a(1000100);

int check(ll x){
    ll ans = 0;
    rep(i, n){
        ans += ((a[i]+x-1)/x )- 1;
    }
    return ans;
}

int main(){
    cin >> n >> k;
    rep(i, n)cin >> a[i];
    ll ng = 0, ok = mod;
    while(ok-ng > 1){
        ll mid = (ok+ng)/2;
        if(check(mid) <= k)ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}

Measured memory_bytes: 11024
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define cl(a) memset((a),0,sizeof(a))
#define all(n) n.begin(),n.end()
#define lson(x) ((x<<1))
#define rson(x) ((x<<1)|1)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod=1000000007;
const int inf=0x3f3f3f3f;
const double eps=1e-8;
const double pi=acos(-1.0);

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int a[3];
    while(cin>>a[0]>>a[1]>>a[2])
    {
        sort(a,a+3);
        cout<<(a[1]-a[0])/2+((a[1]-a[0])%2?2:0)+a[2]-a[1]<<endl;
    }
    return 0;
}


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

int main() {
  long long h, w;
  std::cin >> h >> w;
  long long cnt = 0;
  long long m1 = (h + 1) / 2;
  long long m2 = h%2 == 0 ? m1 : m1-1;
  if (h > 1 && w > 1) {
    cnt += m1 * ((w + 1) / 2);
    cnt += (m2 * (w/2));
  } else {
    cnt = 1;
  }
  std::cout << cnt << std::endl;
}

Measured memory_bytes: 256
var X = readLine()!.characters.split{$0==" "}.map{Int(String($0))!}

var N = X[0]
var K = X[1]
var Q = X[2]
var A = [Int]()
for _ in 0..<N {
    A.append(K - Q)
}

for _ in 0..<Q {
    let n: Int = Int(readLine()!)!
    A[n-1] += 1
}

for i in 0..<N {
    if A[i] > 0 {
        print("Yes")
    }else {
        print("No")
    }
}



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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

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

#define MAX_V 100000

#define MOD 1000000007L
#define INF 2147483647

signed main() {
	string s;
	cin >> s;
	bool ok = true;
	int a = -1;
	int b = -1;
	for (int i = 0; i < s.size() - 1 && ok; ++i) {
		// cout << s[i] << ":" << s[i + 1] << endl;
		if (s[i] == s[i + 1]) {
			a = i + 1;
			b = i + 2;
			ok = false;
			break;
		}
		if (i < s.size() - 2) {
			if (s[i] == s[i + 2]) {
				ok = false;
				a = i + 1;
				b = i + 3;
				break;
			}
		}
	}
	cout << a << " " << b << endl;
}


Measured memory_bytes: 512
/**
 * File    : D.cpp
 * Author  : Kazune Takahashi
 * Created : 12/9/2018, 10:40:14 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
const ll infty = 100000000000000;

ll f(ll b, ll n)
{
  if (n < b)
  {
    return n;
  }
  return f(b, n / b) + n % b;
}

ll N, S;

int main()
{
  cin >> N >> S;
  if (N < S)
  {
    cout << -1 << endl;
    return 0;
  }
  if (N == S)
  {
    cout << N + 1 << endl;
    return 0;
  }
  ll sq = sqrt(N);
  for (auto b = 2; b <= sq + 10; b++)
  {
    if (f(b, N) == S)
    {
      cout << b << endl;
      return 0;
    }
  }
  ll ans = infty;
  for (auto p = 1; p <= sq + 10; p++)
  {
    ll q = S - p;
    if ((N - q) % p != 0)
    {
      continue;
    }
    ll b = (N - q) / p;
    if (!(0 <= q && q < b && p < b))
    {
      continue;
    }
    if (f(b, N) == S)
    {
      ans = min(ans, b);
    }
  }
  if (ans < infty)
  {
    cout << ans << endl;
  }
  else
  {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 256