akhauriyash/Code-Regression huggingface dataset:
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

func main() {
	N := getInt()
	S := getString()

	if N == 1 {
		fmt.Println("No")
		return
	}

	if S[:N/2] == S[N/2:] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

type Graph struct {
	n     int
	edges [][]int
}

func NewGraph(n int) *Graph {
	g := &Graph{
		n:     n,
		edges: make([][]int, n),
	}
	return g
}

func (g *Graph) AddEdge(u, v int) {
	g.edges[v] = append(g.edges[v], u)
	g.edges[u] = append(g.edges[u], v)
}

func dfs(c int, edges [][]int, visited map[int]struct{}) {
	visited[c] = struct{}{}

	for _, v := range edges[c] {
		_, flag := visited[v]
		if flag {
			continue
		}
		dfs(v, edges, visited)
	}
}

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func powMod(n, p int) int {
	if p == 0 {
		return 1
	} else if p%2 == 0 {
		t := powMod(n, p/2)
		return calcMod(t * t)
	} else {
		return calcMod(n * powMod(n, p-1))
	}
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray)-1])
}

func calcMod(x int) int {
	return x % mod
}

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

func isPrime(n int) bool {
	if n < 2 {
		return false
	} else if n == 2 {
		return true
	} else if n % 2 == 0 {
		return false
	}

	sqrtN := int(math.Sqrt(float64(n)))
	for i := 3; i <= sqrtN; i += 2 {
		if n % i == 0 {
			return false
		}
	}

	return true
}


Measured memory_bytes: 640
#include <bits/stdc++.h>                                                                 
using namespace std;                                                             
string a,b;                    
int main(){                                                                            
	cin>>a;
	b=a;
	reverse(a.begin(),a.end());
	for(int i=0;i<a.size();++i){
        if(a[i]=='b') a[i]='d';                                                                               
        else if(a[i]=='d') a[i]='b';
        else if(a[i]=='p') a[i]='q';
        else  a[i]='p';
    }                                                   
    if(a==b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;                    
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int n;
queue<pair<int,int> > q;
vector<int> v; 
bool vis[100100];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	int seed=1;
	v.push_back(seed);
	seed*=6;
	while(seed<=n){
		v.push_back(seed);
		seed*=6;
	}
	seed=9;
	while(seed<=n){
		v.push_back(seed);
		seed*=9;
	}
	q.push(make_pair(0,0));
	while(!q.empty()){
		int x=q.front().first;
		int stp=q.front().second;
		q.pop();
		if(vis[x])
			continue;
		vis[x]=true;
		if(x==n){
			cout<<stp<<endl;
			return 0;
		}
		for(int i=0;i<v.size();i++){
			if(v[i]+x<=n){
				q.push(make_pair(v[i]+x,stp+1));
			}
		}
	}
	return 0;
}


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

using namespace std ;

#define N 200007

int tot , n ;
int nex[2*N] , fire[N] , to[2*N] , sg[N] ;

void add(int u , int v){
    nex[++tot] = fire[u] ;
    fire[u] = tot ;
    to[tot] = v ;
    return ;
}

void dfs(int x , int fr){
    for(int i = fire[x] ; i ; i = nex[i] ){
        int v = to[i] ;
        if( v == fr ) continue ;
        dfs( v , x ) ;
        sg[x] ^= ( sg[v] + 1 ) ;
    }
    return ;
}

int main()
{
    scanf("%d" , &n ) ;
    for(int i = 1 ; i <= n - 1 ; i++ ){
        int u , v ;
        scanf("%d%d" , &u , &v ) ;
        add( u , v ) ; add( v , u ) ;
    }
    dfs( 1 , 0 ) ;
    if( sg[1] ) printf("Alice\n") ;
    else printf("Bob\n") ;
    return 0 ;
}

Measured memory_bytes: 8192
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int main()
{
    int H,W,K;
    char c[7][7];
    
    cin >> H >> W >> K;
    for (int i = 0;i < H;i++){
        for (int j = 0;j < W;j++){
            cin >> c[i][j];
        }
    }
    
    int ans = 0;
    for (int i = 0;i < (1<<H);i++){
        for (int j = 0;j < (1<<W);j++){
            int res = 0;
            for (int k = 0;k < H;k++){
                for (int l = 0;l < W;l++){
                    if (((i>>k)%2) && ((j>>l)%2) && c[k][l] == '#'){
                        res++;
                    }
                }
            }
            if (res == K){
                ans++;
            }
        }
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 3516
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int k;
    ll a[112345];

    cin >> k;

    a[0] = 1;
    REP(i, k)
    cin >> a[i + 1];

    if (a[k] != 2)
    {
        cout << -1 << endl;
        return 0;
    }

    ll l = 2, r = 2;

    for (int i = k; i > 0; i--)
    {
        if (l % a[i] && r % a[i] && (l / a[i] - r / a[i]) == 0)
        {
            cout << -1 << endl;
            return 0;
        }

        l = ((l / a[i - 1]) * a[i - 1] + (l % a[i - 1] > 0) * a[i - 1]);
        r = (((r + a[i] - 1) / a[i - 1]) * a[i - 1]);

        if (l > r)
        {
            cout << -1 << endl;
            return 0;
        }

        if (r < a[i])
        {
            cout << -1 << endl;
            return 0;
        }

        /*
        if (l < r && l % a[i] && r % a[i] && (r / a[i] - l / a[i] == 0))
        {
            cout << -1 << endl;
            return 0;
        }
        */
    }

    cout << l << " " << r << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#define SIZE 10005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

ll C[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%lld",&C[i]);
	for(int i=0;i<n;i++)
	{
		int b;
		scanf("%d",&b);
		C[i]=b-C[i];
	}
	ll t=0;
	for(int i=0;i<n;i++) t+=C[i];
	ll all=t;
	for(int i=0;i<n;i++)
	{
		if(C[i]<0)
		{
			t+=C[i];
			C[i]=0;
		}
	}
	for(int i=0;i<n;i++)
	{
		if(C[i]%2==1)
		{
			C[i]++;
			t--;
		}
	}
	if(t<0)
	{
		puts("No");
		return 0;
	}
	ll mn=0;
	for(int i=0;i<n;i++)
	{
		mn+=C[i]/2;
	}
	if(mn>all) puts("No");
	else puts("Yes");
	return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace ABC089
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var N = ss.Next(Int);
            var S = ss.Next(s => s[0], N);

            var gc = S
                .Where(c => c == 'M' || c == 'A' || c == 'R' || c == 'C' || c == 'H')
                .GroupBy(c => c)
                .Select(g => g.Count())
                .ToArray();

            if (gc.Length <= 2)
            {
                sw.WriteLine(0);
                return;
            }

            var res = 0L;

            for (var i = 0; i <= gc.Length - 3; i++)
            {
                for (var j = i + 1; j <= gc.Length - 2; j++)
                {
                    for (var k = j + 1; k <= gc.Length - 1; k++)
                    {
                        res += (long)gc[i] * gc[j] * gc[k];
                    }
                }
            }

            sw.WriteLine(res);
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
        static readonly Func<string, int> Int = int.Parse;
        static readonly Func<string, long> Long = long.Parse;
        static readonly Func<string, double> Double = double.Parse;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}

Measured memory_bytes: 18516
from collections import Counter
N, K = map(int, input().split())
A = list(map(int, input().split()))

ca = Counter(A)
ca = sorted(ca.items(), key=lambda x:x[1], reverse=True)

ans = 0
for i in range(min(K, len(ca))):
    ans += ca[i][1]

print(N-ans)

Measured memory_bytes: 129788
#include<stdio.h>
int main(){
  int N, M;
  scanf("%d %d", &N, &M);
  int A[10001];

  for(int i=0; i<M; i++){
    scanf("%d", &A[i]);
    //printf("%d", A[i]);
  }
  int sum = 0;
 for(int j=0; j<M;j++){
   sum +=A[j];
 }
 if(sum <=  N){
   printf("%d\n", N - sum);
 }else{
   printf("-1\n");
 }
  return 0;
}

Measured memory_bytes: 1752
#include <cstdio>
#define mod 1000000007

int v[101000]; 
int sum[101000];
int inv[101000], fac[101000];

int main()
{
	inv[0] = inv[1] = fac[0] = 1;
	for(int i = 2; i <= 100000; i++) inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
	for(int i = 1; i <= 100000; i++) sum[i] = (sum[i - 1] + inv[i]) % mod;
	for(int i = 1; i <= 100000; i++) fac[i] = 1ll * fac[i - 1] * i % mod;
	int n; scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &v[i]);
	int ans = 0;
	for(int i = 1; i <= n; i++)
	{
		ans = (ans + 1ll * (sum[i] + sum[n - i + 1] - 1) * v[i]) % mod;
	}
	printf("%lld\n", 1ll * ans * fac[n] % mod);
	return 0;
}

/*
P(i,j)表示当i被删除时，i,j在同一个连通块中的概率 
在删除序列中，i+1~j（或j~i-1）都必须在i之后被删除
由于删除序列均匀随机，所以考虑把i插到i+1~j(或j~i-1)的序列中
有|i-j|+1个空，只有插到第1个空有贡献，所以P(i,j)=1/(|i-j|+1)
ans = n! * ∑i∑j P(i,j)*v[j]
	= n! * ∑j(∑i P(i,j))*v[j]
把1/i拿去前缀和 
*/

Measured memory_bytes: 1792
h,w,d = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
q = int(input())
lr = [list(map(int, input().split())) for _ in range(q)]
b = [0]*(h*w+1)
for i in range(h):
    for j in range(w):
        b[a[i][j]] = (i,j)
#print(b)
ans = [0]*(h*w+1)
for i in range(d+1,h*w+1):
    ans[i] = ans[i-d]+abs(b[i][0]-b[i-d][0])+abs(b[i][1]-b[i-d][1])
#print(ans)
for i in range(q):
    x,y = lr[i][0],lr[i][1]
    print(ans[y]-ans[x])

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

const int INF = 1LL << 60;

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

  int a,b,q; cin >> a >> b >> q;
  vector<int> s(a),t(b);
  for(int i = 0; i < a; i++){
    cin >> s[i];
  }
  for(int i = 0; i < b; i++){
    cin >> t[i];
  }
  s.insert(s.begin(),-INF);
  t.insert(t.begin(),-INF);
  s.push_back(INF);
  t.push_back(INF);

  for(int i = 0; i < q; i++){
    int x; cin >> x;
    int ans = 1LL << 60;

    auto sr = lower_bound(s.begin(),s.end(),x);
    auto p = lower_bound(t.begin(),t.end(),*sr);
    ans = min(ans,abs(*sr - x) + min(abs(*sr - *p),abs(*sr - *(p--))));

    sr--;
    p = lower_bound(t.begin(),t.end(),*sr);
    ans = min(ans,abs(*sr - x) + min(abs(*sr - *p),abs(*sr - *(p--))));

    auto tr = lower_bound(t.begin(),t.end(),x);
    p = lower_bound(s.begin(),s.end(),*tr);
    ans = min(ans,abs(*tr - x) + min(abs(*tr - *p),abs(*tr - *(p--))));

    tr--;
    p = lower_bound(s.begin(),s.end(),*tr);
    ans = min(ans,abs(*tr - x) + min(abs(*tr - *p),abs(*tr - *(p--))));

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 2912
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll cnt[1010];
int main()
{
	int N;
	cin >> N;
	for (int num = 2; num <= N; num++) {
		int tmp = num;
		for (int i = 2; i <= num; i++) {
			while (tmp % i == 0) {
				//cout << tmp << " " << i << endl;
				tmp /= i;
				cnt[i]++;
			}
		}
	}
	ll ans = 1;
	for (int i = 2; i <= N; i++) {
		if (cnt[i] != 0) ans = (ans * (cnt[i] + 1)) % mod;
	}
	cout << ans << endl;
}


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

using namespace std;
using Int = long long;

signed main(){
    Int n, m;
    cin >> n >> m;
    vector<vector<Int>> k_s;
    vector<Int> p;
    for (Int i = 0; i < m; i++){
        Int tmp_k;
        cin >> tmp_k;
        vector<Int> tmp_vs;
        tmp_vs.push_back(tmp_k);
        for (Int j = 0; j < tmp_k; j++){
            Int tmp_s;
            cin >> tmp_s;
            tmp_vs.push_back(tmp_s);
        }
        k_s.push_back(tmp_vs);
    }
    for (Int i = 0; i < m; i++){
        Int tmp_p;
        cin >> tmp_p;
        p.push_back(tmp_p);
    }

    Int ans = 0;
    for (Int i = 0; i < pow(2, n); i++){
        bitset<10> switches = static_cast<bitset<10>>(i);
        bool light_on = true;
        for (Int j = 0; j < m; j++){
            Int tmp = 0;
            for (Int k = 1; k <= k_s[j][0]; k++){
                if (switches[k_s[j][k] - 1]) tmp += 1;
            }
            if (tmp % 2 != p[j]){
                light_on = false;
                break;
            }
        }
        if(light_on) ans += 1;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long int
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,a,b) for(int i=a;i<b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define  vi vector<int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define in cin>>
#define out cout<<
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
void printArray(int arr[],int n)
{
   for(int i=0;i<n;i++)cout<<arr[i]<<' ';
}
void printMp(mp m)
{
  mp ::iterator it;
  for(it=m.begin();it!=m.end();it++)cout<<it->first<<' '<<it->second<<endl;
}
void printUmp(ump m)
{
  ump ::iterator it;
  for(it=m.begin();it!=m.end();it++)cout<<it->first<<' '<<it->second<<endl;
}
void printSt(st s)
{
  st ::iterator it;
  for(it=s.begin();it!=s.end();it++)cout<<*it<<' ';
}
void printMst(mst s)
{
  mst ::iterator it;
  for(it=s.begin();it!=s.end();it++)cout<<*it<<' ';
}
void printVec(vector<int>v)
{
for(int i=0;i<v.size();i++)cout<<v[i]<<' ';
}
void printVec2(vector<int>v[],int n)
{
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<v[i].size();j++)
            cout<<v[i][j]<<' ';
        cout<<endl;
    }
}
 set<pair<int,int>> primeset;
void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
        for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          primeset.insert(mkp(p,1));
}
int32_t main()
{
fastio;
double n;
in n;
double k;in k;
cout<<ceil(n/(2*k+1));

    return 0;
}


Measured memory_bytes: 256
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()
dd= defaultdict(int)
for _ in range(n):
    dd[input()]+=1

print("AC x", dd["AC"])
print("WA x", dd["WA"])
print("TLE x", dd["TLE"])
print("RE x", dd["RE"])


Measured memory_bytes: 70116
R, C = map(int, raw_input().split())
chart = []
for r in range(R):
    row = map(int, raw_input().split())
    chart.append(row)
col = [0] * C
for r in range(R):
    row = chart[r]
    row.append(sum(row))
    print ' '.join(map(str, row))
    for c in range(C):
        col[c] += row[c]
for c in range(C):
    print col[c],
print sum(col)

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

using namespace std;
typedef long long ll;

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)

string str = "abcdefghijklmnopqrstuvwxyz";


int main()
{
   ll n;
   cin >> n;
   n--;
   string s;
   while(1){
     ll sho = n/26;
     int amari = n-sho*26;
     s = str[amari]+s;
     if(sho==0){
       break;
     }
     else{
      n = sho-1;
     }
   }

   cout << s << endl;

   return 0;
}


Measured memory_bytes: 3624
a = [list(map(int,input().split())) for _ in range(3)]
for i in range(int(input())):
  b = int(input())
  for j in range(3):
    for k in range(3):
      if a[j][k]==b:a[j][k]=0
ans="No"
for i in range(3):
  if a[i][0]==a[i][1]==a[i][2]==0:ans="Yes"
  if a[0][i]==a[1][i]==a[2][i]==0:ans="Yes"
if a[0][0]==a[1][1]==a[2][2]==0:ans="Yes"
if a[2][0]==a[1][1]==a[0][2]==0:ans="Yes"
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define INF 1e9
#define pb push_back
#define mp  make_pair
#define loop(a,n) for(long long i=a;i<n;i++)
#define vil vector<long long int>
#define vi vector<int>
#define sz(v) v.size()
#define setbits(x)          __builtin_popcountll(x)
#define ff first
#define ss second
using namespace std;

int nCrevenoroddfinder(int n,int r)
{
    int a=r;
    int b=n-r;
    for(int i=0;i<30;i++)
    {
        int x=1<<i;
        if((x&a)&&(x&b))
        {
            return 0;//even
        }
    }
    return 1;//odd
}

ll gcd(ll a, ll b) {
  if (a == 0)return b;
  return gcd(b % a, a);
}
bool isperfect(ll n) {
  ll y = sqrt(n);
  if (n % y == 0 && y * y == n)return true;
  return false;
}
bool comp(pair<int,int> a, pair<int,int> b) {
    if(a.first == b.first) return a.second>b.second;
  return a.first < b.first;
}
 ll powi(ll a, ll b) {
  ll ans = 1;
  while (b > 0) {
    if (b & 1)ans = (ans * a);
    b = b >> 1;
    a = (a * a);
  }
  return ans;
}
bool isprime(ll n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)return false;
  }
  return true;
}
bool prime[10000000];
void seive() {

  prime[1] = true;
  for (int i = 2; i * i < 10000000; i++) {

    if (prime[i])continue;
    for (int j = i * i; j < 10000000; j += i) {
      prime[j] = true;
    }

  }
}

int main()
{
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  ll n,m;cin>>n>>m;
  ll x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  string s[n];
  for(int i=0;i<n;i++) cin>>s[i];
  ll dp[n+1][m+1];
  
  for(int i=0;i<n+1;i++){
      for(int j=0;j<=m;j++) dp[i][j]=INF;
  }dp[x1][y1]=0;
  pair<ll,ll> dir[4]={{1,0},{0,1},{-1,0},{0,-1}};
  map<pair<ll,ll>,bool> mp;
  deque<pair<ll,ll>> q;
  q.push_front({x1,y1});
  mp[{x1,y1}]=true;
  ll mini=0;ll f=0;
  //cout<<x1<<x2;
  while(!q.empty()){
      pair<ll,ll> p=q.front();
      q.pop_front();
      if(p.ff==x2&&p.ss==y2){
          f=1;
          break;
      }

      for(int i=0;i<4;i++){
          ll x=p.ff+dir[i].ff;
          ll y=p.ss+dir[i].ss;
          if(x<1||y<1||x>n||y>m) continue;
          
          if(s[x-1][y-1]=='.'&&dp[x][y]>dp[p.ff][p.ss]){
              q.push_front({x,y});
              mp[{x,y}]=true;
              dp[x][y]=dp[p.ff][p.ss];
          }
      }
              ll x=p.ff,y=p.ss;
              ll lx=min(1ll,x-2);
              ll rx=min(n,x+2);
              ll ly=min(1ll,y-2);
              ll ry=min(m,y+2);
              for(int i=x-2;i<=x+2;i++){
                    for(int j=y-2;j<=y+2;j++){
                                        if(i<1||j<1||i>n||j>m) continue;
                            if(s[i-1][j-1]=='.'&&dp[i][j]>dp[p.ff][p.ss]+1){
                                 q.push_back({i,j});
                                 mp[{i,j}]=true;
                                 mini++;
                                 dp[i][j]=dp[p.ff][p.ss]+1;
                            }
                    }
              }
  }
  if(f==0) mini=-1;
  else mini=dp[x2][y2];
  cout<<mini;
}



  

Measured memory_bytes: 38448
// ---------- begin scannner ----------
#[allow(dead_code)]
mod scanner {
    use std::str::FromStr;
    use std::str::SplitWhitespace;
    use std::io::Read;
    use std;
    pub struct Scanner<'a> {
        it: SplitWhitespace<'a>
    }
    impl<'a> Scanner<'a> {
        pub fn new(s: &'a String) -> Scanner<'a> {
            Scanner {
                it: s.split_whitespace()
            }
        }
        pub fn next<T: FromStr>(&mut self) -> T {
            match self.it.next().unwrap().parse::<T>() {
                Ok(v) => v,
                _ => panic!("Scanner error")
            }
        }
        pub fn next_chars(&mut self) -> Vec<char> {
            self.next::<String>().chars().collect()
        }
    }
    pub fn read_string() -> String {
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }
}
// ---------- end scannner ----------
use std::io::Write;
use std::cmp::*;
fn main() {
    let sc = scanner::read_string();
    let mut sc = scanner::Scanner::new(&sc);
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    // run(&mut sc, &mut out);
    solvea(&mut sc,&mut out);
    // solveb(&mut sc,&mut out);
    // solvec(&mut sc,&mut out);
    // solved(&mut sc,&mut out);
}

#[allow(dead_code)]
fn solvea(sc: &mut scanner::Scanner, out: &mut std::io::BufWriter<std::io::StdoutLock>){
    let n = sc.next::<i32>();
    writeln!(out,"{}",2.0f64 * 3.141592653 * (n as f64)).ok();
}


#[allow(dead_code)]
fn solved(sc: &mut scanner::Scanner, out: &mut std::io::BufWriter<std::io::StdoutLock>){
    let n = sc.next::<usize>();
    let k = sc.next::<usize>();
    let mut res = 0i64;
    const MOD:i64 = (1e9+7.0) as i64;
    for i in k..=(n+1){
        let l = (i as i64)*((i-1) as i64)/2i64;
        let r = (i as i64)*((2*n-i+1) as i64)/2i64;
        res = (res+r-l+1)%MOD;
    }
    writeln!(out,"{}",res).ok();
}

Measured memory_bytes: 2188
N, M = map(int, input().split())#駒の数N,地点の数M
 
xList = [int(i) for i in input().split()]
xList.sort()#地点座標xList
 
distanse_list = []

#駒の数が座標の数以上のとき動かす必要がない
if N > M:
    N = M

if N == M:
    print("0")
#
else:
    for i in range(len(xList)-1):
        distanse = xList[i+1] - xList[i]
        distanse_list.append(distanse)
 
    distanse_list.sort()
    print(sum(distanse_list[0:int(M - N)]))

Measured memory_bytes: 13832
N = gets.to_i
m = Array.new(2) { Array.new(N) }
2.times do |i|
  gets.chomp.split.map(&:to_i).each_with_index do |c, j|
    m[i][j] = c
  end
end

ans = 0
(1..N).each do |b|
  total = m[0][0, b].inject(:+) + m[1][b-1, m[1].length - b + 1].inject(:+)
  ans = total if ans < total
end
p ans

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

int n, ans;
i64 a[100010], b[100010];

map<i64, int> mp;

i64 square(i64 x)
{
	return x * x;
}

i64 clearCubicFactor(i64 x)
{
	for (i64 i = 2; i * i * i <= x; i++)
		while (x % (i * i * i) == 0)
			x /= (i * i * i);
	return x;
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		i64 x, y = 1;
		scanf("%lld", &x);

		x = clearCubicFactor(x);
		mp[x]++;
		a[i] = x;

		for (i64 j = 2; j * j * j <= x; j++)
			if (x % j == 0)
			{
				y *= (x % (j * j) == 0) ? j : j * j;
				while (x % j == 0)
					x /= j;
			}

		if (square((i64) sqrt(x)) == x)
			y *= (i64) sqrt(x);
		else
			y *= x * x;
		b[i] = y;
	}
	if (mp[1])
		ans++, mp[1] = 0;
	for (int i = 1; i <= n; i++)
		ans += max(mp[a[i]], mp[b[i]]), mp[a[i]] = mp[b[i]] = 0;
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 14336
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int getTime() {
	int h, m;
	cin >> h >> m;
	return h * 60 + m;
}

void compress(vector<int>&v, map<int, int>&m) {
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	for (int i = 0; i < v.size(); ++i) {
		m[v[i]] = i;
	}
}

int N;

vector<int>xc, yc, zc;
map<int, int>xi, yi, zi;
vector<pair<int, int>>xp, yp, zp;

int imos[123][123][123];

int main(void)
{
	cin >> N;
	for (int i = 0; i < N; ++i) {
		int xs, xe, ys, ye, zs, ze;
		xs = getTime();
		xe = getTime(); xe++;
		ys = getTime();
		ye = getTime(); ye++;
		zs = getTime();
		ze = getTime(); ze++;
		xp.push_back({ xs,xe });
		yp.push_back({ ys,ye });
		zp.push_back({ zs,ze });
		xc.push_back(xs);
		xc.push_back(xe);
		yc.push_back(ys);
		yc.push_back(ye);
		zc.push_back(zs);
		zc.push_back(ze);
	}
	compress(xc, xi);
	compress(yc, yi);
	compress(zc, zi);
	for (int i = 0; i < N; ++i) {
		int as = xi[xp[i].first];
		int ae = xi[xp[i].second];
		int bs = yi[yp[i].first];
		int be = yi[yp[i].second];
		int cs = zi[zp[i].first];
		int ce = zi[zp[i].second];
		imos[as][bs][cs]++;
		imos[as][bs][ce]--;
		imos[as][be][cs]--;
		imos[as][be][ce]++;
		imos[ae][bs][cs]--;
		imos[ae][bs][ce]++;
		imos[ae][be][cs]++;
		imos[ae][be][ce]--;
	}
	for (int i = 0; i < 111; ++i)
		for (int j = 0; j < 111; ++j)
			for (int k = 0; k < 111; ++k)
				imos[i + 1][j][k] += imos[i][j][k];
	for (int i = 0; i < 111; ++i)
		for (int j = 0; j < 111; ++j)
			for (int k = 0; k < 111; ++k)
				imos[i][j + 1][k] += imos[i][j][k];
	for (int i = 0; i < 111; ++i)
		for (int j = 0; j < 111; ++j)
			for (int k = 0; k < 111; ++k)
				imos[i][j][k + 1] += imos[i][j][k];
	int ans = 0;
	for (int i = 0; i < 111; ++i)
		for (int j = 0; j < 111; ++j)
			for (int k = 0; k < 111; ++k)
				ans = max(ans, imos[i][j][k]);
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 9652
n=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(1,n-1):
    if p[i-1]<p[i]<p[i+1]:
        ans+=1
    elif p[i+1]<p[i]<p[i-1]:
        ans+=1
print(ans)

Measured memory_bytes: 9184
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

const double EPS = 1.0e-10;

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

    vector<int> f(n), a(n), t(n), x(n), y(n);
    for(int i=0; i<n; ++i)
        cin >> f[i] >> a[i] >> t[i] >> x[i] >> y[i];

    vector<double> dist(2, -1.0);
    vector<double> df(2, -1.0);
    for(int i=1; i<n; ++i){
        if(!(t[i] == t[i-1] && a[i] != a[i-1]))
            continue;

        double dist2 = sqrt(pow(x[i] - x[i-1], 2.0) + pow(y[i] - y[i-1], 2.0));
        if(abs(dist2 - dist[t[i]]) < EPS){
            dist[t[i]] = dist2;
            df[t[i]] = min(df[t[i]], (f[i] - f[i-1]) / 60.0);
        }
        else if(dist2 > dist[t[i]]){
            dist[t[i]] = dist2;
            df[t[i]] = (f[i] - f[i-1]) / 60.0;
        }
    }

    cout.setf(ios_base::fixed, ios_base::floatfield);
    cout << setprecision(10);
    for(int i=0; i<2; ++i){
        if(dist[i] < -0.5){
            cout << -1 << ' ' << -1 << endl;
        }
        else{
            cout << dist[i] << ' ' << df[i] << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1268
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define FOR(i, a, b) for(int i = (a);i <= (b); i++)
#define ROF(i, a, b) for(int i = (a);i >= (b); i--)
const int N = 1111;
int n, m, K;
int a[12][N];
int cnt[12], add[12];
int cal(int s){
    memset(cnt, 0, sizeof cnt);
    int num = 0;
    FOR(i, 0, n - 1)num += s >> i & 1;
    s |= 1 << (n - 1);
    FOR(j, 1, m){
        int tot = 0, now = 0;
        memset(add, 0, sizeof add);
        FOR(i, 1, n){
            now += a[i][j];
            if(s >> (i - 1) & 1){
                add[++tot] += now;
                if(add[tot] > K)return 1e9;
                now = 0;
            }
        }
        FOR(i, 1, tot){
            cnt[i] += add[i];
            if(cnt[i] > K){
                num++;
                memset(cnt, 0, sizeof cnt);
                j--;
                break;
            }
        }
    }
    //printf("num=%d s=%d\n", num, s);
    return num;
}
int main(){
    cin>>n>>m>>K;
    FOR(i, 1, n){
        FOR(j, 1, m)scanf("%1d", &a[i][j]);
    }
    int ans = 1e9;
    FOR(i, 0, (1 << (n - 1)) - 1){
        ans = min(ans, cal(i));
    }   
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
# ABC126D - Even Relation
import sys

sys.setrecursionlimit(10 ** 9)


def dfs(v: int, p: int) -> None:
    for u, w in T[v]:
        if u != p:
            D[u] = (D[v] + w) % 2
            dfs(u, v)


def main():
    global T, D
    N, *A = map(int, open(0).read().split())
    T = [[] for _ in range(N + 1)]
    for i in range(0, (N - 1) * 3, 3):
        v, u, w = A[i : i + 3]
        T[v] += [(u, w)]
        T[u] += [(v, w)]
    D = [0] * (N + 1)  # D[i] := distance from vertex 1 (root)
    dfs(1, -1)
    print(*D[1:], sep="\n")


if __name__ == "__main__":
    main()

Measured memory_bytes: 81564
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdlib>
#include<cstdio>
#include<utility>
#include<list>
using namespace std;
int main(){
	string S;
	cin>>S;
	int cnt=0;

	for(int i=1;i<S.size()-1;i++) cnt++;

	cout<<S[0]<<cnt<<S[S.size()-1]<<endl;

	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <vector>
#include <algorithm>

#define int64 long long int
using namespace std;

typedef pair<int, int> P;

class Hoge {
public:
	int a, v;
	Hoge(int a, int v){
		Hoge::a = a, Hoge::v = v;
	}
	Hoge(){}
};

class LS
{
public:
	bool operator() (Hoge h1, Hoge h2){
		if(h1.v == h2.v) return (h1.a > h2.a) ? true : false;
		else return (h1.v < h2.v) ? true : false;
	}
};

int main()
{
	int n, a, v;
	Hoge *hoge;

	cin >> n;

	hoge = new Hoge[n];

	for(int i=0; i<n; i++){
		cin >> a >> v;
		hoge[i].a = a, hoge[i].v = v;
	}

	priority_queue<Hoge, vector<Hoge>, LS> qu;

	for(int i=0; i<n; i++) qu.push(hoge[i]);

	cout << (qu.top()).a << ' ' << (qu.top()).v << endl;

	delete [] hoge;

	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

const int MAXN = 100005;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int K,X; cin>>K>>X;
	for(ll i=max(-1000000,X-K+1);i<=min(1000000, X+K-1);i++) cout<<i<<" ";
	
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>

int main()
{
	int a, b, c = 0;
	char s;
	int rect_num = 0;
	int diamond_num = 0;
	while (std::cin >> a >> s >> b >> s >> c)
	{
		int a2 = std::pow(a, 2);
		int b2 = std::pow(b, 2);
		int c2 = std::pow(c, 2);
		if ((a2 + b2) == c2)
		{
			rect_num++;
		}
		else
		{
			if ((a + b >= c) && (a == b))
			{
				diamond_num++;
			}
		}
	}
	std::cout << rect_num << std::endl;
	std::cout << diamond_num << std::endl;

	return 0;
}

Measured memory_bytes: 3052
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
  ll x;
  cin >> x;
  while(true) {
    bool xflag = true;
    for(ll i = 2;i < x; i++) {
      if(x%i == 0) {
        xflag = false;
      }
    }
    if(xflag) break;
    x++;
  }
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

ll mod = 1000000007; 
int main(){
    ll h, w, k;
    cin >> h >> w >> k;

    //dp[i][j]=i列目でjにいる数
    vvll dp(h + 1, vll(w, 0));
    //i=0について初期化:0列目で線は引けないと見なし, j=0に辿り着くのが1通り, それ以外は0
    dp[0][0] = 1;

    ll bit = (1LL << (w - 1));
    REP(i, h){
        REP(b, bit){
            //used:t番目(0<=t<=w-2)に線が引かれているかどうか
            vll used(w - 1);
            REP(t, w - 1){
                if((b >> t) & 1) used[t] = 1;
            }
            ll ng = 0;
            REP(t, w - 2){
                if(used[t + 1] * used[t]) ng = 1;
            }
            if(ng) continue;
            REP(j, w){
                //左シフト
                if(j >= 1 && used[j - 1]){
                    dp[i + 1][j - 1] += dp[i][j];
					dp[i + 1][j - 1] %= mod;
                }
                //右シフト
                else if(j <= w - 2 && used[j]){
                    dp[i + 1][j + 1] += dp[i][j];
					dp[i + 1][j + 1] %= mod;
                }
                //直下
                else{
                    dp[i + 1][j] += dp[i][j];
					dp[i + 1][j] %= mod;
                }
            }
        }
    }
    cout << dp[h][k - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("trapv")
#pragma GCC target("sse4")

#include <bits/stdc++.h>
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n"
#define int long long
#define mod 1000000007
#define PI acos(-1)

void solve() {
	string s, t;
	cin >> s >> t;
	int ans = INT_MAX;
	int n = s.size(), m = t.size();
	for(int i = 0; i < n - m + 1; i++) {
		string curr = s.substr(i, m);
		int cnt = 0;
		for(int j = 0; j < m; j++) {
			// deb(curr[j]);
			// deb(t[j]);
			if(curr[j] != t[j]) {
				cnt++;
			}
			
			// deb(cnt);
		}
		ans = min(ans, cnt);
	}
	cout << ans;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int tc = 1;
    // cin >> tc;
    while(tc--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main()
{
	int N;
	cin >> N;
	int K;
	cin >> K;
	int Q;
	cin >> Q;
	int S[N];
	int seikai;

	for (int i = 0; i < N; i++)
			S[i] = K-Q;

	for (int i = 0; i < Q; i++) {
		cin >> seikai;
		S[seikai-1]++;
	
	}
		

	for (int i = 0; i < N; i++) {
		if (S[i] <= 0)
			cout << "No\n";
		else
			cout << "Yes\n";
		
	}

	return 0;
}


Measured memory_bytes: 1024
def partition(A, p, r):
    x = A[r]
    i = p - 1

    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[j], A[i] = A[i], A[j]

    A[i + 1] , A[r] = A[r], A[i + 1]

    return i + 1

n = int(input())
A = [int(a) for a in input().split()]
edge = partition(A, 0, n - 1)

for (i, a) in enumerate(A):
    if i == edge:
        print("[" + str(a) + "]", end = "")
    else:
        print(a, end = "")

    if i != n - 1:
        print(" ", end = "")

print()

Measured memory_bytes: 18356
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    string s;
    cin >> s;
    
    int cnt = 0;
    while(s.length() > 1){
        int n = s.length() - 1;
        
        if(s[0] == s[n]){
            s.erase(s.begin() + n, s.end());
            s.erase(s.begin(), s.begin() + 1);
        }
        else{
            if(s[0] != 'x' && s[n] != 'x'){
                cout << -1 << endl;
                return 0;
            }
            
            if(s[0] != 'x'){
                s.insert(s.begin(), 'x');
                cnt++;
            }
            else{
                s += "x";
                cnt++;
            }
        }
    }
    
    cout << cnt << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,a) for(int i=0;i<a;i++)
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    string s[h+2];
    for(int i=0;i<w;i++){
        s[0][i]='.';
    }
    for(int i=1;i<=h;i++){
        s[i]+=".";
        string enter;
        cin>>enter;
        s[i]+=enter;
        s[i]+=".";
    }
    for(int i=0;i<w;i++){
        s[h+1][i]='.';
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            int count=0;
            if(s[i][j]=='#')    s[i][j]='#';
            else{
                if(s[i+1][j]=='#')    count++;
                if(s[i-1][j]=='#')    count++;
                if(s[i][j+1]=='#')    count++;
                if(s[i][j-1]=='#')    count++;
                if(s[i+1][j+1]=='#')    count++;
                if(s[i+1][j-1]=='#')    count++;
                if(s[i-1][j-1]=='#')    count++;
                if(s[i-1][j+1]=='#')    count++;
                s[i][j]=count+'0';
            }
        }
    }
    rep(i,h){
        rep(j,w){
            cout<<s[i+1][j+1];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_macros)]
use itertools::Itertools;
use std::cmp::{max, min};
use std::collections::*;
use std::i64;
use std::io::{stdin, Read};
use std::usize;

trait ChMinMax {
    fn chmin(&mut self, other: Self);
    fn chmax(&mut self, other: Self);
}
impl<T> ChMinMax for T
where
    T: PartialOrd,
{
    fn chmin(&mut self, other: Self) {
        if *self > other {
            *self = other
        }
    }
    fn chmax(&mut self, other: Self) {
        if *self < other {
            *self = other
        }
    }
}

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, $var:ident $($r:tt)*) => {
        let $var = parse_val!($it, usize);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, q: usize);
    let n = 100010;
    let mut ps = vec![true; n + 1];
    ps[0] = false;
    ps[1] = false;
    for i in 2..=n {
        if ps[i] {
            for j in ((2 * i)..=n).step_by(i) {
                ps[j] = false;
            }
        }
    }
    let mut cur = 0;
    let mut qs = vec![];
    for i in 0..=n {
        if ps[i] & ps[(i + 1) / 2] {
            cur += 1
        }
        qs.push(cur);
    }
    for _ in 0..q {
        parse!(it, l: usize, r: usize);
        println!("{}", qs[r] - qs[l - 1]);
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N,K;
  cin>>N>>K;
  vector<ll> H(N);
  for(ll i=0;i<N;i++)cin>>H[i];
  sort(H.begin(),H.end());
  reverse(H.begin(),H.end());
  ll ans=0;
  for(ll i=K;i<N;i++){
    ans+=H[i];
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void print(int *a, int ax);

void ins_sort(int *a, int ax)
{
    int i;

    for(i=1;i<ax;i++) {
        print(a,ax);
        int key = a[i];
        int j;

        for(j=i-1;j>=0;j--) {
            if(key >= a[j]) {
                break;
            }
            else {
                a[j+1] = a[j];
            }
        }
        a[j+1] = key;
    }
    print(a,ax);
    return;
}

void print(int *a, int ax)
{
    int i;

    for(i=0;i<ax-1;i++) {
        printf("%d ", a[i]);
    }
    printf("%d\n", a[i]);

    return;
}

void read(int n, int *a)
{
    int i;
    char str[1000];
    char tmp[] = " \n";

    fgets(str, sizeof(str), stdin);
    a[0] = atoi(strtok(str, tmp));
    for(i=1;i<n;i++) {
        a[i] = atoi(strtok(NULL, tmp));
    }

    return;
}

int main(void)
{
    int n;
    int a[1000];
    scanf("%d%*c", &n);

    read(n,a);

    ins_sort(a,n);

    return 0;
}

Measured memory_bytes: 608
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef double ld;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};


int main(){
	init();
	vector<pair<pair<string,ll>,ll>>v;
	ll N;
	cin>>N;
	for(int i=0;i<N;i++){
		string s;ll p;cin>>s>>p;
		v.push_back(make_pair(make_pair(s,-1*p),i+1));
	}
	sort(v.begin(),v.end());
	for(auto i:v)cout<<i.second<<endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = [[int(i) for i in input().split()] for i in range(M)]

min = 0
max = N

for i in range(M):
    if min <= A[i][0]:
        min = A[i][0]
    if max >= A[i][1]:
        max = A[i][1]
        
if max - min + 1 > 0:
    print(max - min + 1)
else:
    print(0)

Measured memory_bytes: 21156
#include <stdio.h>
#include <queue>
#include <vector>
using namespace std;
int n, m, r, s, t, f, d[100000], x[100000]; vector<pair<int, int> > g[100000];
int main() {
	scanf("%d%d%d", &n, &m, &r);
	for(int i = 0; i < m; i++) {
		scanf("%d%d%d", &s, &t, &f);
		g[s].push_back(make_pair(t, f)); x[s]++;
	}
	for(int i = 0; i < n; i++) d[i] = 999999999; d[r] = 0;
	priority_queue<pair<int, int> > que; que.push(make_pair(0, r));
	while(!que.empty()) {
		int v = que.top().second; que.pop();
		for(int i = 0; i < x[v]; i++) {
			int u = g[v][i].first;
			int e = g[v][i].second;
			if(d[u] > d[v] + e) {
				d[u] = d[v] + e;
				que.push(make_pair(-d[u], u));
			}
		}
	}
	for(int i = 0; i < n; i++) {
		if(d[i] != 999999999) {
			printf("%d\n", d[i]);
		}
		else {
			printf("INF\n");
		}
	}
	return 0;
}

Measured memory_bytes: 12908
#include <stdio.h>
#include <string.h>
#define LEN 100005
typedef struct pp {
  char name[100];
  int t;
} P;
P Q[LEN];
int head, tail, n;
 
void enqueue(P x) {
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}
P dequeue() {
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}
int min(int a,int b) {
  return a < b ? a : b; 
}
int main() {
  int elaps = 0, c;
  int i, q;
  P u;
  char str[64];
  scanf("%d %d",&n ,&q);
  for(i=1; i<=n; i++) {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;
  while(head != tail) {
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else {
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}


Measured memory_bytes: 11904