akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

namespace ABC134C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            int[] A = new int[N];
            for(int i = 0; i < N; i++)
            {
                A[i] = int.Parse(Console.ReadLine());
            }

            int[] A2 = A.OrderBy(a => -a).ToArray();

            int max1 = A2[0];
            int max2 = A2[1];

            for(int i = 0; i < N; i++)
            {
                if (A[i] == max1)
                {
                    Console.WriteLine(max2);
                }
                else
                    Console.WriteLine(max1);
            }
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 24532
/*
                Author: Ankit Kaul
**********************Code Belongs to Respective Author Only************************************
*/
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include <bits/stdc++.h>
#define endl       '\n'
#define PI          3.141592653589
#define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define int         long long int
#define inf         INT_MAX
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
using namespace std;
int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
    int result=1;
    while(n>0)
    {   if(n % 2 ==1)
        result=(result * x) % M;
        x=(x*x)% M;
        n=n/2;
    }
return result % M;
}      
bool isPrime(int n) 
{ 
if (n <= 1) 
    return false; 
if (n <= 3) 
    return true; 
if (n % 2 == 0 || n % 3 == 0) 
    return false; 
for (int i = 5; i * i <= n; i = i + 6) 
    if (n % i == 0 || n % (i + 2) == 0) 
        return false; 
return true; 
} 
signed main()
{   jaldi
    int x;
    cin>>x;
    if(x==25)
    cout<<"Christmas";
    if(x==24)
    cout<<"Christmas Eve";
    if(x==23)
    cout<<"Christmas Eve Eve";
    if(x==22)
    cout<<"Christmas Eve Eve Eve";
}   

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt(),count=0;
    int[] a=new int[n];
    for(int i=0;i<n;i++) {
    	a[i]=sc.nextInt();
    	if(a[i]==i+1)a[i]=1;
    	else a[i]=0;
    }
    for(int i=0;i<n;i++) {
    	if(a[i]==1) {
    		if(i!=n-1&&a[i+1]==1) {
    			a[i]=0;
    			a[i+1]=0;
    			count++;
    		}else {
    			a[i]=0;
    			count++;
    		}
    	}
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 54292
import sys
sys.setrecursionlimit(10**6)

s = [int(ch) for ch in input()]

ans = [0]*2

for t in range(2):
    tmp = s[:]
    if t == 0:
        for i in range(len(s)-1):
            if i == 0 and tmp[i] == tmp[i+1]:
                tmp[i+1] ^= 1
                ans[t] += 1
            elif i == 0 and tmp[i] != tmp[i+1]:
                pass
            elif tmp[i] == tmp[i+1]:
                tmp[i+1] ^= 1
                ans[t] += 1
    if t == 1:
        for i in range(len(s)-1):
            if i == 0 and tmp[i] == tmp[i+1]:
                tmp[i] ^= 1
                ans[t] += 1
            elif i == 0 and tmp[i] != tmp[i+1]:
                tmp[i] ^= 1
                tmp[i+1] ^= 1
                ans[t] += 2
            elif tmp[i] == tmp[i+1]:
                tmp[i+1] ^= 1
                ans[t] += 1

print(min(ans))

Measured memory_bytes: 11276
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()

	c := scanInts(n)

	ans := 0
	sort.Ints(c)

	for i := 0; i < n; i++ {
		ans = (ans+(n+1-i)*c[i]%mod)%mod
	}

	fmt.Println(ans*modpow(4,n-1)%mod)
}

const mod = 1000000007

func modpow(a,n int) int {
	res := 1
	for n>0 {
		if n&1 == 1 {
			res = res*a%mod
		}
		a = a*a%mod
		n= n>>1
	}
	return res
}


Measured memory_bytes: 4992
fn main(){
    let raw = input();
    let a = raw.parse::<i64>().unwrap();
    println!("{}", a + (a*a) + (a*a*a));
}

fn input() -> String{
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_end().to_string()
}

Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
using namespace std;
const static int LEN=100;
int bubblesort(int a[], int  N)
{
    int num=0;
    for(int i=0;i<N-1;i++){
        for(int j=i+1; j>0; j--){
            if(a[j]<a[j-1]){
                swap(a[j],a[j-1]);
                num++;
            }
        }
    }
    return num;
}
void trace(int a[], int N)
{
    int i;
    for(i=0;i<N-1;i++){
        cout<<a[i]<<" ";
    }
    cout<<a[i]<<endl;
}
int main()
{
    int n;
    cin>>n;
    int a[LEN];
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    int x = bubblesort(a,n);
    trace(a,n);
    cout<<x<<endl;
    return 0;
}



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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define CIN(v) cin >> v;
#define COUT(v) cout << v << "\n";

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

  int H, W, N;

  CIN(H >> W >> N);

  int m = max(H, W);

  int mod = N % m;
  int waru = N / m;

  if (mod == 0) {
    COUT(waru);
  } else {
    COUT(waru + 1);
  }

  return 0;
}


Measured memory_bytes: 256
let rec grading g =
  let s = Scanf.scanf "%d %d %d\n" (fun x y z->(x,y,z)) in
  let grade x = match x with
    (-1,-1,-1) -> g
  | (-1,_,_) | (_,-1,_) -> grading (g^"F\n")
  | (m,f,r) when m+f >= 80 -> grading (g^"A\n")
  | (m,f,r) when m+f >= 65 && m+f < 80 -> grading (g^"B\n")
  | (m,f,r) when m+f >= 50 && m+f < 65 -> grading (g^"C\n")
  | (m,f,r) when m+f >= 30 && m+f < 50 && r >= 50 -> grading (g^"C\n")
  | (m,f,r) when m+f >= 30 && m+f < 50 -> grading (g^"D\n")
  | (m,f,r) when m+f < 30 -> grading (g^"F\n")
  | _ -> ""
  in grade s;;

let () = grading "" |> print_string;;

Measured memory_bytes: 2248
from itertools import product
import sys
input = lambda: sys.stdin.readline().rstrip()
inpl = lambda: list(map(int,input().split()))
N = int(input())
A = [None]*N
xy = [None]*N
for n in range(N):
    A[n] = int(input())
    xy[n] = [(lambda u: (u[0]-1, u[1]))(inpl()) for _ in range(A[n])]
ans = 0
for c in product(range(1,-1,-1), repeat=N):
    if sum(c) <= ans:
        continue
    for i in range(N):
        if c[i]:
            for x, y in xy[i]:
                if c[x] != y:
                    break
            else:
                continue
            break
    else:
        ans = sum(c)
print(ans)

Measured memory_bytes: 51696
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int i,n=s.length();
  int f=1;
  for(i=0;i<n;i++){
    if(s[i]=='7'){
      f=1;
      break;
    }
    else f=0;
  }
  if(f)
    	cout << "Yes" << endl;
  else
    	cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <string>



using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main()
{
    string s,t;
    cin >> s >> t;
    bool res = true;
    rep(i, s.size()) {
        if (s[i] != t[i])
            res = false;
    }
    if (t.size() != s.size() + 1)
        res = false;

    string ress = res ? "Yes" : "No";

    cout << ress << endl;
}


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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  Solver(LL n) : n(n){};

  void solve() {
    vector<int> cnt(4);  //XX, XA, BX, BA
    int ans = 0;
    for (int i = 0; i < n; ++i) {
      string tmp;
      cin >> tmp;
      ans += countAB(tmp);
      int t = 0;
      if (tmp[0] == 'B') t += 2;
      if (tmp.back() == 'A') t += 1;
      cnt[t]++;
    }
    if (cnt[1] == 0 && cnt[2] == 0) {
      ans += max(cnt[3] - 1, 0);
    } else {
      ans += min(cnt[1] + cnt[3], cnt[2] + cnt[3]);
    }

    cout << ans << endl;
  }
  int countAB(string s) {
    int ret = 0;
    for (int i = 0; i < s.size() - 1; ++i) {
      if (s[i] == 'A' && s[i + 1] == 'B') ret++;
    }
    return ret;
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int s,t,H,W;
   for(;;){
       scanf("%d %d",&H,&W);
       if(H==0&&W==0) break;
       for(s=0;s<H;s++){
           for(t=0;t<W;t++){
               printf("#");
           }
           printf("\n");
       }
       printf("\n");
   }
   return 0;
}


Measured memory_bytes: 2048
n,x,y = map(int, input().split())

k = [0]*(n+1)
for i in range(1,n):
    for j in range(i+1,n+1):
        length = min(j-i, abs(x-i)+abs(j-y)+1, abs(y-i)+abs(j-x)+1)
        k[length] = k[length]+1

for i in range(1,n):
    print(k[i])


Measured memory_bytes: 3444
N,P = map(int, input().split())
S = input()

ans = 0
if P == 2:
    for i in range(N-1, -1, -1):
        if int(S[i])%2 == 0:
            ans += i+1
elif P == 5:
    for i in range(N-1, -1, -1):
        if int(S[i])%5 == 0:
            ans += i+1
else:
    L = [0]*P
    num = 0
    for i in range(N-1, -1, -1):
        num += int(S[i])*pow(10, N-1-i, P)
        num %= P
        L[num] += 1

    ans += L[0]
    for i in range(P):
        ans += L[i]*(L[i]-1)//2

print(ans)

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

using namespace std;

const int MOD=1e9+7;

//const int MOD=998244353;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    string s1="ATCG",s2="TAGC";
    
    char a;
    cin>>a;
    
    int pos=s1.find(a);
    cout<<s2[pos];
    
    
}

Measured memory_bytes: 256
' Imports System.Collections.Generic
' Imports System.Globalization
' Imports System.IO
' Imports System.Linq
' Imports System.Text
' Imports System.Text.RegularExpressions

Class Main
    Public Shared Sub Main()
        Dim K, X As Integer
        Dim arr() As String
        arr = Split(Console.ReadLine())
        K = arr(0) : X = arr(1)
        Dim ans As New List(Of Integer)()
        For i As Integer = X - K + 1 To X + K - 1
            ans.Add(i)
        Next
        Console.WriteLine(String.join(" ", ans))
        Return
    End Sub
End Class


Measured memory_bytes: 28720
#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

char buf[20]; int w;
void mypr(int n)
{
	w = 0;
	if (!n) { buf[w++] = '0'; return; }
	while (n) buf[w++] = n%10 + '0', n/=10;
}

#define MAX_N 10000
int f[MAX_N+2];

int main()
{
	int N, i, j, c;

	N = in();
	for (i = 0; i < N; i++) f[in()]++;
	for (i = 0; ; i++) if (c = f[i]) break;
	mypr(i); j = w; while (j--) pc(buf[j]);
	while (--c) { pc(' '); j = w; while (j--) pc(buf[j]); }
	while (++i <= MAX_N) if (c = f[i]) {
		mypr(i); 
		while (c--) { pc(' '); j = w; while (j--) pc(buf[j]); }
	}
	pc('\n');
	return 0;
}



Measured memory_bytes: 2092
#include <iostream>
using namespace std;
static const int N = 50;

int main() {
    int n;
    int d[N];
    int out = 0;

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

    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            out += d[i] * d[j];
        }
    }

    cout << out << endl;

    return 0;
}


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

using namespace std;

int main()
{
    int N, M, tmpA, tmpB;

    cin >> N >> M;

    vector<int> city(N);

    for (int count = 0; count < M; count++)
    {
        cin >> tmpA >> tmpB;
        city.at(tmpA - 1) += 1;
        city.at(tmpB - 1) += 1;
    }
    for (int count = 0; count < N; count++)
    {
        cout << city.at(count) << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;


int main()
{
	int n;
	cin >> n;
	vector<int> cards(n);
	for (int i = 0; i < n; i++) {
		cin >> cards[i];
	}
	sort(cards.begin(), cards.end(), greater<int>());
	int Bob = 0, Alice = 0;
	int i = 0, j = 1;
	while(i < n) {
		Alice += cards[i];
		i += 2;
	}
	while (j < n) {
		Bob += cards[j];
		j += 2;
	}
	cout << Alice - Bob << endl;
	
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  vector<int64_t> v;
  int64_t a = 1;
  if(s.at(0) == '>') v.push_back(0);
  for(int64_t i = 1; i < s.size(); ++i){
    if(s.at(i-1) == s.at(i)) ++a;
    else{
      v.push_back(a);
      a = 1;
    }
  }
  v.push_back(a);
  int64_t r = 0;
  for(int64_t i = 0; i < v.size(); i += 2){
    if(i + 1 < v.size()) r += v.at(i)*(v.at(i)-1)/2 + v.at(i+1)*(v.at(i+1)-1)/2 + max(v.at(i), v.at(i+1));
    else r += v.at(i)*(v.at(i)+1)/2;
  }
  cout << r << endl;
}

Measured memory_bytes: 3068
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;
int main(){

  int n, l[1000], r[1000], ans=0;
  cin >> n;

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

  for(int i=0; i<n; i++){
    ans+=r[i]-l[i]+1;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
///////////////////////////

ll ask(ll n){
    cout<<"? "<<n<<endl;
    fflush(stdout);
    string s;cin>>s;
    if(s[0]=='Y')return 0;
    else return 1;
}
void sayans(ll ans){
    cout<<"! "<<ans<<endl;
    fflush(stdout);
}
bool normal(ll keta){
    ll ok=(ll)powl(10,keta);
    ll ng=(ll)powl(10,keta-1);
    while(abs(ok-ng)>1){
        ll mid=(ok+ng)/2;
        if(ask(mid*10)==0){
            ok=mid;
        }else{
            ng=mid;
        }
    }
    sayans(ok);
    return 0;
}

int main(){fastio
    rep(i,1,10){
        ll t=(ll)powl(10,i);
        ll res=ask(t);
        if(res==1){
            normal(i);
            return 0;
        }
    }
    rep(i,0,9){
        ll t=2*(ll)powl(10,i);
        ll res=ask(t);
        if(res==0){
            sayans(t/2);
            return 0;
        }
    }
    
    return 0;
}


Measured memory_bytes: 1480
import java.util.*;

public class Main{
    
    static int n;
    static List<Integer>[] g;
    static int[] color;
    static int[] cnt;
    
    public static void dfs(int v){
        for(int u : g[v]){
            if(color[u] == -1){
                color[u] = color[v]^1;
                cnt[color[u]]++;
                dfs(u);
            }
        }
    }
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        n = Integer.parseInt(sc.next());
        g = new List[n];
        for(int i=0; i<n; i++){
            g[i] = new ArrayList<>();
        }
        
        for(int i=0; i<n-1; i++){
            int a = Integer.parseInt(sc.next())-1;
            int b = Integer.parseInt(sc.next())-1;
            g[a].add(b);
            g[b].add(a);
        }
        
        cnt = new int[2];
        color = new int[n];
        Arrays.fill(color, -1);
        color[0] = 0;
        cnt[0]++;
        dfs(0);
        
        if(cnt[0] > cnt[1]){
            for(int i=0; i<n; i++){
                color[i] ^= 1;
            }
            cnt[0] = cnt[1];
        }
        
        StringJoiner sj = new StringJoiner(" ");
        int[] p = {1, 2, 3};
        if(cnt[0]<=n/3){
            for(int i=0; i<n; i++){
                if(color[i]==0){
                    sj.add(p[2] + "");
                    p[2] += 3;
                }else{
                    for(int j=0; j<3; j++){
                        if(p[j]<=n){
                            sj.add(p[j] + "");
                            p[j] += 3;
                            break;
                        }
                    }
                }
            }
        }else{
            for(int i=0; i<n; i++){
                if(p[color[i]]<=n){
                    sj.add(p[color[i]] + "");
                    p[color[i]] += 3;
                }else{
                    sj.add(p[2] + "");
                    p[2] += 3;
                }
            }
        }
        
        System.out.println(sj.toString());
    }
}


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

list = map(int, raw_input().split())
W = list[0]
H = list[1]
x = list[2]
y = list[3]
r = list[4]

if (x-r) >= 0 and (y-r) >= 0 and (x+r) <= W and (y+r) <= H:
    print "Yes"
else:
    print "No"

Measured memory_bytes: 6440
#include<iostream>
#include <vector> 
#include <algorithm>
#include<iomanip>
#include<math.h>
#include<string>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
using namespace std;
struct Room {
	int *a;
	int shortest;
	int way;
	int ways;
};
//for (int x = 0; x < N; x++)room[x].a=(int*)malloc(room[x].way * sizeof(int));
int main() {
	long long A, B, V, W, T;
	cin >> A >> V >> B >> W >> T;
	for (long long x = 0; x < T; x++) {
		if (A == B) {
			cout << "YES" << endl;
			return 0;
		}
		if (A > B) {
			A -= V;
			B -= W;
			if (A <= B) {
				cout << "YES" << endl;
				return 0;
			}
		}
		else {
			A += V;
			B += W;
			if (A >= B) {
				cout << "YES" << endl;
				return 0;
			}
		}
	}cout << "NO" << endl;

}

Measured memory_bytes: 3636
A, B = input().split()

# 方針：少数の計算を避け、整数の範囲で計算する
# [A*B] = [A*(100*B)/100]と見る
# Bを100倍して整数に直す操作は、文字列のまま行う
A = int(A)
B = int(B.replace('.', ''))

# 100で割り、小数点を切り捨てる操作は、100で割った商を求めることと同じ
ans = (A*B) // 100
print(ans)

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

int main(){
  long long X;
  cin >> X;
  
  long long money = 100;
  for (int i = 1; ; i++) {
  	money *= 1.01;
    if (money >= X) {
      cout << i << endl;
      break;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3636
n=int(input())
s=list(input())

def rev(x):
    if x=="S":
        return "W"
    else:
        return "S"

def wolfsheep(xy):
    global n,s
    result=[xy[0],xy[1]]

    for i in range(1,n+1):
        s+=s[0]
        if result[i]=="S":
            if s[i]=="o":
                result.append(result[i-1])
            else:
                result.append(rev(result[i-1]))
        else:
            if s[i]=="o":
                result.append(rev(result[i-1]))
            else:
                result.append(result[i-1])

    if result[0]==result[n] and result[1]==result[n+1]:
        return result
    else:
        return 0

#SWパターン
tmp= wolfsheep("SW")
if tmp!=0:
    print("".join(tmp[:-2]))
    exit()

#SSパターン
tmp= wolfsheep("SS")
if tmp!=0:
    print("".join(tmp[:-2]))
    exit()
#WWパターン
tmp= wolfsheep("WW")
if tmp!=0:
    print("".join(tmp[:-2]))
    exit()
#WSパターン
tmp= wolfsheep("WS")
if tmp!=0:
    print("".join(tmp[:-2]))
    exit()

print(-1)

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

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

  if (N.at(0) == '7' || N.at(1) == '7' || N.at(2) == '7') {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}
    


Measured memory_bytes: 3592
#include <stdio.h>
#include <memory.h>
int f[10001][1261];
int main(void){
	int N,M,r,t,n,m,s,q,ts,te,i,j,ans;
	while(1){
		scanf("%d %d",&N,&M);
		if(!N){
			break;
		}
		memset(f,0,sizeof(f));
		scanf("%d",&r);
		for(i=0;i<r;i++){
			scanf("%d %d %d %d",&t,&n,&m,&s);
			f[m][t]+=s?1:-1;
		}
		for(i=1;i<=M;i++){
			for(j=1;j<1261;j++){
				f[i][j]+=f[i][j-1];
			}
		}
		scanf("%d",&q);
		for(i=0;i<q;i++){
			scanf("%d %d %d",&ts,&te,&m);
			ans=0;
			for(j=ts;j<te;j++){
				if(f[m][j]){
					ans++;
				}
			}
			printf("%d\n",ans);
		}
	}
	return 0;
}

Measured memory_bytes: 49868
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
constexpr int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;

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

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

using ld=long double;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	ld ans = 0;
	REP(i, n) {
		int a = i + 1;
		ld p = 1;
		while (a < k) {
			p /= 2;
			a *= 2;
		}
		ans += p / n;
	}
	cout << fixed << setprecision(12) << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
lst = map(int, input().split())

count = [0 for i in range(10**5+1)]
for i in lst:
    count[i]+=1

ans = 0
for i in range(10**5-1):
    ans = max(ans, count[i]+count[i+1]+count[i+2])
print(ans)


Measured memory_bytes: 10764
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

int main() {
  string s, t;
  cin >> s >> t;
  vector<vector<int>> poss(26, vector<int>());

  // 各文字の出現位置の表を作る
  rep(i, s.size()) {
    poss[s[i] - 'a'].push_back(i);
  }

  ll ans = 0;
  ll pos = -1;
  rep(i, t.size()) {
    auto v = &(poss[t[i] - 'a']);
    // 前の文字を見つけた位置より後を探す
    auto itr = upper_bound(v->begin(), v->end(), pos);
    // 見つからなかったら先頭から探す
    if (itr == v->end()) {
      itr = upper_bound(v->begin(), v->end(), -1);
      // それでも見つからなければ -1
      if (itr == v->end()) {
        cout << -1 << endl;
        return 0;
      }
      // 先頭に戻ったので答えに |s| を足す
      ans += s.size();
    }
    pos = *itr;
  }

  // 最後の文字を見つけた位置を足す（答えは1オリジンなので +1）
  ans += (pos + 1);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1216
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main(void) {
	int a[100], n, i, j;
	while (scanf("%d", &n), n != -1) {
		if (n < 4)printf("%d\n", n);
		else {
			for (i = 0; n != 0; i++) {
				a[i] = n % 4;
				n /= 4;
			}
			for (j = i - 1; j >= 0; j--)printf("%d", a[j]);
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 604
#include <cstdio>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <time.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <memory.h>
#include <cstdlib>
#include <queue>
#include <iomanip>
#define P pair<int, int>
#define LL long long
#define LD long double
#define PLL pair<LL, LL>
#define mset(a, b) memset(a, b, sizeof(a))
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI acos(-1.0)
#define random(x) rand() % x
using namespace std;
const int inf = 0x3f3f3f3f;
const LL __64inf = 0x3f3f3f3f3f3f3f3f;
const int MAX = 1e5 + 5;
const int Mod = 1e9 + 7;

int main()
{
    LL n, m;
    cin >> n >> m;
    vector<PLL> A(n);
    rep(i, n){
        cin >> A[i].first >> A[i].second;
    }
    sort(A.begin(), A.end(), [](const P &a, const P &b){
        return a.first < b.first;
    });
    LL ret = 0;
    for(int i = 0; m && i < n; i++){
        LL tmp = min(m, A[i].second);
        ret += tmp * A[i].first;
        m -= tmp;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 1792
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
s=0
for i in range(N):
    s+=B[A[i]-1]
    if A[i]-A[i-1]==1 and i>0:
        s+=C[A[i]-2]
print(s)

Measured memory_bytes: 9124
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;


int main(){
  string s;
  cin>>s;
  if(s[0]==s[2])cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, ai, mx = -10000000, mn = 10000000, sum = 0;
    cin >> n;
    REP(i, n)
    {
        cin >> ai;
        mx = max(mx, ai);
        mn = min(mn, ai);
        sum += ai;
    }
    printf("%lld %lld %lld\n", mn, mx, sum);
    return 0;
}


Measured memory_bytes: 3240
n = int(input())
a = sorted(map(int, input().split()))

x = 0

for i in range(n-1):
    if a[i] == a[i+1]:
        x += 1
        break
    else:
        x += 0
        
if x == 0:
    print('YES')
else:
    print('NO')

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

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define sizeOf(A) (sizeof(A))/(sizeof(A[0]))
#define odd(x) ((x) % (2))
#define fastio ios_base::sync_with_stdio(false), cin.tie(0);
#define fileio freopen("template.in", "r", stdin), freopen("template.out", "w", stdout);
typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
    fastio;
    //fileio;
    
    int n;
    cin >> n;
    int A[n];
    FOR(i, 0, n) {cin >> A[i];}
    int count = 0;
    FOR(i, 0, n) {
        if (!odd(i) && odd(A[i])) {
            count++;
        }
    }
    cout << count << "\n";
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long K, long long X){
	if (500*K >= X) cout << "Yes" << endl; else cout << "No" << endl;
}

int main(){	
	long long K;
	long long X;
	scanf("%lld",&K);
	scanf("%lld",&X);
	solve(K, X);
	return 0;
}



Measured memory_bytes: 256
n, m = map(int, input().split())
a_list = []
b_list = []

for i in range(m):
    a, b = map(int,input().split())
    a_list.append(a)
    b_list.append(b)

for i in range(1,n+1):
    cnt = 0
    for j in range(m):
        if a_list[j] == i or b_list[j] == i:
            cnt += 1
    print(cnt)

Measured memory_bytes: 3060
n = int(input())
v = [[tuple(map(int, input().split()))for i in range(int(input()))]
     for i in range(n)]

ans = 0
for i in range(2**n):
    f = True
    a = 0
    for j in range(n):
        if (i >> j) & 1:
            if all(i >> (x - 1) & 1 == y for x, y in v[j]):
                a += 1
            else:
                f = False
                break
    if f:
        ans = max(ans, a)
print(ans)


Measured memory_bytes: 9136
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def bs(ar,eq,n) en=(eq==1 ? :>= : :>); ar.bsearch_index{|x|x.send(en,n)} end
def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
s = gs.chars
puts(s==s.uniq ? 'yes' : 'no')

Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long int ll;
typedef unsigned long long ull;
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;}
typedef pair<ll,ll> P;


int main()
{
    int n,x;
    cin >> n >> x;
    int pre;
    cin >> pre;
    int ans = abs(x-pre);
    rep(i,n-1)
    {
        int a;
        cin >> a;
        ans = __gcd(ans,abs(a-pre));
        pre = a;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  
  string A, B, C;
  cin >> A >> B >> C;

  int a = A.size() - 1;
  int b = B.size() - 1;
  
  if (A.at(a) == B.at(0) && B.at(b) == C.at(0)) {
    cout << "YES" <<endl;
  }
  else {
    cout << "NO" <<endl;
  }
  
return 0;
}

Measured memory_bytes: 3576
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
//#define ll long long
#define ull  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 340000;
int mod = 1e9 + 7;
int a[N], s[N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    for (int i =1; i <= n; i++){
        cin >> a[i];
        s[i] = s[i - 1] + a[i];
    }
    int ans = 1e17;
    for (int i = 1; i < n; i++){
        int x = s[i];
        int y = s[n] - s[i];
        ans = min(ans, abs(x - y));
    }
    cout << ans;
}


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

using Lint=long long;

int main()
{
   int N; cin>>N;
   vector<vector<int>> score(N,vector<int>(N));
   for(int i=0;i<N;i++) for(int j=0;j<N;j++) cin>>score[i][j];

   vector<Lint> dp(1<<N);
   for(int S=1;S<(1<<N);S++){
      for(int i=0;i<N;i++) for(int j=i+1;j<N;j++){
         if(S>>i&1 and S>>j&1) dp[S]+=score[i][j];
      }
      for(int T=(S-1)&S;T>0;T=(T-1)&S){
         dp[S]=max(dp[S],dp[T]+dp[S^T]);
      }
   }
   cout<<dp[(1<<N)-1]<<endl;
   return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

int main(){
	int n;
	int a[2000001];
	cin >> n;
	for(int i=0;i<n;i++) cin >> a[i];

	int m=0;
	for(int i=0;i<n;i++){
		if(a[m]<a[i]) m=i;
	}
	sort(a,a+n);
	reverse(a,a+n);

	for(int i=0;i<n;i++){
		if(i!=m) cout << a[0] << endl;
		else cout << a[1] << endl;
	}

	return 0;
}


Measured memory_bytes: 4224
#define MAXSIZE 1000
 
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
 
char init_str[MAXSIZE]={};
 
 
int main()
{
    char str[MAXSIZE];
    int sum;
 
    while(1){
        strcpy(str,init_str);
        scanf("%s",&str);
        if((int)(str[0]-'0')!=0){
            sum=0;
            for(int i=0;(i<MAXSIZE&&(str[i]!='\0'));i++){
                sum += (int)(str[i]-'0');
            }
            cout << sum << endl;
        }
        else break;
    }
    return 0;
}


Measured memory_bytes: 3244
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define v(T) vector<T>
#define p(T, N) pair<T, N>
#define tp(A, B, C) tuple<A, B, C>
#define ii p(int, int)
#define vi v(int)
#define vii v(p(int, int))
#define vvi v(v(int))
#define vl v(long long)
#define vll v(p(long long, long long))
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> a, pair<int, int> b){return a.se < b.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define pt(a, b, c) emplace_back(make_tuple(a, b, c))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; ++i)
#define foris(i, a, b) for(ll i = a; i < b; ++i)
#define forise(i, a, b) for(ll i = a; i <= b; ++i)
#define ford(i, n) for(ll i = n; i >= 0; --i)
#define fords(i, a, b) for(ll i = a; i >= b; --i)
#define fordse(i, a, b) for(ll i = a; i > b; --i)
#define fora(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define digits(i) (int)((log(i)/(log(10))+1)
#define umap unordered_map
#define uset unordered_set
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;

int N, L;
vi apples;

int main() {
  io();
  
  int mi = 0;
  cin >> N >> L;
  fori(i, N) {
    int a = L + i;
    apples.pb(a);
    if(abs(apples[i]) < abs(apples[mi])) mi = i;
  }
  apples.erase(apples.begin() + mi);
  int t = 0;
  fori(i, N-1) {
    t += apples[i];
  }
  cout << t;
  
  return 0;
}

Measured memory_bytes: 256
//include <bits/stdc++.h>
// Headder {{{
#pragma GCC optimize("O3")
#include <complex>
#include <cstdint>
#include <iostream>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <climits>
// }}}
using namespace std;
#define int long long
#define read cin >>
#define echo cout <<
#define fin << '\n'
#define _ << ' ' <<
#define in :
#define var auto&&
#define let const auto

/*
#########################################################
#                                                       #
#    ##      ##### #   # ####  ##### #   # ##### ####   #
#   # #        #   ##  # #   # #      # #  #     #   #  #
#     #   --   #   # # # #   # #####   #   ##### #   #  #
#     #        #   #  ## #   # #      # #  #     #   #  #
#   #####    ##### #   # ####  ##### #   # ##### ####   #
#                                                       #
#########################################################
*/
// {{{ BinaryIndexedTree
struct BinaryIndexedTree {

    vector<int> data;
    int size = 500500;

    BinaryIndexedTree ( ) {
        size = 500500;
        this->data.resize(size);
    }

    void add ( int pos, int value ) {
        for ( int i = pos; i <= size; i += i & -i ) {
            data[i] += value;
        }
    }

    // [1, pos]
    int getSum ( int pos ) {
        int sum = 0;
        for ( int i = pos; i > 0; i -= i & -i ) {
            sum += data[i];
        }
        return sum;
    }

    // [begin, end]
    int getSum ( int begin, int end ) {
        if ( begin == 1 ) return getSum(end);
        return getSum(end) - getSum(begin-1);
    }
};
// }}};

BinaryIndexedTree bit[32];

signed main ( ) {

    int n;
    string s;
    read n >> s;
    for ( int i = 0; i < n; i++ ) {
        bit[s[i]-'a'].add(i+1, 1);
    }
    int q;
    read q;
    for ( int i = 0; i < q; i++ ) {
        int t;
        read t;
        if ( t == 1 ) {
            int pos;
            char c;
            read pos >> c;
            bit[s[pos-1]-'a'].add(pos, -1);
            s[pos-1] = c;
            bit[c-'a'].add(pos, 1);
        }
        else {
            int begin, end;
            read begin >> end;
            int cnt = 0;
            for ( int i = 0; i <= 'z'-'a'; i++ ) {
                cnt += !!bit[i].getSum(begin, end);
            }
            echo cnt fin;
        }
    }

    return 0;
}

Measured memory_bytes: 127488
// Rustで競技プログラミングの入力をスッキリ記述するマクロ
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8

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 solve(k: usize, v: Vec<i64>) {
    let comb = {
        let mut i = 0;
        let mut ret = vec![]; // (start, end)
        while let Some(n) = v.get(i + k - 1) {
            ret.push((v.get(i).unwrap(), n));
            i += 1;
        }
        ret
    };
    let ans = {
        let c = |start: i64, end: i64| -> i64 {
            std::cmp::min(
                start.abs() + (end - start).abs(),
                end.abs() + (end - start).abs(),
            )
        };
        let mut ret = std::i64::MAX;
        for &(&start, &end) in comb.iter() {
            let cost = c(start, end);
            if cost < ret {
                ret = cost;
            }
        }
        ret
    };
    println!("{:?}", ans);
}

fn main() {
    input! {
        n: usize,
        k: usize,
        v: [i64; n]
    };
    solve(k, v);
}


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

#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[n]; rep(i,n){ gets(x[i]);}
#define ll long long
typedef pair<int, int> P;

int main(){
  string T, S;
  cin >> S >> T;
  int len = S.size()-1, i = 0;
  while (i < len + 1) {
    if (S == T) {
      cout << "Yes" << endl;
      exit(0);
    }
    char target = S[len];
    S.pop_back();
    S = target + S;
    i += 1;
  }
  cout << "No" << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

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

    int bs = count(s.begin(), s.end(), '#');
    int ws = count(s.begin(), s.end(), '.');

    int bcnt = 0;
    int ans = ws;

    for (int i = 0; i < n; ++i) {
        if (s[i] == '#') ++bcnt;
        ans = min(ans, bcnt+(ws - ((i+1) - bcnt)));
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 640
import Data.List
import Data.Array

erst :: Int->([Int],[Int])->[Int]
erst nmax (tosearch, primes)
    | x*x >= nmax  = sort $ primes' ++ tosearch'
    | otherwise    = erst nmax (tosearch', primes')
    where
        x = head tosearch
        tosearch' = [n|n<-(tail tosearch),(n`mod`x)/=0]
        primes' = primes ++ [x]

nmax = 50000
primes = erst nmax (filter odd [3..nmax], [2])
primes_b :: Array Int Bool
primes_b =  array (1,nmax) $ map (\i->(i,elem i primes)) [1..nmax]

solve::Int->Int
solve dat -- 4<=dat<=50000
    | odd dat    = if primes_b!(dat-2) then 1 else 0
    | otherwise  = length $ [n| n<-primes, n<=(dat-n) && primes_b!(dat-n)]

main::IO ()
main = do
    str<-getContents::IO String
    let input = takeWhile (/=0) . map (\x->read x::Int) . lines $ str
    mapM_ print $ map solve input

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

string s;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> s;
	if (s.size()>=4&&s[0]=='Y'&&
	s[1]=='A'&&s[2]=='K'&&s[3]=='I'){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod=1000000007;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
void YN(bool flg){cout<<(flg?"YES":"NO")<<endl;}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<endl;}
void yn(bool flg){cout<<(flg?"yes":"no")<<endl;}
signed main(){
	int M;cin>>M;
	cout<<48-M<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<static_cast<int>(n);++i)
#define per(i, n) for(int i=static_cast<int>(n)-1;i>=0;--i)
#define eee(a) (cerr<<(#a)<<": "<<(a)<<'\n');
#define ppp(a) (cout<<(a)<<'\n'); 
#define cop(a) for(auto x:(a)){cerr<<(x)<<'\n';}
using ll = long long;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll inverse(ll n,ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}
template<class T>inline bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename T1,typename T2>ostream& operator<<(ostream& s,const pair<T1, T2>& p){return s <<"("<<p.first<<", "<<p.second<<")";}
template<typename T> ostream& operator<<(ostream& s,const vector<T>& v){s<<'[';for(size_t i=0;i<v.size();++i){s<<v[i];if(i<v.size()-1)s<<", ";}s<<']';return s;}

int main(){
    cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    
    
    int n;
    cin >> n;
    rep(i, n){
        int a;
        cin >> a;
        if(a%2 == 0){
            if(a%3 != 0 and a%5 != 0){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;
using ll = long long;

int main(void) {
    string N;
    cin >> N;
    for (int i = 0; i < 3; i++)
    {
        if(N[i] == '7'){
            cout << "Yes"<<endl;
            return 0;
        }
    }

    cout <<"No"<<endl;
    
    return 0;
}


Measured memory_bytes: 3628
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

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

    int N, T, A;
    cin >> N >> T >> A;
    vector<double> temp(N);
    rep(i, N) {
        double h;
        cin >> h;
        temp[i] = T - h * 0.006;
    }

    double diff = 1e9;
    int ans = -1;

    rep(i, N) {
        if (diff > abs(A - temp[i])) {
            diff = abs(A - temp[i]);
            ans = i + 1;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3860
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<numeric>
#include<map>
using namespace std;

#define R(i,s,n) for(int i=s;i<n;i++)
#define D(i,n,s) for(int i=n-1;i>=s;i--)
typedef pair<int,int> P;

int main() {
  int n;
  while (cin >> n && n) {
    int a[n];
    R(i,0,n) {
      cin >> a[i];
    }
    int ans = 1e+6;
    R(i,0,n-1) {
      R(j,i+1,n) {
        int tmp = abs(a[i]-a[j]);
        ans = min(tmp, ans);
      }
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3096