akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
#define DEB(variable) cout << #variable << '=' << variable << endl

#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

using llint = long long int;

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr long long int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){
    string s, t;
    cin >> s >> t;
    s += t;
    llint n = stoi(s);
    REP(i,100000){
        if(i*i==n){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
//config = { input: 'tmp', newline: '\r\n' }; // win
config = { input: '/dev/stdin', newline: '\n' }; // linux

line = require('fs').readFileSync(config.input, 'ascii')
  .split(config.newline, 2);

S = line[1].split(' ').map(Number);
sorted = [].concat(S);
cnt = 0;
mergeSort(sorted, 0, sorted.length);
console.log(sorted.join(' '));
console.log(cnt);

function merge(A, left, mid, right) {
  var n1, n2, L, R, i, j, k;
  n1 = mid - left;
  n2 = right - mid;
  L = new Array(n1 + 1);
  R = new Array(n2 + 1);
  for (i = 0; i < n1; i++)
    L[i] = A[left + i];
  for (i = 0; i < n2; i++)
    R[i] = A[mid + i];
  L[n1] = Number.POSITIVE_INFINITY;
  R[n2] = Number.POSITIVE_INFINITY;
  i = 0;
  j = 0;
  for (k = left; k < right; k++) {
    cnt++;
    if (L[i] <= R[j]) {
      A[k] = L[i];
      i = i + 1;
    } else {
      A[k] = R[j];
      j = j + 1;
    }
  }
}

function mergeSort(A, left, right) {
  var mid;
  if (left+1 < right) {
    mid = Math.floor((left + right) / 2);
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

Measured memory_bytes: 112628
from sys import stdin


def check_palindrome(str_):
    if str_ == str_[::-1]:
       return True
    return False

def get_result(data):
    S = data[0]
    right_idx = int((len(S) - 1) / 2)
    left_idx = int((len(S) + 3) / 2) - 1
    right_S = S[0:right_idx]
    left_S = S[left_idx:]
    if check_palindrome(S) and check_palindrome(right_S) and check_palindrome(left_S):
        return 'Yes'
    return 'No'


if __name__ == '__main__':
    data = list(map(str, stdin.readline().rstrip('\n').split(' ')))
    result = get_result(data)
    print(result)

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

int main()
{
    int i,n,k;
    int count=0;
    scanf("%d%d",&n,&k);
    int a[1000];
    while(n)
    {
        a[count] = n%k;
        n=n/k;

        count++;
    }
    printf("%d",count);
//    printf("\n");
//    for(int i = count - 1; i>=0; i--) {
//        printf("%d", a[i]);
}


Measured memory_bytes: 128
import java.util.*

fun min(i: Long, j:Long):Long {
    return if (i < j) i else j
}

// ABC143 E
fun main(args: Array<String>) {
    val inf = Long.MAX_VALUE
    val (N, M, L) = readLine()!!.split(" ").map { it.toInt() }
    val dp = Array(N) {Array(N) {inf} }
    val dp2 = Array(N) {Array(N) {inf} }
    val A = IntArray(M)
    val B = IntArray(M)
    val C = IntArray(M)
    for (i in 0 until M) {
        val arr = readLine()!!.split(" ").map { it.toInt() }
        dp[arr[0]-1][arr[1]-1] = arr[2].toLong()
        dp[arr[1]-1][arr[0]-1] = arr[2].toLong()
        A[i] = arr[0]
        B[i] = arr[1]
        C[i] = arr[2]
    }
    val Q = readLine()!!.toInt()
    val s = IntArray(Q)
    val t = IntArray(Q)
    for (i in 0 until Q) {
        val arr = readLine()!!.split(" ").map { it.toInt() }
        s[i] = arr[0]
        t[i] = arr[1]
    }

    for (k in 0 until N) {
        for (i in 0 until N) {
            for (j in 0 until N) {
                if (dp[i][k] != inf && dp[k][j] != inf) {
                    dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])
                }
            }
        }
    }

    for (j in 0 until N) {
        for (i in 0 until N) {
            if (dp[i][j] <= L) {
                dp2[i][j] = 1
            }
        }
    }

    for (k in 0 until N) {
        for (i in 0 until N) {
            for (j in 0 until N) {
                if (dp2[i][k] != inf && dp2[k][j] != inf) {
                    dp2[i][j] = min(dp2[i][j], dp2[i][k] + dp2[k][j])
                }
            }
        }
    }

    for(i in 0 until Q) {
        val ans = dp2[s[i]-1][t[i]-1]
        if (ans == inf) {
            println(-1)
        } else {
            println(ans -1)
        }
    }
}


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

int main() {
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  int L=A+B;
  int R=C+D;
  if(L>R){
    cout<<"Left"<<endl;}
  else if(L<R){
    cout<<"Right"<<endl;}
  else if(L=R){
    cout<<"Balanced"<<endl;}
}

















Measured memory_bytes: 256
def resolve():
    import sys
    input = sys.stdin.readline
    k = int(input().rstrip())

    if k <= 9:
        print(k)
        sys.exit()

    def judge(number_list, index, total):
        if index == len(number_list) - 2:  # 最後から2番目の桁
            num = number_list[index]
            add_num = 2 if num in (0, 9) else 3
            if (total + add_num) < k:
                total += add_num
                return total
            else:
                if num == 0:
                    right_nums = [num, num + 1]
                elif num == 9:
                    right_nums = [num-1,num]
                else:
                    right_nums = [num-1,num,num+1]
                number_list[-1] = right_nums[k-total-1]
                # print("".join(number_list))
                print(*number_list,sep="")
                sys.exit()
        else:  # 最後から２番目の桁じゃない
            num = number_list[index]
            if num == 0:
                right_nums = [num, num + 1]
            elif num == 9:
                right_nums = [num - 1, num]
            else:
                right_nums = [num - 1, num, num + 1]

            for right_num in right_nums:
                number_list[index+1] = right_num
                total = judge(number_list, index+1, total)
            return total

    total = 9
    num_list = [9]
    while True:
        num_list = [0 for _ in range(len(num_list)+1)]
        for left in [1,2,3,4,5,6,7,8,9]:
            num_list[0] = left
            # print(num_list, 0, total)
            total = judge(num_list, 0, total)




if __name__ == "__main__":
    resolve()


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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<long> prime, sieve(31622, 1);
    for(long i = 2; i < 31622; ++i){
        if(sieve[i]){
            prime.push_back(i);
            for(auto j = i * i; j < 31622; j += i)sieve[j] = 0;
        }
    }

    vector<long> a(N + 1);
    long u{0};
    for(auto& i : a){
        cin >> i;
        u = __gcd(u, abs(i));
    }

    vector<long> ans;
    for(long i = prime.size() - 1; i >= 0; --i){
        auto p = prime[i];
        if(u % p == 0){
            ans.push_back(p);
            while(u % p == 0)u /= p;
        }else if(p <= N){
            vector<long> v(p);
            for(unsigned long j = 0, k = 0; j < N; ++j){
                (v[k] += p + (a[j] % p)) %= p;
                if(++k == p - 1)k = 0;
            }
            auto tapi = (p + (a[N] % p)) % p;
            for(auto j : v)tapi += j % p;
            if(tapi == 0)ans.push_back(p);
        }
    }
    reverse(ans.begin(), ans.end());
    for(const auto i : ans)cout << i << endl;
    if(u != 1)cout << u << endl;
}

Measured memory_bytes: 768
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
for i in range(n):
    # 正面の町を救う
    beaten = min(a[i], b[i])
    b[i] -= beaten
    # 隣町を救う
    beaten2 = min(a[i + 1], b[i])
    a[i + 1] -= beaten2
    ans += beaten + beaten2
print(ans)

Measured memory_bytes: 19116
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;

template <typename T>
void prime_factor(T n, map<T, T>& m) {
    for (T i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            ++m[i];
            n /= i;
        }
    }

    if (n != 1) {
        ++m[n];
    }
}

int main() {
    const int MOD = 1e9 + 7;
    int N;
    cin >> N;

    long long nfact = 1;
    map<int, int> m;
    for (int i = 2; i <= N; ++i) {
        prime_factor(i, m);
    }

    long long ans = 1;
    for (auto e : m) {
        ans *= e.second + 1;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 504
#include<stdio.h>

int main(void){
    int K,A,B;
    scanf("%d %d %d",&K,&A,&B);
    if(A%K==0 || B/K-A/K>0){
        printf("OK\n");
    }else{
        printf("NG\n");
    }
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>

int main(){
  u_int max_line;
  const std::string before("Hoshino");
  const std::string after("Hoshina");
  std::cin >> max_line;
  std::cin.ignore();
  for(int i = 0; i < max_line; ++i){
    std::string str;
    std::getline(std::cin,str);
    auto pos = str.find(before);
    while(pos != std::string::npos){
      str.replace(pos, before.length(), after);
      pos = str.find(before);
    }
    std::cout << str << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1216
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    shogen=[]
    nums=[]
    for i in range(n):
        a=int(readline())
        nums.append(a)
        xy=[0]*a
        for j in range(a):
            xy[j]=list(map(int,readline().split()))
        shogen.append(xy)
    
    res=0
    for i in range(1<<n):
        output=[]
        for j in range(n):
            if(i>>j)&1:
                output.append(j)
        
        flag=True
        for p in output:
            num_p=nums[p]
            shogen_p=shogen[p]
            for j in range(num_p):
                if shogen_p[j][1]==1:
                    if shogen_p[j][0]-1 in output:
                        pass
                    else:
                        flag=False
                        break
                else:
                    if shogen_p[j][0]-1 in output:
                        flag=False
                        break
                    else:
                        pass
            if flag==False:
                break
        else:
            res=max(res,len(output))

    print(res)

if __name__=="__main__":
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,j,ans=0;
	string s;
	cin>>s;
	i=0;j=s.size()-1;
	while(i<j)
	{
		if(s[i]!=s[j])ans++;
		i++;j--;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int k, x;
int main() {
    cin >> k >> x;
    for (int i=x-k+1; i<=x+k-1; i++) {
        printf("%d%c", i, i==x+k-1?'\n':' ');
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card
{
  char suit;
  int value;
};

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[], int n, int left, int mid, int right)
{
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;

  for (i=0; i < n1; i++ ) L[i] = A[left + i];
  for (i=0; i < n2; i++ ) R[i] = A[mid + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;

  for ( k = left; k < right; k++ )
  {
    if ( L[i].value <= R[j].value )
    {
      A[k] = L[i++];
    }
    else
    {
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card A[], int n, int left, int right)
{
  int mid;

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

int partition(struct Card A[], int n, int p, int r)
{
  int i, j;

  struct Card t, x;

  x = A[r];
  i = p - 1;
  for (j=p; j<r; j++ )
  {
    if ( A[j].value <= x.value )
    {
      i++;
      t=A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  t = A[i + 1];
  A[i + 1] = A[r];
  A[r] = t;
  return i + 1;
}


void quickSort(struct Card A[], int n, int p, int r)
{
  int q;
  if (p<r)
  {
    q = partition(A, n, p, r);
    quickSort(A, n, p, q - 1);
    quickSort(A, n, q + 1, r);
  }
}

int main()
{
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for (i = 0; i < n; i++ )
  {
    scanf("%s %d", S, &v);
    A[i]. suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A, n, 0, n);
  quickSort(B, n, 0, n-1);

  for ( i=0; i< n; i++ )
  {
    if ( A[i].suit != B[i].suit ) stable=0;
  }
  if ( stable == 1 ) printf("Stable\n");
  else printf("Not stable\n");
  for ( i=0; i < n; i++ )
  {
    printf("%c %d\n", B[i].suit, B[i].value);
  }
  return 0;
}



Measured memory_bytes: 4112
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
const ll inf=1e15;
int main(void){
    int n,m,R;cin>>n>>m>>R;
    vector<int> r(R);
    rep(i,R){
        cin>>r[i];r[i]--;
    }
    vector<vector<ll>> t(n,vector<ll>(n,inf));
    rep(i,m){
        int a,b;ll c;cin>>a>>b>>c;a--;b--;
        t[a][b]=t[b][a]=c;
    }
    rep(i,n)t[i][i]=0;
    rep(k,n)rep(i,n)rep(j,n)chmin(t[i][j],t[i][k]+t[k][j]);
    sort(r.begin(),r.end());
    ll res=inf;
    do{
        ll buf=0;
        rep(i,R-1){
            buf+=t[r[i]][r[i+1]];
        }
        chmin(res,buf);
    }while(next_permutation(r.begin(),r.end()));
    cout<<res<<endl;
}


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

namespace ABC_C
{
    class C090
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]), M = int.Parse(s[1]);
            long c = 0;
            if (N == 1)
            {
                if (M == 1) c = 1;
                else c = M - 2;
            }
            else if (M == 1)
            {
                c = N - 2;
            }
            else
            {
                c = (long)(N - 2) * (M - 2);
            }
            Console.WriteLine(c);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
 
string S; int N, cnt;
 
int main() {
	int A,B;
    cin >> A >> B;
    int Ans=-1;
    for(int i=12;i<=1000;i++){
        int a=(i*8)/100;
        int b=(i*10)/100;
        if((a==A)&&(b==B)){
            Ans = i;
            break;
        }
    }
    cout << Ans << endl;
}

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

#define N	100000

int main() {
	static int dd[N], dd_[N], ae[N];
	int n, h, h_, i, j, i_, j_, m;

	scanf("%d", &n);
	for (h = 0; h < n - 1; h++) {
		scanf("%d%d", &i, &j), i--, j--;
		dd[i]++, ae[i] ^= j, dd[j]++, ae[j] ^= i;
	}
	memcpy(dd_, dd, n * sizeof *dd);
	for (i = 0; i < n; i++)
		if (dd[i] == 1) {
			j = ae[i];
			dd_[i] = -1, dd_[j]--, ae[j] ^= i;
		}
	i_ = -1, j_ = -1;
	for (i = 0; i < n; i++)
		if (dd_[i] == 0 || dd_[i] == 1) {
			if (i_ == -1)
				i_ = i;
			else if (j_ == -1)
				j_ = i;
			else {
				printf("-1\n");
				return 0;
			}
		}
	if (j_ == -1)
		j_ = i_;
	m = 0;
	dd_[m++] = 1;
	while (i_ != j_) {
		dd_[m++] = dd[i_] - 1;
		j = ae[i_];
		ae[j] ^= i_;
		i_ = j;
	}
	dd_[m++] = dd[i_] - 1, dd_[m++] = 1;
	for (h = 0, h_ = m - 1; h < h_; h++, h_--)
		if (dd_[h] != dd_[h_]) {
			if (dd_[h] > dd_[h_]) {
				int tmp;

				for (h = 0, h_ = m - 1; h < h_; h++, h_--)
					tmp = dd_[h], dd_[h] = dd_[h_], dd_[h_] = tmp;
			}
			break;
		}
	for (h = 0, i = 0; h < m; h++, i = j) {
		j = i + 1;
		while (--dd_[h])
			printf("%d ", j++ + 1);
		printf("%d ", i + 1);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2872
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>


int main() {
	ll k, x;
	cin >> k >> x;
	vector<ll> ans;
	for (int i = x - k + 1; i < k + x; i++)
	{
		ans.push_back(i);
	}
	REP(i, ans.size()) {
		if (i != 0)cout << " ";
		cout << ans[i];
	}
}
	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,T;cin>>n>>T;
  int t[n],x=T;
  for(int i=0;i<n;i++){
    cin>>t[i];
    if(i==0)continue;
    if(T<=t[i]-t[i-1])x+=T;
    else x+=t[i]-t[i-1];    
  }
  cout<<x;
}

Measured memory_bytes: 1024
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn main() {
   input! {
      h: usize,
      w: usize,
      _a: [String; h]
   }
   let mut a = vec![vec![]; h];
   for i in 0..h {
      for c in _a[i].chars() {
         if c == '#' {
            a[i].push(1);
         } else {
            a[i].push(0);
         }
      }
   }
   let m: usize = 1000000007;
   let mut dp = vec![vec![0; w + 1]; h + 1];
   dp[1][1] += 1;
   for i in 0..h {
      for j in 0..w {
         if a[i][j] == 0 {
            dp[i + 1][j + 1] += dp[i][j + 1] + dp[i + 1][j];
            dp[i + 1][j + 1] %= m;
         }
      }
   }
   println!("{}", dp[h][w]);
}


Measured memory_bytes: 16636
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#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, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)++)
#define p(...) printf(__VA_ARGS__); cout << endl;
#define input(x) x; cin >> x;
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](const a, const b){ return c ;}
#define key(t, x, compare) [](const t& a, const t& b){ return a x compare b x ;}

using namespace std;

int sum(int *a, int n){
  int r = 0;
  rep(i, n){
    r += a[i];
  }
  return r;
}

bool maina(){
  int input(n);
  int input(m);
  if(n == 0 &&  m == 0) return false;
  int list_input(t, n);
  int list_input(h, m);

  rep(i, n){
    rep(j, m){
      int tmp = h[j];
      h[j] = t[i];
      t[i] = tmp;
      if(sum(h, m) == sum(t, n)){
        p("%d %d", h[j], t[i]);
        goto GOAL;
      }
      tmp = t[i];
      t[i] = h[j];
      h[j] = tmp;
    }
  }
  p("%d", -1) return true;

GOAL:
  return true;
}

int main(){
  while(maina());
}

Measured memory_bytes: 3212
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 = new int[m*2];
		for(int i=0; i<m*2; i++){
			c[i] = sc.nextInt();
		}
		int count = 0;
		for(int i=0; i<n; i++){
          	count = 0;
			for(int j=0; j<m*2; j++){
				if(c[j]==i+1)count++;
			}
		System.out.println(count);
		}
	}
}

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

int main() {
  int n;
  cin >> n;
  int A[n], L[n];
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  L[0] = A[0];
  int length = 1;
  for (int i = 1; i < n; i++) {
    if (A[i] > L[length-1]) {
      L[length++] = A[i];
    } else {
      *lower_bound(L, L+length, A[i]) = A[i];
    }
  }
  cout << length << endl;
  return 0;
}



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

int main(){
    string s;
    cin >> s;
    if(s=="AAA" || s=="BBB"){
        printf("No\n");
        return 0;
    }
    printf("Yes\n");

}

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


n,m = map(int,input().split())
p = list(map(int,input().split()))
for i in range(n):
    p[i] -= 1

#連結成分に属するかどうかを見るときはUnion-Findを用いる
#根(属するクラス)を返す関数
def root(x):
    if par[x] == x:
        return x
    par[x] = root(par[x])
    return par[x]
#同じクラスに属するかどうかを返す関数
def same(x,y):
    return root(x) == root(y)
#木を結合する関数
def union(x,y):
    x = root(x)
    y = root(y)
    #高さの高いほうに低いほうを結合
    if rank[x] < rank[y]:
        par[x] = y#xの親(属するクラス)をyとする
    else:
        par[y] = x
        if rank[x] == rank[y]:#高さが同じ場合
            rank[x] += 1#高さは1つ増える
par = [i for i in range(n)]
rank = [0 for _ in range(n)]
for i in range(m):
    x,y = map(int,input().split())
    #swapできる頂点は同じ木にして同じ連結成分にする
    if not same(x-1,y-1):
        union(x-1,y-1)

ans = 0
for i in range(n):
    #p[i]とiが同じ連結成分ならばans+1
    if root(p[i]) == root(i):
        ans += 1
print(ans)


Measured memory_bytes: 99692
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		int n = Integer.parseInt(std.next());
		double vector_a[] = new double[n];
		for (int i=0; i<n; i++){
			vector_a[i] =  Double.parseDouble(std.next());
		}
		double vector_b[] = new double[n];
		for (int i=0; i<n; i++){
			vector_b[i] =  Double.parseDouble(std.next());
		}

		double dim1 = 0;
		for (int i=0; i<n; i++){
			dim1 += Math.abs(vector_a[i]-vector_b[i]);
		}

		double dim2 = 0;
		for (int i=0; i<n; i++){
			dim2 += Math.pow(Math.abs(vector_a[i]-vector_b[i]),2);
		}
		dim2 = Math.pow(dim2, 0.5);

		double dim3 = 0;
		for (int i=0; i<n; i++){
			dim3 += Math.pow(Math.abs(vector_a[i]-vector_b[i]),3);
		}
		dim3 = Math.pow(dim3, (1/3.0));

		double diminf = 0;
		for (int i=0; i<n; i++){
			diminf = Math.max(Math.abs(vector_a[i]-vector_b[i]),diminf);
		}

		System.out.println(String.format("%.5f", dim1));
		System.out.println(String.format("%.5f", dim2));
		System.out.println(String.format("%.5f", dim3));
		System.out.println(String.format("%.5f", diminf));
	}
}

Measured memory_bytes: 26492
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  vector<vector<int>>edge(2*n);
  int id=n;
  rep(i,n-1)
  {
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    if(c%2)
    {
      edge[a].push_back(b);
      edge[b].push_back(a);
    }
    else
    {
      edge[a].push_back(id);
      edge[id].push_back(a);
      edge[id].push_back(b);
      edge[b].push_back(id);

      id++;
    }
  }
  vector<int>  used(2*n,0);
  queue<int>que;
  vector<int>res(2*n,0);

  que.push(0);used[0]=1;res[0]=0;
  while(!que.empty())
  {
    int no=que.front();que.pop();
    for(auto nn:edge[no])
    {
      if(used[nn])continue;
      que.push(nn);used[nn]=1;res[nn]=1-res[no];
    }
  }
  rep(i,n)cout<<res[i]<<endl;
  return 0;

}


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

typedef long double     lf;

using namespace std;

const lf EPS = 1e-9;

struct pt {
  lf x, y;
  pt( ) { }
  pt( lf x, lf y ) : x( x ), y ( y ) { }
};

inline lf x( pt P ) { return P.x; }
inline lf y( pt P ) { return P.y; }

istream& operator >> ( istream& in, pt& p ) {
  lf x,y; in >> x >> y;
  p = pt(x,y); return in;
}

ostream& operator << ( ostream& out, const pt& p ) {
  out << double(p.x) << " " << double(p.y);
  return out;
}

pt operator + ( const pt& A, const pt& B ) {
  return pt( x(A)+x(B), y(A)+y(B) );
}

pt operator - ( const pt& A, const pt& B ) {
  return pt( x(A)-x(B), y(A)-y(B) );
}


pt operator * ( const lf& B, const pt& A ) {
  return pt( x(A)*B, y(A)*B );
}

pt operator * ( const pt& A, const lf& B ) {
  return pt( x(A)*B, y(A)*B  );
}

inline lf dot( pt A, pt B ) {
  return x(A)*x(B) + y(A)*y(B);
}

inline lf norm( pt A ) {
  return x(A)*x(A) + y(A)*y(A);
}

inline lf abs( pt A ) {
  return sqrt( norm(A) );
}

inline lf dist ( pt A, pt B ) { return abs( B - A ); }

lf distToLine (pt p, pt A, pt B, pt &c) {
  lf u = dot( p-A , B-A ) / norm( B-A );
  c = A + u*( B-A );
  return dist( p , c );
}

pt refPoint(pt X, pt A, pt B) {
  pt aux; distToLine(X, A, B, aux);
  return X + lf(2.0)*(aux-X);
}

inline bool same ( lf a, lf b ) {
  return a+EPS > b && b+EPS > a;
}

inline lf cross( pt A, pt B ) {
  return x(A)*y(B) - y(A)*x(B);
}

///CHANGE
// 0  for collineal points ( angle = 0 )
// 1  for angle BAX counter clockwise
// -1 for angle BAX clockwise
inline int ccw (pt X, pt A, pt B) {
  lf c = cross( B-A, X-A );
  if( same( c, 0.0 ) ) { return 0; }
  if( c > EPS ) { return 1; }
  return -1;
}

///CHANGE
inline bool segContains ( pt X, pt A, pt B) {
  if ( !same ( 0, cross ( A-X, B-X ) ) ) return 0;
  return ( dot ( A-X, B-X ) < EPS );
}

inline bool parallel( pt A, pt B, pt C, pt D ) {
  return same ( 0, cross( B-A, D-C ) );
}

///NEW
inline bool ortho( pt A, pt B, pt C, pt D ) {
  return same ( 0, dot( B-A, D-C ) );
}

/// --------------------------------------------

inline bool samePt ( pt A, pt B ) {
  return same ( x(A), x(B) ) && same ( y(A), y(B) );
}

pt linesIntersection ( pt A, pt B, pt C, pt D ) {
  lf x = cross ( C, D-C ) - cross ( A, D-C );
  x /= cross ( B-A, D-C );
  return A + x*(B-A);
}

inline bool collinearSegsIntersects ( pt A, pt B, pt C, pt D ) {
  return segContains(A,C,D) || segContains(B,C,D)
      || segContains(C,A,B) || segContains(D,A,B);
}

bool segmentsIntersect(pt A, pt B, pt C, pt D) {
  if( samePt(A,B) )
    return segContains( A, C, D );
  if( samePt(C,D) )
    return segContains( C, A, B );
  if( parallel(A,B,C,D) )
    return collinearSegsIntersects( A,B,C,D );
  pt aux = linesIntersection(A,B,C,D);
  return segContains(aux,A,B) && segContains(aux,C,D);
}

int n;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(10);

  cin >> n;
  for( int i = 0; i < n; ++i ) {
    pt A,B,C,D;
    cin >> A >> B >> C >> D;
    if( segmentsIntersect( A, B, C, D ) ) {
      cout << "1\n";
    }
    else {
      cout << "0\n";
    }
  }
}

Measured memory_bytes: 3276
#include <stdio.h>
int main (){
  int n,i,a[1000],sum;

  while (1){
    sum=0;
    scanf("%d",&n);
    if(n==0)break;
    for (i=0;i<n/4;i++){
      scanf("%d",&a[i]);
      sum=sum+a[i];
    }
    printf("%d\n",sum);
  }
  return 0;
}
      

Measured memory_bytes: 600
import java.io.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] data = br.readLine().split(" ");
    long n = Long.parseLong(data[0]);
    long k = Long.parseLong(data[1]);
    
    if (n < k){
      System.out.println(Math.min(n, k-n));
    } else {
      System.out.println(Math.min(n%k, Math.abs(n%k-k)));
    }
  }
}


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

const int N = 15e4;
vector<vector<int>> g(N);
map<int, ld> dp[N];
int n;
ld dfs(int i, int p, int f = 0) {
  if(dp[i].count(p)) return dp[i][p];
  int cnt = 0;
  ld res = 0;
  if(f || p == -1) {
    for(int j : g[i]) if(j != p) {
      cnt++;
      res += dfs(j, i, f);
    }
  } else {
    cnt = g[i].size() - 1;
    res = (dfs(i, -1, f) - 1.0) * g[i].size() - dfs(p, i, f);
  }
  if(cnt) res /= cnt, res += 1.0;
  return dp[i][p] = res;
}
int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  cin >> n;
  for(int i = 0; i < n - 1; i++) {
    int a, b; cin >> a >> b; a--; b--;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }
  dfs(0, -1, 1);
  cout << fixed << setprecision(8);
  for(int i = 0; i < n; i++) cout << dfs(i, -1) << endl;
  return 0;
}


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

int main() 
{
  int A = 0, B = 0, i = 0, ans = 0;
  cin >> A >> B;
  
  for (i = A; i <= B; i++) {
    int k5 = i/10000;
    int k4 = (i%10000)/1000;
    int k2 = (i%100)/10;
    int k1 = i%10;
    if ((k5 == k1) && (k4 == k2)) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import bisect

ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
l = nl()

l = sorted(l)

ans = 0

for a in range(n):
    fl = 0
    A = l[a]
    for b in range(a+1,n):
        B = l[b]

        idx = bisect.bisect_left(l, A+B)
        ans += max(0,idx-b-1)

print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <limits.h>
using namespace std;

int main(){
  int n, m; cin >> n >> m;
  int x[n];
  for(int i = 0; i < n; i++) x[i] = 0;
  int ac = 0, pn = 0;
  for(int i = 0; i < m; i++){
    int p; string s; cin >> p >> s;
    if(x[p - 1] >= 0){
      if(s.compare("AC") == 0){
        ac++;
        pn += x[p - 1];
        x[p - 1] = -1;
      }
      else x[p - 1]++;
    }
  }

  cout << ac << " " << pn << endl;
  return 0;
}


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

int main(){
  string S;
  cin>>S;
 if (S.at(0)==S.at(1)&&S.at(2)==S.at(3)&&S.at(0)!=S.at(2))
    {cout<<"Yes"<<endl;}
 else if (S.at(3)==S.at(0)&&S.at(1)==S.at(2)&&S.at(0)!=S.at(2))
      {cout<<"Yes"<<endl;}
 else if (S.at(2)==S.at(0)&&S.at(1)==S.at(3)&&S.at(0)!=S.at(3))
      {cout<<"Yes"<<endl;}
 else{cout<<"No"<<endl;}
    }

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

int main(){
    vector<vi> c(3, vi(3));
    rep(i, 3) rep(j, 3) cin >> c[i][j];
    vi x(3), y(3);
    rep(i, 3) x[i] = c[0][i] - y[0];
    rep(i, 3) y[i] = c[i][0] - x[0];
    bool ans = true;
    rep(i, 3) rep(j, 3) if (y[i]+x[j] != c[i][j]) ans = false;
    if (ans) cout << YES << endl;
    else cout << NO << endl;
    return 0;
}


Measured memory_bytes: 3412
a, b = map(int, input().split())
if a > 0 and b > 0:
    print("Positive")
elif a < 0 and b < 0:
    if (abs(a - b) + 1)%2 == 0:
        print("Positive")
    else:
        print("Negative")
else:
    print("Zero")



Measured memory_bytes: 2940
import sys
import math
import itertools

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def pp(n):
    c = 1
    for i in range(1, n+1):
        c *= i
    return c


def solve(inputs):
    towns = list(map(string_to_int, inputs))

    distances = []
    sum_distance = 0
    for t in towns:
        ds = []
        for t2 in towns:
            d = math.sqrt((t[0] - t2[0]) ** 2 + (t[1] - t2[1]) ** 2)
            ds.append(d)
            sum_distance += d
        distances.append(ds)

    per = list(itertools.permutations(range(0, len(towns))))
    sum_d = 0
    count = 0
    for p in per:
        d = 0
        for i, index in enumerate(p):
            if i == len(towns) - 1:
                break
            d += distances[index][p[i+1]]
        sum_d += d
        count += 1
    return sum_d / count


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    N = int(input())
    ret = solve(inputs(N))
    print(ret)


Measured memory_bytes: 8052
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
class trie
{
public:
	int nxt[100000][11];
	int cst[100000];
	int fail[100000];//failure link
	int fc[100000];//failure linkの合計コスト
	int pt;
	void init()
	{
		pt = 1;
		fill(nxt[0], nxt[0] + 11, -1);
	}
	void add(string s, int t)
	{
		int now = 0;
		for (int i = 0; i < s.size(); i++)
		{
			if (nxt[now][s[i] - '0'] == -1)
			{
				fill(nxt[pt], nxt[pt] + 11, -1);
				nxt[now][s[i] - '0'] = pt++;
			}
			now = nxt[now][s[i] - '0'];
		}
		cst[now] += t;
	}
	void makefail(string s)
	{
		int zz = 0;
		for (int i = 0; i < s.size(); i++)zz = nxt[zz][s[i] - '0'];
		int c = 0;
		for (int i = 0; i < s.size(); i++)
		{
			bool f = true;
			int now = 0;
			for (int j = i + 1; j < s.size(); j++)
			{
				if (nxt[now][s[j] - '0'] == -1)
				{
					f = false;
					break;
				}
				now = nxt[now][s[j] - '0'];
				c += cst[now];
			}
			if (f)
			{
				fail[zz] = now;
				fc[zz] = c;
				break;
			}
		}
	}
	void dfs(int node, string s)//addをやったあとこれを(0,"")で呼べばfailure linkができる
	{
		for (int i = 0; i < 11; i++)
		{
			if (nxt[node][i] != -1)
			{
				s.push_back('0' + i);
				makefail(s);
				dfs(nxt[node][i], s);
				s.pop_back();
			}
		}
	}
	pii getnext(int n, char k)//node nから文字kでの遷移先
	{
		if (nxt[n][k] == -1)
		{
			int x = 0;
			int c = 0;
			for (;;)
			{
				c += fc[n];
				n = fail[n];
				if (nxt[n][k] != -1)
				{
					x = nxt[n][k];
					c += cst[x];
					break;
				}
				if (n == 0)break;
			}
			return make_pair(x, c);
		}
		else
		{
			int x = nxt[n][k];
			return make_pair(x, cst[x]);
		}
	}
};
trie tr;
ll dp[41][100000];
ll mod = 1000000007;
vector<string>zv;
void dfs(int g, string s)
{
	if (g == 0)zv.push_back(s);
	for (int i = 1; i <= g; i++)
	{
		s.push_back(i + '0');
		dfs(g - i, s);
		s.pop_back();
	}
}
int main()
{
	int num;
	int g[3];
	scanf("%d%d%d%d", &num, &g[0], &g[1], &g[2]);
	vector<string>now;
	now.push_back("");
	for (int i = 0; i < 3; i++)
	{
		zv.clear();
		dfs(g[i], "");
		vector<string>z;
		for (int j = 0; j < now.size(); j++)for (int k = 0; k < zv.size(); k++)z.push_back(now[j] + zv[k]);
		now = z;
	}
	tr.init();
	for (int i = 0; i < now.size(); i++)tr.add(now[i], 1);
	tr.dfs(0, "");
	dp[0][0] = 1;
	for (int i = 0; i < num; i++)
	{
		for (int j = 0; j < tr.pt; j++)
		{
			for (int k = 1; k <= 10; k++)
			{
				pii z = tr.getnext(j, k);
				if (z.second == 0)
				{
					dp[i + 1][z.first] += dp[i][j];
					dp[i + 1][z.first] %= mod;
				}
			}
		}
	}
	ll ans = 1;
	for (int i = 0; i < num; i++)ans = (ans * 10) % mod;
	for (int i = 0; i < tr.pt; i++)
	{
		int c = 0;
		int now = i;
		for (;;)
		{
			if (now == 0)break;
			c += tr.fc[now];
			now = tr.fail[now];
		}
		if (c == 0)
		{
			ans += mod - dp[num][i];
			ans %= mod;
		}
	}
	printf("%lld\n", ans);
}

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

#define all(x) (x).begin(), (x).end()
#define szof(x) int32_t((x).size())
#define str(x) to_string(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;

const ll MOD = 1e9 + 7;
const ll MOD998 = 998244353;
const int INF = 1e9;
const ll LLINF = 1e18;

mt19937_64 rng((uint) chrono::steady_clock::now().time_since_epoch().count());

template <class T>
T rnd(T l, T r) {
	return uniform_int_distribution<T>(l, r)(rng);
}

int add(int x, int y, int mod = MOD998) {
	return x + y >= mod ? x + y - mod : x + y;
}

int sub(int x, int y, int mod = MOD998) {
	return x - y < 0 ? x - y + mod : x - y;
}

int mul(int x, int y, int mod = MOD998) {
	return 1LL * x * y % mod;
}

int pw(int a, int n, int mod = MOD998) {
	int res = 1;
	while (n) {
		if (n & 1) {
			res = mul(res, a, mod);
		}
		a = mul(a, a, mod);
		n >>= 1;
	}
	return res;
}

int inv(int x, int mod = MOD998) {
	return pw(x, mod - 2, mod);
}

vector<int> get_invs(int upto, int mod = MOD998) {
	vector<int> res(upto + 1);
	res[1] = 1;
	for (int i = 2; i <= upto; i++) {
		res[i] = mod - mul(mod / i, res[mod % i], mod);
	}
	return res;
}

void run() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int &x : a) {
		cin >> x;
	}
	vector<int> dp(k + 1);
	for (int i = 0; i <= k; i++) {
		dp[i] = add(i ? dp[i - 1] : 0, i <= a[0], MOD);
	}
	for (int who = 1; who < n; who++) {
		auto new_dp = dp;
		for (int i = 0; i <= k; i++) {
			int cur = sub(dp[i], i - a[who] - 1 < 0 ? 0 : dp[i - a[who] - 1], MOD);
			new_dp[i] = add(cur, i ? new_dp[i - 1] : 0, MOD);
		}
		dp.swap(new_dp);
	}
	cout << sub(dp[k], k ? dp[k - 1] : 0, MOD) << "\n";
}

int32_t main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cout.precision(10); cout << fixed;
	int tests = 1;
	// cin >> tests;
	while (tests--) {
		run();
	}
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<list>
#include<cstdlib>
using namespace std;
typedef list<char>L;
typedef L::iterator I;
int main()
{
	int N,M;
	string cmd,s;
	L buf;
	I cur;
	for(getline(cin,s),N=atoi(s.c_str());N--;)
	{
		getline(cin,s);
		buf.assign(s.begin(),s.end());
		cur=buf.begin();
		for(getline(cin,s),M=atoi(s.c_str());M--;)
		{
			getline(cin,cmd);
			if(cmd=="forward char")
			{
				if(cur!=buf.end())++cur;
			}
			else if(cmd=="backward char")
			{
				if(!buf.empty()&&cur!=buf.begin())--cur;
			}
			else if(cmd=="forward word")
			{
				bool c=0;
				for(;cur!=buf.end();++cur)
				{
					if(*cur==' ')
					{
						if(c)break;
					}
					else c=1;
				}
			}
			else if(cmd=="backward word")
			{
				bool c=0;
				if(!buf.empty()&&cur!=buf.begin())
					for(--cur;cur!=buf.begin();--cur)
					{
						if(*cur==' ')
						{
							if(c){++cur;break;}
						}
						else c=1;
					}
			}
			else if(cmd=="delete char")
			{
				if(cur!=buf.end())
				{
					cur=buf.erase(cur);
				}
			}
			else if(cmd=="delete word")
			{
				I b=cur;
				bool c=0;
				for(;cur!=buf.end();++cur)
				{
					if(*cur==' ')
					{
						if(c)
						{
							buf.erase(b,cur);
							c=0;
							break;
						}
					}
					else c=1;
				}
				if(c)buf.erase(b,cur);
			}
			else if(cmd.find("insert")!=string::npos)
			{
				s=cmd.substr(cmd.find('"')+1);
				s.erase(s.find('"'));
				buf.insert(cur,s.begin(),s.end());
			}
		}
		for(I i=buf.begin();i!=buf.end();++i)
		{
			if(i==cur)cout<<'^';
			cout<<*i;
		}
		if(buf.end()==cur)cout<<'^';
		cout<<'\n';
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

string S,T,U;
int a,b,c;
vl A,B;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    
    string N;cin>>N;
	if(N[0] == '7' or N[1] == '7' or N[2] == '7') Yes
	No
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using vect=vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}

ll primejudge(ll n){
  if(n<2)return 0;
  else if(n==2)return 1;
  else if(n%2==0)return 0;
  double sqrtn=sqrt(n);
  Loop(i,3,sqrtn+1){
     if(n%i==0){
        return 0;
     }
     i++;
  }
  return 1;
}

int main() {
  cout << fixed << setprecision(30);
  ll n,d,a;
  cin3(n,d,a);
  vec x(n);
  vec h(n);
  ll m=0;
  loop(i,n){
    cin>>x[i]>>h[i];
    m=max(m,h[i]);
  }
  pair<ll,ll> itv[n];
  loop(i,n){
    itv[i].first=x[i];
    itv[i].second=h[i];
  }
  sort(itv,itv+n);
  vec X(n);
  vec H(n);
  loop(i,n){
    X[i]=itv[i].first;
    H[i]=itv[i].second;
  }
  ll ans=0;
  if(d>=500000000){
    if(m%a==0)putout(m/a);
    else putout(m/a+1);
  }
    else{
  loop(i,n){
    if(H[i]<=0)continue;
    ll now=X[i];
    ll count=0;
    if(H[i]%a==0)count=H[i]/a;
    else count=H[i]/a+1;
    ans+=count;
    Loop(j,i+1,n){
      if(X[j]>now+2*d)break;
      if(H[j]<=0)continue;
      H[j]-=count*a;
    }
  }
  putout(ans);
    }
}


Measured memory_bytes: 9600
#include <iostream>
#include <vector>

int main() {
    int N;
    std::cin >> N;

    int m = 0, k;
    std::cin >> k;
    for (int j = 0; j < k; ++j) {
        int i;
        std::cin >> i;
        m += (1 << i);
    }

    std::vector<int> ans;
    for (int b = m; b > 0; b = ((b - 1) & m)) ans.push_back(b);
    ans.push_back(0);

    while (!ans.empty()) {
        int b = ans.back();
        ans.pop_back();

        std::cout << b << ":";
        for (int i = 0; i < N; ++i) {
            if ((b >> i) & 1) std::cout << " " << i;
        }
        std::cout << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3800
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
#include<iomanip>
using namespace std;
 
typedef long long ll;


double distance(int x,int y,int xx,int yy){
	return sqrt((x-xx)*(x-xx)+(y-yy)*(y-yy));
}

double sum = 0;
double num = 0;
int n ;

double calc(vector<double> &X,vector<double> &Y,vector<int> v){
	double res = 0;
	
	for(int i=0;i<n-1;++i){
		int ii = v[i];
		int jj = v[i+1];
		res += distance(X[ii],Y[ii],X[jj],Y[jj]);
	}
	
	return res;
}

void dfs(vector<double> &X,vector<double> &Y,vector<int> v){
	//cout << v.size()  << endl;
	if(v.size() == n){
		sum += calc(X,Y,v);
		num++;
	}else{
		for(int i=0;i<n;++i){
			if(find(v.begin(),v.end(),i) == v.end()){
				vector<int> vv = v;
				vv.push_back(i);
				dfs(X,Y,vv);
			}
			
		}
	}
}

int main(){
	cin >> n;
	vector<double> X(n),Y(n);
	
	for(int i=0;i<n;++i){
		cin >> X[i] >> Y[i];
	}
	
	dfs(X,Y,vector<int>());
	
	//cout << num <<endl;
	cout<<std::setprecision(20) << sum/num <<endl;
	
	return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def mergef(a,b):
    c = []
    h = j = 0
    while j<len(a) and h<len(b):
        if a[j]>b[h]:
            c.append(a[j])
            j+=1
        else:
            c.append(b[h])
            h+=1
    if j==len(a):
        for i in b[h:]:
            c.append(i)
    else:
        for i in a[j:]:
            c.append(i)
    return c

def merge_sortf(lists):
    if len(lists) <= 1:
        return lists
    middle = int(len(lists)/2)
    left = merge_sortf(lists[:middle])
    right = merge_sortf(lists[middle:])
    return mergef(left,right)


X,Y,A,B,C= map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

pm=merge_sortf(p)
qm=merge_sortf(q)
rm=merge_sortf(r)

k=0;i=X-1;j=Y-1
while i>=0 and j>=0 and k<C:
    if min((pm[i]-rm[k]),(qm[j]-rm[k])) < 0 :
        if pm[i]>=qm[j] :
            qm[j]=rm[k]
            if j>0:
                j=j-1
        elif pm[i]<qm[j]:
            pm[i]=rm[k]
            if i>0:
                i=i-1
    elif min((pm[i]-rm[k]),(qm[j]-rm[k])) > 0:
        break
    k=k+1

ans=sum(pm[:X])+sum(qm[:Y])
print(ans)


Measured memory_bytes: 22720