akhauriyash/Code-Regression huggingface dataset:
package main

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var par []int

func root(x int) int {
	if par[x] == x {
		return x
	}
	par[x] = root(par[x])
	return par[x]
}

func unite(x, y int) {
	xr := root(x)
	yr := root(y)
	if xr == yr {
		return
	}
	par[xr] = par[yr]
}

func main() {
	n := readInt()
	m := readInt()
	par = make([]int, n)
	for i := range par {
		par[i] = i
	}

	for i := 0; i < m; i++ {
		x := readInt()
		y := readInt()
		readInt()
		x--
		y--
		unite(x, y)
	}

	roots := make(map[int]struct{})
	for i := range par {
		roots[root(par[i])] = struct{}{}
	}

	fmt.Println(len(roots))
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define Edge pair< i_i, int>
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define vd vector<double>
#define vvd vector< vd >
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
signed main()
{
    int2(a, b);
    while (a) {
        vvd table(a, vd(a));
        rep(i, a) { rep(j, a) {
            cin >> table[i][j];
        } }

        vvd dp(b, vd(a, 0.0));
        rep(i, a) {
            dp[0][i] = 1.0;
        }
        rep(i, b-1) {
            rep(j, a) {
                rep(k, a) {
                    dp[i+1][k] = max(dp[i+1][k], 
                            dp[i][j] * table[j][k]);
                }
            }
        }
            
        double ans = 0.0;
        rep(i, a) {
            ans = max(dp[b-1][i], ans);
        }
        long ret = round(ans * 100);
        printf("%.2lf\n", (double)ret / 100);
        cin >> a >> b;
    }
    return 0;
}

Measured memory_bytes: 3400
//  s.at(0) = toupper(s.at(0));//小文字なら大文字へ//大文字の場合はそのまま
//  s.at(i) = tolower(s.at(i));//大文字なら小文字へ//小文字の場合はそのまま
//  string s;
//  cin >> s;
//  cout << s.at(0) <<endl;
//  cout << s.at(0)-'0' <<endl;
//  Aが16？
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n,k;
  cin >> n >> k;
  vector<int>a(n);
  for(int i=0;i<k;i++){
    int d;
    cin >> d;
    d = d -1;
    for(int j=0;j<=d;j++){
      int t;
      cin >> t;
      t = t - 1;
      a.at(t)++;
    }
  }
  int count = 0;
  rep(i,n) if(a.at(i)==0)count++;
  cout << count << endl;
}


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

int main() {
  int A,B;
  int cnt=0;
  cin >> A >> B;
  for (int i = A; i < B+1; i++){
    int a = i/10000;
    int b = i%10000/1000;
    int c = i%1000/100;
    int d = i%100/10;
    int e = i%10;
    int r = e*10000+d*1000+c*100+b*10+a*1;
    if (i==r)
      cnt +=1;
  }
  cout << cnt << endl;

}



Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n, m, x[100000], d[100000], ans=0;
  cin >> n >> m;
  for(int i=0;i<m;i++){
    cin >> x[i];
  }
  if(n>=m){
    cout << 0 << endl;
    return ans;
  }
  sort(x, x+m);
  for(int i=0;i<m-1;i++){
    d[i] = x[i+1] - x[i];
  }
  sort(d, d+m-1);
  for(int i=0;i<m-n;i++){
    ans += d[i];
  }
  cout << ans << endl;
  return 0;
}


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

int main(void)
{
	int s, t;
	char a[11];
	char b[11];
	char c[11];

	cin >> a >> b >> c;

	for (s = 0; s < 12; s++) {
		if (a[s] == '\0') {
			s--;
			break;
		}
	}
	for (t = 0; t < 12; t++) {
		if (b[t] == '\0') {
			t--;
			break;
		}
	}
	if (a[s] == b[0] && b[t] == c[0]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 764
N = int(input())
A = [int(input()) for _ in range(N)]

m1, m2 = 0, 0
for a in A:
    if a >= m1:
        m2 = m1
        m1 = a
    elif a > m2:
        m2 = a

for a in A:
    if a == m1:
        print(m2)
    else:
        print(m1)

Measured memory_bytes: 69080
# -*- coding: utf-8 -*-
from collections import Counter
from operator import itemgetter
def solve():
    input()
    V = list(map(int, input().split()))
    l = sorted(list(Counter(V[::2]).items())+[(0,0)], key=itemgetter(1), reverse=True)
    u = sorted(list(Counter(V[1::2]).items())+[(0,0)], key=itemgetter(1), reverse=True)
    res = sum(map(itemgetter(1), l+u)) - (max(l[0][1]+u[1][1], l[1][1]+u[0][1]) if l[0][0]==u[0][0] else (l[0][1]+u[0][1]))
    return str(res)

if __name__ == '__main__':
    print(solve())



Measured memory_bytes: 20572
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++)
    cin>>a.at(i);
  int l=0;
  int r=0;
  int64_t s=0;
  int o=0;
  while(1){
    if((o&a.at(r))==0){
      s+=r-l+1;
      o|=a.at(r);
      r++;
      if(r==n)
        break;
    }else{
      o^=a.at(l);
      l++;
    }
  }
  cout<<s<<endl;
}

Measured memory_bytes: 1024
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete



main = flip divMod 60 . sum <$> replicateM 4 getInt >>= mapM_ putStrLn . wordsBy (==',') . init . tail . show

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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	string s;
	cin >> s;
	int n = s.size();

	int now = 2;
	vector<P> ans;
	ans.push_back(P(1,2));
	if(s[0] == '0' || s[n-1] == '1'){
		cout << -1 << endl;
		return 0;
	}

	for(int i = 0; i < n/2; i++){
		int j = i+1;
		if(s[i] != s[n-1-j]){
			cout << -1 << endl;
			return 0;
		}
	}

	int v = 3;
	for(int i = 1; i < n; i++){
		if(s[i] == '0'){
			ans.push_back(P(now,v));
			v++;
		}else{
			ans.push_back(P(now,v));
			now = v;
			v++;
		}

		if(v > n) break;
	}

	for(int i = 0; i < ans.size(); i++){
		cout << ans[i].first << " " << ans[i].second << endl;
	}


	return 0;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,c;
  cin>>a>>b>>c;
  if((a+b)-c > 0){cout<<"No"; return 0;}
  if(((a+b-c)*(a+b-c))>(4*a*b))cout<<"Yes";
  else cout<<"No";
  
}

Measured memory_bytes: 3604
import scipy.optimize as optimize


def main():
    L = float(input())
    def fun(x): return -x[0] * x[1] * x[2]
    cons = ({'type': 'eq', 'fun': lambda x: x[0] + x[1] + x[2] - L})
    bnds = ((0, None), (0, None), (0, None))
    res = optimize.minimize(fun, (0, 0, 0), method='SLSQP',
                            bounds=bnds, constraints=cons, tol=1e-8)
    print("{:.18f}".format(-res.fun))


main()


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

using namespace std;

#define N 3001

int n;
int vis[N][N] = {0};
double dp[N][N], a[N], ans = 0;

double solve(int i, int c, float p = 0)
{
	if (i == n)
	{
		if (c > n / 2)
			return 1;
		return 0;
	}
	if (vis[i][c])
		return dp[i][c];
	vis[i][c] = 1;
	return dp[i][c] = a[i] * solve(i + 1, c + 1) + (1 - a[i]) * solve(i + 1, c);
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	ans = solve(0, 0, 1);
	cout << setprecision(10) << ans << endl;
	return 0;
}


Measured memory_bytes: 104320
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
int main (){
    int n, l;  cin >> n >> l;
    vector<string>s(n);
    for(int i=0; i<n; i++)  cin >> s[i];
    sort(s.begin(),s.end());
    for(int i=0; i<n; i++) cout << s[i];
    cout << endl;
}

Measured memory_bytes: 256
#約数
def divisor(x):
    ret = []
    for i in range(1,int(x ** 0.5) + 1):
        if x % i == 0:
            ret.append(i)
            ret.append(x // i)
    return list(set(ret))

n,m = map(int,input().split())

div = divisor(m)
div.sort(reverse=True)

for i in div:
    if m / i >= n:
        print(i)
        exit()

Measured memory_bytes: 38640
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll h,w;
    cin>>h>>w;
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
    	cin>>a[i];
    }
    ll index=0;
    ll b[h][w];
    for(int i=0;i<h;i++){
    	if(i&1){
    		for(int j=0;j<w;j++){
    			if(a[index]){
    				b[i][j]=index+1;
    				a[index]--;
    			}else{
    				index++;
    			    j--;
    			}
    		}
    	}else{
    		for(int j=w-1;j>=0;j--){
    			if(a[index]){
    				b[i][j]=index+1;
    				a[index]--;
    			}else{
    				index++;
    			    j++;
    			}
    		}
    	}
    }
    for(int i=0;i<h;i++){
    	for(int j=0;j<w;j++){
    		cout << b[i][j] <<" ";
    	}
    	cout << endl;
    }
    return 0;
}


Measured memory_bytes: 512
N = int(input())
odd_count = (N + 1) // 2
odds = [2*i+1 for i in range(odd_count)]
#print(odds, end=" ")
count = 0
for n in odds:
    divisor_count = 0
    for i in range(1, n + 1):
        if n % i == 0:
            divisor_count += 1
    if divisor_count == 8:
        count += 1
print(count)


Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

struct lazy_segtree {
  int n;
  vector<ll> data;
  vector<ll> lazy;

  lazy_segtree(const int s) {
    init(s);
  }

  lazy_segtree(const vector<ll> &v) {
    int s = v.size();
    init(s);
    for (int i = 0; i < s; i++) {
      data[i+n-1] = v[i];
    }
    for (int i = n-2; i >= 0; i--) {
      data[i] = data[i*2+1] + data[i*2+2];
    }
  }

  void init(const int s) {
    n = 1;
    while (n < s) n <<= 1;
    data = vector<ll>(2*n-1);
    lazy = vector<ll>(2*n-1);
  }

  void evaluate(int p) {
    if (lazy[p] != 0) {
      data[p] += lazy[p];
      if (p <= n-2) {
        lazy[p*2+1] += lazy[p] / 2;
        lazy[p*2+2] += lazy[p] / 2;
      }
      lazy[p] = 0;
    }
  }

  void update(int l, int r, ll v, int p = 0, int a = 0, int b = -1) {
    if (b < 0) b = n; // init

    // evaluate lazy value
    evaluate(p);

    if (r <= a || b <= l) return; // out of range
    if (l <= a && b <= r) { // fully covered
      lazy[p] += v * (b - a);
      evaluate(p);
    }
    else {
      update(l, r, v, p*2+1, a, (a + b) / 2); // left
      update(l, r, v, p*2+2, (a + b) / 2, b); // right
      data[p] = data[p*2+1] + data[p*2+2]; // update
    }
    return;
  }

  ll query(int l, int r, int p = 0, int a = 0, int b = -1) {
    if (b < 0) b = n; // init
    if (r <= a || b <= l) return 0LL; // out of range

    // evaluate lazy value
    evaluate(p);

    if (l <= a && b <= r) return data[p];// fully covered

    ll vl = query(l, r, p*2+1, a, (a + b) / 2); // left
    ll vr = query(l, r, p*2+2, (a + b) / 2, b); // right
    return vl + vr;
  }
};

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

  int n;
  cin >> n;
  vector<vector<int> > edge(n);
  for (int i = 0; i < n-1; i++) {
    int a, b;
    cin >> a >> b;
    edge[a-1].push_back(b-1);
    edge[b-1].push_back(a-1);
  }

  lazy_segtree lst(n);
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    lst.update(0, i+1, 1);
    for (auto &x: edge[i]) {
      if (x < i) {
        lst.update(0, x+1, -1);
      }
    }
    ans += lst.query(0, n);
  }

  cout << ans << endl;

  return 0;
}


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

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define w(t) int t;cin>>t;while(t--)
#define mod 1000000007



int main(){
	
		fast
		int n;
		cin>>n;
		int counter=0;
		int max_count=0;
		int done=0;
		for(int k=0;k<n;k++)
		{

			int i,j;
			cin>>i>>j;
			if(i==j)
			{
				counter++;
				if(counter>=3&&done==0)
			{
				max_count=counter;
				counter=0;
				done=1;
			}
			}

			else{
				counter=0;
			}
		}
		if(max_count>=3)
			cout<<"Yes";
		else
			cout<<"No";


	return 0;
}





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

const int NIL = -1;
class Node {
public:
	int p, l, r;
	Node(int pp, int ll, int rr) { p = pp; l = ll; r = rr; }
};

vector<int> pre;
vector<int> in;
vector<int> post;
int pos;

void build( int l, int r )
{
	if( l >= r ) return;
	int n = pre[pos];
	pos++;
	int m = distance( in.begin(), find( in.begin(), in.end(), n ) );
	build( l, m );
	build( m + 1, r );
	post.push_back( n );
}

int main()
{
	int n;
	cin >> n;
	pre = vector<int>( n );
	in = vector<int>( n );
	for( int i = 0; i < n; i++ ) {
		cin >> pre[i];
	}
	for( int i = 0; i < n; i++ ) {
		cin >> in[i];
	}

	build( 0, n );

	for( int i = 0; i < post.size(); i++ ) {
		if( i ) cout << " ";
		cout << post[i];
	}
	cout << endl;
}



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

using namespace std;

int n;
vector<vector<int>> edge;

bool bfs(int start, int goal) {
  vector<int> cost = vector<int>(n + 1, 1e9);
  queue<pair<int, int>> q;
  cost[start] = 0;
  cost[goal] = 0;
  q.push(make_pair(start, 0));
  q.push(make_pair(goal, 1));
  int black = 0, white = 0;
  while (!q.empty()) {
    auto p = q.front();
    int u = p.first, color = p.second;
    q.pop();
    for (auto v: edge[u]) {
      if (cost[v] != 1e9) {
        continue;
      }
      if (color == 0) {
        black++;
      } else {
        white++;
      }
      cost[v] = cost[u] + 1;
      q.push(make_pair(v, color));
    }
  }
  return black > white;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  edge = vector<vector<int>>(n + 1, vector<int>());
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  if (bfs(1, n)) {
    cout << "Fennec" << endl;
  } else {
    cout << "Snuke" << endl;
  }
  return 0;
}

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

#define MOD 1000000007ll
#define all(v) v.begin() , v.end()
#define allr(v) v.rbegin(), v.rend()
#define for0(i,n) for(__typeof(n) i = 0; i < n ; i++) 
#define forab(i,a,b) for(__typeof(a) i = a ; i < b ; i++) 
#define forba(i,b,a) for(__typeof(a) i = b ; i > a ; i--) 
#define forc(c,it) for(__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define pb     push_back
#define mp     make_pair
#define MAX 100005
template<typename T, template<typename ELEM, typename ALLOC=std::allocator<ELEM> > class Container>
std::ostream& operator<< (std::ostream& o, const Container<T>& container)
{ typename Container<T>::const_iterator beg = container.begin();
  /*o << "[";*/ while(beg != container.end()) o << " " << *beg++; /*o << " ]";*/ return o; }

string s , t;
int q , a , b , c , d;
vector<int> As , Bs, At, Bt;

int main(int argc, char const *argv[])
{
  ios_base::sync_with_stdio(false);
  
  // #ifndef ONLINE_JUDGE
  // freopen("in","r",stdin);
  // freopen("out","w",stdout);
  // #endif

  cin>>s>>t;
  As.pb(0);
  Bs.pb(0);
  At.pb(0);
  Bt.pb(0);

  int sizs = s.size();
  int sizt = t.size();

  for(int i = 0 ; i < sizs ; i++)
  {
  	if(s[i] == 'A')
  	{
  		As.pb(1 + As[i]);
  		Bs.pb(Bs[i]);
  	}
  	else
  	{
  		Bs.pb(1 + Bs[i]);
  		As.pb(As[i]);
  	}
  }

  for(int i = 0 ; i < sizt ; i++)
  {
  	if(t[i] == 'A')
  	{
  		At.pb(1 + At[i]);
  		Bt.pb(Bt[i]);
  	}
  	else
  	{
  		Bt.pb(1 + Bt[i]);
  		At.pb(At[i]);
  	}
  }

  cin>>q;

  while(q--)
  {
  	cin>>a>>b>>c>>d;

  	int as = As[b] - As[a - 1] + 2*(Bs[b] - Bs[a-1]);
  	int at = At[d] - At[c - 1] + 2*(Bt[d] - Bt[c-1]);

  	if(as%3 == at%3)
  		cout << "YES\n";
  	else
  		cout << "NO\n";
  }




  return 0;
}  

Measured memory_bytes: 3008
#include <stdio.h>

int main(void) {
  int x, y;
  int i;

  scanf("%d %d", &x, &y);
  while (x != 0 || y != 0){
    if (x > y)
      printf("%d %d\n", y, x);
    else if(x < y)
      printf("%d %d\n", x, y);
    else
      printf("%d %d\n", x, y);
    scanf("%d %d", &x, &y);
  }

  return 0;
}



Measured memory_bytes: 1864
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;

typedef vector<vector<int>> Matrix;

Matrix d;

const int INF = 10e6;

void warshall_floyd(int n)
{
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

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

    d = Matrix(n, vector<int>(n, INF));
    for (int i = 0; i < n; i++) {
        d[i][i] = 0;
    }

    int from[m + 7];
    int to[m + 7];
    int cost[m + 7];

    for (int i = 0; i < m; i++) {
        cin >> from[i] >> to[i] >> cost[i];
        from[i]--;
        to[i]--;
        d[from[i]][to[i]] = cost[i];
        d[to[i]][from[i]] = cost[i];
    }

    warshall_floyd(n);
    int ans = 0;

    for (int i = 0; i < m; i++) {
        if (d[from[i]][to[i]] != cost[i]) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846264338327950;
inline int newline() { putchar('\n'); return 0; }

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

    vector<ll> a(n), b(n), c(n);
    cin(a[0]); cin(b[0]); cin(c[0]);

    rep3(i, 1, n) {
        ll ai, bi, ci;
        cin(ai); cin(bi); cin(ci);

        a[i] = max(b[i - 1] + ai, c[i - 1] + ai);
        b[i] = max(a[i - 1] + bi, c[i - 1] + bi);
        c[i] = max(a[i - 1] + ci, b[i - 1] + ci);
    }

    ll last = n - 1;
    print(max(max(a[last], b[last]), c[last]));
    return 0;
}

Measured memory_bytes: 2560
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;

map<int,int>a,b;

int n,m;

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		a[x]++;
	}
	cin>>m;
	for(int i=1;i<=m;i++)
	{
		int x;
		cin>>x;
		a[x]--;
		if(a[x]<0)
		{
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES";
}

Measured memory_bytes: 9600
def main():
    k, a, b = input_list()

    # たたきルート１手１枚増える
    # 交換ルートは2手必要
    if b - a > 2:
        # bisketをA枚にする
        bis = a
        k -= a - 1
        
        if k % 2 == 1:
            bis += 1
            k -= 1
        bis += (k//2) * (b-a)
        print(bis)
    else:
        print(k+1)

def input_list():
    return map(int, input().split())

if __name__ == "__main__":
    main()

Measured memory_bytes: 61876
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <vector>
#include <cstring>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#define fr first
#define sc second
#define MP make_pair
#define PB push_back
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define lli long long int
#define y1 arayikhalatyan
using namespace std;

lli gcd(lli a, lli b) {
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
lli cg(lli n) {
	return n ^ (n >> 1);
}
lli SUM(lli a)
{
	return (a * (a + 1) / 2);
}
bool CAN(int x, int y, int n, int m)
{
	if (x >= 0 && y >= 0 && x < n && y < m)
	{
		return true;
	}
	return false;
}
double her(double x1, double y1, double x2, double y2)
{
	return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
string strsum(string a, string b)
{
	int p = 0;
	string c;
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());
	if (b.length() < a.length())
	{
		for (int i = b.length(); i < a.length(); i++)
		{
			b += "0";
		}
	}
	else
	{
		for (int i = a.length(); i < b.length(); i++)
		{
			a += "0";
		}
	}

	a += "0", b += "0";
	for (int i = 0; i < a.length(); i++)
	{
		c += (a[i] - '0' + b[i] - '0' + p) % 10 + '0';
		p = (a[i] + b[i] - '0' - '0' + p) / 10;
	}
	if (c[c.length() - 1] == '0') c.erase(c.length() - 1, 1);
	reverse(c.begin(), c.end());
	return c;
}
string strmin(string a, string b)
{
	if (a.length() > b.length()) return b;
	if (b.length() > a.length()) return a;
	for (int i = 0; i < a.length(); i++)
	{
		if (a[i] > b[i]) return b;
		if (b[i] > a[i]) return a;
	}
	return a;
}

char vow[] = { 'a', 'e', 'i', 'o', 'u' };
int dx[] = { 1, -1, 0, 0 };
int dy[] = { 0, 0, 1, -1 };



const int N = 1e6 + 30;
const lli mod = 998244353;
string t, sm, nax;
set <string> s;
int k;
int main()
{
	fastio;
	cin >> t;
	k++;
	nax = t[0];
	for (int i = 1; i < t.length(); i++)
	{
		sm += t[i];
		if (sm != nax)
		{
			k++;
			nax = sm;
			sm = "";
		}
	}
	cout << k;
	return 0;
}

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

#define ll long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define eb emplace_back
#define in insert
#define ff first
#define ss second
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define si set<int>
#define mpii map<int, int>
#define prq priority_queue
#define sz(s) (int) s.size()
#define pf(a) printf("%d ",a)
#define si1(a) scanf("%d",&a)
#define si2(a,b) scanf("%d%d",&a,&b)
#define si3(a,b,c) scanf("%d%d%d",&a,&b,&c)
//#define scan(v) for(int i = 0; i<n; i++){int x;cin>>x;v.pb(x);}
#define pi 2 * acos (0.0)
#define inf 1e9
#define co cout
#define en '\n'
#define re return
#define con continue
#define dbg cout<<"___________ok____________"<<endl;
#define yes() printf("YES\n")
#define no() puts("NO\n")
#define FOR(i, j, k) for(int i=(j); i<(k); i++)
#define REV(i, j, k) for(int i=(n-1); i>=k; i--)
#define all(v) v.begin(), v.end()
#define unq(a) sort(all(a)), a.erase(unique(all(a)),a.end())
#define rnd(a, b) ((((rand()<<15)^rand())%((b)-(a) + 1))+(a))
#define FAST_IO ios_base::sync_with_stdio(false),cin.tie(NULL)
#define mem(x, y) memset(x, y, sizeof(x))
#define prn(v) for(auto x: v)cout<<x<<" ";
const double EPS = 1e-9;
const int MXX = 2e5 + 5;

int a[MXX];
int main ()
{

    FAST_IO;
    ll x;cin>>x;
    ll ans1 = x/500;
    x = x % 500;
    ll ans2 = x/5;

    co<<(ans1*1000)  + (ans2*5)<<en;
    return 0;
}


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

ll h;
int main(){
    cin >> h;
    ll res = 0;
    ll num = 1;
    while(h)
    {
        res += num;
        h >>= 1;
        num <<= 1;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	r = 0
	while 2^r<n
		r += 1
	end
	for i in 1:n-1
		for j in i+1:n-1
			x = i$j
			for k in 0:r
				if (x>>k)%2==1
					print(k+1," ")
					break
				end
			end
		end
		x = i$n
		for k in 0:r
			if (x>>k)%2==1
				println(k+1)
				break
			end
		end
	end
end
main()

Measured memory_bytes: 120364
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <algorithm>
#include <limits>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

constexpr int MAX_N = 100;
constexpr double INF = 1e15;

int N;
int t[MAX_N + 1];
double v[MAX_N];
double maxv[40005]; // サイズを大きく

int main()
{
	scanf("%d", &N);
	rep(i, N)
		scanf("%d", t + i), t[i] *= 2;
	rep(i, N)
		scanf("%lf", v + i);

	std::fill( maxv, maxv+40005, INF );

	int cur = 0;

	rep(i, N)
	{
		repi(j, cur, cur+t[i]+1)
			maxv[j] = std::min( maxv[j], v[i] ); // ここが肝 (区間の境界のつじつまがあった)

		cur += t[i];
	}

	maxv[0] = 0; maxv[cur] = 0;

	rep(i, cur-1)
		maxv[i + 1] = std::min(maxv[i + 1], maxv[i] + 0.5);

	for (int i = cur - 1; i >= 0; --i)
		maxv[i] = std::min(maxv[i], maxv[i + 1] + 0.5);

	double ans = 0.0;

	rep(i, cur)
		ans += maxv[i] + maxv[i + 1];

	printf("%f\n", ans/4.0);

	return 0;
}

Measured memory_bytes: 512
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        int[][] A = new int[2][N];
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < N; j++) {
                A[i][j] = sc.nextInt();
            }
        }

        int max = 0;
        for (int k = 0; k < N; k++) {
            int tmpMax = 0;
            for (int j = 0; j <= k; j++) {
                tmpMax += A[0][j];
            }

            for (int j = k; j < N; j++) {
                tmpMax += A[1][j];
            }
            max = Math.max(max, tmpMax);
        }

        out.println(max);
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define mp make_pair
using namespace std;
const int mxn=1e5+5;
pair<int,int>p[mxn];
int n,m,Xor[mxn];
bool used[mxn];
vector<pair<int,int> >g[mxn];
vector<int>ans;
inline int dfs(int x){
	used[x]=1;int rt=Xor[x];
	for(pair<int,int>P:g[x]){
		int y=P.first;
		if(used[y])continue;
		int t=dfs(y);
		if(t)ans.push_back(P.second);
		rt^=t;
	}
	return rt;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=0;i<n;++i)cin>>p[i].first>>p[i].second;
	sort(p,p+n);
	Xor[0]=p[0].second;
	for(int i=1;i<n;++i)Xor[i]=p[i-1].second^p[i].second;
	Xor[n]=p[n-1].second;
	for(int i=0,l,r;i<m;++i){
		cin>>l>>r;
		l=lower_bound(p,p+n,mp(l,0))-p;
		r=upper_bound(p,p+n,mp(r,1))-p;
		g[l].push_back({r,i+1});
		g[r].push_back({l,i+1});
	}
	for(int i=0;i<=n;++i)if(!used[i])if(dfs(i))return puts("-1")*0;
	cout<<ans.size()<<endl;sort(ans.begin(),ans.end());
	for(int i:ans)cout<<i<<' ';cout<<endl;
}

Measured memory_bytes: 13564
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define reps(i,n) for(int i=1;i<=(int)n;i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define MOD 1000000007
#define itn int
#define enld endl
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    int N,K; cin >> N >> K;
    cout << N - K + 1 << endl;
    return 0;
}

Measured memory_bytes: 3592
N,M=list(map(int,input().strip().split(' ')))
Cards=list(map(int,input().strip().split(' ')))
magic=[]
dic={}
for _ in range(M):
    b,c=list(map(int,input().strip().split(' ')))
    magic+=[c]
    if c in dic:
        dic[c]+=b
    else:
        dic[c]=b    
magic=sorted(magic)[::-1]    
Cards=sorted(Cards)
index_now=0


for i in range(len(Cards)):
    #print(dic)
    if index_now>=len(magic):
        break
    magic_now=magic[index_now]
    while dic[magic_now]==0:
        index_now+=1
        if index_now>=len(magic):
            break
        magic_now=magic[index_now]
    
    if magic_now>Cards[i]:
        if dic[magic_now]>0:
            Cards[i]=magic_now
            dic[magic_now]-=1
print(sum(Cards))
        




    

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin>>n;
	int x = 0;
	vector<int> a(n);
	for (int &i : a){
		cin>>i;
		x ^= i;
	}
	for (int i : a){
		cout<<(i^x)<<" ";
	}
}


Measured memory_bytes: 3972
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    string S;
    cin >> S;
    if (S == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}


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

int main(){
	
	int a;
	int cnt = 0;
	while(cin>>a){
		if(a==0) {
			
		
			cout << cnt+1<< endl;
			return 0;
		}

		++cnt;
	}
}













Measured memory_bytes: 3596
#include<iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
  int N;
  cin >> N;
  int L[100];
  rep(i, N){
    cin >> L[i];
  }
  int count=0;
  rep(i, N){
    for (int j=i+1; j<N; j++){
      for (int k=j+1; k<N; k++){
      vector<int> vec = {L[i],L[j],L[k]};
      sort(vec.begin(), vec.end());
        if(vec[0]!=vec[1] && vec[1]!=vec[2]){
          if(vec[0]+vec[1] > vec[2]){
            count++;
            //cout << L[i] << L[j] << L[k] << endl;
            //cout << i+1 << j+1 << k+1 << endl;
          }
        }
      }
    }
  }
  cout << count << endl;
  return 0;
}


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

using namespace std;

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

    int ans = 0;
    for(int i = 0; i < N-2; ++i) {
        if (S.substr(i, 3) == "ABC") ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n , q;
    cin >> n;
    vector<int> v(10001,0);

        for (int i = 1; i <= 100; i++) {
            for (int j = 1; j <= 100; j++) {
                for (int k = 1; k <= 100; k++) {
                  q = i * i + j * j + k * k + i * j + j * k + i * k;
                    if (q < 10001) {
                        v[q]++;
                    }
                }

            }
        }
        
 for(int i = 0; i <n; i++){
     cout<<v[i+1]<<endl;
 }


    return 0;
}




Measured memory_bytes: 3636
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    DCaracalVsMonster solver = new DCaracalVsMonster();
    solver.solve(1, in, out);
    out.close();
  }

  static class DCaracalVsMonster {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      long h = in.nextLong();
      out.println(fun(h));
    }

    long fun(long h) {
      return h == 1 ? 1 : fun(h / 2) * 2 + 1;
    }

  }
}



Measured memory_bytes: 24020
#include <iostream>
#include <math.h>
using namespace std;

int main() {
    string a, b;
    cin >> a >> b;
    int x = stoi(a + b);
    bool ans = false;
    for (int i = 1; i <= 1000; i++) {
        if (pow(i, 2) == x) {
            ans = true;
            break;
        }
    }
    if (ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  long long sum = 0;
  for(int i=1;i<N;i++){
    sum += i;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		long inputNum = sc.nextInt();

		if (inputNum != 0) {
			for (int i = (int)inputNum; i > 1; i--) {
				inputNum *= (i - 1);
			}
			System.out.println(inputNum);
		} else {
			System.out.println(1);
		}
	}

}

Measured memory_bytes: 26264
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int A, B, C, D;
    cin >> A >> B >> C >> D;
    
    int ans = min(B, D) - max(A, C);
    if (ans < 0) ans = 0;

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

Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu) FUNC(printe) FUNC(printe0);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    string s; cin >> s;
    cout << 
        (s[0] == 'R' && s[1] == 'R' && s[2] == 'R' ? 3 :
         (s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R') ? 2 :
         s[0] == 'R' || s[1] == 'R' || s[2] == 'R' ? 1 : 0)
        << '\n';
}


Measured memory_bytes: 3164
import math
def solve():
    N, P = map(int, input().split())
    fac = list(prime_factorize(P).items())
    res = 1
    for p in fac:
        for i in range(p[1] // N):
            res *= p[0]
    
    print(int(res))

def prime_factorize(n):
    prime_numbers = {}
    for p in range(2, int(math.sqrt(n)+1)):
        if n % p != 0:
            continue
        num = 0
        while n % p == 0:
            n /= p
            num += 1
        prime_numbers[p] = num

    if n != 1:
        prime_numbers[n] = 1
    return prime_numbers

if __name__ == '__main__':
    solve()

Measured memory_bytes: 38768
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }

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

  auto isPd = [&](string s) {
    string t = s;
    reverse(rng(t));
    return t == s;
  };

  bool ok = true;
  if (!isPd(s)) ok = false;
  if (!isPd(s.substr(0,(n-1)/2))) ok = false;
  if (ok) yn;
  return 0;
}

Measured memory_bytes: 256
s=input()
n=len(s)
a=1
for i in range(0,n//2 -1):
	if s[i]!=s[n//2 -1 -i]:
		a=0
for i in range(n//2 +1,n):
	if s[i]!=s[n + n//2  -i]:
		a=0
for i in range(0,n):
	if s[i]!=s[n-1-i]:
		a=0
if a:
	print('Yes')
else:
	print('No')

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

using namespace std;

constexpr int MAXN=2e5+5;

string s[MAXN];

int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		cin>>s[i];
	sort(s+1,s+n+1);
	int cnt=unique(s+1,s+n+1)-s-1;
	printf("%d",cnt);
}


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

int main() {
  int N;
  cin >> N;
  int a[N];
  int cnt = 0;
  
  for(int i = 0; i < N; i++) {
    cin >> a[i];
    if(a[i] == (cnt + 1)) cnt++;
  }
  
  if(cnt == 0) cout << -1 << endl;
  else cout << N - cnt << endl;
    
}

Measured memory_bytes: 1024
#pragma comment(linker,"/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include <unordered_set>
#include<set>
#include<time.h>
#include<queue>
#include<map>
#include<vector>
#define inf 1000000000
#define LL long long
#define ULL unsigned long long
#define dinf ~0uLL>>1
#define FO(i,n) for(LL i=0;i<n;i++)
#define FOD(i,n) for(LL i=n-1;i>=0;i--)
#define FOR(i,a,b,c) for(LL i=a;i<=b;i+=c)
#define FORD(i,a,b,c) for(LL i=a;i>=b;i-=c)
#define clr(a,b) memset(a,b,sizeof(a))
#define pi acos(-1.0)
#define H_J(a) ((a)*180.0/pi)
#define J_H(a) ((a)*pi/180.0)
#define lson l,mid,rt<<1
#define rson mid+1,r,(rt<<1)+1
#define eps 1e-8
#define zero(x) (abs(x)<eps?0:(x<0?-1:1))
#define printime printf("%.3lf\n",(double)clock() / CLOCKS_PER_SEC)

using namespace std;

const int maxn = 1e5+5;

int a[maxn],v[maxn];




int main() {

    int n;
    cin>>n;
    for(int i =0;i<n;i++){
        cin>>a[i];
    }
    for(int i = 0;i<maxn-3;i++){
        v[i] = 0;
    }

    for(int i= 0;i<n;i+=2){
        v[a[i]] ++;
    }
    int maxx11 = 0,maxx12 = 0;
    int num11 = -1,num12 = -1;
    for(int i = 0;i<maxn-3;i++){
        if(v[i] > maxx11){
            maxx12 = maxx11;
            num12 = num11;
            maxx11 = v[i];
            num11 = i;

        }
        else if(v[i] > maxx12){
            maxx12 = v[i];
            num12 = i;
        }
        v[i] = 0;
    }
    for(int i= 1;i<n;i+=2){
        v[a[i]] ++;
    }
    int maxx21 = 0, maxx22 = 0;
    int num21 = -1,num22 = -1;
    for(int i = 0;i<maxn-3;i++){
        if(v[i] > maxx21){
            maxx22 = maxx21;
            num22 = num21;
            maxx21 = v[i];
            num21 = i;

        }
        else if(v[i] > maxx22){
            maxx22 = v[i];
            num22 = i;
        }
    }
    //cout<<maxx11<<" "<<maxx22<<endl;
    if(num11 != num21){
        cout<<(n - maxx11 - maxx21)<<endl;
    }
    else {
        cout<<min((n - maxx11 - maxx22),(n - maxx12 - maxx21))<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
n,m = map(int,input().split())
s = []
for i in range(n):
  s.append(tuple(map(int,input().split())))
p = []
for i in range(m):
  p.append(tuple(map(int,input().split())))

for a,b in s:
  mnl = float('inf')
  for i in range(m):
    c,d = p[i]
    l = abs(a-c)+abs(b-d)
    if l < mnl:
      mnp = i+1
      mnl = l
  print(mnp)


Measured memory_bytes: 67480
#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
typedef long long ll;
typedef long double ld;
const int MAXN = 100005;
char str[MAXN];
bool C[MAXN]; // 0 -> black
int sub1[MAXN], sub2[MAXN];
vector<int> E[MAXN];
struct TwoMin {
	int mn = INT_MAX, mn2 = INT_MAX;
	void update(int x) {
		if (x <= mn) {
			mn2 = mn;
			mn = x;
		} else {
			mn2 = min(mn2, x);
		}
	}
};
void go(int x, int p = -1) {
	int nonblacks = 0;
	int sumsub2 = 0;
	int mndiff = 0;
	int color = 1 - C[x];
	for (int y : E[x]) {
		if (y == p) continue;
		go(y, x);
		if (sub2[y] != -1) {
			sumsub2 += sub2[y] + 2;
			mndiff = min(mndiff, sub1[y] - sub2[y] - 1);
			color = 1 - color;
			++nonblacks;
		}
	}
	if (!nonblacks && !C[x]) sub2[x] = -1;
	else {
		sub2[x] = color + sumsub2;
		sub1[x] = !nonblacks ? 0 : (1 - color) + sumsub2 + mndiff;
	}
}
int ans = INT_MAX;
void come(int x, int p, int psub1, int psub2) {
	int nonblacks = 0;
	int sumsub2 = 0;
	int color = 1 - C[x];
	TwoMin mndiff;
	for (int y : E[x]) {
		if (y == p) continue;
		if (sub2[y] != -1) {
			sumsub2 += sub2[y] + 2;
			mndiff.update(sub1[y] - sub2[y] - 1);
			color = 1 - color;
			++nonblacks;
		}
	}
	if (psub2 != -1) {
		sumsub2 += psub2 + 2;
		mndiff.update(psub1 - psub2 - 1);
		color = 1 - color;
		++nonblacks;
	}
	int val = !nonblacks ? color : (1 - color) + sumsub2 + mndiff.mn;
	ans = min(ans, val + 1);
	for (int y : E[x]) {
		if (y == p) continue;
		if (sub2[y] == -1) continue;
		int ps1 = 0, ps2;
		if (nonblacks == 1 && !C[x]) ps2 = -1;
		else {
			int take = mndiff.mn;
			if (sub1[y] - sub2[y] - 1 == mndiff.mn) take = mndiff.mn2;
			int ncolor = 1 - color;
			int nsumsub2 = sumsub2 - sub2[y] - 2;
			ps2 = nsumsub2 + ncolor;
			ps1 = nonblacks == 1 ? 0 : nsumsub2 + take + (1 - ncolor);
		}
		come(y, x, ps1, ps2);
	}
}
int main() {
	int N;
	scanf("%d", &N);
	for (int i = 1; i < N; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		E[x].push_back(y);
		E[y].push_back(x);
	}
	scanf("%s", str);
	for (int i = 0; i < N; ++i) C[i + 1] = str[i] == 'W';
	go(1, -1);
	come(1, -1, 0, -1);
	if (sub2[1] == -1) ans = 0;
	printf("%d\n", ans);
}


Measured memory_bytes: 15616