akhauriyash/Code-Regression huggingface dataset:
#pragma region template

#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#pragma region random

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T> T randint(T a, T b) {
    return uniform_int_distribution<T>(a, b)(rng);
}

#pragma endregion

#pragma region debug
string to_string(string s) { return '"' + s + '"'; }

string to_string(const char *s) { return to_string((string)s); }

string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B> string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A> string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first)
            res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

#pragma endregion

#pragma endregion

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    multiset<int,greater<int>>A;
    ll n,m;
    cin>>n>>m;
    ll a;
    for(ll i=0;i<n;i++)
    {
        cin>>a;
        A.insert(a);
    }
    for(ll i=0;i<m&&(A.size()>0);i++)
    {
        auto j = A.begin();
        a = *j;
        A.erase(j);
        a>>=1;
        if(a>0)
        A.insert(a);
    }
    ll sum = 0;
    for(auto i:A)
    sum+=i;
    cout<<sum;
    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);
        long a = sc.nextLong(), b = sc.nextLong(), c = sc.nextLong(), k = sc.nextLong();
        long res = Math.min(a, k);
        res = k - res - b <= 0 ? res :res  -(k - res - b);
        System.out.println(res);
    }
}


Measured memory_bytes: 35704
#include <iostream>

using namespace std;

//#define INT_MIN     (-2147483647 - 1) /* minimum (signed) int value */
//#define INT_MAX       2147483647    /* maximum (signed) int value */
#define  INT_MAX (1 << 21)

static const int MAX = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, m[MAX][MAX];

int prim()
{
	int color[MAX], p[MAX], d[MAX];
	int u, minv;

	for (int i = 0; i < n; ++i)
	{
		color[i] = WHITE;
		p[i] = -1;
		d[i] = INT_MAX;
	}

	d[0] = 0;

	while (1)
	{
		minv = INT_MAX;
		u = -1;
		for (int i = 0; i < n; ++i)
		{
			if (d[i] < minv && color[i] != BLACK)
			{
				u = i;
				minv = d[i];
			}
		}

		if (-1 == u)
			break;
		color[u] = BLACK;

		for (int i = 0; i < n; ++i)
		{
			if (m[u][i] < d[i] && color[i] != BLACK)
			{
				d[i] = m[u][i];
				p[i] = u;
				color[i] = GRAY;
			}
		}
	}

	int sum = 0;
	for (int i = 0; i < n; ++i)
	{
		if (p[i] != -1)
			sum += m[p[i]][i];
	}
	return sum;
}

void dijkstra()
{
	int minv;
	int d[MAX], color[MAX];

	for (int i = 0; i < n; ++i)
	{
		d[i] = INT_MAX;
		color[i] = WHITE;
	}

	d[0] = 0;
	color[0] = GRAY;

	while (1)
	{
		minv = INT_MAX;
		int u = -1;
		for (int i = 0; i < n; ++i)
		{
			if (d[i] < minv && color[i] != BLACK)
			{
				u = i;
				minv = d[i];
			}
		}

		if (-1 == u) break;
		color[u] = BLACK;

		for (int i = 0; i < n; ++i)
		{
			if (color[i] != BLACK && m[u][i] + d[u] < d[i])
			{
				d[i] = d[u] + m[u][i];
				color[i] = GRAY;
			}
		}
	}

	for (int i = 0; i < n; ++i)
		cout << i << " " << ((d[i] == INT_MAX) ? -1 : d[i]) << endl;
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			m[i][j] = INT_MAX;
		}
	}

	int k, c, u, v;
	for (int i = 0; i < n; ++i)
	{
		cin >> u >> k;
		for (int j = 0; j < k; ++j)
		{
			cin >> v >> c;
			m[u][v] = c;
		}
	}

	dijkstra();
	return 0;
}

Measured memory_bytes: 3112
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

OUTER:
	for i := 1; i <= n; i++ {
		x := i
		if x%3 == 0 {
			fmt.Printf(" %d", i)
			continue OUTER
		}

	INNER:
		for {
			if x%10 == 3 {
				fmt.Printf(" %d", i)
				continue OUTER
			} else {
				x /= 10
				if x != 0 {
					continue INNER
				}
			}
			break INNER
		}
	}
	fmt.Print("\n")
}

Measured memory_bytes: 1148
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
//#define DEBUG
#ifdef DEBUG
#define DEBUG_PRINT(fm, ...) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout << "DEBUG PRINT ";std::printf(fm, __VA_ARGS__);}while(0)
#define DEBUG_VAL(a, b) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout <<"DEBUG VAL " << a << ":" << b << endl;}while(0)
#else
#define DEBUG_PRINT(...)do{}while(0);
#define DEBUG_VAL(a, b)do{}while(0);
#endif

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
    int A, B, M;
    cin >> A >> B >> M;
    v1 a(A+1);
    v1 b(B+1);
    int ma = 1e6;
    int mb = 1e6;
    rep(i, A){
        int aa;
        cin >> aa;
        a[i+1] = aa;
        ma = min(ma, aa);
    }
    rep(i, B){
        int bb;
        cin >> bb;
        b[i+1] = bb;
        mb = min(mb, bb);
    }
    int ans = ma+mb;
    rep(i, M){
        int x, y, c;
        cin >> x >> y >> c;
        int value = a[x] + b[y] -c;
        ans = min(ans, value);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4044
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

    private void solve(FastScanner sc) {
        char[] s = sc.next().toCharArray();
        int len = 0;
        int depth = 0;
        for (int i = 0; i < s.length; i++) {
            if (s[i] == 'S') {
                depth++;
            } else if (depth > 0) {
                depth--;
            } else {
                len++;
            }
        }
        System.out.println(len + depth);
    }

    /*
     * template
     */

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        new Main().solve(sc);
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int bufLen = 0;

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

        boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
            return hasNextByte();
        }

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

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

        int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 10580
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace AtCoder
{
    class Program
    {
        
        static void Main()
        {
            //ここから

            int n = ReadLineToInt();
            int[] vs = ReadLineToIntArray();

            int[] H = ReadLineToIntArray();

            int ans = 0;
            double min = double.MaxValue;

            for(int i = 0; i < n; i++)
            {
                double dif = Math.Abs(vs[1] - (vs[0] - H[i]*0.006));
                if (min > dif)
                {
                    ans = i+1;
                    min = dif;
                }
            }

            //ここまで
            Console.WriteLine(ans);
            Console.ReadKey();
        }


        static public void Swap<T>(ref T a,ref T b) { T temp = a;a = b;b = temp; }
        static public long GCD(int a, int b){ return b != 0 ? GCD(b, a % b) : a;}
        static public long LCM(int a, int b){ return (long)a * b / GCD(a, b); }
        static public int Factorial(int a) { return a == 1 ? a : a * Factorial(a - 1); }
        static public int Conbin(int n,int m) { return Factorial(n) / (Factorial(n - m) * Factorial(m)); }


        
        static public string ReadLineToString(){return Console.ReadLine();}
        static public int ReadLineToInt(){return int.Parse(Console.ReadLine());}
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public string[] ReadLineToStringArray(){return Console.ReadLine().Split(' ').ToArray();}
        static public int[] ReadLineToIntArray(){return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();}
        static public long[] ReadLineToLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<string> ReadLineToStringList(){return Console.ReadLine().Split(' ').ToList();}
        static public List<int> ReadLineToIntList(){return Console.ReadLine().Split(' ').Select(int.Parse).ToList();}
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
    }
    
}


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

int n, k, a[100004];
int main() {
	int n,k;
	cin>>n>>k;
	for(int i = 0;i<n;i++)	cin>>a[i];
	int ans = 987654321;
	for(int l = 0; l <= n-k; l++){
		int r = l+k-1;
		ans = min(a[r] - a[l] + min(abs(a[l]), abs(a[r])), ans);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

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

		int price = sc.nextInt();

		if(price % 1000 == 0) {
			System.out.println(0);
		}else {
			int change = 1000 - (price % 1000);

			System.out.println(change);
		}
	}

}

Measured memory_bytes: 35752
#include "bits/stdc++.h"
#define ll long long
#define mk make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pie acos(-1.0)
using namespace std;
const int MAXN=1e5+9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll a,b,h,m;
	cin>>a>>b>>h>>m;
	ll ff=h*5*6;
	ll ss=m*6;
	long double ans=ff+((1.0*m)/(2.0))-1.0*ss;
	if(ans>180.0)
	{
		ans=360-ans;
	}
	long double angle=((1.0*ans)*pie);
	angle=(angle/180.00);
	long double fans=sqrt(1.0*a*a+1.0*b*b-2.0*a*b*cos(angle));
	cout.precision(12);
	cout<<fans<<endl;
	return 0;
}

Measured memory_bytes: 4108
#include <stdio.h>
long long a[1000000];
long long sum1[300000];
long long sum2[300000]; 
long long temp[300000]; 
int main(){
	int n,i,j,last;
	long long max;
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	  scanf("%lld",&a[i]);
	sum1[0]=0;
	sum2[0]=0;
	for (i=1;i<=n/2;i++)
	 {sum1[i]=sum1[i-1]+a[2*i-1];
	  sum2[i]=sum2[i-1]+a[2*i];
		 }
	if (n%2==0){
		max=sum2[n/2];
		for (i=1;i<=n/2;i++){
			if (sum1[i]+sum2[n/2]-sum2[i]>max)
			  max=sum1[i]+sum2[n/2]-sum2[i];
		}
		printf("%lld",max);
	}else{
		sum1[n/2+1]=sum1[n/2]+a[n];
		if (sum1[1]<sum2[1]) 
		  {temp[1]=sum2[1];
		   last=0;
		  }else{
		  temp[1]=sum1[1];
		  last=1;
		  }
		for (i=2;i<=n/2;i++){
			if (temp[i-1]+a[i*2]>sum1[i])
				temp[i]=temp[i-1]+a[i*2];else
				  temp[i]=sum1[i];
		}
		max=sum1[n/2+1]-sum1[1];
		for (i=1;i<=n/2;i++)
		  if (temp[i]+sum1[n/2+1]-sum1[i+1]>max)
		    max=temp[i]+sum1[n/2+1]-sum1[i+1];
		printf("%lld",max);
	}
} 

Measured memory_bytes: 5648
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rrep(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll h1,h2,m1,m2,k; cin >> h1 >> m1 >> h2 >> m2 >> k;
  ll time = 60 * h2 + m2 - (60 * h1 + m1);
  time -= k;
  if(time < 0) cout << "0";
  else cout << time;
  
  return 0;
}

Measured memory_bytes: 3636
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let (x, y, z) = read!(usize, usize, usize);
    println!("{}", (x - z) / (y + z));
}


Measured memory_bytes: 4352
P,Q,R=map(int,input().split())

#P=AB Q=BC R=AC
#ABC ACB BAC BCA CAB CBA

list=[]
list.append(P+Q)
list.append(R+Q)
list.append(P+R)
list.append(Q+R)
list.append(R+P)
list.append(Q+P)


a=sorted(list)

print(a[0])

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

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

    int a = (s.at(0) - '0') * 10 + (s.at(1) - '0');
    int b = (s.at(2) - '0') * 10 + (s.at(3) - '0');
    
    if (a == 0 && b == 0) {
        cout << "NA" << endl;
        return 0;
    }

    bool a_less12 = false;
    bool b_less12 = false;
    if (a <= 12) a_less12 = true;
    if (b <= 12) b_less12 = true;
  
    if (a_less12 && b_less12) {
        if (a == 0) {
            cout << "YYMM" << endl;
        }
        else if (b == 0) cout << "MMYY" << endl;
        else cout << "AMBIGUOUS" << endl;
    }
    else if (a_less12 && !b_less12) {
        if (a == 0) cout << "NA" << endl;
        else cout << "MMYY" << endl;
    }
    else if (!a_less12 && b_less12) {
        if (b == 0) cout << "NA" << endl;
        else cout << "YYMM" << endl;
    }
    else cout << "NA" << endl;
}


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

template<typename T, typename U> bool chmin(T &a, const U &b) {
	return (a > b ? a = b, true : false);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
	return (a < b ? a = b, true : false);
}
const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;

int d[200010];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;cin>>n;

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

	int min = d[0];
	int ans =0;
	for(int i=0; i<n; i++){

		if(min >=d[i]){
			ans++;
			min = d[i];
		}
	}

	writeln(ans);


}




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

int main()
{
    int a, b;
    cin >> a >> b;
    int ans = 0;
    ans = a * b;
    if(a >= 10 || b >= 10){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }

  
}


Measured memory_bytes: 256
#! /usr/bin/env python3

H, W = map(int, input().split())
F = [list(input()) for x in range(H)]
ans = True
px = py = 0
while py < H-1 or px < W-1:
    if py<H-1 and F[py+1][px]=='#':
        if (px<W-1 and F[py][px+1]=='#') or (px>0 and F[py+1][px-1]=='#'):
            ans = False
            break
        py += 1
    elif px<W-1 and F[py][px+1]=='#':
        if py>0 and F[py-1][px+1]=='#':
            ans = False
            break
        px += 1
    else:
        ans = False
        break
print('Possible' if ans else 'Impossible')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int a, b, c;
    cin >> a >> b >> c;

    if(a == b + c || b == c + a || c == a + b)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

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

#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to));
#define sort(a) sort(a.begin(), a.end())

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

int main() {
  int n, k;
  cin >> n >> k;
  if (n % k == 0) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
}

Measured memory_bytes: 384
def is_prime(x):
    # 解説見た
    if x <= 1:
        return True
    i = 2
    while i * i <= x:
        if x % i == 0:
            return True
        i += 1
    return False


def main():
    X = int(input())
    p = X
    while is_prime(p):
        p += 1
    print(p)

if __name__ == "__main__":
    main()

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n, m;
  cin >> n >> m;

  for (int i = 1; i <= m; ++i) {
    int j = n - i + 1;
    if (n % 2 == 0 && i > n / 4) {
      j--;
    }

    cout << i << ' ' << j << '\n';
  }
  return 0;
}

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

bool is_prime(int x) {
	for(int i = 2; i < x; i++) {
		if(x % i == 0)
			return false;
	}

	return true;
}

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

	while(!is_prime(X)) {
		X++;
	}

	cout << X << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#define maxn 200005
#define inf 0x3f3f3f3f
using namespace std;
int n, from, to;
int a[maxn], dp[maxn], ans[maxn];
vector<int> edge[maxn];
void dfs(int p, int pre)
{
    int pos = lower_bound(dp, dp + n, a[p]) - dp, pp = dp[pos];
    dp[pos] = a[p];
    ans[p] = lower_bound(dp, dp + n, inf) - dp;
    for (int i : edge[p])
        if (i != pre)
            dfs(i, p);
    dp[pos] = pp;
}
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", a + i);
    for (int i = 1; i < n; i++)
    {
        scanf("%d%d", &from, &to);
        edge[from].push_back(to);
        edge[to].push_back(from);
    }
    fill(dp, dp + n, inf);
    dfs(1, 0);
    for (int i = 1; i <= n; i++)
        printf("%d\n", ans[i]);
    return 0;
}

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

string verdicts[4];
int counts[4];

int main()
{
	int N;
	scanf("%d", &N);
	
	verdicts[0] = "AC";
	verdicts[1] = "WA";
	verdicts[2] = "TLE";
	verdicts[3] = "RE";
	
	for(int i = 1; i <= N; i++)
	{
		string si;
		cin >> si;
		
		for(int j = 0; j < 4; j++)
		{
			if(si == verdicts[j])
			{
				counts[j]++;
				break;
			}
		}
	}
	
	for(int i = 0; i < 4; i++)
	{
		printf("%s x %d\n", verdicts[i].c_str(), counts[i]);
	}
}


Measured memory_bytes: 3796
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

///////////////////////////////////////////////////
// -------------------- I/O -------------------- //
///////////////////////////////////////////////////
// https://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords
template<typename T> void outputVec(const std::vector<T>& vec, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	for (auto it = vec.begin(); it != vec.end() - 1; ++it) { std::cout << *it << " "; }
	std::cout << *(vec.end() - 1) << "\n";
}
template<typename T> void outputVal(const T& res, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	std::cout << res << "\n";
}
template<typename T> T inputVal() { T a; std::cin >> a; return a; }
template<typename T> std::vector<T> inputVec(int N) {
	std::vector<T> vec(N);
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
	return vec;
}
template<typename T> void inputVec(std::vector<T>& vec) {
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
}

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
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; }

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {
	const int N = inputVal<int>();
	const int D = inputVal<int>();
	vector<vector<int> > X(N, vector<int>(D));
	rep(i, N) {
		rep(j, D) {
			cin >> X[i][j];
		}
	}

	int cnt = 0;
	REP(i, 0, N-1) {
		REP(j, i+1, N) {
			double sqdst = 0.0;
			rep(k, D) {
				sqdst += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
			}
			double dst = sqrt(sqdst);
			if (lround(dst) == dst) cnt++;
		}
	}

	outputVal(cnt);
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout << std::fixed << std::setprecision(15);
	Main();

	double tmp;
	cin >> tmp;

	return 0;
}


Measured memory_bytes: 256
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int n, b, c;
int a[10000];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++)
    {
      if(i*j==n){
        return yes,0;
      }
    }
  }
    no;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int d,w[2],p[2],dw[2];
  cin >>d;
  for(int i=0; i<2; i++) cin >>w[i];
  for(int i=0; i<2; i++) cin >>p[i];
  for(int i=0; i<2; i++){
    int r = (w[i]%p[i])? 1:0;
    dw[i] = w[i]/p[i]+r;
  }
  cout <<d-max(dw[0],dw[1])<<endl;
}

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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))

template<typename V,typename T>
T find_num(V v, T num) {
    if ( find(ALL(v), num) == v.end() ) {
        return false;
    } else {
        return true;
    }
}

// π M_PI
// deg = rad*180/M_PI

int main() {
    ll n, k;
    cin >> n >> k;
    cout << min( n%k, k-(n%k) ) << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	string ans;
	if(n < 1000) ans = "ABC";
	else ans = "ABD";
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

int ans;

int main(void) {
    int n;
    ll d;
    cin >> n >> d;
    rep(i, 0, n) {
        ll x, y;
        cin >> x >> y;
        if (x*x+y*y<=d*d) ans++;
    }


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



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

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define mp make_pair

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro

string str;
int n;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'

    cin>>str;
    n = str.size();

    bool rekt = false;
    if(str[n-1] != '0')rekt = true;
    if(str[0] != '1')rekt = true;
    if(n-2 > 0 && str[n-2] != '1')rekt = true;
    for(int i=1, j=n-3; i<j; i++,j--){
        if(str[i] != str[j])rekt = true;
    }

    if(rekt)cout << -1 << endl;
    else{
        cout << "1 2" << endl;
        int now = 2;
        int next = 3;
        for(int i=1, j=n-3; i<=j; i++, j--){
            cout << now << " " << next << endl;
            if(str[i] == '1'){
                now = next;
            }
            next++;
        }
        while(next <= n)cout << now << " " << next++ << endl;
    }

    return 0;
}


Measured memory_bytes: 1616
#include <iostream>

using namespace std;

int main()
{
    int d;
    cin>>d;
    if(d==25)
    {
        cout<<"Christmas";
    }
    else if(d==24)
    {
        cout<<"Christmas Eve";
    }
    else if(d==23)
    {
        cout<<"Christmas Eve Eve";
    }
    else
    {
        cout<<"Christmas Eve Eve Eve";
    }
}

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

#define pb push_back
#define fi first
#define se second


using namespace std;



long long gcd(long long x, long long y)
{
	if(y==0)
		return x;
	return gcd(y, x%y);
}


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

	cout<< (a*b)/gcd(a,b) <<endl;

	return 0;
}


Measured memory_bytes: 3608
N = int(raw_input())
Card = map(str, raw_input().split())
Card2 = Card[:]
Card3 = Card[:]

def bubbleSort(A, N):
    flag = 1
    while flag:
        flag = 0
        for i in range(N-1, 0, -1):
            if int(A[i][1]) < int(A[i-1][1]):
                temp = A[i]
                A[i] = A[i-1]
                A[i-1] = temp
                flag = 1
                
def selectionSort(A, N):
    for i in range(0, N):
        minj = i
        for j in range(i, N):
            if int(A[j][1]) < int(A[minj][1]):
                minj = j
        if i != minj:
            temp = A[i]
            A[i] = A[minj]
            A[minj] = temp

def stableJudge(A, B):
    i = 0
    while(1):
        if i >= N-1:
            return "Stable"
        strB = []
        strB += B[i][0]
        strA = []
        for j in range(i+1, N):
            if B[i][1] == B[j][1] and j != N-1:
                strB += B[j][0]
            else:
                if B[i][1] == B[j][1] and j == N-1:
                    strB += B[j][0]
                if len(strB) != 1:
                    for k in range(0, N):
                        if A[k][1] == B[i][1]:
                            strA += A[k][0]
                    if strA != strB:
                        return "Not stable"
                    else:
                        i += len(strB)
                        break
                else:
                    i += len(strB)
                    break

bubbleSort(Card2, N)
print " ".join(Card2)
print stableJudge(Card, Card2)
selectionSort(Card3, N)
print " ".join(Card3)
print stableJudge(Card, Card3)
            

Measured memory_bytes: 6468
def main():
	import sys

	table = [0]*51

	for a in range(10):
		for b in range(10):
			for c in range(10):
				for d in range(10):
					table[a+b+c+d] += 1

	for line in sys.stdin:
		n = int(line)
		print(table[n])


if __name__ == '__main__':
	main()

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

int main(){
    int n,k;
    cin>>n>>k;
    vector<int>a(n);
    int one;
    rep(i,0,n){
        cin>>a.at(i);
        if(a.at(i)==1)one=i;
    }
    cout<<((n-1)+(k-2))/(k-1)<<endl;
return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	string t;
  	cin>>s;
  	cin>>t;
	int count = 0;
	for(int i=0; i<s.length(); i++) {
		if(s[i] == t[i])
			count++;
	}
	cout<<count<<endl;
}	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define x first
#define y second
#define mod 1e9+7
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rof(i,a,b) for(ll i=a;i>b;i--)

ll lcm(ll a, ll b){
    return a / __gcd(a, b) * b;
}
//memset can initialize to 0 or -1 ONLY
// memset(a,0,sizeof(a[0][0])*n*n); //2D array
//memset(a, 0, sizeof(a));  //1D array
//memset(str, 't', sizeof(str)); // string
void solve()
{
    string s;cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])
    	cout<<"Yes";
    else cout<<"No";
    
}


int main()
{

ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t=1;
   // cin>>t;
    while(t--)
    {
    
    solve();
    
    }

}

Measured memory_bytes: 256
# n choose 2
def binomial_2(n):
    if n < 2:
        return 0
    else:
        return n * (n - 1) // 2

N = int(input())
A = [int(x) for x in input().split()]

dict = {}
for a in A:
    if a in dict:
        dict[a] += 1
    else:
        dict[a] = 1

tot = 0
for num in dict.values():
    tot += binomial_2(num)

for i in range(N):
    print(tot - dict[A[i]] + 1)


Measured memory_bytes: 25768
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <limits>
#include <memory>
#include <queue>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define all(a) (a).begin(), (a).end()
#define sz(a) static_cast<int>((a).size())
#define fillchar(a, x) memset(a, x, sizeof(a))
#define rep(i, a, b) for(int i=int(a); i<=int(b); ++i)
#define irep(i, a, b) for(int i=int(a); i>=int(b); --i)
#define replr(i, a, b) rep(i, a, (b)-1)
#define reprl(i, a, b) irep(i, (b)-1, a)
#define repn(i, n) rep(i, 0, (n)-1)
#define irepn(i, n) irep(i, (n)-1, 0)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
typedef vector<LL> VL;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<string> VS;
template<class T, class S> ostream& operator<<(ostream& os, const pair<T, S>& v) { return os<<"("<<v.first<<", "<<v.second<<")"; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { os<<"["; repn(i, sz(v)) { if(i) os<<", "; os<<v[i]; } return os<<"]"; }
template<class T> bool setmax(T &_a, T _b) { if(_b>_a) { _a=_b; return true; } return false; }
template<class T> bool setmin(T &_a, T _b) { if(_b<_a) { _a=_b; return true; } return false; }
template<class T> T gcd(T _a, T _b) { return _b==0?_a:gcd(_b,_a%_b); }

const int N=200000;

VI es[N];
bool liked[N];
int n;
LL ans;

PII f[N];

PII merge(PII a, PII b) {
    PII c;
    c.fi=max(a.fi, b.fi);
    c.se=a.se|b.se;
    return c;
}

void dfs(int x, int fa) {
    f[x]=mp(0, liked[x]);
    for(int y: es[x]) if(y!=fa) {
        dfs(y, x);
        f[x]=merge(f[x], f[y]);
    }
    ++f[x].fi;
}

void dfs2(int x, int fa, PII top) {
    VI ys;
    for(int y: es[x]) if(y!=fa) ys.pb(y);
    vector<PII> l(sz(ys)+1), r(sz(ys)+1);
    repn(i, sz(ys)) l[i+1]=merge(l[i], f[ys[i]]);
    irepn(i, sz(ys)) r[i]=merge(r[i+1], f[ys[i]]);
    repn(i, sz(ys)) {
        PII tmp=merge(top, merge(l[i], r[i+1]));
        if(liked[x]) tmp.se=1;
        ++tmp.fi;
        dfs2(ys[i], x, tmp);
    }

    VPI vs;
    for(int y: es[x]) {
        vs.pb(y==fa ? top : f[y]);
    }
    sort(all(vs), greater<PII>());
    if(!vs.empty()) {
        int ubound=min(vs[0].fi-1, sz(vs)>1 ? vs[1].fi+1 : 1);
        int lbound=0;
        if(!liked[x]) {
            int i=sz(vs)-1;
            while(i>=0 && !vs[i].se) --i;
            if(i>=0) lbound=vs[i].fi;
                else lbound=ubound+1;
        }
        if(lbound<=ubound) {
            ans+=ubound-lbound+1;
        }
    }
}

int main() {
    scanf("%d", &n);
    repn(i, n-1) {
        int a, b; scanf("%d%d", &a,&b);
        --a, --b;
        es[a].pb(b), es[b].pb(a);
    }
    static char buf[N+1];
    scanf("%s", buf);
    repn(i, n) {
        liked[i]=(buf[i]=='1');
    }

    dfs(0, -1);
    ans=0;
    dfs2(0, -1, mp(0, 0));
    if(count(liked, liked+n, true)>0) ++ans;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 53632
N = str(input())
A = int(N[0])
B = int(N[1])
C = int(N[2])
D = int(N[3])

if   A-B-C-D == 7:
  print(str(A)+"-"+str(B)+"-"+str(C)+"-"+str(D)+"=7")
elif A-B-C+D == 7:
  print(str(A)+"-"+str(B)+"-"+str(C)+"+"+str(D)+"=7")
elif A-B+C-D == 7:
  print(str(A)+"-"+str(B)+"+"+str(C)+"-"+str(D)+"=7")
elif A-B+C+D == 7:
  print(str(A)+"-"+str(B)+"+"+str(C)+"+"+str(D)+"=7")
elif A+B-C-D == 7:
  print(str(A)+"+"+str(B)+"-"+str(C)+"-"+str(D)+"=7")
elif A+B-C+D == 7:
  print(str(A)+"+"+str(B)+"-"+str(C)+"+"+str(D)+"=7")
elif A+B+C-D == 7:
  print(str(A)+"+"+str(B)+"+"+str(C)+"-"+str(D)+"=7")
elif A+B+C+D == 7:
  print(str(A)+"+"+str(B)+"+"+str(C)+"+"+str(D)+"=7")

Measured memory_bytes: 9232
#include<iostream>
using namespace std;
typedef long long ll;

const ll mod = 1e9 + 7;

int main(){
    ll n, m;
    cin >> n >> m;
    if(n == 1){
        cout << (m+1)%mod << endl;
    }else{
        ll d = (m+1)/(n-1)%mod;
        cout << ( (m+1)%(n-1)*(d+1)%mod*(d+1)%mod + (n-1-(m+1)%(n-1))*d%mod*d%mod )%mod << endl;
    }
    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-6;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair

const int MOD = 1e9+7;
const int MAX_N = 1e5+15;
int N, M;
int a[MAX_N];
int dp[MAX_N];

void solve()
{
	set<int> s;
	for(int i=0;i<M;++i)s.insert(a[i]);
	dp[0]=1;
	for(int i=1;i<=N;++i){
		if(s.count(i)) dp[i]=0;
		else{
			if(i==1) dp[i]=dp[i-1];
			else dp[i]=(dp[i-1]+dp[i-2])%MOD;
		}
	}
	cout << dp[N] << endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N >> M;
	for(int i=0;i<M;++i)cin >> a[i];
	solve();
	return 0;
}

Measured memory_bytes: 5760
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.next());

		List<Integer> list = new ArrayList();
		for(int i = 0; i < N;i++) {
			list.add(0);
		}

		for(int i = 1;i < N;i++) {
			int c = Integer.parseInt(sc.next()) -1;
			int a = list.get(c);
			list.set(c, ++a);
		}

		for(Integer b : list) {
			System.out.println(b);
		}


	}
}

Measured memory_bytes: 60756
data = input()
#data = '\\\\///\\_/\\/\\\\\\\\/_/\\\\///__\\\\\\_\\\\/_\\/_/\\'
diff = {'\\':-1, '_':0, '/':1}
height = [0]
[height.append(height[-1]+diff[i]) for i in data]
bottom = min(height)
height = [h-bottom for h in height]

m = max(height)
water = [m for h in height]

height00 = [0] + height + [0]
water00 = [0] + water + [0]

idx = list(range(1,len(water00)-1))
for i in idx + idx[::-1]:
	water00[i] = max(height00[i],min(water00[i-1:i+2]))

water = water00[1:-1]
depth = [w-h for w,h in zip(water,height)]

paddles = [0]
for d1,d2 in zip(depth[:-1],depth[1:]):
	if d1==0 and d2>0:
		paddles.append(0)
	paddles[-1] += min(d1,d2) + 0.5*abs(d1-d2)

paddles = [int(p) for p in paddles[1:]]
print(sum(paddles))
print(len(paddles), *paddles)

Measured memory_bytes: 10204
// 正答者のソースを勉強する.
// kmjp氏
// https://atcoder.jp/contests/abc140/submissions/7385434
#include <bits/stdc++.h>
using namespace std;

int main(){
    
    // 1. 入力情報取得.
    int N, K;
    scanf("%d %d", &N, &K);
    char c[111111];
    scanf("%s", c);
    
    // 2. 同じ(same), 異なる(different) を 集計.
    int s = 0, d = 0;
    for(int i = 0; i < N - 1; i++){
        if(c[i] == c[i + 1]) s++;
        else                 d++;
    }
    
    // 3. 出力.
    printf("%d\n", s + min(d, K * 2));
    return 0;
}

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

int main() {
    int n, m;
    cin >> n;
    vector<int> t(n);
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> t.at(i);
        sum += t.at(i);
    }
    cin >> m;
    vector<int> p(m), x(m);
    for (int i = 0; i < m; i++) {
        cin >> p.at(i);
        cin >> x.at(i);
    }
    for (int i = 0; i < m; i++) {
        cout << sum - t.at(p.at(i) - 1) + x.at(i) << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>

main(){
  int i,j,num,array[100],sum;
  scanf("%d",&num);
  for(i=0;i<num;i++) scanf("%d",&array[i]);
  
  for(i=0;i<num-1;i++)
    for(j=i+1;j<num;j++)
      sum+=array[i]*array[j];
  
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
def F_0_n(n):
    if (n + 1) % 2 == 0:
        return 0 if ((n + 1) // 2) % 2 == 0 else 1
    else:
        return n if (n // 2) % 2 == 0 else n ^ 1


A, B = [ int(x) for x in input().split(" ") ]
 
F_A_B = F_0_n(A - 1) ^ F_0_n(B)

print(F_A_B)


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int x,a,b;cin>>x>>a>>b;
  int res = (x-a);

  res = res - (res / b) * b;
  cout<< res <<endl;

  return 0;
}


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

int main(){
    long long X;
    cin >> X;
    long long ureshisa = 0;
    while(X >= 500){
        ureshisa += 1000;
        X -= 500;
    }
    while(X >= 5){
        ureshisa += 5;
        X -= 5;
    }
    cout << ureshisa << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
const int R = 0, G = 1, Y = 2, N = 400;
int convert(char c) {
    if(c == 'R') {
        return R;
    } else if(c == 'G') {
        return G;
    } else {
        return Y;
    }
}
int n;
vector<int> position_of[3];
vector<int> rbefore = {0}, gbefore = {0}, ybefore = {0};
int mem[2][N+1][N+1][3];
int cost_to_move(int r, int g, int y, int from_pos, int to_pos) {
    return max(max(r, rbefore[from_pos]) + max(g, gbefore[from_pos]) + max(y, ybefore[from_pos]) - to_pos, 0);
}
int opt(int r, int g, int y, int last) {
    return mem[r & 1][g][y][last];
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> n >> s;
    for(int i = 0; i < s.size(); i++) {
        position_of[convert(s[i])].push_back(i);
    }
    for(int i = 1; i < s.size(); i++) {
        rbefore.push_back(rbefore.back() + (s[i - 1] == 'R'));
        gbefore.push_back(gbefore.back() + (s[i - 1] == 'G'));
        ybefore.push_back(ybefore.back() + (s[i - 1] == 'Y'));
    }
    for(int r = position_of[R].size(); r >= 0; r--) {
        for(int g = position_of[G].size(); g >= 0; g--) {
            for(int y = position_of[Y].size(); y >= 0; y--) {
                for(int last : {R, G, Y}) {
                    int& ans = mem[r & 1][g][y][last];
                    int pos = r + g + y;
                    if(pos == n) {
                        ans = 0;
                    } else {
                        ans = n * (n + 1) / 2;
                        if(r < position_of[R].size() and last != R) {
                            ans = min(ans, cost_to_move(r, g, y, position_of[R][r], pos) + opt(r + 1, g, y, R));
                        }
                        if(g < position_of[G].size() and last != G) {
                            ans = min(ans, cost_to_move(r, g, y, position_of[G][g], pos) + opt(r, g + 1, y, G));
                        }
                        if(y < position_of[Y].size() and last != Y) {
                            ans = min(ans, cost_to_move(r, g, y, position_of[Y][y], pos) + opt(r, g, y + 1, Y));
                        }
                    }
                }
            }
        }
    }
    int ans = min({opt(0, 0, 0, R), opt(0, 0, 0, G), opt(0, 0, 0, Y)});
    cout << (ans == n * (n + 1) / 2 ? -1 : ans) << endl;
    return 0;
}



Measured memory_bytes: 4840
N, K = map(int,input().split())
A = []
B = []
copy = K
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
target = []
while K >= 2:
    target.append(K%2)
    K = K//2
target.append(K)

def check(A,B,N,K):
    compare = 0
    for i in range(N):
        if A[i]|K <= K:
            compare+=B[i]
    return(compare)

ans = check(A,B,N,copy)
for i in range(len(target)):
    if target[i] ==1:
        copy = copy^2**i
        if i >0:
            copy = copy | (2**i-1)
        chance = check(A,B,N,copy)
        if chance > ans:
            ans = chance
print(ans)

Measured memory_bytes: 85816
#include<bits/stdc++.h>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD1 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{
  int N;cin>>N;
  vector<int> vec (N+1,0);
  for (int i = 0; i < N; i++)
  {
    char X;cin>>X;
    vec[i+1] = (int)(X == '#');
  }
  
  for (int i = 0; i < N; i++)
  {
    vec[i+1] += vec[i];
  }
  int res = INF;
  for (int i = 0; i < N+1; i++)
  {
    int B = N - (i) - (vec[N] - vec[i]);
    int W = vec[i];
    
    chmin(res,B + W);
  }
  cout<<res<<endl;
  

  
  
  
  
  
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 4800
#include<iostream>
using namespace std;
int a[110],n;
double ans,t;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i],ans+=(double)1/a[i];
	}
	if(n==1)
	{
		cout<<a[1];
		return 0;
	}
	printf("%.7lf",(double)1/ans);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cctype>
using namespace std;
int main()
{ 
    int x,y;
    cin>>x>>y;
    if(x%y)cout<<x;
    else cout<<-1;
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256