akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
ll p=pow(10,9)+7;
ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while(n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if(n > 1)
        result -= result / n;
    return result;
}
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      
    x = x % p;  
   while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p; 
    } 
    return res; 
} 

ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
}


 
int main() {
 
    int n,x,i,j;
    cin>>n;
    ld p[n];
    for(i=0;i<n;i++)
    cin>>p[i];
    ld dp[n][n+1];
    for(j=0;j<=n;j++)
    {
        if(j==0)
        dp[0][j]=1-p[0];
        if(j==1)
        dp[0][j]=p[0];
        else if(j>1)
        dp[0][j]=0;
    }
    for(i=1;i<n;i++)
    {
        for(j=0;j<=n;j++)
        {
            
            if(j==0)
            {
                dp[i][j]=dp[i-1][j]*(1-p[i]);
            }
            else
            {
            if((j)<=(i+1))
            dp[i][j]=dp[i-1][j-1]*p[i]+dp[i-1][j]*(1-p[i]);
            else
            dp[i][j]=0;
            }

        }

    }
    ld ans=0;
    for(i=((n+1)/2);i<=n;i++)
    ans+=dp[n-1][i];
    cout<<fixed<<setprecision(10)<<ans;
 
    return 0;
    
}  



Measured memory_bytes: 140928
#include<bits/stdc++.h>                               
using namespace std;
 
#define PI acos(-1)
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define all(c) (c).begin(), (c).end()
#define TIMESTAMP fprintf(stderr, "Execution time: %.3lf s.\n", (double)clock()/CLOCKS_PER_SEC)
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair <int, int> pii;
typedef vector <vi> vvi;
typedef vector <pii> vpii;
typedef vector<string> vs;
 
const int INF = 100500;
const int MAXN = 1e5 + 9;
const int MOD = 1e9 + 7;
 
int n;
vvi gg;
ll ans[MAXN];
vll tt[MAXN];
 
void dfs(int v) {     
	for(int i = 0; i < sz(gg[v]); i++) {
		int to = gg[v][i];
		dfs(to);
		tt[v].pb(ans[to]);
	}
	sort(all(tt[v]));
	for(int i = 0; i < sz(tt[v]); i++) ans[v] = max(ans[v] + 1, tt[v][i] + 1);
}
 
 
 
void input() {                  
	cin >> n;         
	gg.resize(n + 1);
	for(int i = 2; i <= n; i++) {
		int x;
		cin >> x;
		gg[x].pb(i);
	}
}
 
void solve() {          
	dfs(1);
	cout << ans[1] << endl;
}
 
int main() {     
#ifdef LOCAL
	freopen("xxx.in", "r", stdin);
	freopen("xxx.out", "w", stdout);
#else
	//freopen("xxx.in", "r", stdin);
	//freopen("xxx.out", "w", stdout);
#endif	
	input();
	solve();
	return 0;
}

Measured memory_bytes: 18176
#include <cstdio>

int A, B;

int main()
{
  int counter = 0;
  scanf("%d %d", &A, &B);
  if (A > B) {
    counter += A--;
  } else {
    counter += B--;
  }
  if (A > B) {
    counter += A--;
  } else {
    counter += B--;
  }
  printf("%d\n", counter);
  return 0;
}



Measured memory_bytes: 128
#[doc = " https://github.com/hatoo/competitive-rust-snippets"]
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( [ $ t : ty ] ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; ( [ $ t : ty ] ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( [ $ t ] ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}
fn solve() {
    let n = get!(usize);
    let hs = get!([usize]);

    let mut maxi = 0;
    let mut ans = 0;
    for h in hs {
        if h >= maxi {
            ans += 1;
        }

        maxi = max(maxi, h);
    }

    println!("{}", ans);
}


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

int d,G;
int p[10],c[10];
int dp[1001];

int main() {
    cin>>d>>G;
    for(int i=0;i<d;i++)cin>>p[i]>>c[i];
    for(int i=0;i<d;i++){
        for(int k=1000;k>=1;k--){
            for(int j=1;j<=p[i]&&j<=k;j++){
                dp[k]=max(dp[k],dp[k-j]+(i+1)*100*j+(j==p[i]?c[i]:0));
            }
        }
    }
    for(int i=0;i<=1000;i++){
        if(dp[i]>=G){
            cout<<i<<endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<(x)<<endl
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
//#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
#define fi first
#define se second
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; }
typedef pair<int, int>P;
const int MOD = 998244353; const int MAX = 200020;
const double pi = 3.141593; const double EPS = 1e-12;
const ll INF = 2e18;
const int INT_INF = 1e9;
typedef pair<double, double>Pd;
double dist(P& p1, P& p2) {
	return sqrt((p1.first - p2.first) * (p1.first - p2.first) + (p1.second - p2.second) * (p1.second - p2.second));
}
double dist(Pd& p1, Pd& p2) {
	return sqrt((p1.first - p2.first) * (p1.first - p2.first) + (p1.second - p2.second) * (p1.second - p2.second));
}


void solve() {
	int N, K; cin >> N >> K;
	string S; cin >> S;
	S[K - 1] = 'a'+(S[K - 1] - 'A');
	print(S);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;cin>>q;
	//while(q--)
	solve();
}




Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    string s;
    cin >> s;
    set<char> a;
    for (auto i : s)
        a.insert(i);
    if (a.size() == s.size())
        cout << "yes" << endl;
    else
        cout << "no" << endl;
}

Measured memory_bytes: 256
use std::collections::VecDeque;
use std::io;

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

fn bfs(v: &mut Vec<Vec<isize>>, h: usize, w: usize, s: &mut usize) -> bool {
    let mut q: VecDeque<(usize, usize, isize)> = VecDeque::with_capacity(h * w);
    q.push_front((0, 0, 1));

    while !q.is_empty() {
        let buf = q.pop_back().unwrap();
        if buf.0 >= 1 && v[buf.0 - 1][buf.1] != -1 && v[buf.0 - 1][buf.1] > buf.2 + 1 {
            v[buf.0 - 1][buf.1] = buf.2 + 1;
            q.push_front((buf.0 - 1, buf.1, buf.2 + 1));
        }
        if buf.0 < h - 1 && v[buf.0 + 1][buf.1] != -1 && v[buf.0 + 1][buf.1] > buf.2 + 1 {
            v[buf.0 + 1][buf.1] = buf.2 + 1;
            q.push_front((buf.0 + 1, buf.1, buf.2 + 1));
        }
        if buf.1 >= 1 && v[buf.0][buf.1 - 1] != -1 && v[buf.0][buf.1 - 1] > buf.2 + 1 {
            v[buf.0][buf.1 - 1] = buf.2 + 1;
            q.push_front((buf.0, buf.1 - 1, buf.2 + 1));
        }
        if buf.1 < w - 1 && v[buf.0][buf.1 + 1] != -1 && v[buf.0][buf.1 + 1] > buf.2 + 1 {
            v[buf.0][buf.1 + 1] = buf.2 + 1;
            q.push_front((buf.0, buf.1 + 1, buf.2 + 1));
        }
    }

    if v[h - 1][w - 1] != 999_999_999 {
        *s = v[h - 1][w - 1] as usize;
        true
    } else {
        false
    }
}

fn main() {
    let mut v = Vec::new();
    let h: usize;
    let w: usize;
    let mut black_count: usize = 0;
    input!(h, w);
    for _ in 0..h {
        let line = str2vec(&input_line_str());
        let mut vbuf: Vec<isize> = Vec::new();
        for z in &line {
            if *z == '#' {
                black_count += 1;
                vbuf.push(-1);
            } else {
                vbuf.push(9999999);
            }
        }

        v.push(vbuf);
    }

    let mut shortest = 0;
    v[0][0] = 1;
    v[h - 1][w - 1] = 999_999_999;
    if bfs(&mut v, h, w, &mut shortest) {
        println!("{}", h * w - black_count - shortest);
    } else {
        println!("-1");
    }
}

Measured memory_bytes: 4352
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <iterator>
#include <locale>
#include <memory>
#include <stdexcept>
#include <utility>
#include <string>
#include <fstream>
#include <ios>
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <streambuf>
#include <complex>
#include <numeric>
#include <valarray>
#include <exception>
#include <limits>
#include <new>
#include <typeinfo>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdlib>
#include <cstddef>
#include <cstdarg>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <cwchar>
#include <cwctype>
using namespace std;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
using ll = long long;
using ull = unsigned long long;

#define ALL(c) (c).begin(), (c).end()
#define CLEAR(v) memset(v,0,sizeof(v))
#define MP(a,b) make_pair((a),(b))
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ABS(a) ((a)>0?(a):-(a))
template<class T> T MIN(const T& a, const T& b) { return a < b ? a : b; }
template<class T> T MAX(const T& a, const T& b) { return a > b ? a : b; }
template<class T> void MIN_UPDATE(T& a, const T& b) { if (a > b) a = b; }
template<class T> void MAX_UPDATE(T& a, const T& b) { if (a < b) a = b; }

constexpr int mo = 1000000007;
int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
	std::ios::sync_with_stdio(false);

	int H, W;
	cin >> H >> W;
	vector<string> maze;
	maze.push_back(string(W + 2, '#'));
	REP(h, H) {
		string row;
		cin >> row;
		maze.push_back("#" + row + "#");
	}
	maze.push_back(string(W + 2, '#'));

	int best_steps = 0;
	for (int start_row = 1; start_row <= H; ++start_row) {
		for (int start_column = 1; start_column <= W; ++start_column) {
			if (maze[start_row][start_column] == '#') {
				continue;
			}

			vector<vector<int> > steps(H + 2, vector<int>(W + 2, -1));
			queue<int> q;
			q.push(start_row);
			q.push(start_column);
			steps[start_row][start_column] = 0;
			while (!q.empty()) {
				int row = q.front();
				q.pop();
				int column = q.front();
				q.pop();

				REP(dir, 4) {
					int next_row = row + dx[dir];
					int next_column = column + dy[dir];
					if (maze[next_row][next_column] == '#') {
						continue;
					}
					if (steps[next_row][next_column] != -1) {
						continue;
					}
					steps[next_row][next_column] = steps[row][column] + 1;
					best_steps = MAX(best_steps, steps[next_row][next_column]);
					q.push(next_row);
					q.push(next_column);
				} 
			}
		}
	}

	cout << best_steps << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"

	"os"
	"io"
	"bufio"
	"bytes"

	"strings"
	"strconv"
)

//  長い入力を読む
func ReadLongLines(times int) ([]string, error) {
	result := make([]string, times)
	reader := bufio.NewReader(os.Stdin)
	buffer := bytes.NewBuffer(make([]byte, 0))
	readBytes := int64(2)
	for i := 0; i < times; i++ {
		for {
			readBuf, isPrefix, err := reader.ReadLine()
			// fmt.Printf("Reader.Read: %d\n", len(readBuf))
			readBytes += int64(len(readBuf) + 1)
			if err != nil {
				if err == io.EOF {
					fmt.Println("EOF")
					break
				} else {
					return result, err
				}
			}
			_, err = buffer.Write(readBuf)
			if err != nil {
				return result, err
			}
			// end of line
			if !isPrefix {
				result[i] = buffer.String()
				buffer.Reset()
				// reader = bufio.NewReader(os.Stdin)
				break
			}
		}
	}
	// 先読みしてしまうようなので、戻しておく
	os.Stdin.Seek(-int64(reader.Buffered()), os.SEEK_CUR)
	return result, nil
}

// go だと固定長配列とか辛いので無理だった
type ListItem struct {
	value int
	// prev *ListItem
	next *ListItem
}
type List struct {
	front *ListItem
	// end *ListItem
	current *ListItem
}

func NewList() List {
	front := ListItem{0, nil}
	return List{&front, &front}
}

// INSERT
func (this *List)Add(i int) {
	// fmt.Printf("Add: %d\n", i)
	// fmt.Println(this.current)
	item := ListItem{i, nil}
	this.current.next = &item
	this.current = &item
	// fmt.Println("---- ----")
	// this.Dump()

}

func (this *List) Append(list *List) {
	// fmt.Println("Append")
	// this.Dump()
	// list.Dump()
	// fmt.Println("---- ---- ---- ----")
	this.current.next = list.First()
	// fmt.Println(this.current)
	this.current = list.current
	// fmt.Println(this.current)
	list.front.next = nil
	list.current = list.front
	// this.Dump()
	// fmt.Println("---- ---- ---- ----")
}

func (this *List) First() *ListItem {
	return this.front.next
}

func (this *List) Next(item *ListItem) *ListItem {
	return item.next
}

var w = bufio.NewWriter(os.Stdout)
func (this *List) Dump() {
	c := this.First()
	if c != nil {
		fmt.Fprintf(w, "%d", c.value)
		c = c.next
	}
	for ; c != nil; c = c.next {
		fmt.Fprintf(w, " %d", c.value)
	}
	fmt.Fprintln(w)
}


func main() {
	var n int
	var q int

	fmt.Scanf("%d %d", &n, &q)
	lists := make([]List, n)
	for i := 0; i < n; i++ {
		lists[i] = NewList()
	}

	lines, _ := ReadLongLines(q)
	for _, line := range lines {
		args := strings.Split(line, " ")
		cmd := args[0]
		switch cmd {
		case "0":
			t, _ := strconv.Atoi(args[1])
			x, _ := strconv.Atoi(args[2])
			// fmt.Printf("insert %d < %d\n", t, x)
			lists[t].Add(x)
		case "1":
			t, _ := strconv.Atoi(args[1])
			// fmt.Printf("getMax %d\n", t)
			lists[t].Dump()
		case "2":
			s, _ := strconv.Atoi(args[1])
			t, _ := strconv.Atoi(args[2])
			// // fmt.Printf("deleteMax %d\n", t)
			lists[t].Append(&lists[s])
		}
	}
	w.Flush()
}


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

int main(){
  int n;
  cin >> n;
  int board[n];

  for(int i=0;i < n;i++)
    {
      cin >> board[i];
    }
  int cnt=1;
  int mark = 1;
  
  for(int i=0;i< n;i++)
    {
      if(board[i] == 1){
	cnt++;
	mark = max(mark,cnt);
      }
      else{
	cnt = 1;
      }
    }
  cout << mark << endl;
  return 0;
}


Measured memory_bytes: 3128
import java.util.Scanner;


public class Main {

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

		int N = sc.nextInt();
		long sum = 0;

		for(int i = 1; i <= N; i++) {

			if(i % 3 != 0 && i % 5 != 0) {
				sum = sum + i;
			}
		}

		System.out.println(sum);
	}
}


Measured memory_bytes: 27188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
#define pb push_back
typedef long long ll;
const ll INF = 1LL << 60;

int main(){
    string s;
    ll k;
    cin >> s >> k;
    ll l = s.size();
    ll renzoku = 1;
    ll naibu_num = 0;
    ll first_renzoku=0;
    ll final_renzoku=0;
    string reset_flag = "No";
    if(l==1){
        first_renzoku = 1;
        final_renzoku = 1;
    }
    else{
        reps(i,1,l){
            if(s[i]==s[i-1]){
                renzoku ++;
            }
            if(s[i] != s[i-1] || i==l-1){
                naibu_num += renzoku/2;
                if(reset_flag == "No"){
                    first_renzoku = renzoku;
                }
            }
            if(s[i] != s[i-1]){
                renzoku = 1;
                reset_flag = "Yes";
            }
        }
        final_renzoku = renzoku;
    }

    ll ans = 0;
    if(first_renzoku == l){
        ans = (l*k)/2;
    }
    else if(s[0] != s[l-1]){
        ans = k*naibu_num;
    }
    else{
        if(first_renzoku%2==1 && final_renzoku%2==1){
            ans = k*naibu_num+(k-1);
        }
        else{
            ans = k*naibu_num;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-5;
const ll MOD=1e9+7;
int main(){
    int a,b,c,d,e,f;cin>>a>>b>>c>>d>>e>>f;
    double ma=-1;int a1,a2;
    for(int i=0;i<=f/(100*a)+1;i++){
        for(int j=0;j<=(f-100*a*i)/(100*b)+1;j++){
            for(int k=0;k<=(f-100*a*i-100*b*j)/c+1;k++){
                for(int l=0;l<=(f-100*a*i-100*b*j-c*k)/d+1;l++){
                    double m=100*a*i+100*b*j;
                    double s=c*k+d*l;
                    if(m+s>f)break;
                    if(m*e<s*100)continue;
                    if(ma<(100*s)/(s+m)){
                        ma=(100.0*s)/(s+m);
                        a1=m+s,a2=s;
                    }
                }
            }
        }
    }
    cout<<a1<<" "<<a2<<endl;
}   


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int N,K;
int a[100000];

int main(){
    cin >> N >> K;
    for(int i=0;i<N;i++) cin >> a[i];
    int ans = (N-1) / (K-1);
    if((N-1)%(K-1)!=0) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
#define MAX 500000
#define INF 2000000000

int L[MAX / 2 + 2],R[MAX / 2 + 2];
int cnt;

void merge(int A[],int n,int left,int mid,int right){
    int n1 = mid - left;
    int n2 = right - mid;
    for(int i = 0;i < n1;i ++) L[i] = A[left + i];
    for(int i = 0;i < n2;i ++) R[i] = A[mid + i];
    L[n1] = R[n2] = INF;
    int i = 0,j = 0;
    for(int k = left;k < right;k ++){
        cnt ++;
        if(L[i] <= R[j]) A[k] = L[i ++];
        else A[k] = R[j ++];
    }
}

void mergeSort(int A[],int n,int left,int right){
    if(left + 1 < right){
        int mid = (left + right) / 2;
        mergeSort(A,n,left,mid);
        mergeSort(A,n,mid,right);
        merge(A,n,left,mid,right);
    }
}

int main(){
    int A[MAX],n,i;
    cnt = 0;
    
    cin >> n;
    for(i = 0;i < n;i ++) cin >> A[i];
    
    mergeSort(A,n,0,n);
    for(i = 0;i < n;i ++){
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 6908
//C - Guess The Number

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <functional>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int n, m;

    cin >> n >> m;

    int s[m];
    string c[m];

    REP(i, m){
        cin >> s[i] >> c[i];
    }

    int ans = -1;

    REP(i, pow(10,n)){
        bool flag = true;
        char ss[4]; sprintf(ss, "%03d", i);
        string sss = ss;
        sss = sss.substr(3-n, n);
        //cout << sss << endl;
        REP(j, m){
            if ((c[j][0]) != sss[s[j]-1]){
                flag = false;
                break;
            }
        }

        if (n>1 && sss[0] == '0') flag = false;

        if (flag){
            ans = i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
/* ex6_2
   Acro */

#include <stdio.h> 
#include <string.h>
int main(void){
    char string[101];
    int count;
    /* 入力 */
    scanf("%s",string);
    /* 文字数を取得 */
    count = (int)strlen(string);
    printf("%c%d%c\n",string[0],count-2,string[count-1]);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=(b);++i)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define pi pair<int, int>
#define mk make_pair
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin>>n;
    ll ans=0;
    for(int i=1;i<=n;++i){
        if(i%3==0||i%5==0) continue;
        ans+=i;
    }
    cout<<ans<<endl;
}


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

using ll = long long;

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

    int N; cin >> N;

    auto initial = vector<int>(N);
    for (auto& x : initial) cin >> x;

    auto delta = vector<int>(N-1);
    for (auto i = 0; i < N-1; i++)
        delta[i] = initial[i+1]-initial[i];

    int M; ll K; cin >> M >> K;

    auto pi = vector<int>(N-1);
    iota(begin(pi), end(pi), 0);

    for (auto i = 0; i < M; i++)
    {
        int a; cin >> a;
        a--;
        swap(pi[a], pi[a-1]);
    }

    auto used = vector<bool>(N-1);
    for (auto i = 0; i < N-1; i++) if (!used[i])
    {
        auto cycle = vector<int>({i});
        for (auto j = pi[i]; j != i; j = pi[j])
        {
            cycle.push_back(j);
            used[j] = true;
        }

        for (auto j = 0; j < int(cycle.size()); j++)
            pi[cycle[j]] = cycle[(j + K) % cycle.size()];
    }

    auto x = ll(initial[0]);
    for (auto i = 0; i < N; i++)
    {
        cout << x << "\n";
        if (i != N-1) x += delta[pi[i]];
    }
}


Measured memory_bytes: 2544
#include<cstdio>
#include<algorithm>
#define ll long long
#define fo(i, x, y) for(int i = x; i <= y; i ++)
#define abs(a) ((a) > 0 ? (a) : -(a))
using namespace std;

const int N = 2e5 + 5;

int n, a[N];
ll ans;

int main() {
	scanf("%d", &n);
	fo(i, 1, n) scanf("%d", &a[i]), a[i] -= i;
	sort(a + 1, a + n + 1);
	fo(i, 1, n) ans += abs(a[i] - a[(n + 1) / 2]);
	printf("%lld", ans);
}

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

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

typedef long long ll;
const ll INF = 1LL <<60;

int main ()
{
	ll n, w;
  	cin >> n >> w;
  	ll weight[110], value[110];
  	for(int i = 0; i < n; i++)
    {
    	cin >> weight[i] >> value[i];
    }
  	ll dp[110][100010];
  	for(int i = 0; i < 110; i++)
    {
    	for(int j = 0; j < 100010; j++)
        {
        	dp[i][j] = INF;
        }
    }
  	dp[0][0] = 0;
  	for(int i = 0; i < n; i++)
    {
    	for(int sum_v = 0; sum_v <100010; sum_v++)
        {
        	if(sum_v >= value[i])
            {
            	chmin(dp[i+1][sum_v], dp[i][sum_v - value[i]] + weight[i]);
            }
          	chmin(dp[i+1][sum_v], dp[i][sum_v]);
        }
    }
  	ll res = 0;
  	for(int sum_v = 0; sum_v < 100010; sum_v++)
    {
    	if(dp[n][sum_v] <= w)
        {
        	res = sum_v;
        }
    }
  	cout << res << endl;
}


Measured memory_bytes: 86144
#include <stdio.h>
#include <string.h>

struct data
{
  char x[1001], y[1001];
};

struct data a[150];

int LCS(char*,char*);
int max(int, int);

int main()
{
  int q, i, c[150];

  scanf("%d",&q);

  for(i = 0; i < q; i++)
    {
      scanf("%s %s",a[i].x,a[i].y);
      c[i] = LCS(a[i].x,a[i].y);
    }

 for(i = 0; i < q; i++)
    {
      printf("%d\n",c[i]);
    }

  
  return 0;
}

int LCS(char *x, char *y)
{
  int m, n, i, j, c[1001][1001], maxl = 0;
  char X[1001], Y[1001];

  m = strlen(x);
  n = strlen(y);

  strcpy(&X[1],x);
  strcpy(&Y[1],y);
  
  for(i = 1; i <= m; i++)
    {
      c[i][0] = 0;
    }
  for(j = 1; j <= n; j++)
    {
      c[0][j] = 0;
    }
  
  for(i = 1; i <= m; i++)
    {
      for(j = 1; j <= n; j++)
	{
	  if(X[i] == Y[j])c[i][j] = c[i-1][j-1]+1;
	  else if(c[i-1][j] >= c[i][j-1])
	    {
	      c[i][j] = c[i-1][j];
	    }
	  else c[i][j] = c[i][j-1];

	  maxl = max(maxl, c[i][j]);
	}
    }

  return maxl;
}

int max(int a, int b)
{
  if(a > b)return a;
  else return b;
}



Measured memory_bytes: 5660
import java.util.*;

public class Main
{

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

    public void print(int[] a)
    {
        for (int i = 0; i <a.length-1 ; i++)
        {
            System.out.print(a[i]+" ");
        }
        System.out.println(a[a.length-1]);
    }

    public int[] insert(int[] a)
    {

        for (int i = 0; i <a.length ; i++)
        {
            int key=a[i];
            int j=i-1;

            while (j>=0 && a[j]>key)
            {
                a[j+1] = a[j];
                j--;
            }
            a[j+1] = key;
            new Main().print(a);
        }
        return a;

    }

    public void go()
    {
        int N = in.nextInt();

        int[] box = new int[N];

        for (int i = 0; i < N; i++)
        {
            box[i] = in.nextInt();
        }

        new Main().insert(box);

    }

    public static void main(String[] args)
    {
        new Main().go();

    }
}

Measured memory_bytes: 32836
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A, B;
    cin >> A >> B;
    int cnt[3] = {};
    rep(i, N) {
        int p; cin >> p;
        if (p <= A) cnt[0]++;
        else if (p > B) cnt[2]++;
        else cnt[1]++;
    }
    cout << min({cnt[0], cnt[1], cnt[2]}) << endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define all(a) a.begin(),a.end()
#define fi first
#define se second
int M=1e9+7;
int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M

signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	string s;
		vector<int> r,g;
		set<int> b;
		
		int n,l=0;cin>>n;
		int ans=0;
		cin>>s;
		for(int i=0;i<n;i++){
			if(s[i]=='R') r.pb(i);
			else if(s[i]=='G') g.pb(i);
			else if(s[i]=='B') {
				l++;b.insert(i);
			}
		}
		for(int i:r) for(int j:g) {
			ans+=l;
			if(b.find(2*i-j)!=b.end()) ans--;
			if(b.find(2*j-i)!=b.end()) ans--;
			if((i+j)%2==0 and b.find((i+j)/2)!=b.end()) ans--;
		}
		
		//int a[n];rep(i,n) cin>>a[i];
		cout<<ans;
	return 0;
}




Measured memory_bytes: 3684
import math
from decimal import Decimal as D
from decimal import *

getcontext().prec = 1000

A, B, H, M = map(int, input().split())


def d_round(d):
    return d.quantize(D('0.1') ** D(100), ROUND_DOWN)

def get_point(a, deg):
    r = math.radians(deg)
    return (a * d_round(D(math.cos(r))), a * d_round(D(math.sin(r))))


h_deg = D(360) - (D(H) % D(12)) / D(12) * D(360) + D(90)
m_deg = D(360) - (M % D(60)) / D(60) * D(360) + D(90)

h_deg -= (M % D(60) / D(60)) * D(30)

a_p = get_point(D(A), h_deg)
b_p = get_point(D(B), m_deg)

print(((a_p[0] - b_p[0]) ** D(2) + (a_p[1] - b_p[1]) ** D(2)) ** (D(1) / D(2)))


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

using namespace std;

int main(){
    int score_1 = 0,score_2 = 0,score_3 = 0;
    while(true){
        cin >> score_1 >> score_2 >> score_3;

        if(score_1 ==-1 && score_2 == -1 && score_3==-1) break;
        int sum_score ;
        sum_score = score_1 + score_2;        

        if(score_1 == -1 || score_2==-1) cout << "F" << "\n";
        else if(sum_score >= 80) cout << "A" << "\n";
        else if(sum_score >= 65 && sum_score < 80) cout << "B" << "\n";
        else if(sum_score >= 30 && sum_score < 65){
            if(sum_score >= 50 || score_3 >= 50) cout << "C" << "\n";
            else cout << "D" << "\n";
        }
        else if (sum_score < 30) cout << "F" << "\n";
}   
    return 0;   
}


Measured memory_bytes: 3020
#include<stdio.h>
#define N 100000

int a[N], num;

int par(int p, int r){
	int x,i,j,f;
	
	x=a[r];
	i=p-1;

	for(j=p;j<r;j++){
		if(a[j]<=x){
			i++;

			f=a[i];
			a[i]=a[j];
			a[j]=f;
		}
	}

	f=a[i+1];
	a[i+1]=a[r];
	a[r]=f;

	return i+1;
}

int main(){

	int i,s;

	scanf("%d",&num);

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

	s=par(0,num-1);

	for(i=0;i<num;i++){
		if(i)
			printf(" ");
		if(i==s)
			printf("[");

		printf("%d",a[i]);

		if(i==s)
			printf("]");
	}

	printf("\n");

	return 0;
}


Measured memory_bytes: 2108
#include <algorithm>
#include <iostream>
#include <numeric>
#include <queue>
#include <vector>

using Edge = std::pair<uint32_t, uint32_t>;
using Graph = std::vector<std::vector<Edge>>;

int main() {
  uint32_t n = 0;
  std::cin >> n;
  Graph G(n);
  for (size_t i = 0; i < n; i++) {
    for (size_t j = 0; j < n; j++) {
      int32_t cost = 0;
      std::cin >> cost;
      if (cost != -1) G[i].push_back({j, cost});
    }
  }

  std::vector<uint32_t> min_cost(n, -1);
  min_cost[0] = 0;
  std::vector<bool> seen(n, false);
  while (!std::all_of(seen.begin(), seen.end(), [](bool v) { return v; })) {
    uint32_t current = -1, cost = -1;
    for (size_t i = 0; i < n; i++) {
      if (!seen[i] && (cost > min_cost[i])) {
        current = i;
        cost = min_cost[i];
      }
    }

    seen[current] = true;
    for (auto &&node : G[current]) {
      if (seen[node.first]) continue;
      min_cost[node.first] = std::min(node.second, min_cost[node.first]);
    }
  }

  std::cout << std::accumulate(min_cost.begin(), min_cost.end(), 0)
            << std::endl;

  return 0;
}


Measured memory_bytes: 3208
def main():
    k = int(input())
    a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    print(a[k - 1])


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


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

int main(){
  int k,s;
  cin >> k >> s;
  int count = 0;
  rep(x,k){
    for(int y = x; y <= k;++y){
      for(int z = y; z <= k;++z){
        if(x + y + z == s){
          //cout << x << y << z << endl;
          if(x == y && y == z) count++;
          else if(x == y || y == z || z == x) count+=3;
          else count+=6;
        }
      }
    }
  }
  cout << count << endl;
  return 0;
}


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

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

  int ans = 0;
  ll s = 100;
  while (s < X) {
    s += s / 100;
    ans++;
  }

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

Measured memory_bytes: 3592
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{

		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		if(n%1000==0){
			System.out.println(0);
	}else{
		int mod = n%1000;
		System.out.println(1000-mod);
	}
}}

Measured memory_bytes: 35672
n, m = map(int, input().split())
ok_step = [True for i in range(n + 1)]
dp = [0 for i in range(n + 1)]

for i in range(m):
    broken = int(input())
    ok_step[broken] = False

dp[0] = 1
for now in range(n):
    for next in range(now + 1, min(n, now + 2) + 1):
        if ok_step[next]:
            dp[next] += dp[now]
            dp[next] %= 10**9 + 7
print(dp[n])

Measured memory_bytes: 7864
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    string s, t; cin >> s >> t;
    bool ok = true;
    rep(i,s.size()) {
        if (s[i] != t[i]) ok = false;
    }
    printf(ok?"Yes\n":"No\n");
}

Measured memory_bytes: 3716
// AOJ 1002: Extraordinary Girl I
// 2018.1.18 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define INF 0x30303030
int cost[3][3][2][2] = {
	{{{0,3},{1,3}},{{1,2},{1,2}},{{2,2},{2,2}}},
	{{{1,2},{1,2}},{{0,1},{1,2}},{{1,1},{2,2}}},
	{{{2,2},{2,2}},{{1,1},{2,2}},{{0,1},{3,3}}}};
int dp[3][10011];
char shelf[2][10011];
char book[40003];

int main()
{
	int cno, n, n2, i, j, x;
	char buf[10], *p;

	fgets(buf, 10, stdin), cno = atoi(buf);
	while (cno--) {
		fgets(buf, 10, stdin), n = atoi(buf), n2 = n << 1;
		memset(shelf, 0, sizeof(shelf));
		fgets(p=book, 40003, stdin);
		for (i = 0; i < n2; i++) if (*p++ == 'Y') shelf[0][(i+1)>>1] = 1;
		for (i = 0; i < n2; i++) if (*p++ == 'Y') shelf[1][(i+1)>>1] = 1;

		memset(dp, INF, sizeof(dp));
		dp[0][0] = 0;
		for (i = 0; i <= n; i++) for (j = 0; j < 9; j++) {
			x = dp[j/3][i] + cost[j/3][j%3][shelf[0][i]][shelf[1][i]] + 1;
			if (x < dp[j%3][i+1]) dp[j%3][i+1] = x;
		}
		printf("%d\n",dp[0][n+1] - 1);
	}
	return 0;
}



Measured memory_bytes: 2036
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <limits>
#include <algorithm>
#include <memory>
#include <climits>
#include <iomanip>

constexpr long long MOD = 1000000007;

int main()
{
  int N, M;
  std::cin >> N >> M;
  int L = 0, R = INT_MAX;
  while (M--)
  {
    int l, r;
    std::cin >> l >> r;
    L = std::max(L, l);
    R = std::min(R, r);
  }
  if (R < L)
    std::cout << 0 << std::endl;
  else
    std::cout << R - L + 1 << std::endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
char s[N];
int n,cnt[210];
bool era[N];
stack<int> e[210];
struct bit{
    int a[N];
    void add(int p,int d){
        for (;p<=n;p+=p&-p) a[p]+=d;
    }
    int query(int p){
        int ans=0;
        for (;p;p-=p&-p) ans+=a[p];
        return ans;
    }
    int query(int l,int r){
        return query(r)-query(l-1);
    }
}T;
int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    for (int i=1;i<=n;i++){
        cnt[s[i]]++;
        e[s[i]].push(i);
        T.add(i,1);
    }
    int odd=0;
    for (int i='a';i<='z';i++) if (cnt[i]&1) odd++;
    if (odd>1) return puts("-1"),0;
    long long ans=0;
    for (int l=1,res=n;l<=n;l++)
    if (!era[l]){
        int r=e[s[l]].top();e[s[l]].pop();
        era[l]=era[r]=1;
        if (l==r){
            T.add(l,-1);
            ans+=res/2;
            res--;
        }
        else{
            T.add(l,-1);T.add(r,-1);
            ans+=T.query(r,n);
            res-=2;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2432
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_C&lang=jp

#include <iostream>
#include <vector>
using namespace std;

class SieveManager{
protected:
	vector<bool> sieve;
	vector<int> primes;
public:
	int maxN;
	SieveManager(int aMaxN);
	void doSieve();
	bool isPrime(int p);
};

SieveManager::SieveManager(int aMaxN){
	maxN = aMaxN;
	for(int n = 0; n <= aMaxN; n++){
		sieve.push_back(true);
	}
	sieve[0] = false; // 0 is not prime
	sieve[1] = false; // 1 is not prime
}

void SieveManager::doSieve(){
	for (int index = 2; index <= maxN; index++){
		if (sieve[index] == false){
			continue;
		}
		primes.push_back(index);
		for (int removeIndex = index*2; removeIndex <= maxN; removeIndex += index){
			sieve[removeIndex] = false;
		}
	}
}

bool SieveManager::isPrime(int p){
	if (p <= maxN){
		return sieve[p];
	} else {
		for (auto it = primes.begin(); it != primes.end(); it++){
			if (p % (*it) == 0){
				return false;
			}
		}
		return true;
	}
}

int main(){
	SieveManager sieve(10000);
	sieve.doSieve();

	int numOfNums, count = 0, input;
	cin >> numOfNums;
	for (int n = 0; n < numOfNums; n++){
		cin >> input;
		if (sieve.isPrime(input)){
			count++;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3104
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
using namespace std;

int main(void){
	int n, m, i = 1, b;
	cin >> n >> m;
		while(true){
			if(m % i == 0){
				b = max(b,i);
				if((long) (m/i) * n <= m) b = max(b,m/i);
			}
			i++;
			if((long)i * n > m) break;
			if(i > sqrt(m))break;
		}
	cout << b << endl;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
var n = parseInt(input[0].substr(-1))
var ans = (function() {
  if (n == 3) {
    return 'bon'
  }
  else if (n === 0 || n == 1 || n == 6 || n == 8) {
    return 'pon'
  }
  return 'hon'
})()
console.log(ans)


Measured memory_bytes: 29624
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int c = sc.nextInt();
        int[][] a = new int[n][m];
        int[] b = new int[m];
        for(int i = 0 ; i < m ; i++ ){
            b[i] = sc.nextInt();
        }
        for(int i = 0 ; i < n ; i++ ){
            for(int j = 0 ; j < m ; j++ ){
                a[i][j] = sc.nextInt() * b[j];
                if(j != 0){
                    a[i][0] += a[i][j];
                }
            }
        }
        sc.close();
        int s = 0;
        for(int i = 0 ; i < n ; i++ ){
            if(a[i][0] + c > 0){
                s++;
            }
        }
        System.out.println(s);
    }
}

Measured memory_bytes: 38000
n = int(input())
a = input()
b = input()
c = input()
ans = 0
for i in range(n):
  if a[i] == b[i] == c[i]:
    continue
  if a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
    ans += 1
  else:
    ans += 2
print(ans)

Measured memory_bytes: 9156
a = list(map(int, '1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'.split(',')))
k = int(input())
print(a[k-1])

Measured memory_bytes: 2940
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    vector<int> A(3);
    rep(i,3) cin >> A.at(i);
    sort(A.begin(),A.end());
    cout << A[2] * 10 + A[1] + A[0] << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
#include<iomanip>
using namespace std;

int N;

int main() {
    cin >> N;
    int x = (100 * N + 107) / 108;
    if (x * 108 / 100 == N) {
        cout << x << endl;
    } else {
        cout << ":(" << endl;
    }
}


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

using namespace std;

main()
{
	bool ok = true;
	
	string s;
	cin >> s;
	
	s = ' ' + s;
	
	for(int i = 1; i < s.size(); i++)
		if(i % 2 == 1 && s[i] == 'L')
		{
			ok = false;
			break;
		}
		else
			if(i % 2 == 0 && s[i] == 'R')
			{
				ok = false;
				break;
			}
		
	if(ok == true)
		cout << "Yes\n";
	else
		cout << "No\n";
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  std::string s, t;
  std::cin >> s >> t;
  int64_t n = 0;

  for (int64_t i = 0; i < 3; i++) {
    if (s[i] == t[i]) {
      n++;
    }
  }
  std::cout << n << std::endl;
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from itertools import product
A, B, C, D = map(int, input())
pm = {1: "+", -1: "-"}

for op1, op2, op3 in product([1, -1], repeat=3):
    if A + op1*B + op2*C + op3*D == 7:
        print("".join(map(str, [A, pm[op1], B, pm[op2], C, pm[op3], D, "=7"])))
        break

Measured memory_bytes: 3060
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007

ll N;
vector<ll> A(200010,0);
vector<ll> Sum(200010,0);
vector<ll> Xsum(200010,0);

int main() {
    cin >> N;
    rep(i,N) cin >> A[i+1];
    rep(i,N){
        Sum[i+1] = Sum[i]+A[i+1];
        Xsum[i+1] = Xsum[i]^A[i+1];
    }
    ll ans = 0;
    ll active = 1;
    repi(i,1,N+1){
        while(active <= N && ((Xsum[active]^Xsum[i-1]) == Sum[active]-Sum[i-1])){
            active++;
        }
        ans += active-i;

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


Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        final int N = sc.nextInt();
        
        final int[] a = new int[N];
        int xor = 0;
        
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
            xor ^= a[i];
        }
        
        StringBuilder str = new StringBuilder();
        str.append(xor ^ a[0]);
        for (int i = 1; i < N; i++) {
            str.append(" ").append(xor ^ a[i]);
        }
        
        System.out.println(str);
    }
}


Measured memory_bytes: 60896