akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

ll n, m, x, ans;

void isSkill(ll bit, vvll a){//この組の理解度を算出
    bool flag = true;
    vll now(m+1, 0);
    ll money = 0;
    REP(i, n){
        if (bit & 1 << i){//  そのbitが1ならば
            FOR(j, 1, m) now[j] += a[i][j];
            money += a[i][0];
        }
    }
    FOR(i, 1, m){//今回の組がいけているか判断
        if (now[i] < x){
            flag = false;
            break;
        }
    }
    if(flag) ans = min(ans, money);
    return;
}

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m >> x;
    ans = inf;
    vvll a(n+1, vll(m+1, 0));
    //input
    REP(i, n) REP(j, m+1) cin >> a[i][j];
    //bit full search
    REP(bit, 1 << n){
        isSkill(bit, a);
    }

    if(ans == inf) ans = -1;
    cout << ans <<"\n";
	return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;

int power(int n){
  if(n==0) return 1;
  else return 10*power(n-1);
}

int main(){
  	int N, M;
    cin >> N >> M;
    int s[M], c[M];
    for(int i=0;i<M;i++){
      cin >> s[i] >> c[i];
    }

    if(N==1){
      bool flag = true;
      for(int i=0;i<M;i++){
        if(s[i]!=1|| c[i]!=0) flag = false;
      }
      if(flag){
        cout << 0 << endl;
        return 0;
      }
    }
    

    int Mrange = power(N);
    int mrange = power(N-1);

    for(int k=mrange;k<Mrange;k++){
      int a[N];
      int i=0;
      int tmp = k;
      while( tmp > 0 ){
        a[i] = tmp%10;
        tmp /= 10;
        i++;
      }

      bool check = true;
      for(int j=0;j<M;j++){
        if(a[N-s[j]]!=c[j]) check = false;
      }

      if(check){
        cout << k <<endl;
        return 0;
      }
    }

    cout << -1 <<endl;

  	return 0;
}



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

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

  vector<int> a(n);
  rep(i,n) cin >> a[i];

  ll answer = 0;
  ll sum = 0;
  for (int i = 0; i < n - 1; i++) {
    if(a[i + 1] - sum <= t) {
      answer += (a[i + 1] - sum);
    } else {
      answer += t;
    }
    sum = a[i + 1];
  }
  answer += t;

  cout << answer << '\n';
  return 0;
}


Measured memory_bytes: 4044
#include <iostream>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <typeinfo>
#include <queue>
#include <math.h>
using namespace std;



int main(){
	int w,h,n,sum=0;
	cin>>w>>h>>n;
	int a[n][3];
	int b[w][h];
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < 3; ++j)
		{
			cin>>a[i][j];
		}
	}
	for (int i = 0; i < w; ++i)
	{
		for (int j = 0; j < h; ++j)
		{
			b[i][j]=0;
		}
	}

	for (int i = 0; i < n; ++i)
	{
		int x,y,ai;
		x=a[i][0];
		y=a[i][1];
		ai=a[i][2];

		if(ai==1){
			for (int k = 0; k < x; ++k)
			{
				for (int j = 0; j < h; ++j)
				{
					b[k][j]=1;
				}
			}
		}
		if (ai==2)
		{
			for (int k = x; k < w; ++k)
			{
				for (int j = 0; j < h; ++j)
				{
					b[k][j]=1;
				}
			}
		}
		if(ai==3){
			for (int k = 0; k < w; ++k)
			{
				for (int j = 0; j < y; ++j)
				{
					b[k][j]=1;
				}
			}

		}
		if(ai==4){
			for (int k = 0; k < w; ++k)
			{
				for (int j = y; j < h; ++j)
				{
					b[k][j]=1;
				}
			}

		}

	}

	for (int i = 0; i < w; ++i)
	{
		for (int j = 0; j < h; ++j)
		{
			if(b[i][j]==0)
				sum=sum+1;
		}
	}
	cout<<sum<<endl;








return 0;
}

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

#define int long long
#define fs first
#define sc second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define len(v) ((int)v.size())
#define vc vector
#define pr pair
#define endl "\n"

using namespace std;


void ans(bool c) {
	if (c) {
		cout << "Possible";
	}
	else {
		cout << "Impossible";
	}
}

main() {
	ios_base::sync_with_stdio(0);
	int n, m;
	cin >> n >> m;
	bool a[n][m];
	bool used[n + 1][m + 1];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			char c;
			cin >> c;
			a[i][j] = (c == '#');
			used[i][j] = 0;
		}
	}
	int l = 0;
	int r = 0;
	used[l][r] = 1;
	while ((l < n && r < m)) {
		if (l < n - 1 && a[l + 1][r]) {
			l++;
		}
		else {
			r++;
		}
		used[l][r] = 1;
	}
	bool prav = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (a[i][j] && !used[i][j]) {
				prav = 1;
			}
		}
	}
	ans(!prav);
}

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
using tp = tuple<ll, ll, ll>;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll)1e9 + 7;
constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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;
}

//グラフ関連
struct Edge {
    ll to, cap, rev;
    Edge(ll _to, ll _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll H, W, h, w;
    cin >> H >> W >> h >> w;

    int k = (H + h - 1) / h;
    if(H - k < (h - 1) * k) {
        ll b = 2 * k;
        ll a = ((h - 1) * k * b - 1) / k;
        cout << "Yes" << en;
        REP(i, H) {
            REP(j, W) {
                cout << (i % h == 0 ? a : -b) << " ";
            }
            cout << en;
        }
        return;
    }
    k = (W + w - 1) / w;
    if(W - k < (w - 1) * k) {
        ll b = 2 * k;
        ll a = ((w - 1) * k * b - 1) / k;
        cout << "Yes" << en;
        REP(i, H) {
            REP(j, W) {
                cout << (j % w == 0 ? a : -b) << " ";
            }
            cout << en;
        }
        return;
    }

    cout << "No" << en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    ll t;
    cin >> t;
    while(t--)*/
    solve();

    return 0;
}


Measured memory_bytes: 3564
#include <math.h>
#include <string.h>
#include <stdio.h>

int main(void){
    char a[100];
    int length=0;
    int answer=0;
    scanf("%s",a);
    int i=0;
    length = strlen(a);

    for(int j=0; j<(length)/2; j++){
        if(a[j]!=a[length-1-j]) answer++;
    }
    printf("%d\n",answer);
}

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

int main()
{
  long long n;
  cin >> n;
  vector<long long> v(n);
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    cin >> v.at(i);
    sum += v.at(i);
  }
  long long tmp = 0;
  long long min_diff = LLONG_MAX;
  for (long long i = 0; i < n; i++) {
    tmp += v.at(i);
    min_diff = min(min_diff, abs(tmp - (sum - tmp)));
  }
  cout << min_diff << '\n';
  return 0;
}


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

int main(){
  int w,a,b,c;
  cin>>w>>a>>b;
  c=0;
  if((a+w>=b and b>=a) or (b+w>=a and a>=b)){
    cout<<c<<endl;
  }
  
  else if(a>b){
    while(!(b+w+c>=a)){
      c+=1;
    }
    cout<<c<<endl;
  }
  else if(a<b){
    while(!(a+w+c>=b)){
      c+=1;
    }
    cout<<c<<endl;
    
  }
}

Measured memory_bytes: 256
import java.io.PrintStream
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`);
    try {
        solve(sc, System.out);
    } finally {
        sc.close();
    }
}

fun solve(sc: Scanner, wr: PrintStream) {
    val N = sc.nextInt()
    val point = (0 until N).map { (sc.nextLong() to sc.nextLong()) }

    val p1 = point.map { it.first + it.second }.sorted()
    val p2 = point.map { it.first - it.second }.sorted()

    val cand1 = (p1.max() ?: 0) - (p1.min() ?: 0)
    val cand2 = (p2.max() ?: 0) - (p2.min() ?: 0)

    wr.println(Math.max(cand1, cand2))
}


Measured memory_bytes: 87572
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

class Prog
{
    public Prog() { }
    public static int Main()
    {
        new Prog().calc();
        return 0;
    }

    Scanner cin;

    public void calc()
    {
        cin = new Scanner();
        string s = cin.next();
        int N = s.Length;

        int totalscore = 0;
        for(int i = 0;i<N;i++)
        {
            char h = i % 2 == 0 ? 'g' : 'p';
            totalscore += score(h, s[i]);
        }

        Console.WriteLine(totalscore);
    }

    private int score(char h1,char h2)
    {
        if (h1 == h2) return 0;
        if (h1 == 'g' && h2 == 'p') return -1;
        if (h1 == 'p' && h2 == 'g') return 1;
        return 0;
    }
}


class Scanner
{
    string[] s;
    int i;

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

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

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

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

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

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

}

Measured memory_bytes: 3416
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	// ReadString returns a WORD string.
	ReadString func() string
)

func init() {
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
}

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	n, _ := strconv.Atoi(ReadString())
	return n
}

// 10 11 12 => [10, 11, 12]
func readIntSlice(size int) []int {
	a := make([]int, size)
	for i := 0; i < size; i++ {
		a[i] = readInt()
	}
	return a
}

func get2byte(size int) [][]byte {
	a := make([][]byte, size)
	for i := 0; i < size; i++ {
		var low string
		fmt.Scan(&low)
		a[i] = []byte(low)
	}
	return a
}

func transpose(a [][]int) {
	n := len(a)
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			a[i][j], a[j][i] = a[j][i], a[i][j]
		}
	}
}

func fact(n, m int) int {
	res := 1
	for i := m + 1; i <= n; i++ {
		res *= i
	}
	return res
}

func perm(n, r int) int {
	if r > n {
		return 0
	}
	return fact(n, n-r)
}

func comb(n, m int) int {
	if m > n {
		return 0
	}
	return fact(n, n-m) / fact(m, 0)
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

func max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

func main() {
	S := ReadString()
	var count int
	var max int
	for _, c := range S {
		if c == 'R' {
			count++
		} else if c == 'S' {
			count = 0
		}
		if max < count {
			max = count
		}

	}
	fmt.Println(max)
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int x, y, z, k;
    cin >> x >> y >> z >> k;

    vector<int> a(x), b(y), c(z);
    REP(i, x) cin >> a[i];
    REP(i, y) cin >> b[i];
    REP(i, z) cin >> c[i];

    sort(all(a));
    sort(all(b));
    sort(all(c), greater<int>());

    vector<int> d;
    REP(i, x) REP(j, y)
    {
        d.push_back(a[i] + b[j]);
    }
    sort(all(d), greater<int>());

    vector<int> ans;
    REP(i, min(k, x*y)) REP(j, z)
    {
        ans.push_back(d[i] + c[j]);
    }
    sort(all(ans));
    REP(i, k)
    {
        cout << ans[ans.size() - i - 1] << endl;
    }

}

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


int main(){
  ll x,a,b;
  cin>>x>>a>>b;
  x = x-a;
  cout<<x%b<<endl;
  
  return 0;
}

Measured memory_bytes: 764
import java.util.Map.Entry;
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int x = sc.nextInt();
		int y = sc.nextInt();
		int ans = Integer.MAX_VALUE;
		
		ans = Math.min(ans, calc(x, y));
		ans = Math.min(ans, calc(-x, y) + 1);
		ans = Math.min(ans, calc(x, -y) + 1);
		ans = Math.min(ans, calc(-x, -y) + 2);
		System.out.println(ans);		
	}
	
	public static int calc(int xx, int yy){
		if(yy < xx) return 2000000010;	
		return yy - xx;
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21204
import sys
sys.setrecursionlimit(1000000)
N=int(input())
g = [[] for i in range(N)]
for i in range(N-1):
    a,b = map(int,input().split())
    g[a-1].append([b-1,i])
    g[b-1].append([a-1,i])

ans=[0 for i in range(N-1)]

def dfs(i,j,col):
    k=1
    for nec in g[i]:
        if nec[0]==j:continue
        if k==col:k+=1
        ans[nec[1]]=k
        dfs(nec[0],i,k)
        k+=1

dfs(0,-1,-1)
print(max(ans))
for i in range(N-1):
    print(ans[i])


Measured memory_bytes: 104988
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
const int inf = 1e8;

int main(){
  int n,m;
  cin >> n >> m;
  int a[1000], b[1000], c[1000], dist[100][100];
  FOR(i,0,m){
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;b[i]--;
  }

  FOR(i,0,n){
    FOR(j,0,n){
      if(i==j) dist[i][j] = 0;
      else dist[i][j] = inf;
    }
  }

  // 連結してるとこはcを代入
  FOR(i,0,m){
    dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]);
    dist[b[i]][a[i]] = min(dist[b[i]][a[i]], c[i]);
  }

  // ワーシャルフロイド
  FOR(k,0,n) FOR(i,0,n) FOR(j,0,n) {
    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  }
  int ans = m;
  // O(NM)
  // 辺ごとに通るか調べる
  // dist[i][b[j]] == dist[i][a[j]] + c[j]
  FOR(j,0,m){
    bool ok = false;
    FOR(i,0,n){
      if(dist[i][b[j]] == dist[i][a[j]] + c[j]) ok = true;
    }
    if(ok) ans--;
  }
  cout << ans << endl;
}


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

#define _GLIBCXX_DEBUG

//vector<int> A(M), B(M);
//vector<vector<char>> answer(N, vector<char>(N, '-'));

int main() {
  int n, m;
  string ans;
  
  cin >> n >> m;
  
  if(n == m) ans = "Yes";
  else ans = "No";
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3580
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define fi first
//#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

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; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1

i64 ncr(i64 n, i64 r) {
  if (n < r) return 0;
  
  i64 a = 1, b = 1;
  int im = r;
  F0R(i, im) {
    a *= n; b *= r;
    n--; r--;
  }
  return a / b;
}

i64 calc(string N, int K) {

  if (K == 0) return 1;
  if (N.size() == 0) return 0;

  i64 result = 0;

  int n = N.front() - '0';

  // 最上位が0 で、下位は全ての桁が 0～9 をとりうるとき
  if (n > 0) {
    result += ncr(N.size() - 1, K) * pow(9, K);
  }
  //debug(result);

  // 最上位が1以上 n未満（nを最上位の数とするとき）で、
  // 下位は全ての桁が 0～9 をとりうるとき
  if (n > 0) {
    result += (n - 1) * ncr(N.size() - 1, K - 1) * pow(9, K - 1);
    //debug(result);
  }

  // 最上位がn なので、下位の桁のとりうる数が 0～9 のうち一部
  if (n > 0) {
    result += calc(N.substr(1, N.size() - 1), K - 1);
  }
  else {
    result += calc(N.substr(1, N.size() - 1), K);
  }

  return result;
}

i64 calc2(string N, int K) {

  string s = "0";

  i64 result = 0;
  while (true) {

    // count non-zeros
    int nzc = 0;
    for (char c : s) {
      if (c != '0') nzc++;
    }
    if (nzc == K) result++;

    if (s == N) break;

    int idx = s.size() - 1;
    while (true) {
      if (s[idx] != '9') {
        s[idx]++;
        break;
      }
      s[idx] = '0';
      idx--;
      if (idx < 0) {
        s = '1' + s;
        break;
      }
    }
  }

  return result;
}

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

#if 0
  // automatic verify
  F0R(i, 10000) {
    string s = to_string(i);
    FOR(k, 1, 3) {
      if (calc(s, k) != calc2(s, k)) {
        cout << "mismatch" << newl;
        cout << s << ' ' << k << newl;
        cout << calc(s, k) << " != " << calc2(s, k) << newl;
        i = INT32_MAX - 1;
        break;
      }
    }
  }
#endif

  string N;
  int K;
  cin >> N >> K;

  cout << calc(N, K);


}
#endif


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define double ld
//#define int ll
//#define int __int128
//#define ll __int128
typedef pair<int, int   > pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
//typedef complex<double> base;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < (int)(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef RUS_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";

template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}



void smain();

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

#ifdef RUS_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef RUS_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

const int N = 1e6 + 1, oo = 1e9, MOD = 998244353;

void smain() {

    string s, t = "", cur = "";
    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
        cur += s[i];
        if (cur == t) {
            ;
        } else {
            t = cur;
            ans++;
            cur = "";
        }
    }
    cout << ans;






}


Measured memory_bytes: 720
S=input()
total=0
if len(S)==1:
    print(S)
    exit(0)
for i in range(2**(len(S)-1)):
    a = int(S[0])
    t=format(i,'b').zfill(len(S)-1)
    for j in range(len(t)):
        if t[j]=='0':
            a=a*10+int(S[j+1])
        else:
            total+=a
            a=int(S[j+1])
    total+=a

print(total)


Measured memory_bytes: 3064
N,D=(int(x) for x in input().split())
X=[[0]*D for _ in range(N)]
for n in range(N):
    A=list(map(int,input().split()))
    for d in range(D):
        X[n][d]=A[d]
def kyori(x,y,d):
    c=0
    for dd in range(d):
        c=c+(x[dd]-y[dd])**2
    return(c**(1/2))
ans=0
for i in range(N):
    for j in range(i+1,N):
        kyo=kyori(X[i],X[j],D)
        if kyo.is_integer()==True:
            ans=ans+1
print(ans)


Measured memory_bytes: 3188
import bisect
N = int(input())
A = list(map(int, input().split()))

dp = [float('inf') for _ in range(N)]

for i in range(N):
    a = A[i]
    idx = bisect.bisect_left(dp, a)
    dp[idx] = a

s = [i for i, d in enumerate(dp) if i + 1 == d]
if len(s) == 0:
    print(-1)
else:
    print(N - 1 - max(s))



Measured memory_bytes: 98000
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Stack;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		
		int N = Integer.parseInt(br.readLine());
		
		st = new StringTokenizer(br.readLine());
		long[] psa = new long[N+1];
		psa[0] = 0;
		for(int i=1; i<=N; i++) {
			psa[i] = Integer.parseInt(st.nextToken()) + psa[i-1];
		}

		long[][] dp = new long[N][N];
		for(int i=N-1; i>=0; i--) {
			for(int j=i+1; j<N; j++) {
				dp[i][j] = Long.MAX_VALUE;
				for(int k=i; k<j; k++) {
					dp[i][j] = Math.min(dp[i][j], dp[i][k]+dp[k+1][j]+psa[j+1]-psa[i]);
				}
				//dp[i][j] += ;
			}
		}
		System.out.println(dp[0][N-1]);
	}
}


Measured memory_bytes: 34628
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=min(A[0],B[0])
B[0]-=ans
for i in range(N-1):
    score=min(A[i+1],B[i]+B[i+1])
    ans+=score
    B[i+1]-=max(0,score-B[i])
print(ans+min(B[N-1],A[N]))

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



typedef long long ll;
template<class V, int NV> class SegTree {
public:
	#define DEF make_pair(0,0)
	V comp(V l, V r) { return max(l, r); };

	vector<V> val;
	SegTree() { val = vector<V>(NV * 2, DEF); }

	V getval(int l, int r) { //[l,r]
		l += NV; r += NV + 1;
		V ret = DEF;
		while (l < r) {
			if (l & 1) ret = comp(ret, val[l++]);
			if (r & 1) ret = comp(ret, val[--r]);
			l /= 2; r /= 2;
		}
		return ret;
	}
	void update(int i, V v) {
		i += NV;
		val[i] = v;
		while (i>1) i >>= 1, val[i] = comp(val[i * 2], val[i * 2 + 1]);
	}
};
int N, M;
ll A[5010];
ll B[5010][205];
//-----------------------------------------------------------------
ll dp[5010][5010];
SegTree<pair<ll,int>, 1 << 13> st;
void pre() {
	rep(j, 0, M) {
		rep(i, 0, N) st.update(i, { B[i][j], i });

		queue<pair<int, int>> que;
		que.push({ 0, N - 1 });
		while (!que.empty()) {
			auto p = que.front();
			que.pop();

			int l = p.first;
			int r = p.second;

			auto pp = st.getval(l, r);
			ll ma = pp.first;
			int c = pp.second;

			dp[l][l] += ma;
			dp[l][r + 1] -= ma;
			dp[r + 1][l] -= ma;
			dp[r + 1][r + 1] += ma;
			if (l < c) {
				dp[l][l] -= ma;
				dp[l][c] += ma;
				dp[c][l] += ma;
				dp[c][c] -= ma;
				que.push({ l, c - 1 });
			}

			if (c < r) {
				dp[c + 1][c + 1] -= ma;
				dp[c + 1][r + 1] += ma;
				dp[r + 1][c + 1] += ma;
				dp[r + 1][r + 1] -= ma;
				que.push({ c + 1, r });
			}
		}
	}

	rep(i, 0, N) rep(j, 1, N) dp[i][j] += dp[i][j - 1];
	rep(i, 0, N) rep(j, 1, N) dp[i][j] += dp[i - 1][j];
}
//-----------------------------------------------------------------
ll dp2[5010];
void pre2() {
	dp2[0] = 0;
	rep(i, 0, N - 1) dp2[i + 1] = dp2[i] + A[i];
}
//-----------------------------------------------------------------
int main() {
	cin >> N >> M;
	rep(i, 0, N - 1) scanf("%lld", &A[i]);
	rep(i, 0, N) rep(j, 0, M) scanf("%lld", &B[i][j]);

	pre();
	pre2();

	/*rep(i, 0, N) rep(j, i, N) {
		printf("dp[%d][%d] = %lld\n", i, j, dp[i][j]);
	}*/
	/*rep(i, 0, N) rep(j, i, N) {
		printf("dp2[%d][%d] = %lld\n", i, j, dp2[j] - dp2[i]);
	}*/

	ll ans = 0;
	rep(i, 0, N) rep(j, i, N) {
		ll a = dp[i][j] - (dp2[j] - dp2[i]);
		ans = max(ans, a);
	}
	cout << ans << endl;
}

Measured memory_bytes: 204416
n = int(input())
c = str(input())
cn = [False]*n
for i in range(n):
    if c[i]=="R":
        cn[i]= True


ans = 0
k=n-1
b=0

for i in range(n):
    if b==1:
        break

    if not(cn[i]):
        for j in range(k,0,-1):

            if cn[j]:
                k =j-1
                if i < j:
                    #cn[i]=True
                    #cn[j]=False
                    ans +=1
                    break
            if i>=j:
                b=1
                break
print(ans)

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

#define forn(i,x,y) for(int i = int(x); i<int(y); i++)
#define debug(x) cerr << #x << " == " << (x) << '\n';
#define all(V) V.begin(), V.end()
#define on(x, b) (x & (1LL << b))
#define trav(x, v) for(auto &x : v)

#define f first
#define s second

const int W = 1024;
const int H = 16;

int h, w, k;
char s[H][W];

int main() {
    ios::sync_with_stdio(false); cin.tie(NULL);
    cin >> h >> w >> k;
    forn(i,0,h) forn(j,0,w) cin >> s[i][j];
    int ans = 1e8;

    for(int mask = 0; mask < (1 << (h)) - 1; mask++) {

        int cuts = 0;
        int up = __builtin_popcount(mask);
        int cnt[up + 1] = {0};
        bool ok = true;
        forn(j,0,w) {
            int at = 0;
            int add[up + 1] = {0};
            for(int i = 0; i < h; i++) {
                if(s[i][j] == '1') add[at]++;
                if(on(mask, i)) at++;
            }
            bool fiz = false;
            forn(i,0,up+1) {
                if(add[i] > k) {
                    ok = false;
                    break;
                }
                if(cnt[i] + add[i] > k) {
                    forn(x,0,up+1) cnt[x] = add[x];
                    cuts++;
                    fiz = true;
                    break;
                }
            }
            if(!ok) break;
            if(!fiz) forn(i,0,up+1) cnt[i] += add[i];
        }

        if(ok) ans = min(ans, cuts + up);
    }

    cout << ans << '\n';
    return 0;
}

/* don't forget to check:
   int overflow
   min/max cases (n = 1)
   printing index of sorted array
   limits for ans (start with inf)
   s = 'x' + s is linear! dont use it!
 */

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a+b > c+d) cout << "Left" << endl;
  else if(a+b < c+d) cout << "Right" << endl;
  else cout << "Balanced" << endl;
}

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

int main(){
	string S;
  	bool T=false;
  	cin>>S;
  	for(int i=1;i<3;i++){
		if(S[i-1]!=S[i]){
          T=true;
          break;
        }
    }
  	if(T){
		cout<<"Yes";
    }
  	else{
		cout<<"No";
    }
  	return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int A;
    cin >> A;
    N -= A;
    if (N < 0) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << N << endl;
  return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int>h(N+1);
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
    h[N] = 0;
    int ans = 0;
    for (int i = 1; i <= N; i++){
        if(h[i] < h[i-1]) {
            ans += h[i-1]-h[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
double INF = 1000000;
int main(){
  while (1){
    int d;
    cin >> d;
    if (d == 0){
      break;
    }
    vector<double> v(d + 3);
    for (int i = 0; i < d + 3; i++){
      cin >> v[i];
    }
    double mn = INF;
    int ans;
    for (int i = 0; i < d + 3; i++){
      vector<vector<pair<double, double>>> f(d + 2, vector<pair<double, double>>(d + 3));
      for (int j = 0; j < d + 3; j++){
        if (i == j){
          f[0][j] = make_pair(1, 0);
        } else {
          f[0][j] = make_pair(0, v[j]);
        }
      }
      for (int j = 0; j < d + 1; j++){
        for (int k = 0; k < d + 2 - j; k++){
          f[j + 1][k].first = f[j][k + 1].first - f[j][k].first;
          f[j + 1][k].second = f[j][k + 1].second - f[j][k].second;
        }
      }
      double r;
      if (i == 0){
        r = abs(f[d + 1][1].second);
      } else if (i == d + 2){
        r = abs(f[d + 1][0].second);
      } else {
        vector<double> x(2);
        for (int j = 0; j < 2; j++){
          x[j] = (- f[d + 1][j].second) / f[d + 1][j].first;
        }
        r = abs(x[0] - x[1]);
      }
      if (r < mn){
        mn = r;
        ans = i;
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2000005,M=10000005;
int ne[M],fi[N],sl[M],zz[M],tot,n,m,g[N],l,r,val,f[N],cnt,dis[N];
struct Tree{
	int l,r,ls,rs;
}T1[N],T2[N];
void jb(int x,int y,int z){
	ne[++tot]=fi[x];
	fi[x]=tot;
	zz[tot]=y;
	sl[tot]=z;
//	printf("%d %d\n",x,y);
}
void build1(int x,int l,int r){
	T1[x].l=l;T1[x].r=r;
	if (T1[x].l==T1[x].r){
		jb(l,x,0);
		return;
	}
	int mid=(l+r)/2;
	build1(T1[x].ls=++cnt,l,mid);
	build1(T1[x].rs=++cnt,mid+1,r);
	jb(T1[x].ls,x,0);jb(T1[x].rs,x,0);
}
void build2(int x,int l,int r){
	T2[x].l=l;T2[x].r=r;
	if (T2[x].l==T2[x].r){
		jb(x,l,0);
		return;
	}
	int mid=(l+r)/2;
	build2(T2[x].ls=++cnt,l,mid);
	build2(T2[x].rs=++cnt,mid+1,r);
	jb(x,T2[x].ls,0);jb(x,T2[x].rs,0);
}
void link1(int x,int l,int r){
	if (T1[x].l>r||l>T1[x].r)return;
	if (T1[x].l>=l&&T1[x].r<=r){
		jb(x,cnt,val);
		return;
	}
	link1(T1[x].ls,l,r);link1(T1[x].rs,l,r);
}
void link2(int x,int l,int r){
	if (T2[x].l>r||l>T2[x].r)return;
	if (T2[x].l>=l&&T2[x].r<=r){
		jb(cnt,x,0);
		return;
	}
	link2(T2[x].ls,l,r);link2(T2[x].rs,l,r);
}
void up(int x){
	if (x==1)return;
	if (dis[f[x/2]]>dis[f[x]]){
		swap(f[x],f[x/2]);
		swap(g[f[x]],g[f[x/2]]);
		up(x/2);
	}
}
void down(int x){
	int i=x;
	if (x*2<=l&&dis[f[x*2]]<dis[f[x]])i=x*2;
	if (x*2<l&&dis[f[x*2+1]]<dis[f[i]])i=x*2+1;
	if (i!=x){
		swap(f[x],f[i]);
		swap(g[f[x]],g[f[i]]);
		down(i);
	} 
}
signed main(){
	scanf("%lld%lld",&n,&m);
	cnt=n;int t1,t2;
	build1(t1=++cnt,1,n);
	build2(t2=++cnt,1,n);
	while (m--){
		scanf("%lld%lld%lld",&l,&r,&val);
		++cnt;
		link1(t1,l,r);
		link2(t2,l,r);
	}
	memset(dis,0x3f3f3f3f,sizeof dis);
	for (int i=1;i<=cnt;i++)f[i]=g[i]=i;
	dis[1]=0;
	l=cnt;
	for (int i=1;i<=cnt;i++){
		int k=f[1];
		f[1]=f[l--];
		g[f[1]]=1;
		down(1);
		for (int j=fi[k];j;j=ne[j])
			if (dis[zz[j]]>dis[k]+sl[j]){
				dis[zz[j]]=dis[k]+sl[j];
				up(g[zz[j]]);
			}
	}
	if (dis[n]>n*1000000000)puts("-1");
	else printf("%lld\n",dis[n]);
}

Measured memory_bytes: 133376
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  vector<string> A(N);
  vector<string> B(M);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  for(int i=0;i<M;i++){
    cin >> B.at(i);
  }

  for(int i=0;i<N-M+1;i++){
    for(int j=0;j<N-M+1;j++){
      bool flag=true;
      for(int k=0;k<M;k++){
        for(int l=0;l<M;l++){
          if(B.at(k).at(l)!=A.at(i+k).at(l+j))  flag=false;
        }
      }
      if(flag){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
  	cin >> vec.at(i);
  }
  int a=1;
  int b=vec.at(0);
  while(a<N){
  if(b==2) break;
  else{
  b=vec.at(b-1);
  a++;
  }
  }
  if(a==N) cout << -1;
  else cout << a;
}  

Measured memory_bytes: 3780
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL){
    y = x; // 親を設定
    if (z->key < x->key) x = x->left; // 左の子へ移動
    else x = x->right; // 右の子へ移動
  }
  z->parent=y;

  if (y == NIL) // T が空の場合
    root= z;
  else if (z->key < y->key)
    y->left = z; // z を y の左の子にする
  else 
    y->right = z; // z を y の右の子にする
}

void inorder(Node u){
  if (u != NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if (u != NIL) {
    printf(" %d" ,u->key);
    preorder(u->left);
    preorder(u->right);
  }
}


int main(){
  int  n,i, x;
  char com[20];
  Node t;
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  }

  return 0;
}

Measured memory_bytes: 24040
#include<iostream>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
using namespace std;

int power(int b,int e,int p){
	int ret = 1;
	while(e>0){
		if((e&1)!=0){
			ret = (ret*b)%p;
		}
		b = (b*b)%p;
		e>>=1;
	}
	return ret%p;
}

bool fermat(int p){
	if(p<=1)return false;
	if(p!=2 && p%2==0)return false;
	if(p!=3 && p%3==0)return false;
	if(p!=5 && p%5==0)return false;
	if(p!=7 && p%7==0)return false;
	if(p!=11 && p%11==0)return false;
	for(int x=0;x<50;++x){
		int a = rand()%(p-1)+1;
		if(power(a,p-1,p)!=1)return false;
	}
	return true;
}

int main(){
	int n;
	map<int,int> table;
	for(int x=2;x<100000;++x){
		if(fermat(x))table[x]=100;
	}
	while(scanf("%d",&n)==1){
		int t = 0;
		for(int x=1,y=n;x<=n;x++,y--){
			if(table[x]==100 && table[y]==100){
				++t;
			}
		}
		cout<<t<<endl;
	}
	return 0;
}

Measured memory_bytes: 1848
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
signed main()
{
    SPEED;
    int n;
    cin>>n;
    double p[n];
    for(int i=0;i<n;i++)
    {
        cin>>p[i];
    }
    double dp[n+2]={0},res=0;
    dp[0]=(1.00-p[0]);
    dp[1]=p[0];
    for(int i=1;i<n;i++)
    {
        for(int j=i;j>=0;j--)
        {
            if(dp[j]>0)
            {
                dp[j+1]=(double)dp[j]*(1.00*p[i])+(double)dp[j+1]*(1.00-p[i]);
            }
        }
        dp[0]*=(1.00-p[i]);
    }
    for(int i=n/2;i<n;i++)
    res+=dp[i+1];
    cout<<fixed<<setprecision(10)<<res;
}

Measured memory_bytes: 3800
#include <stdio.h>

int main(){
  int W,H,x,y,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  
  if(x+r <= W && x-r >= 0 && y+r <= H && y-r >=0){
  	printf("Yes\n");
  }
   else{
   		printf("No\n");
   }
  return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int ans = 0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n/i;j++)
        {
            if(n - i*j > 0)
            {
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include <sstream>
#include <iostream>
#include <cstdlib>

using namespace std;

#define BUF_SIZE 1024
#define ARRAY_SIZE 100

int main(){

	char buf[BUF_SIZE];
	int n = atoi(fgets(buf,BUF_SIZE,stdin));
	int array[ARRAY_SIZE];
	int change_count = 0;

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

	int tmp = 0;
	for(int i = n-1;i > 0;i--){
		for(int j = 0; j < i;j++){
			if(array[j] > array[j+1]){
				tmp = array[j+1];
				array[j+1] = array[j];
				array[j] = tmp;
				change_count++;
			}
		}
	}

	for(int i = 0; i < n; i++){
		if(i != n-1){
			printf("%d ",array[i]);
		}else{
			printf("%d\n",array[i]);
		}
	}
	printf("%d\n",change_count);
}


Measured memory_bytes: 3164
# -*- coding: utf-8 -*-
 
N, C = map(int, input().split())
D = [list(map(int, input().split())) for i in range(C)]
cN = [list(map(int, input().split())) for i in range(N)]

# [mod 3でどれになるか][今の色] = 該当する数
memo = [[0] * C for i in range(3)]
for i in range(N):
    for j in range(N):
        memo[(i+j+2)%3][cN[i][j]-1] += 1

ans = float('inf')
# 変わる色を全組み合わせループ
for i in range(C):
    for j in range(C):
        for k in range(C):
            if i == j or j == k or k == i:
                continue
            sm = 0
            # 元の色ループ
            for l in range(C):
                # メモを元に、各塗り替えでどのくらい違和感が出るか算出
                sm += D[l][i] * memo[0][l]
                sm += D[l][j] * memo[1][l]
                sm += D[l][k] * memo[2][l]
            ans = min(sm, ans)
print(ans)


Measured memory_bytes: 5620
def main():
  n = list(input())
  #s = input()
  #s = input().split()
  #a,b = list(map(int,input().split()))
  #a = [input() for i in range(n)]
  #a = [int(input()) for i in range(n)]
  #a = [input().split() for i in range(n)]
  #a = [list(map(int,input().split())) for i in range(n)]
  ans = 0
  count = 0
  lis = []
  
  for i in range(len(n)):
    if n[i] == "1":
      n[i] = "9"
    elif n[i] == "9":
      n[i] = "1"
  print("".join(n))

if __name__ == '__main__':
  main()

Measured memory_bytes: 2940
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

ll sum(int i,ll* bit){
	int s = 0;
	while(i > 0){
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(int i, ll x,ll* bit,ll n){
	while(i <= n){
		bit[i] += x;
		i += i & -i;
	}	
}

int main(){
	int* dp = new int[1000000];
	fill((int*)dp,(int*)dp + 1000000,1);
	dp[0]=0;
	dp[1]=0;
	for(int i=2;i<1000000;i++){
		if(dp[i] != 0){
			for(int j=i+i;j<1000000;j+=i){
				dp[j] = 0;
			}
		}
	}

	int idx=1;
	ll* bit = new ll[1000000];
	fill((ll*)bit,(ll*)bit + 1000000,0);

	for(int i=2;i<1000000;i++){
		if(dp[i] != 0){
			add(idx++,i,bit,1000000);
		}
	}

	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;
		cout << sum(n,bit) << endl;
	}
}

Measured memory_bytes: 12000
<?php
define('MOD', pow(10, 9) + 7);

fscanf(STDIN, "%d %d", $N, $K);

$ans = [];

for ($i = 1; $i <= $K; $i++) {
    
    $rs = $i;
    $rb = $N - $K - ($i - 1);
	
	if ($rb < 0) {
		$ans[] = 0;
	} else {
    	$r = pascal($rs + $rb, $rb);

    	$bs = $i - 1;
    	$bb = $K - $i;
    	$b = pascal($bs + $bb, $bb);

    	$ans[] = ($r * $b) % MOD;
	}
}
echo implode(PHP_EOL, $ans);

function pascal($x, $y) {
    if ($x / 2 < $y) {
	    $y = $x - $y;
    }
    global $memo;
    if (isset($memo[$x][$y])) {
        return $memo[$x][$y];
    }

    if($y === 0 || $y === $x) {
        $tmp = 1;
        $memo[$x][$y] = $tmp;
        return $tmp;    
    } else {
        $tmp = pascal($x - 1, $y - 1) + pascal($x - 1, $y);
        $tmp %= MOD;
        $memo[$x][$y] = $tmp;
        return $tmp;
    }
}

Measured memory_bytes: 37368
#include<iostream>
#include<vector>
#include<cstdlib>

using namespace std;

int main(){
  int a,b,c,i,x;
  cin >>a>>b>>c;
  for(i=0;i<10;i++){
    x=(c*a)-b;
    c=x;
    cout << x <<endl;
  }


  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}



int main(){
  string s;
  cin>>s;
  if(s=="RRR"){
     cout<<3;
  }
  else if (s=="SSS"){
     cout<<0;
  }
  else if(s=="SRS"){
     cout<<1;
  }
  else if(s[1]=='S'){
     cout<<1;
  }
  else {
     cout<<2;
  }

  

return 0;
}


Measured memory_bytes: 3580
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int, X: int):
    ret = 0
    for i in range(A + 1):
        for j in range(B + 1):
            for k in range(C + 1):
                if 500 * i + 100 * j + 50 * k == X:
                    ret += 1
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    solve(A, B, C, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repi(i, j, n) for(int i = j;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define F first
#define S second

// #define COMMENT

/*

const int NN = 200090;
ll fact[NN];
ll finv[NN];
ll inv[NN];

void inverse_modulao() {
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;

  for(int i = 2;i < NN;i++) {
    fact[i] = fact[i-1]*i%mod;
    inv[i] = mod-mod/i*inv[mod%i]%mod;
    finv[i] = finv[i-1]*inv[i]%mod;
  }
}

ll nCr(int n, int r) {
  return fact[n]*finv[r]%mod*finv[n-r]%mod;
}

*/

bool ncrmod2(int n,int r) {
  /* using lucas formula
   * http://www.cecm.sfu.ca/organics/papers/granville/paper/binomial/html/node2.html
  */
  while(n > 0) {
    if(!(n & 1) & (r & 1)) return 0;
    n >>= 1;
    r >>= 1;
  }
  return 1;
}

int N;string s;

int main() {

  //freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

  cin >> N >> s;
  bool ans = 0, one = 0;
  rep(i, N) {
    bool ib = (s[i]-'1') & 1;
    if(ib) {

      ans ^= ncrmod2(N-1, i);
      one = true;
    }
  }
  if(ans) {cout << 1 << endl;return 0;}
  if(one) {cout << 0 << endl;return 0;}

  rep(i, N) {
    bool ib = (s[i]-'1') >> 1;
    if(ib) {

      ans ^= ncrmod2(N-1, i);
    }
  }

  cout << (ans ? 2 : 0) << endl;


  return 0;
}


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

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			int[][] t = new int[N][N + 1];
			for (int i = 0; i < N; ++i) {
				for (int j = 0; j <= N; ++j) {
					t[i][j] = sc.nextInt();
				}
			}
			int[] dp = new int[1 << N];
			Arrays.fill(dp, Integer.MAX_VALUE);
			dp[0] = 0;
			for (int i = 0; i < (1 << N); ++i) {
				for (int j = 0; j < N; ++j) {
					int next = 1 << j;
					if ((i & next) != 0) continue;
					dp[i + next] = Math.min(dp[i + next], dp[i] + t[j][0]);
					for (int k = 0; k < N; ++k) {
						int prev = 1 << k;
						if ((i & prev) == 0) continue;
						dp[i + next] = Math.min(dp[i + next], dp[i] + t[j][k + 1]);
					}
				}
			}
			System.out.println(dp[(1 << N) - 1]);
		}
	}
}

Measured memory_bytes: 35636
#include <stdio.h>

int main (void){
	char a, b, starting;
	
	starting = 'A';
	
	while (scanf("%c, %c", &a, &b) != EOF){
		
		if (starting == a){
			starting = b;
		}
		else if(starting == b){
			starting = a;
		}
	}
	printf("%c\n", starting);
	return (0);
}

Measured memory_bytes: 544