akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
struct LCA {
    vector<vector<int>> par;
    vector<int> d;
    int n;
    LCA(vector<vector<int>> graph, int root) {
        n = graph.size();
        par.resize(n, vector<int>(30));
        d.resize(n, 0);
        function<void(int, int, int)> dfs = [&](int c, int p, int depth) {
            d[c] = depth;
            par[c][0] = p;
            for (auto ch : graph[c]) {
                if (ch != p) dfs(ch, c, depth + 1);
            }
        };
        dfs(0, 0, 0);
        for (int j = 1; j < 30; j++) {
            REP(i, n) { par[i][j] = par[par[i][j - 1]][j - 1]; }
        }
    }
    int getdistance(int u, int v) { return (d[u] + d[v]) - 2 * (d[query(u, v)]); }
    int query(int u, int v) {
        if (d[u] > d[v]) {
            swap(u, v);
        }
        for (int i = 29; 0 <= i; i--) {
            if (d[u] <= d[par[v][i]]) {
                v = par[v][i];
            }
        }
        /* LCA */
        for (int i = 29; 0 <= i; i--) {
            if (par[v][i] != par[u][i]) {
                v = par[v][i];
                u = par[u][i];
            }
        }
        if (u == v) {
            return u;
        } else {
            return par[v][0];
        }
    }
};

struct UnionFind {
    vector<int> parent, size;
    UnionFind(int n) {
        parent.resize(n, -1);
        size.resize(n, 1);
    }
    void unite(int x, int y) {
        if (same(x, y)) {
            return;
        }
        x = root(x);
        y = root(y);
        if (size[x] <= size[y]) {
            swap(x, y);
        }
        parent[y] = x;
        size[x] += size[y];
    }
    bool same(int x, int y) { return (root(x) == root(y)); }
    int root(int x) {
        while (parent[x] != -1) {
            x = parent[x];
        }
        return x;
    }
    int getsize(int x) { return size[root(x)]; }
};
void aoj(vector<int> bs) {
    REP(i, bs.size() - 1) { cout << bs[i] << " "; }
    cout << bs[bs.size() - 1] << endl;
}

signed main() {
    int n, x;
    cin >> n >> x;
    int cheap = 1e9;
    REP(i, n) {
        int m;
        cin >> m;
        x = x - m;
        cheap = min(cheap, m);
    }
    cout << n + x / cheap << endl;
}

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

int main() {
  int a, b;
  cin >> a >> b;

  int cnt = 0;
  for (int i = a; i <= b; i++) {
    string a = to_string(i);
    if (a[0] == a[4] && a[1] == a[3]) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
import heapq


N = 3
FORE = 1
BACK = 0

board_goal = [i for i in range(1, N ** 2)] + [0]


BOARD_ADJACENT = (
    (1, 3),        # 0
    (0, 2, 4),     # 1
    (1, 5),        # 2
    (0, 4, 6),     # 3
    (1, 3, 5, 7),  # 4
    (2, 4, 8),     # 5
    (3, 7),        # 6
    (4, 6, 8),     # 7
    (5, 7)         # 8
)


def slove(board_start):
    if board_start == board_goal:
        return 0

    dict_board_state = {}
    dict_board_state[tuple(board_start)] = (FORE, 0)

    heap_board = [(0, board_start, board_start.index(0), None, FORE)]

    while heap_board:
        cnt_move, board, space_now, space_prev, direction = heapq.heappop(heap_board)
        cnt_move += 1

        for board_next, space_next in next_board(board, space_now, space_prev):
            key = tuple(board_next)
            if key in dict_board_state:
                continue

            dict_board_state[key] = (direction, cnt_move)
            if board_next == board_goal:
                return cnt_move

            heapq.heappush(heap_board, (cnt_move, board_next, space_next, space_now, direction))

            
def next_board(board, space_now, space_prev):
    for space_next in BOARD_ADJACENT[space_now]:
        if space_next == space_prev:
            continue

        board_next = board[:]
        board_next[space_now], board_next[space_next] = board_next[space_next], 0
        yield board_next, space_next



board_input = []

for _ in range(N):
    board_input.extend(list(map(int, input().split())))


print(slove(board_input))


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

long vecSum(vector<long> v) {
  long sum = 0;
  for (int i = 0; i < v.size(); i++) {

    sum += v[i];
  }

  return sum;

}

long func(string remain, vector<long> list, int index) {
  if (remain.length() == 0) {
    return vecSum(list);
  }
  if (index >= remain.length()) {
    vector<long> pushed = list;
    string str = remain.substr(0, remain.size());
    pushed.push_back(stol(str));
    return vecSum(pushed);
  }

  vector<long> pushed = list;
  pushed.push_back(stol(remain.substr(0, index).c_str()));
  return func(remain.substr(index, remain.length()), pushed, 1) + func(remain, list, index + 1);
} 

string s;

int main() {
  cin >> s;

  cout << func(s, vector<long> {}, 1) << endl;
}


Measured memory_bytes: 256
#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 all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1e9+7
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; }
typedef long long ll;
typedef pair<int, int> P;


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

    if (s=="SUN") cout << 7 << endl;
    else if (s=="MON") cout << 6 << endl;
    else if (s=="TUE") cout << 5 << endl;
    else if (s=="WED") cout << 4 << endl;
    else if (s=="THU") cout << 3 << endl;
    else if (s=="FRI") cout << 2 << endl;
    else if (s=="SAT") cout << 1 << endl;


}

Measured memory_bytes: 256
K,A,B=map(int,input().split())
if A+2>=B:
    print(1+K)
else:
    if K<=A-1:
        print(1+K)
    else:
        K-=A-1
        ans=A
        ans=A+(B-A)*(K//2)+K%2
        print(ans)
        

Measured memory_bytes: 3064
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, r) for (int i = (l); i < (r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <class T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <class T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Main Code
int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    a.push_back(-1);
    ++n;
    
    vector<pair<int, int>> vec(n);
    rep(i, n) vec[i] = pair<int, int>(a[i], i);
    sort(all(vec));
    int ans = inf, cnt = 0; // cnt: どこまで見たか
    vector<int> ng(n, false);
    while (true) {
        int cnt_ = n;
        rep(i, n) {
            if (a[i] == vec[cnt].first) {
                ng[i] = true;
            }
            if (a[i] > vec[cnt].first) {
                int idx = lower_bound(all(vec), pair<int, int>(a[i], -1)) - vec.begin();
                chmin(cnt_, idx);
            }
        }
        if (cnt_ == n) break;
        vector<int> num(n, -1);
        int j = 0;
        rep(i, n) {
            if (i) if (ng[i] && (!ng[i - 1])) ++j;
            if (!ng[i]) num[i] = j;
        }
        vector<int> c(j + 1, 0);
        rep(i, n) {
            if (!ng[i]) ++c[num[i]];
        }
        int mx = 0;
        int qc = 0;
        rep(i, cnt_, n) {
            if (c[num[vec[i].second]] >= k) {
                --c[num[vec[i].second]];
                ++qc;
                chmax(mx, vec[i].first);
            }
            if (qc == q) break;
        }
        if (qc == q) chmin(ans, mx - vec[cnt_].first);
        else break;
        cnt = cnt_;
    }
    
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3732
#include <iostream>
#include <cstdlib>
#include <string>
#include <queue>
using namespace std;

int main(void){

	priority_queue <int> X;
	string text;
	int n;

	while (true){
		cin>>text;
		if (text[2] == 'd'){
			break;
		}
		else if (text[0] == 'i'){
			cin>>n;
			X.push(n);
		}
		else if (text[0] == 'e'){
			cout<<X.top()<<endl;
			X.pop();
		}
	}
	return 0;
} 

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<long long> p(N);
    for (int i = 0; i < N; ++i)
        cin >> p[i], ++p[i]; // 1 足しておく

    // 累積和
    vector<long long> s(N + 1, 0);
    for (int i = 0; i < N; ++i)
        s[i + 1] = s[i] + p[i];

    // K 差を見ていく
    long long res = 0;
    for (int i = 0; i + K <= N; ++i)
        res = max(res, s[i + K] - s[i]);
    cout << fixed << setprecision(10) << (double)(res) / 2 << endl;
}

Measured memory_bytes: 3328
import java.util.Scanner;
 
public class Main {

	public static final MyScanner in = new MyScanner();
	
	public static void main(String[] args) {

		String s = in.next();

		if (s.equals("SUN")) System.out.println(7);
		else if (s.equals("MON")) System.out.println(6);
		else if (s.equals("TUE")) System.out.println(5);
		else if (s.equals("WED")) System.out.println(4);
		else if (s.equals("THU")) System.out.println(3);
		else if (s.equals("FRI")) System.out.println(2);
		else if (s.equals("SAT")) System.out.println(1);

	}

	public static class MyScanner{
		Scanner sc = new Scanner(System.in);
		String nextLine() {return sc.nextLine();}
		String next() {return sc.next();}
		int nextInt() {return Integer.valueOf(sc.next());}
		long nextLong() { return Long.valueOf(sc.next());}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


int main() {
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;
    if (s=="ARC") cout << "ABC" << endl;
    else cout << "ARC" << endl; 


    return 0;   
}


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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	string s[n];
	int a=0,b=0,ans=0,f=1;
	for (int i = 0; i < n; ++i)
	{
		cin>>s[i];
		if (s[i].at(0)=='B')
		{
			++b;
		}
		if (s[i].at(s[i].size()-1)=='A')
		{
			++a;
		}
		if (a!=b)
		{
			f=0;
		}
		for (int j = 1; j < s[i].size(); ++j)
		{
			if (s[i].at(j-1)=='A'&&s[i].at(j)=='B')
			{
				++ans;
			}
		}
	}
	if (a==0&&b==0)
	{
		f=0;
	}
	cout<<ans+min(a,b)-f<<endl;
	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

struct BIT{
	int s[100010];
	void init(){
		rep(i,100010)s[i] = 0;
	}
	void add(int x){
		while(x > 0){
			s[x] ++;
			x -= x&-x;
		}
	}
	int query(int x){
		int ret = 0;
		while(x < 100010){
			ret += s[x];
			x += x&-x;
		}
		return ret;
	}
}bit[2];

int main(){
	static int n;
	static int a[4][100010];
	scanf("%d",&n);
	rep1(i,3)rep1(j,n)scanf("%d",&a[i][j]);
	
	static int s[100010],t[100010];
	rep1(j,n){
		if(a[1][j]+a[3][j] != 2*a[2][j]){
			puts("No");
			return 0;
		}
		if(a[1][j]-a[2][j] == -1)s[j] = 0;
		else if(a[1][j]-a[2][j] == 1)s[j] = 1;
		else {
			puts("No");
			return 0;
		}
		if((a[2][j]+1)%3 != 0){
			puts("No");
			return 0;
		}
		t[j] = (a[2][j]+1)/3;
	}
	
	ll cnt[2] = {};
	ll sum[2] = {};
	bit[0].init();
	bit[1].init();
	rep1(j,n){
		if((t[j]^j)&1){
			puts("No");
			return 0;
		}
		cnt[j%2] += bit[j%2].query(t[j]);
		bit[j%2].add(t[j]);
		sum[j%2] += s[j];
	}
	
	if(((cnt[0]^sum[1])&1)||((cnt[1]^sum[0])&1))puts("No");
	else puts("Yes");
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define prin(a) cout<<(a)<<endl
using ll=int64_t;
using namespace std;

//define gcd and lcm (using 64bit)
ll gcd(ll a,ll b){
    if (a < b) {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}

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


int main(){
    int n,b1,b2,ans=0;
    cin>>n;
    cin>>b1;
    ans+=b1;
    rep(i,n-2){
        b2=b1;
        cin>>b1;
        ans+=min(b1,b2);
    }
    ans+=b1;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    ll Q, H, S, D, N;
    cin >> Q >> H >> S >> D >> N;

    ll ans = 0;

    ll a  = Q * 8;
    ll b  = H * 4;
    ll c  = S * 2;
    ll mn = min(a, min(b, min(c, D)));

    if (mn == D) {
        ll mn2 = min(a, min(b, c));
        ans     = N / 2 * D + N % 2 * mn2 / 2;
    } else {
        ans = N * mn / 2;
    }

    std::cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
e=input
for _ in[0]*int(e()):
 X,z=e(),[]
 for y in e():
  s=i=0
  for k in z:
   t=X.find(y,s)+1
   if t<1:break
   if t<k:z[i]=t
   s=k;i+=1
  else:
   t=X.find(y,s)+1
   if t:z+=[t]
 print(len(z))


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

using namespace std;
typedef long long ll;

string solve(string s) {
  string res = "";
  res.push_back('A');
  res.push_back(s == "ABC" ? 'R' : 'B');
  res.push_back('C');
  return res;
}

int main() {
  string s;
  cin >> s;
  cout << solve(s);
}

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

namespace kupc2016_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i = 0; i < a[0]; i++)
            {
                int s = int.Parse(Console.ReadLine());
                if (s >= a[1] && s < a[2]) { ans++; }
            }Console.WriteLine(a[0]-ans);
        }
    }
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
typedef long long ll;
using namespace std;
map<int, int> p{{0, 1}};
int main()
{
    ll n, x, ans = 0;
    cin >> n >> x;
    ll a[n];
    REP(i, n)
    {
        cin >> a[i];
    }
    sort(a, a + n);
    REP(i, n)
    {
        x -= a[i];
        if (x >= 0)
        {
            ans++;
        }
    }
    if (x > 0)
        ans--;
    cout << ans;
}

Measured memory_bytes: 256
<?php
$input = fgets(STDIN);
$input_pieces = explode(" ", $input);

$N = $input_pieces[0];
$M = $input_pieces[1];

$input = fgets(STDIN);
$A_N = explode(" ", $input);

$work = 0;
foreach($A_N as $A_i){
  $work = $work + intval($A_i);
}

$h_day = $N - $work;

if($h_day < 0){
  echo(-1);
  echo("\n");
}else{
  echo($h_day);
  echo("\n");
}

Measured memory_bytes: 16856
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 anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DWalkAndTeleport solver = new DWalkAndTeleport();
        solver.solve(1, in, out);
        out.close();
    }

    static class DWalkAndTeleport {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long a = in.nextInt(), b = in.nextInt();

            long[] x = new long[n];
            for (int i = 0; i < n; i++)
                x[i] = in.nextInt();

            long answer = 0;

            for (int i = 1; i < n; i++) {
                answer += Math.min(b, a * (x[i] - x[i - 1]));
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 36912
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[13],t[13];
    cin>>s>>t;
    int l1=strlen(s);
    int l2=strlen(t);
    if(l1!=l2-1){
        cout << "No";
    }
    else
    {
        int flag=0;
        for(int i=0;i<l1;i++){
            if(s[i]!=t[i]){
                flag=1;
                break;
            }
        }
        if(flag==1){
            cout << "No";
        }
        else{
            cout << "Yes";
        }
    }
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define REP(i,a,n) for(int i = a ; i < n ; i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

int main(){
  string s;

  while(1){
    getline(cin,s);
    if(s == "END OF INPUT") break;
    int before = 0;
    rep(i,s.length()+1){
      if(i == s.length() || s[i] == ' '){
        cout<<i-before;
        before = i+1;
      }
    }
    cout<<endl;
  }
}

Measured memory_bytes: 0
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;

//#define int ll


const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


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

int x;
main() {
  file("threesum");
  ios;
  cin>>x;
  cout<<(x+1)/2;
  cerr << "\nTime elapsed: " << (clock() + 0.0) / CLOCKS_PER_SEC;
  return 0;
}
/**

*/


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef pair<int , int> pp;
#define X first
#define Y second
typedef long long int ll;
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
const int N = 1e6 + 1;
const ll K = 1e9 + 7;
ll dx[4] = {0, 1};
ll dy[4] = {1, 0};
ll ans[N];
ll value(ll index, ll a[], ll n) {
	if (ans[index] != -1) {
		return ans[index];
	}
	if (index == n - 2) {
		return abs(a[n - 1] - a[n - 2]) + value(n - 1, a, n);
	}
	if (index > n - 2) {
		return 0;
	}
	return ans[index] = min(abs(a[index + 1] - a[index]) + value(index + 1, a, n), abs(a[index + 2] - a[index]) + value(index + 2, a, n));
}
int main() {
	ll n;
	cin >> n;
	ll a[n];
	for (ll i = 0; i < n; i++) {
		ans[i] = -1;
	}
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
	}
	cout << value(0, a, n);
}

Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int A[100001];
int main(){
    int N;
    cin >> N;
    rep(i,N)cin >> A[i];
    sort(A,A+N);
    int i=0;
    int ans = 0;
   while(i<N){
       int t = A[i];
       int count = 0;
       while(i<N && A[i]==t)i++,count++;
       ans += count%2;
   }
    cout << ans << endl;
    return 0;
}

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

#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(v) int(v.size())
#define pii pair<int, int>
#define mp make_pair
#define f first
#define ll long long
#define ld long double
#define s second
#define vec vector<int>

using namespace std;

const int N = (int) 1e5 + 10;
const int M = (int) 1e6 + 10;
const int K = (int) 500 + 10;
const int INF = (int) 1e9 + 7;
const int mod = (int) 1e9 + 7;
const ld EPS = (ld) 1e-9;
const ll LINF = (ll) 1e18;

int n, s;
int x[N], p[N];

int main() {
	#ifdef sony
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	srand(time(0));
	cin >> n >> s;
	deque<pair<ll, ll> > q[2];
	for (int i = 1; i <= n; i++) {
		cin >> x[i] >> p[i];
		q[x[i] > s].pb(mp(x[i], p[i]));
	}
	ll ans = 0;
	while (!q[0].empty() && !q[1].empty()) {
		//cout << q[0].front().s << ' ' << q[1].back().s << '\n';
		ans += q[1].back().f - q[0].front().f;
		if (q[0].front().s >= q[1].back().s) {
			while (!q[1].empty() && q[0].front().s >= q[1].back().s) {
				q[0].front().s += q[1].back().s;
				q[1].pop_back();
			}
		} else {
			while (!q[0].empty() && q[0].front().s < q[1].back().s) {
				q[1].back().s += q[0].front().s;
				q[0].pop_front();
			}
		}
	}
	if (!q[0].empty()) 
		ans += s - q[0].front().f;
	if (!q[1].empty()) 
		ans += q[1].back().f - s;
	cout << ans;
	return 0;
}

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int n,q;
  string s;
  cin>>n>>q>>s;
  vector<int> a(q),b(q),c(n),d(n);
  
  rep(i,q) cin>>a[i]>>b[i];
  
  rep(i,n-1){
    if(s[i]=='A' && s[i+1]=='C'){
      c[i]=1;
    }else{
      c[i]=0;
    }
  }
  c[n-1]=0;
  d[0]=0;
  rep(i,n-1){
    d[i+1]=d[i]+c[i];
  }
    
    
  rep(i,q){
    cout<<d[b[i]-1]-d[a[i]-1]<<endl;
    
  }
  
  
}
///////////////////////////



Measured memory_bytes: 2688
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
        int Y = scanner.nextInt();
        
        if(Y%2==0 && 2*X<=Y && Y<=4*X){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

    }
}


Measured memory_bytes: 35840
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;

int main()
{
    int n; cin >> n;
    int point = 0; //昇順になってないところ
    vector<int> p(n);
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }

    for(int i = 0; i < n; i++){
        if(p[i] != i + 1) point++;
    }
    if(point <= 2){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

}


Measured memory_bytes: 256
L=str(input())
L=L.replace(", ",",")
L=L.replace(" ",",")
L=L.replace(".","")
M=L.split(",")
N=list(M)
l=len(N)
A=[]

for i in range(l):
    m=len(N[i])
    
    if i==l-1:
        m=m-1
    
    if 3<=m<=6:
        A.append(N[i])
    
a=len(A)
for j in range(a):
    if j<a-1:
        print(A[j],end=" ")
    else:
        print(A[j])
        
        



Measured memory_bytes: 5556
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
#include <climits>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
        // setw(6) << setfill('0')
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << "(" << v.first << ", " << v.second << ")";
    return ostr;
}

vector<string> split(const string &s, char delim) {
    vector<string> result;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
    if (!item.empty()) {
            result.push_back(item);
        }
    }
    return result;
}

int64 powmod(int64 n, int64 count, int64 mod) {
    if (count == 0) return 1;
    if (count % 2 == 0) {
        int64 t = powmod(n, count / 2, mod);
        return t * t % mod;
    }
    return n * powmod(n, count - 1, mod) % mod;
}

int64 ncr(int64 n, int64 r, int64 mod) {
    int64 a;
    if (n < r) a = min(n, r - n);
    else a = min(n - r, r);

    int64 res = 1;
    rep(i, a) {
        res = res * (n - i) % mod;
        res = res * powmod(i + 1, mod - 2, mod) % mod;
    }

    return res;
}

int main() {
    int a, b,  c; cin >> a >> b >> c;
    if (a + b >= c) {
        cout << "Yes" <<endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i=(a); i<(b); i++)
const ll maxn=100;
ll h,w,dp[maxn][maxn];
string a[maxn];
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cin>>h>>w;
    rep(i,0,h) cin>>a[i];
    memset(dp, 0x3f, sizeof dp);
    dp[0][0] = a[0][0]!='.';
    rep(i,0,h) {
        rep(j,0,w) {
            if(i>0) dp[i][j] = min(dp[i][j], dp[i-1][j] + (a[i][j]!=a[i-1][j]));
            if(j>0) dp[i][j] = min(dp[i][j], dp[i][j-1] + (a[i][j]!=a[i][j-1]));
        }
    }
    cout<<(dp[h-1][w-1]+(a[h-1][w-1]=='#'))/2<<"\n";
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <vector>
#include <set>
using namespace std;


int main()
{
  long n, w;
  scanf("%ld %ld", &n, &w);
  vector<long> values(n, 0);
  vector<long> weights(n, 0);
  for(int i = 0; scanf("%ld %ld", &weights[i], &values[i])!=EOF; i++){}
  vector<long long> arr(n * w, 0);

  for (long i=0; i<w; i++){
    if (i+1 < weights[0]){
      arr[i*n] = 0;
    } else {
      arr[i*n] = values[0];
    }
  }
  
  for (int j=1; j<n; j++) {
    for (long i=0; i<w; i++){
      if (i < weights[j]){
        arr[i*n + j] = arr[i*n+j-1]; 
      } else {
        arr[i*n + j] = std::max(arr[i*n+j-1], arr[(i-weights[j])*n + j-1] + values[j]);
      }
    }
  }
  //for (int j=0; j<n; j++) {
  //  for (int i=0; i<w; i++){
  //    printf("%lld ", arr[i*n+j]);
  //  }
  //  printf("\n");
  //}
  printf("%lld", arr[w*n - 1]);

}


Measured memory_bytes: 78336
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <string>
#define LL long long
using namespace std;

int n, a, b, c, d;
int main() 
{
	cin >> n;
	a = n % 10;
	b = n / 10 % 10;
	c = n / 100 % 10;
	d = n / 1000;
	
	if((a == b && b == c) || (b == c && c == d)) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&b!=c)cout<<"Yes";
  else if(a==c&&a!=b)cout<<"Yes";
  else if(b==c&&a!=b)cout<<"Yes";
  else cout<<"No";
  }

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		boolean flag = true;
		if(s.length()%2==0) {
			for (int i = 0; i < s.length(); i+=2) {
				if(s.charAt(i)!='h'||s.charAt(i+1)!='i')flag = false;
			}
		}else {
			flag = false;
		}
		if(flag)System.out.println("Yes");
		else System.out.println("No");
		sc.close();
	}
}

Measured memory_bytes: 22996
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize, k: usize,
    }

    if k > (n-1) * (n-2) / 2 {
        println!("-1");
        return;
    }

    let mut edge = Vec::new();
    let mut count = (n-1) * (n-2) / 2;
    for i in 2..=n {
        edge.push((1, i));
    }
    for i in 2..n {
        for j in i+1..=n {
            if count == k {
                break;
            }
            edge.push((i, j));
            count -= 1;
        }
    }

    println!("{}", edge.len());
    for (from, to) in edge {
        println!("{} {}", from, to);
    }
}


Measured memory_bytes: 2200
import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())

    graph = []
    for _ in range(M):
        a, b, d = map(int, input().split())
        graph.append([a-1, b-1, -d])

    INF = int(1E18)

    D = [INF for _ in range(N)]
    D[0] = 0

    for c in range(N-1):
        update = False
        for i, j, d in graph:
            if D[i] != INF and D[j] > D[i] + d:
                D[j] = D[i] + d
                update = True
        if not update:
            break

    negative = [False for _ in range(N)]
    for c in range(N):
        update = False
        for i, j, d in graph:
            if D[i] != INF and D[j] > D[i] + d:
                update = True
                D[j] = D[i] + d
                negative[j] = True
        if not update:
            break
    if negative[N-1]:
        print('inf')
    else:
        print(-D[N-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 3440
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    bool res = false;
    if (abs(a-c) <= d) res = true;
    if (abs(a-b)<=d && abs(b-c)<=d) res=true;
    if (res) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            int n = ip(br);
            if (n == 0) {
                break;
            }
            int[] big = new int[n];
            int[] small = new int[n];
            int[] columns = ai(br);
            big = columns;
            small[0] = columns[0];
            for (int i : columns) {
                small[0] = Math.min(small[0], i);
            }
            for (int i = 1; i < n; i++) {
                columns = ai(br);
                for (int j = 0; j < n; j++) {
                    big[j] = Math.max(big[j], columns[j]);
                }
                small[i] = columns[0];
                for (int j : columns) {
                    small[i] = Math.min(small[i], j);
                }
            }
            int result = 0;
            out: for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if (big[i] == small[j]) {
                        result = big[i];
                        break out;
                    }
                }
            }
            System.out.println(result);
        }

    }

    static int[] ai(BufferedReader br) throws IOException {
        String[] lines;
        lines = br.readLine().split(" ");
        int n = lines.length;
        int[] list = new int[n];
        while (n-- > 0) {
            list[n] = Integer.parseInt(lines[n]);
        }
        return list;
    }

    static int ip(BufferedReader br) throws IOException {
        return Integer.parseInt(br.readLine());
    }
}

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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

int main(){
    int a,b;
    cin >> a >> b;

    if(a<10 && b<10)
        cout << a*b << endl;
    else
        cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 3648
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1124

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int main() 
{
	int N,Q,M;

	while(cin >> N >> Q)
	{
		if(N == 0 && Q == 0){ break; }
		
		vector<int> date;
		rep(nth,N)
		{
			cin >> M;

			int tmp;
			rep(i, M)
			{
				cin >> tmp;
				date.push_back(tmp);
			}
		}	

		if(date.size() == 0){ date.push_back(0);}

		int MAX = *max_element(ALL(date));
		int count=0;
		bool flag=false;
		for(int m=N; m>=Q; --m)
		{
			REP(num,1,MAX+1)
			{
				count=0;
				rep(i,date.size())
				{
					if(date[i] == num){count++;}
					if(count == m)
					{
						cout << num << endl; 
						flag=true; 
						goto end;
					}
				}
			}
		}
end:
		if(!flag){ cout << 0 << endl; }
		
	}
	return 0;
}

Measured memory_bytes: 1236
N = int(input())
XL = [list(map(int, input().split())) for _ in range(N)]

LR = [(x - l, x + l) for x, l in XL]
LR.sort(key = lambda x: x[1])
#print(LR)

right = LR[0][1]
answer = 1

for i in range(1, N):
  if right <= LR[i][0]:
    right = LR[i][1]
    answer += 1
print(answer)

Measured memory_bytes: 71768
#include<iostream>
#include<string.h>
#include<cmath>

#define MAX_NUM 1000001
#define MAX_CHAR 12
#define DEPTH 7

char data[MAX_NUM][MAX_CHAR] = {};
int p[DEPTH];
int separate = pow(5,DEPTH);

void setPow(){
    for(int i=0;i<DEPTH;i++){
        p[i] = pow(5,i);
    }
}

void printData(){
    for(int i=1;i<MAX_NUM;i++){
        if(data[i][0] != '\0'){
            std::cout << "i=" << i << ':' << data[i] << '\n';
        }
    }
}


int hash(char str[]){
    int count=0;
    for(int i=0;i<DEPTH;i++){
        char tmp=str[i];
        if(tmp == 'A'){
            count += p[i]*1;
        }else if(tmp == 'C'){
            count += p[i]*2;
        }else if(tmp == 'G'){
            count += p[i]*3;
        }else if(tmp == 'T'){
            count += p[i]*4;
        }else if(tmp == '\0'){
            return count;
        }else{
            std::cout << "errar: 指定の文字で始まっていません\n";
            return 0;
        }
    }
    return count;
}

void insert(char str[]){
    int h = hash(str);
    if(h == 0){ return; }
    int end = h;
    
    do {
        if(data[h][0] == '\0'){
            strcpy(data[h],str);
            return;
        }else{
            h += separate;
            if(h >= 1000000){
                h = (h+1)%separate;
            }
        }
    }while (h != end);
    
}

void find(char str[]){
    int h = hash(str);
    if(h == 0){ return; };
    int end = h;
    do {
        if(strcmp(data[h],str)==0){
            std::cout << "yes\n";
            return;
        }else if(data[h][0] == '\0'){
                std::cout << "no\n";
                return;
        }else{
            h += separate;
            if(h >= 1000000){
                h = (h+1)%separate;
            }
        }
    }while(h != end);
}

void Command(char com[]){
    if(strcmp(com,"insert")==0){
        char str[MAX_CHAR];
        std::cin >> str;
        insert(str);
    }else if(strcmp(com,"find")==0){
        char str[MAX_CHAR];
        std::cin >> str;
        find(str);
    }else{
        std::cout << "errar : 定義されていないコマンドです\n";
    }
}

int main(){
    setPow();
    int n;
    char com[10];
    std::cin >> n;
    for(int i=0;i<n;i++){
        //std::cout << "i=" << i << '\n';
        std::cin >> com ;
        Command(com);
    }
    //printData();
    
    return 0;
}
    
        



Measured memory_bytes: 11536
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int main()
{
  int a,b,c,ma,ans;
  scanf("%d%d%d",&a,&b,&c);
  ma=max(a,max(b,c));
  if ((ma-a+ma-b+ma-c)%2==0) ans=(ma-a+ma-b+ma-c)/2;
  else ans=(ma+1-a+ma+1-b+ma+1-c)/2;
  printf("%d\n",ans);
  
}

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

int main() {

  while (1) {

    int n;
    cin >> n;

    if (n == 0) {
      return 0;
    }

    vector<int> v(n);
    int sum = 0;

    for (int i = 0; i < n; i++) {
      cin >> v[i];
      sum += v[i];
    }

    double m = (double) sum / n;
    double sum2 = 0;

    for (int i = 0; i < n; i++) {
        double m_ = abs(v[i] - m);
        sum2 += m_ * m_;
    }

    printf("%.8f", sqrt(sum2 / n));
    printf("\n");

  }

  return 0;

}


Measured memory_bytes: 3208
#include <iostream>
#include <cstdio>
using namespace std;
int h, w, c;
char a[55][55];
int main() {
	int i, j, x, y;
	cin>>h>>w;
	for(i=1; i<=h; i++) scanf("%s", &a[i][1]);
	for(i=1; i<=h; i++) for(j=1; j<=w; j++) {
		if(a[i][j]=='#') continue;
		c = 0;
		for(x=i-1; x<=i+1; x++) for(y=j-1; y<=j+1; y++) {
			c += (a[x][y]=='#');
		}
		a[i][j] = (char)(c+'0');
	}
	for(i=1; i<=h; i++, puts("")) for(j=1; j<=w; j++) {
		printf("%c", a[i][j]);
	}
	return 0;
}

Measured memory_bytes: 256
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.System.*;

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

public class Main {

    static void solve() throws Exception {
        long x = scanLong();
        out.print((x / 500 * 1000) + (x % 500 / 5 * 5));
    }

    static int scanInt() throws IOException {
        return parseInt(scanString());
    }

    static long scanLong() throws IOException {
        return parseLong(scanString());
    }

    static String scanString() throws IOException {
        while (tok == null || !tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            in.close();
            out.close();
        }
        catch (Throwable e) {
            e.printStackTrace();
            exit(1);
        }
    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a,b;
  cin>>a>>b;
  int c=0;
  for(int i=0;i<3;i++){
    if(a[i]==b[2-i]) c++;
  }
  if(c==3) cout<<"YES";
  else cout<<"NO";
  cout<<"\n";
}


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

using namespace std;

string rotate(string str) {
  return str.at(str.size() - 1) + str.substr(0, str.size() - 1);
}

int main() {
  string S, T;
  cin >> S >> T;

  bool possible = false;

  string str = S;
  for (auto i = 0; i < S.size(); i++) {
    if (str == T) {
      possible = true;
      break;
    }
    str = rotate(str);
  }

  if (possible) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	int i,j,k;
	for(i=0;i<n;i++)
	cin>>a[i];
	int count=0;
	for(i=0;i<n-2;i++)
	{
		for(j=i+1;j<n-1;j++)
		{
			for(k=j+1;k<n;k++)
			{
				if((a[i]+a[j]>a[k]) && (a[i]+a[k]>a[j]) && (a[j]+a[k]>a[i]))
				{
				if((a[i]!=a[j]) && (a[j]!=a[k]) && (a[i]!=a[k]))
				count+=1;
			    }
			}
		}
	}
	cout<<count;
}

Measured memory_bytes: 3636
S = input()

s0_splited = S.split(sep=S[0])

vals = []
if len(s0_splited) == 3:
    for s_i in s0_splited:
        if len(s_i) == 2:
            if s_i[0] != s_i[1]:
                print("No")
                break
        elif len(s_i) == 1:
            vals.append(s_i)
        if len(vals) == 2:
            if vals[0] != vals[1]:
                print("No")
                break
    else:
        print("Yes")
else:
    print("No")

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    ll n,k; cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];

    vector<ll> sum(n+1,0); // sum of [0,i)
    for(int i=0;i<n;i++){
        sum[i+1] = sum[i] + a[i];
    }

    vector<ll> b;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<=n;j++){
            b.emplace_back(sum[j]-sum[i]);
        }
    }
    sort(all(b));
    reverse(all(b));
    //debug(b);

    //for(auto v : b){
    //    cout << v << " " << bitset<10>(v) << endl;
    //}

    for(int i=40;i>=0;i--){
        vector<ll> c;
        for(auto v : b){
            if(v & (1LL << i)){
                c.emplace_back(v);
            }
        }

        if(c.size() >= k){
            b = c;
        }
    }

    ll ans = b[0];
    for(auto v : b){
        ans = ans & v;
    }
    cout << ans << endl;
}


Measured memory_bytes: 9024