akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

const double pi = acos(-1.0);
inline double sqr(double x) { return x * x; }
struct point {
    double x, y;
    point() {}
    point(double a, double b) : x(a), y(b) {}
    void input() { scanf("%lf%lf", &x, &y); }
    friend point operator+(const point &a, const point &b) {
        return point(a.x + b.x, a.y + b.y);
    }
    friend point operator-(const point &a, const point &b) {
        return point(a.x - b.x, a.y - b.y);
    }
    friend point operator*(const point &a, const double &b) {
        return point(a.x * b, a.y * b);
    }
    friend point operator*(const double &b, const point &a) {
        return point(a.x * b, a.y * b);
    }
    double norm() { return sqrt(sqr(x) + sqr(y)); }
};

double det(const point &a, const point &b) { return a.x * b.y - a.y * b.x; }

double dot(const point &a, const point &b) { return a.x * b.y + a.y * b.x; }

double dist(const point &a, const point &b) { return (a - b).norm(); }

point rotate_point(const point &p, double A) {
    double tx = p.x, ty = p.y;
    return point(tx * cos(A) - ty * sin(A), tx * sin(A) + ty * cos(A));
}

void circle_center(point p0, point p1, point p2, point &cp) {
    double a1 = p1.x - p0.x, b1 = p1.y - p0.y, c1 = (sqr(a1) + sqr(b1)) / 2;
    double a2 = p2.x - p0.x, b2 = p2.y - p0.y, c2 = (sqr(a2) + sqr(b2)) / 2;
    double d = a1 * b2 - a2 * b1;
    cp.x = p0.x + (c1 * b2 - c2 * b1) / d;
    cp.y = p0.y + (a1 * c2 - a2 * c1) / d;
}

void circle_center(point p0, point p1, point &cp) {
    cp.x = (p0.x + p1.x) / 2;
    cp.y = (p0.y + p1.y) / 2;
}

point center;
double radius;
bool point_in(const point &p) { return (dist(p, center) - radius) < 0; }

void min_circle(point a[], int n) {
    radius = 0;
    center = a[0];
    for (int i = 0; i < n; i++) {
        if (!point_in(a[i])) {
            center = a[i];
            radius = 0;
            for (int j = 0; j < i; j++) {
                if (!point_in(a[j])) {
                    circle_center(a[i], a[j], center);
                    radius = dist(a[j], center);
                    for (int k = 0; k < j; k++) {
                        if (!point_in(a[k])) {
                            circle_center(a[i], a[j], a[k], center);
                            radius = dist(a[k], center);
                        }
                    }
                }
            }
        }
    }
}
int main() {
    int N;
    cin >> N;
    point a[N]{};
    for (int i = 0; i < N; i++) {
        cin >> a[i].x >> a[i].y;
    }
    min_circle(a, N);
    printf("%f", radius);

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 文字列の入力
		String s = sc.next();

		if ( s.charAt(2)==s.charAt(3) && s.charAt(4)==s.charAt(5) ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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

int main(){
	int n, m; cin >> n >> m;
	int a[n][2]; a[0][0] = 1; a[0][1] = 1;
	for(int i = 1; i < n; ++i){
		a[i][0] = 0;
		a[i][1] = 1;
	}
	for(int i = 0; i < m; ++i){
		int x, y; cin >> x >> y; --x; --y;
		if(a[x][0]){
			if(a[x][1] <= 1){
				a[x][0] = 0;
			}
			--a[x][1];
			++a[y][1];
			a[y][0] = 1;
		}else{
			--a[x][1];
			++a[y][1];
		}
	}
	int ans = 0;
	for(int i = 0; i < n; ++i){
		if(a[i][0]){
			++ans;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
d = dict()
for i in range(N):
    S = input()
    if S not in d:
        d[S] = 1
    else:
        d[S] += 1
max_vote = max(d.values())
ans = []
for k, v in d.items():
    if v == max_vote:
        ans.append(k)
ans.sort()
for a in ans:
    print(a)

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

using namespace std;

int main(){

	string S,T,U;
	cin >> S >> T;
	int A,B;
	cin >> A >> B;
	cin >> U;
	if(S==U){
		cout << A-1 << ' ' << B;
	} else {
		cout << A << ' ' << B-1;
	}

	cout << '\n';

}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

vi g[MAXN];
vector<pair<int, pii> > edges;
set<pair<int, pii> > ee[MAXN];
int par[MAXN];
ll w[MAXN];
vector<pair<int, pii> > ee_del;

int get_par(int v) {
	return par[v] == v ? v : par[v] = get_par(par[v]);
}

void solve(){
	int n, m;
	scanf("%d%d", &n, &m);
	REPN(i, 1, n) {
		scanf("%lld", &w[i]);
		par[i] = i;
	}
	edges.resize(m);
	REP(i, 0, m) {
		scanf("%d%d%d", &edges[i]._2._1, &edges[i]._2._2, &edges[i]._1);
	}
	SORT(edges);
	int ans = m;
	REP(i, 0, m) {
		int a = edges[i]._2._1;
		int b = edges[i]._2._2;
		a = get_par(a);
		b = get_par(b);
		if (a == b) {
			if (w[a] >= edges[i]._1) {
				ans--;
				//printf("%lld: %d %d\n", w[a], edges[i]._2._1, edges[i]._2._2);
			} else {
				ee[a].insert(edges[i]);
			}
		} else {
			if (SZ(ee[a]) < SZ(ee[b])) {
				swap(a, b);
			}
			FA(it, ee[b]) {
				ee[a].insert(*it);
			}
			ee[b].clear();
			par[b] = a;
			w[a] += w[b];
			
			if (w[a] >= edges[i]._1) {
				/*FA(it, ee[a]) {
					printf("%lld: %d %d\n", w[a], it->_2._1, it->_2._2);
				}
				printf("%lld: %d %d\n", w[a], edges[i]._2._1, edges[i]._2._2);*/
				ans -= SZ(ee[a]);
				ans--;
				ee[a].clear();
			} else {
				ee[a].insert(edges[i]);
			}
			/*int cnt = 0;
			FA(it, ee[a]) {
				if (it->_1 > w[a]) {
					break;
				}
				cnt++;
			}
			REP(j, 0, cnt) {
				ans--;
				printf("%lld: %d %d\n", w[a], ee[a].begin()->_2._1, ee[a].begin()->_2._2);
				ee[a].erase(ee[a].begin());
			}*/
		}
	}
	printf("%d\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 25344
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define trav(var, container) for(auto& var: container)
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define sz(x) (int)x.size()
using namespace std;
using namespace __gnu_pbds;
using ld = long double; 
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
struct chash { // large odd number for C
	const uint64_t C = ll(4e18 * acos(0)) | 71;
	ll operator()(ll x) const { return __builtin_bswap64(x*C); }
};


ll my_ceil(ll a, ll b) {
  if(a <= 0) return 0;
  ll x = a + b - 1;
  if(x >= b) return x / b;
  return 1;
}

int main() {
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int n;
  ll h;
  cin >> n >> h;
  vector<pair<ll, ll>> v(n);
  ll maxA = LLONG_MIN;
  for(auto& i: v) {
    cin >> i.first >> i.second;
    maxA = max(maxA, i.first);
  }
  sort(all(v), [](auto& a, auto& b) {
    return a.second > b.second;
  });
  ll ans = LLONG_MAX;
  ll cum_sum = 0;
  ans = my_ceil(h, maxA);
  int cnt = 0;
  for(auto& i: v) {
    // ll a = i.first;
    ll b = i.second;
    cum_sum += b;
    ++cnt;
    // cout << my_ceil(h - cum_sum, maxA) + cnt << " ";
    ans = min(my_ceil(h - cum_sum, maxA) + cnt, ans);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#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 srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,K;
    cin >> n >> K;
    vector<ll> x(n),y(n);
    vector<ll> u(n),v(n);
    rep(i,n){
        cin >> x[i] >> y[i];
        u[i] = x[i],v[i] = y[i];
    }
    rep(i,n){
        x.pb(x[i]+1),y.pb(y[i]+1);
    }
    zip(x),zip(y);
    ll ans = (1LL << 62);
    rep(i,len(x)-1){
        srep(j,i+1,len(x)){
            rep(k,len(y)-1){
                srep(l,k+1,len(y)){
                    int res = 0;
                    rep(m,n){
                        if(x[i] <= u[m] && u[m] <= x[j] && y[k] <= v[m] && v[m] <= y[l]){
                            res++;
                        }
                    }
                    if(res >= K){
                        ans = min(ans,(x[j]-x[i])*(y[l]-y[k]));
                        break;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main(){
        map<int,int> m;
        int i1,i2;
        char c;
        cin >> i1 >> c >> i2; 
        bool list[31];
        for(int i = 0; i < 31; i++) list[i] = false;
        while(i1){
                m.insert(make_pair(i1,i2));
                list[i2] = true;
                cin >> i1 >> c >> i2; 
        }   
        while(cin >> i1){
                int v = m.find(i1)->second;
                int n = 0;
                int idx = 30; 
                while(idx+1 && idx >= v){ 
                        if(list[idx]) n++;
                        idx--;
                }   
                cout << n << endl;
        }   
}

Measured memory_bytes: 0
N,W=map(int,input().split())
items=[(0,0)]
for _ in range(N):
    w,v=map(int,input().split())
    items.append((w,v))

dp=[[0 for _ in range(W+1)] for _ in range(N+1)]

for i in range(1,N+1):
    for w in range(1,W+1):
        if w-items[i][0]<0:
            dp[i][w]=dp[i-1][w]
        else:
            dp[i][w]=max(dp[i-1][w],dp[i-1][w-items[i][0]]+items[i][1])
print(dp[N][W])

Measured memory_bytes: 171784
n, W = map(int, input().split())
w = [0] * n
v = [0] * n
for i in range(n):
    w[i], v[i] = map(int, input().split())

INF = float('inf')
V = max(v)
dp = [[INF for i in range(V * n + 1)] for j in range(n + 1)]
dp[0][0] = 0

for i in range(n):
    for j in range(V * n + 1):
        if v[i] <= j:
            dp[i + 1][j] = min(dp[i][j - v[i]] + w[i], dp[i][j])
        else:
            dp[i + 1][j] = dp[i][j]

ans = 0
for i in range(V * n + 1):
    if dp[n][i] <= W:
        ans = i

print(ans)


Measured memory_bytes: 337784
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String s = scan.next();
        s = s.replaceAll("eraser", "");
        s = s.replaceAll("erase", "");
        s = s.replaceAll("dreamer", "");
        s = s.replaceAll("dream", "");
        System.out.println(s.length() == 0 ? "YES" : "NO");
    }
}


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

using namespace std;

int main() {
	int n;
	double d;
	ios::sync_with_stdio(0);
	cin >> n >> d;
	int cnt = 0;
	for(int i = 0 ; i < n ; i++) {
		double x , y;
		cin >> x >> y;
		if(d >= sqrt(x * x + y * y)) {
			cnt++;
		}
	} 
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3716
/* You can't connect the dots looking forward 
   you can only connect them looking backwards. */

/* Nothing is impossible; impossible itself says "I'm possible" */

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(10);cout << fixed;
#define dbset(x) for(int i=0 ; i<x.size(); i++) cerr << x[i] << " "; cerr << endl;
#define inf 1000000007
#define INF 1000000000000000000LL
#define PI 3.14159265358979323846
#define mod 1000000007
#define mod1 1000696969
#define flusz fflush(stdout);
#define VI vector<int>
#define VPI vector < pair<int,int> >
#define PII pair<int, int>
#define BIT bitset<N>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define REP(x, y) for(int x = 0; x < (y); ++x)
#define FOR(x, y, z) for(int x = y; x <= (z); ++x)
#define FORR(x, y, z) for(int x = y; x >= (z); --x)
using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<","; _dbg(sdbg+1, a...);
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

#define int long long
#define N 500007

int test;

int n;

int t[N];
int pref[N];

void solve()
{
    cin >> n;

    int sum = 0,res = INF;

    FOR(i,1,n){
        cin >> t[i];
        sum+=t[i];
        pref[i] = t[i] + pref[i-1];
    }

    FORR(i,n,2){
        t[i] += t[i+1];
        res = min(res,abs(t[i]-(sum-t[i]) ));
    }

    cout << res;


    return;
}

int32_t main()
{
    boost

    test=1;

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

  return 0;
}


Measured memory_bytes: 5888
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int n; cin >> n;
	string s; cin >> s;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		a[i] = s[i] - '1';
	}
	bool one = false;
	for (int i = 0; i < n; i++) {
		one |= a[i] == 1;
	}
	if (one) {
		for (int i = 0; i < n; i++) {
			if (a[i] == 2) a[i] = 0;
		}
	}
	else {
		for (int i = 0; i < n; i++) {
			if (a[i] == 2) a[i] = 1;
		}
	}

	auto func = [](int w) {
		int ret = 0;
		while (w > 0 && w % 2 == 0) {
			ret++;
			w /= 2;
		}
		return ret;
	};
	int t = 0, u = 0;
	bool b = 0;
	for (int i = 0; i < n; i++) {
		if (i > 0) {
			t += func(n - i);
			u += func(i);
		}
		if (a[i] == 0) continue;
		b ^= t <= u;
	}
	int ans = b;
	if (!one) ans *= 2;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 5252
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

struct Pt {
  int x, y, i;
};

int ccw(const Pt& a, const Pt& b, const Pt& c) {
  llint w = 0;
  w += llint(a.x) * (b.y - c.y);
  w += llint(b.x) * (c.y - a.y);
  w += llint(c.x) * (a.y - b.y);
  return w < 0 ? -1 : w > 0;
}

llint dist(const Pt& a, const Pt& b) {
  llint dx = a.x - b.x;
  llint dy = a.y - b.y;
  return dx * dx + dy * dy;
}

vector<Pt> hull(vector<Pt>& v) {
  int first = 0;
  REP(i, (int)v.size()) {
    if (make_pair(v[i].x, v[i].y) < make_pair(v[first].x, v[first].y)) first = i;
  }

  swap(v[0], v[first]);
  sort(v.begin() + 1, v.end(), [&] (const Pt& a, const Pt& b) {
      int c = ccw(v[0], a, b);
      if (c == 0) return dist(v[0], a) < dist(v[0], b);
      return c > 0;
    });

  vector<Pt> hull;
  for (auto& p: v) {
    while (hull.size() >= 2 && ccw(hull[(int)hull.size()-2], hull.back(), p) <= 0) hull.pop_back();
    hull.push_back(p);
  }
  return hull;
}

int main(void) {
  int n;
  scanf("%d", &n);
  vector<Pt> v(n);
  REP(i, n) {
    scanf("%d %d", &v[i].x, &v[i].y);
    v[i].i = i;
  }

  v = hull(v);

  vector<double> angles(n, 0);
  REP(i, (int)v.size()) {
    int p = i == 0 ? (int)v.size() - 1 : i - 1;
    int q = (i + 1) % (int)v.size();
    llint x1 = v[i].x - v[p].x;
    llint y1 = v[i].y - v[p].y;
    llint x2 = v[q].x - v[i].x;
    llint y2 = v[q].y - v[i].y;
    double cs = (x1 * x2 + y1 * y2) / sqrt(x1*x1 + y1*y1) /  sqrt(x2*x2 + y2*y2) + 1e-12;
    double angle = acos(cs);
    if (angle < 0) angle += acos(-1);
    angles[v[i].i] = angle;
  }

  double total = accumulate(angles.begin(), angles.end(), 0.0);
  REP(i, n) printf("%.12lf\n", angles[i] / total);
  return 0;
}


Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline().rstrip()


def tc():
    N = int(input())



def main():
    N = int(input())

    dp = [0]*(N+1)
    rt = int(N **0.5) +1
    for i in range(1,rt):
        for j in range(1,rt):
            if i**2 + j **2 + 1 + i*j + i + j  >N:
                break
            for k in range(1,rt):
                case =int( i**2 + j **2 + k **2 + i*j + i*k + j*k )
                if case <=N:
                    dp[case] +=1
                else:
                    break

    for l in range(1,N+1):
        print(dp[l])










if __name__ == "__main__":
    main()


Measured memory_bytes: 69456
L, R = map(int, input().split())
p = 2019
ret = p-1
if (R-L+1)//p<=0:
    for i in range(L, R):
        for j in range(i+1, R+1):
            ret = min(i*j%p, ret)
            if ret==0:
                print(0)
                break
        else:
            continue
        break
    else:
        print(ret)
else:
    print(0)

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

namespace joi2019_yo_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int m = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i = 0; i < m; i++)
            {
                if (a[i] == n) { if (x[a[i] - 1] != 2019) x[a[i] - 1]++; }
                else { if (x[a[i] - 1] + 1 != x[a[i]]) x[a[i] - 1]++; }
            }
            for (int i = 0; i < n; i++) Console.WriteLine(x[i]);
        }
    }
}


Measured memory_bytes: 18336
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
#include <iomanip>
#include <queue>
#include <cmath>
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vector<vector<T>>;
using vl = vector<ll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const long double EPS = 1e-11;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r)-1; i >= (l); i--)

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N;
    cin>>N;
    ll ans=INF;
    repe(i,1,N/2+1){
    	ll tmp=0;
    	ll a=i,b=N-i;
    	while(a){
    		tmp+=a%10;
    		a/=10;
    	}
    	while(b){
    		tmp+=b%10;
    		b/=10;
    	}
    	ans=min(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
l = []
for i in range(1, int(m**(1/2)) + 1):
	if m % i == 0:
		l.append(i)
		l.append(m // i)
l.sort()
l=l[::-1]
for i in l:
    if m//n>=i:
        print(i)
        break



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

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

using namespace std;

int main(){
	int n; scanf("%d",&n);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	int m =*min_element(a.begin(),a.end());
	int m2=*max_element(a.begin(),a.end());

	if(m2-m>=2){
		puts("No");
	}
	else if(m2-m==0){
		if(m==n-1 || m<=n/2) puts("Yes");
		else                 puts("No");
	}
	else{
		int c1=count(a.begin(),a.end(),m);
		int c2=n-c1;
		if(1<=m-c1+1 && m-c1+1<=c2/2) puts("Yes");
		else                          puts("No");
	}

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
 

int main(){
    int n; cin >> n;
    vector<int> a(n),ans(n);
    rep(i,n){
        cin >> a[i];
        ans[a[i]-1]=i+1;
    }
    rep(i,n) printf("%d ",ans[i]);
return 0;
}


Measured memory_bytes: 1536
import java.util.Scanner;
 
 
 
public class Main {
 
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
 
		String a = s.next();
		String b = s.next();
 
		int x = Integer.parseInt(a+b);
		int r = (int)Math.sqrt(x);
		System.out.println(x == r *  r ? "Yes":"No");
	}
 
}


Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
using P = pair<int, int>;
int n;
vector<int> v, w;
vector< set< P > > mem;

int f(int x, int l){
    if(x <= (1<<9)){
        auto itr = mem[x].upper_bound(P(l, 1000000));
        itr--;
        return itr->second;
    }
    int res = 0;
    if(l - w[x] >= 0) res = f(x/2, l-w[x]) + v[x];
    return max(res, f(x/2, l));
}

void ins(int id, int val, int wei){
    auto itr = mem[id].lower_bound(P(wei, 0));
    if(itr != mem[id].begin()){
        itr--;
        if(itr->second > val) return;
    }
    for(;;){
        auto itr = mem[id].lower_bound(P(wei, 0));
        if(itr == mem[id].end()) break;
        if(itr->first == wei){
            if(itr->second > val) return;
            mem[id].erase(itr);
        }else{
            if(itr->second > val) break;
            // cout << "era: " << id << " " << (itr->second) << " " << (itr->first) << endl;
            mem[id].erase(itr);
        }
    }
    mem[id].insert(P(wei, val));
    // cout << "ins: " << id << " " << wei << " " << val << endl;
}

int main(void){
    cin >> n;
    v.assign(n+1, 0);
    w.assign(n+1, 0);
    for(int i=1;i<=n;i++){
        cin >> v[i] >> w[i];
    }

    mem.assign((1<<9)+1, set<P>());
    mem[0].insert(P(0, 0));
    for(int i=1;i<=(1<<9);i++){
        if(i > n) break;
        for(P p: mem[i/2]){
            ins(i, p.second, p.first);
            if(p.first+w[i] <= 100000) ins(i, p.second+v[i], p.first+w[i]);
        }

    }

    int q;
    cin >> q;
    for(int i=0;i<q;i++){
        int x, l;
        cin >> x >> l;
        cout << f(x, l) << endl;
    }

}


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

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int W = scanner.nextInt();
        int[] w = new int[n];
        int[] v = new int[n];
        for (int i = 0; i < n; ++i) {
            w[i] = scanner.nextInt();
            v[i] = scanner.nextInt();
        }
//        System.out.println(solve(W, w, v));
        System.out.println(solve2(W, w, v));
    }

    private static long solve(int W, int[] w, int[] v) {
        long[][] dp = new long[w.length][W + 1];
        for (int i = 0; i < dp.length; ++i)
            Arrays.fill(dp[i], -1);
        return findMax(0, w, v, W, dp);
    }

    private static long findMax(int ind, int[] w, int[] v, int W, long[][] dp) {
        if (ind > w.length - 1)
            return 0;
        if (dp[ind][W] >= 0)
            return dp[ind][W];
        long res;
        if (w[ind] > W) {
             res = findMax(ind + 1, w, v, W, dp);
        } else {
            res = Math.max(
                    v[ind] + findMax(ind + 1, w, v, W - w[ind], dp),
                    findMax(ind + 1, w, v, W, dp));
        }
//        System.out.println("ind:" + ind + " W:" + W);
        dp[ind][W] = res;
        return res;
    }

    private static long solve2(int W, int[] w, int[] v) {
//        for (int ind = w.length - 1; ind >= 0; --ind) {
//            for (int i = 0)
//        }
        long[][] dp = new long[w.length][W + 1];
        for (int i = 0; i < dp.length; ++i)
            Arrays.fill(dp[i], 0);
        for (int ww = 1; ww <= W; ++ww) {
            for (int ind = 0; ind < w.length; ++ind) {
                if (w[ind] <= ww) {
                    if (ind == 0) {
                        dp[ind][ww] = v[ind];
                    } else {
                        dp[ind][ww] = Math.max(v[ind] + dp[ind - 1][ww - w[ind]], dp[ind - 1][ww]);
                    }
                } else if (ind > 0) {
                    dp[ind][ww] = dp[ind - 1][ww];
                }
            }
        }
        return dp[w.length - 1][W];
    }
}


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

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

      int max = 1;
      
      for(int i = 2; i * i <= x; i++) {
        int num = i;
        while(num * i <= x)
          num *= i;
        max = Math.max(max, num);
      }
      System.out.println(max);
  }

}


Measured memory_bytes: 22612
#include<stdio.h>
#include<stdlib.h>
int main(){

  int N,i,v,j,k;
  int *A;

  scanf("%d",&N);

  A = (int *)malloc(sizeof(int)*N);
  if(A == NULL)exit(0);

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

  for(k=0;k<N-1;k++)printf("%d ",A[k]);
  printf("%d\n",A[N-1]);

  for(i=1;i<=N-1;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-1;k++)printf("%d ",A[k]);
    printf("%d\n",A[N-1]);

  }


  free(A);

  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main(){
    string s,t;cin >> s >> t;
    if(s==t.erase(s.size()))cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3616
<?php
list($n, $m, $v, $p) = ints();
$a = ints();
rsort($a);
$min = 0;
$max = $n-1;
while($max > $min){
    $mid = floor(($min + $max+1) / 2);
    if(isOK($mid)){
        $min = $mid;
    }else{
        $max = $mid-1;
    }
}
echo $max+1;
function isOK($k){
    global $a, $m, $v, $n, $p;
    $minusable = ($n-$v) * $m;
    $over = 0;
    for($i = $k-1; $i >= $p-1; $i--){
        $o = $a[$i] - $a[$k];
        if($o > $m){
            return false;
        }
        $over += $o; 
        if($over>$minusable){
            return false;
        }
    }
    return true;
}


function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}


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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

const double PI=3.14159265358979323846;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define ZERO(a) memset(a, 0, sizeof(a))

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

template<class T> void dump(const vector<T> &v)
{
	REP(i, SZ(v)-1){ cout << v[i] << " "; }
	cout << v[SZ(v)-1] << endl;
}

template<class T> void dump(int w, int h, const vector<T> &v)
{
	REP(j, h){
		REP(i, w-1){ cout << v[j * w + i] << " "; }
		cout << v[j * w + w-1] << endl;
	}
}

template<class T> struct Matrix
{
	T w, h;
	vector<T> A;
	Matrix(T w_, T h_) : w(w_), h(h_), A(w * h) {}
	T get(T x, T y) const { return A[y * w + x]; }
};

template<class T> void input(Matrix<T> &m)
{
	REP(j, m.h){
		REP(i, m.w){
			cin >> m.A[j * m.w + i];
		}
	}
}

template<class T> Matrix<T> prod(const Matrix<T> &a, const Matrix<T> &b)
{
	Matrix<T> m(b.w, a.h);

	REP(j, m.h){
		REP(i, m.w){
			ll c = 0;
			REP(k, a.w){
				c += a.A[j * a.w + k] * b.A[k * b.w + i];
			}
			m.A[j * m.w + i] = c;
		}
	}

	return m;
}

void dump(const Matrix<ll> &m)
{
	REP(j, m.h){
		REP(i, m.w-1){ printf("%lld ", m.A[j * m.w + i]); }
		printf("%lld\n", m.A[j * m.w + m.w-1]);
	}
}

void dump(const Matrix<double> &m)
{
	REP(j, m.h){
		REP(i, m.w-1){ printf("%f ", m.A[j * m.w + i]); }
		printf("%f\n", m.A[j * m.w + m.w-1]);
	}
}

string &to_upper(string &s)
{
	REP(i, s.length()){
		if('a' <= s[i] && s[i] <= 'z'){
			s[i] -= 32;
		}
	}

	return s;
}

string &to_lower(string &s)
{
	REP(i, s.length()){
		if('A' <= s[i] && s[i] <= 'Z'){
			s[i] += 32;
		}
	}

	return s;
}

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

	int q;
	cin >> q;

	REP(i, q){
		string cmd;
		int a, b;
		cin >> cmd >> a >> b;

		if(cmd == "print"){
			cout << str.substr(a, b-a+1) << endl;
		}
		else if(cmd == "reverse"){
			string ss = str.substr(a, b-a+1);
			reverse(ALL(ss));
			str = str.substr(0, a) + ss + str.substr(b+1);
		}
		else if(cmd == "replace"){
			string p;
			cin >> p;
			str = str.substr(0, a) + p + str.substr(b+1);
		}
	}

	return 0;
}



Measured memory_bytes: 3232
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
vector<int>x;
int main(){
	string s;
	int i;
	while(getline(std::cin, s)){
		for(i=0;i<s.size();i++)if (s[i]==',')s[i]=' ';
		stringstream ss(s);
		vector<int>A,B;
		while(ss>>i)A.push_back(i);
		if(x.size()<A.size()){
			x.insert(x.begin(),1,0);
			x.push_back(0);
		}
		for(i=0;i<A.size();i++)B.push_back(x[x[i]>x[i+1]?i:i+1]+A[i]);
		x=B;
	}
	cout<<x[0]<<endl;
}

Measured memory_bytes: 1252
program answer
  implicit none
  integer(8) :: i, K, a
  read(*,*) k

  a=7
  do i = 1, K
     if(mod(a,K)==0) then
        write(*,*) i
        stop
     end if
     a=mod(10*a+7,K)
  end do

  write(*,*) '-1'
  stop
 end program answer

Measured memory_bytes: 2852
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define lamsort(v,p) sort(v.begin(),v.end(),[](p a, p b){return a.num < b.num;});
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
const long long LLINF = 1LL<<60;
const int INF = 1e9;
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; }
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int x; cin >> x;
    int cnt = x/100;
    x %= 100;
    if(x<=cnt*5) cout << 1 << endl;
    else cout << 0 << endl; 

    return 0;
}

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

namespace Competitive
{
    internal class Solution
    {
        public int N, Z, W;
        public int[] A;
        public void Run()
        {
            {
                var line = Input.ReadIntArray();
                N = line[0];
                Z = line[1];
                W = line[2];

                A = Input.ReadIntArray();
            }

            int L = A.Length;
            int ret = Math.Abs(W - A[L - 1]);
            if (A.Length >= 2)
                ret = Math.Max(ret, Math.Abs(A[L - 1] - A[L - 2]));
            Console.WriteLine(ret);

        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

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

using namespace std;

int main()
{
    int n, c, k;
    cin >> n >> c >> k;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    int j = 0;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (i - j + 1 > c ||  v[i] - v[j] > k) {
            j = i;
            ++ans;
        }
    }
    ++ans;
    cout << ans << endl;
    return 0;
}


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

int main(){
  int h, w;
  cin >> h >> w;
  
  char data[h][w];
  
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> data[i][j];
    }
  }
  
  for(int i = 0; i < h + 2; i++){
    if(i == 0 || i == h + 1){
      for(int j = 0; j < w + 2; j++){
        cout << '#';
      }
      cout << endl;
    }
    
    else{
      cout << '#';
      for(int j = 0; j < w; j++){
        cout << data[i - 1][j];
      }
      cout << '#' << endl;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#define INF (1<<29)

using namespace std;

typedef pair<int,int>pii;
typedef pair<pii,int>P;

int main(void){

  int N;
  while(cin >> N,N){
    vector<P>v(N-1);
    
    for(int i=0;i<N-1;i++){
      cin >> v[i].first.first >> v[i].first.second;
      v[i].second = i+1;
    }

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

    vector<pii>a(N,pii(0,0));

    for(int i=0;i<N-1;i++){
      int costx = 0, costy = 0;
      if(v[i].first.second % 2 == 0)costx = v[i].first.second - 1;
      else costy = v[i].first.second - 2;

      a[v[i].second].first = a[v[i].first.first].first + costx;
      a[v[i].second].second = a[v[i].first.first].second + costy;
    }

    int minx=INF,maxx=-INF,miny=INF,maxy=-INF;
    for(int i=0;i<N;i++){
      minx = min(minx, a[i].first);
      maxx = max(maxx, a[i].first);
      miny = min(miny, a[i].second);
      maxy = max(maxy, a[i].second);
    }
    
    cout << maxx+abs(minx)+1 << " " << maxy+abs(miny)+1 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3088
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i,x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(ll)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
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 (a > b) { a = b; return 1; } return 0; }

using namespace std;
int a[100000];
int b[100000];
int c[100000];
int dp[100001][3];
int main() {
  int n;
  cin >> n;
  rep(i, n){
    cin >> a[i] >> b[i] >> c[i];
  }
  reps(i, n){
    rep(j, 3){
      rep(k, 3){
        if(j == k) continue;
        int nv;
        if(j == 0) nv = a[i-1];
        else if(j == 1) nv = b[i-1];
        else nv = c[i-1];
        chmax(dp[i][j], dp[i-1][k] + nv);
      }
    }
  }
  int ans = 0;
  rep(i, 3){
    ans = max(ans, dp[n][i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
#include<stdio.h>
//#include<bits/stdc++.h>
#include<string.h>
#include<iostream>
#include<math.h>
#include<sstream>
#include<set>
#include<queue>
#include<vector>
#include<algorithm>
#include<limits.h>
#define inf 0x3fffffff
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
using namespace std;
int main()
{
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[0]+a[1]==a[2])
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner scan=new Scanner(System.in);
		String a=scan.next();
		//int b=scan.nextInt();
		//int c=scan.nextInt();
		boolean bool=false;
		String ans="";
if(a.equals("A")) {
			ans="T";
		}
if(a.equals("C")) {
	ans="G";
}
if(a.equals("T")) {
	ans="A";
}
if(a.equals("G")) {
	ans="C";
}
		
		System.out.println(ans);
	}
	}


Measured memory_bytes: 22228
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const ll mod = 1e9+7;
const int N = 2e5+6;
ld px[N],py[N];
int n;
ld chxy(ld x,ld y){
	ld ret = 0;
	for(int i=1;i<=n;i++){
		ret = max(ret,hypot(px[i]-x,py[i]-y));
	}
	return ret;
}
ld chy(ld x){
	ld st = 0;
	ld en = 1e4;
	for(int i=0;i<100;i++){
		ld len = (en-st)/3;
		ld mid1 = st+len;
		ld mid2 = en-len;
		if(chxy(x,mid1)<chxy(x,mid2)){
			en = mid2;
		}
		else{
			st = mid1;
		}
	}
	return min({chxy(x,st),chxy(x,en)});
}
ld ch(){
	ld st = 0;
	ld en = 1e4;
	for(int i=0;i<100;i++){
		
		ld len = (en-st)/3;
		ld mid1 = st+len;
		ld mid2 = en-len;
		if(chy(mid1)<chy(mid2)){
			en = mid2;
		}
		else{
			st = mid1;
		}
	}
	return min({chy(st),chy(en)});
}
void solve(){
	cout<<fixed<<setprecision(12);
	cin>>n; 
	for(int i=1;i<=n;i++)cin>>px[i]>>py[i];
	cout<<ch()<<endl;

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


Measured memory_bytes: 3900
N = int(input())
listA =input().split(' ')
count = 0
for i in range(len(listA)):
    listA[i]=int(listA[i])

flag = False
while True:
    for i in listA:
        if int(i)%2!=0:
            flag=True

    if flag==True:
        break


    for j in range(N):
        listA[j] = int(listA[j])/2
    count+=1

print(count)




Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
signed main(){
  int n,d[105],ans=0;
  d[0]=0;
  cin>>n;
  for(int i=1;i<=n;i++)
    cin>>d[i];
  sort(d,d+(n+1));
  for(int i=1;i<=n;i++){
    if(d[i] != d[i-1])
      ans++;
  }

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


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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int N, a, h[100001] = {};
    cin >> N;
    for(int i = 1; i<= N; i++){
        cin >> a;
        h[a] = i;
    }
    for(int i = 1; i<= N; i++){
        cout << h[i] << " ";
    }
    cout << endl;
}

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



int main(){
  
  long long a,b,n;
  cin>>a>>b>>n;
  long long x = min(b-1,n);
  cout<<(a*x)/b - a*(x/b)<<endl;
  
  
  
  
 return 0; 
  
}

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

using namespace std;

int main()
{
    int N,i,r,sum=0;
    string s;
    cin>>N>>s;
    r=0;
    for(i=0; i<s.length(); i++)
        if(s[i]=='R')
            r++;
    for(i=0; i<s.length(); i++)
    {
        if(r==0)
            break;
        if(s[i]=='W')
        {
            r--;
            sum++;
        }
        else
            r--;
    }
    cout<<sum<<endl;
    return 0;
}	

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

int main() {
    int N;
    int X, Y;
    cin >> N >> X >> Y;
    X--, Y--;

    vector<vector<int>> to(N, vector<int>(0));
    for (int i = 0; i < N - 1; i++) {
        to[i].push_back(i + 1);
        to[i + 1].push_back(i);
    }
    to[X].push_back(Y);
    to[Y].push_back(X);

    vector<vector<int>> dist2(N, vector<int>(N, INF));
    for (int start = 0; start < N; start++) {
        vector<int> dist(N, INF);
        dist[start] = 0;
        queue<int> q({start});
        while (!q.empty()) {
            int c = q.front();
            q.pop();
            for (auto n : to[c]) {
                if (dist[n] != INF) continue;
                dist[n] = dist[c] + 1;
                q.push(n);
            }
        }

        for (int j = 0; j < N; j++) {
            dist2[start][j] = dist[j];
        }
    }
    // ddump(dist2);

    vector<int> cnt(N);
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            cnt[dist2[i][j]]++;
        }
    }

    for (int k = 1; k < N; k++) {
        cout << cnt[k] << endl;
    }

    return 0;
}

Measured memory_bytes: 19404
#include<iostream>
using namespace std;
string s;
int main()
{
    cin>>s;
    cout<<s[0]<<s[1]<<s[2]<<s[3]<<" "<<s[4]<<s[5]<<s[6]<<s[7]<<s[8]<<s[9]<<s[10]<<s[11]<<endl;
    return 0; 
} 

Measured memory_bytes: 256
s=list(input())
c1 = 0
c2 = 0
for i in range(len(s)):
    if i%2 == 0:
        if s[i] == '0':
            c1 += 1
    else:
        if s[i] == '1':
            c1 += 1
    if i%2 != 0:
        if s[i] == '0':
            c2 += 1
    else:
        if s[i] == '1':
            c2 += 1
print(min(c1,c2))

Measured memory_bytes: 49648
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 2e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};

//連結成分の判定のために用意
struct UnionFind {
    //自身が親であれば，その集合に属する頂点数に-1を掛けたもの
    //そうでなければ親のid
    vector<int> r;

    UnionFind(int n) {
        r = vector<int>(n, -1);
    }

    int root(int x) { //木の根を調べる（どのグループに属しているか）
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }

    bool unite(int x, int y) { //xとyの属する集合を併合
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }

    int size(int x) { //xが属する集合の頂点数を調べる
        return -r[root(x)];
    }

    bool same(int x, int y) { //xとyが同じ集合に属するか否か
        return root(x) == root(y);
    }
};

struct edge { int u, v, cost; }; //点uとvを結ぶ重みcostの辺

bool comp(const edge& e1, const edge& e2) {
    return e1.cost < e2.cost;
}

vector<edge> es;
int n, m; //頂点数と辺数

ll kruskal() {
    sort(all(es), comp); //edge.costが小さい順にソート
    UnionFind UF(n); //連結成分の判定用
    ll res = 0;
    rep(i,2*(n-1)) {
        edge e = es[i];
        if (!UF.same(e.u, e.v)) { //同じ連結成分に属していなければ閉路できないためOK
            UF.unite(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}

int main() {
    cin >> n;
    vector<P> x(n), y(n);
    rep(i,n) {
        cin >> x[i].first >> y[i].first;
        x[i].second = i; y[i].second = i;
    }
    sort(all(x)); sort(all(y));

    //考えるグラフの辺集合を構築
    rep(i,n-1) {
        edge e;
        e.u = x[i].second; e.v = x[i+1].second;
        e.cost = x[i+1].first - x[i].first;
        es.pb(e);
        e.u = y[i].second; e.v = y[i+1].second;
        e.cost = y[i+1].first - y[i].first;
        es.pb(e);
    }

    ll ans = kruskal();
    cout << ans << endl;
}

Measured memory_bytes: 7980
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
#import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**6)
input=lambda: sys.stdin.readline().rstrip()

show_flg=False
#show_flg=True

ans=0
n=I()
a=LI()

tot=sum(a)
acc=0
for i in range(n):
    acc+=a[i]
    if acc>=tot/2:
        k=i
        break
if tot==acc*2:
    print(0)
    exit()
else:
    l=min(abs(2*acc-tot),abs(2*(acc-a[k])-tot))
    ans=l

show(k,tot,acc,acc-a[k])
print(ans)


Measured memory_bytes: 80612