akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(void){

	int A, B , K;	cin >> A >> B >> K;
  	int end;
  	if(B < A + K)
      end = B + 1;
  	else
      end = A + K;
  
	for(int i = A ; i < end ; i++)	cout << i << endl;
  	int next;
    if(B - K + 1 <= A + K - 1)
      	next = A + K;
  	else
    	next = B - K + 1;
  
	for(int i = next ; i <= B ; i++) cout << i << 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 REP(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
typedef pair<int,int> pii;

ll ans[2005];
int main(){
    int n,x,y;
    cin>>n>>x>>y;
    for(int i=1;i<n;i++){
        for(int j=i+1;j<=n;j++){
            int d = min(min(min(j-i,abs(x-i)+abs(x-j)),abs(x-i)+abs(y-j)+1),abs(y-i)+abs(x-j)+1);
            ans[d]+=1;
        }
    }
    REP(i,n-1){
        cout<<ans[i]<<endl;
    }
    return 0;
}

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

char a[300];
int solve(int n){
	if(n == 1)return 1;
	if(n%2 == 1)return 0;
	int m = n/2;
	for(int i = 0;i < m;i++){
		if(a[i] != a[i+m])return 0;
	}
	return 1;
}

int main(){
	scanf("%s", a);
	int n = strlen(a);
	for(int i = n-1;i >= 0;i--){
		if(solve(i) == 1){
			printf("%d\n", i);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;

void main()
{
	auto input = split( readln() );
	long N = to!long(input[0]), K = to!long(input[1]);
	
	
	long cnt = 0;
	long b = K+1;
	while ( b <= N ) {
		cnt += (b-K) * (N/b);
		long s = N%b - K + 1;
		if (s > 0) { cnt += s; }
		if (K == 0) { cnt -= 1; }
		b += 1;
	}
	
	writeln(cnt);
}

Measured memory_bytes: 380
#include<iostream>
#include<vector>
#include<queue>
#include<set>
#include<cassert>
#include<tuple>

using namespace std;
#define repeat(i,n) for(int i=0;i<(n);i++)
using pii=pair<int, int>;

struct Data{
   int v;
   pii s;
   Data(int vv, pii ss){v=vv; s=ss;}
};

bool operator<(const Data &l, const Data &r){
   return l.v<r.v;
}

struct SegmentTree{

   int sz;
   const int inf=1e9;
   vector<pii> seg;
   SegmentTree(int N){
      sz=1;
      while(sz<N) sz*=2;
      seg.resize(2*sz-1, {inf, -1});
   }

   void init(vector<int> &a, int ev){
      repeat(i, a.size()){
         if((i+ev)%2==1) seg[i+sz-1]={a[i], i};
         else seg[i+sz-1]={inf, i};
      }
      for(int i=sz-2; i>=0; i--){
         seg[i]=mrg(seg[2*i+1], seg[2*i+2]);
      }
   }

   pii mrg(pii l, pii r){
      pii rt;
      rt.first=min(l.first, r.first);
      rt.second=(l.first<r.first?l.second:r.second);
      return rt;
   }

   pii mi(int a, int b, int i, int l, int r){
      if(a<=l and r<=b){
         return seg[i];
      }else if(b<=l or r<=a){
         return {inf, -1};
      }else{
         int m=(r+l)/2;
         auto vl=mi(a, b, 2*i+1, l, m);
         auto vr=mi(a, b, 2*i+2, m, r);
         return mrg(vl, vr);
      }
   }

   pii mi(int a, int b){
      return mi(a, b, 0, 0, sz);
   }

   void out(){
      repeat(i, sz){
         cout<< seg[i+sz-1].first<< " ";
      }cout<< endl;
   }

};

int main(){

   int N; cin>> N;
   vector<int> a(N);
   repeat(i, N) cin>> a[i], a[i]--;

   SegmentTree st[2](N);
   st[0].init(a, 1); st[1].init(a, 0);
   priority_queue<tuple<int, int, int>> Q; // min, l, r
   Q.push(make_tuple(-st[0].mi(0, N).first, 0, N));
   vector<int> q;
   // st[0].out(); st[1].out();
   while(not Q.empty()){
      int v, i, j;
      tie(v, i, j)=Q.top(); Q.pop();
      auto ev=st[i%2].mi(i, j);
      auto od=st[(i+1)%2].mi(ev.second+1, j);
      // cout<< v<< " "<< i<< " "<< j<< endl;
      assert(j-i>=2);
      assert((i+ev.second)%2==0);
      assert((i+od.second)%2==1);
      q.push_back(ev.first); q.push_back(od.first);
      if(i<ev.second){
         auto e=st[i%2].mi(i, ev.second);
         Q.push(make_tuple(-e.first, i, ev.second));
      }
      if(od.second+1<j){
         auto e=st[(od.second+1)%2].mi(od.second+1, j);
         Q.push(make_tuple(-e.first, od.second+1, j));
      }
      if(ev.second+1<od.second){
         auto e=st[(ev.second+1)%2].mi(ev.second+1, od.second);
         Q.push(make_tuple(-e.first, ev.second+1, od.second));
      }
   }

   repeat(i, N){
      if(i){
         cout<< " "<< q[i]+1;
      }else{
         cout<< q[i]+1;
      }
   }cout<< endl;

   return 0;
}


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

int main() {
    int N;
    char si;
    string ans = "Three";
    cin >> N;
    rep(i, N) {
        cin >> si;
        if (si=='Y') ans = "Four";
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
use std::env;
use std::io::*;
use std::str::*;
use std::mem;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}
fn read_char() -> char {
    let c = read::<String>();
    let c = c.chars().collect::<Vec<char>>();
    c[0]
}
fn read_String_Vec() -> Vec<char> {
    let S = read::<String>();
    S.chars().collect::<Vec<char>>()
}

fn vecchar_to_String(Vs: Vec<char>) -> String {
    let mut S = String::new();
    for i in 0..Vs.len() {
        S.push(Vs[i]);
    }
    S
}

/*
A : 65
Z : 90
a : 97
z : 122
*/

/*
let N = read::<i32>();
let S = read::<String>();
let S = read_String_Vec();
let C = read_char();
*/

/*
 .to_string() : * -> String
 &*S          : String -> &str
*/

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let S = read_String_Vec();
    let mut string = String::new();

    let len = S.len();
    for i in 0..len {
        if i % 2 == 1 { continue; }
        string.push(S[i]);
    }
    println!("{}", string);
}


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

typedef long long lint;
#define REP(i, x, n) for(lint i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const lint inv = MOD - 2;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    int n;
    cin >> n;
    int dp[2][110] = {{0}};
    rep(i, 2){
        REP(j, 1, n+1){
            cin >> dp[i][j];
        }
    }
    REP(j, 1, n+1){
        dp[0][j] += dp[0][j-1];
        dp[1][j] += max(dp[0][j], dp[1][j-1]);
    }
    cout << dp[1][n] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>

using namespace std;

int main() {
        int t, a, b, c;
        cin>>t;
        for(int i; i<t; i++) {
                cin>>a>>b>>c;
                int ax = pow(a, 2);
                int bx = pow(b, 2);
                int cx = pow(c, 2);
                if(ax+bx==cx || bx+cx==ax || ax+cx==bx) cout << "YES" << endl;
                else cout << "NO" << endl;
        }
        return 0;
}

Measured memory_bytes: 1152
#include <cstdio>
#include <algorithm>
const int MOD = 998244353;
int cnt[3];

int main() 
{
	int n; scanf("%d ", &n);
	long long res = 1;
	for (int i = 0; i < 3 * n; ++i)
	{
		char c = getchar();
		int *x = &cnt[(++c ^ 64) / 8];
		int *y = x > cnt ? x - 1 : x + 2;
		int *z = y > cnt ? y - 1 : y + 2;
		if (*y > *z) std::swap(y, z);
		res = res * ((*x < *y ? *y : *x < *z ? *z : -1) - (*x)++) % MOD;
	}
	printf("%lld\n", res < 0 ? -res : res);
}

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

int k, d[100005];

void f(int p, int q) {
	if (p >= d[q]) return;
	d[q] = p;
	f(p, q * 10 % k);
	f(p + 1, (q + 1) % k);
}

int main()
{
	int i;
	cin >> k;
	for (i = 0; i < k; i++) d[i] = 45;
	f(1, 1);
    cout << d[0] << endl;
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector <vector <int >> arr(n,vector <int> (3,0));
    for(int i=0;i<n;i++){
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    }
    vector <int > dp1;
    
    dp1.push_back(arr[0][0]);
    dp1.push_back(arr[0][1]);
    dp1.push_back(arr[0][2]);
    for(int i=1;i<n;i++){
        vector <int>  dp2(3,0);
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(j==k)
                    continue;
                dp2[j]=max(dp2[j],dp1[k]+arr[i][j]);
            }
        }
        dp1=dp2;
    }
    cout<<max({dp1[0],dp1[1],dp1[2]})<<endl;
    
}

Measured memory_bytes: 5760
#include<iostream>

using namespace std ;

int ans = 0 ;

bool answer( int n ,long num[] ,int p )
{
	if( n == num[ p ] )
	{
		ans++ ;
		return true ;
	}
	return false ;
}

int main()
{
	int s ,t ,n ;

	cin >> s ;
	long num[ s ] ;

	for( int i = 0 ; i < s ; i++ )
		cin >> num[ i ] ;

	cin >> t ;
	for( int i = 0 ; i < t ; i++ )
	{
		int p = 0 ,pp = s ;
		cin >> n ;
		while( true )
		{
			int a = p + ( ( pp - p ) / 2 ) ;
			if( answer( n ,num ,a ) )
				break ;
			else if( n > num[ a ] )
			{
				if( answer( n ,num ,a + 1 ) )
					break ;
				p = a + 1 ;
				if( p == pp )
					break ;				
			}
			else if( answer( n ,num ,a - 1 ) )
				break ;
			else
			{
				pp = a - 2 ;
				if( pp <= p )
					break ;
			}
		}
	}

	cout << ans << endl ;

	return 0 ;
}

Measured memory_bytes: 3864
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N; cin >> N;
    map<int,int> mp;
    REP(i,N)
    {
        int A; cin >> A;
        mp[A]++;
    }
    LL ans = 0;
    for(auto p : mp)
    {
        if(p.second % 2 == 1) ans++;
    }
    cout << ans << endl;

}


Measured memory_bytes: 4992
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize
    }
    let mut v = vec![0; n+1];
    let m = (n as f64).sqrt() as usize;
    for x in 1..m {
        for y in x..m {
            for z in y..m {
                let i = x*x + y*y + z*z + x*y + y*z + z*x;
                if i <= n {
                    if x == y && y == z {
                        v[i] += 1;
                    } else if x != y && y != z && x != z {
                        v[i] += 6;
                    } else {
                        v[i] += 3;
                    }
                }
            }
        }
    }
    for i in v.iter().skip(1) {
        println!("{}", i);
    }
}


Measured memory_bytes: 2140
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const int maxn=100010;
const int INF=0x7fffffff;
int n,h[maxn],dp[maxn];
void init(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&h[i]);
	for(int i=2;i<=n;i++) dp[i]=INF;
	for(int i=1;i<=n;i++){
		dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
		dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
	}
	printf("%d",dp[n]);
}
int main(){
	init();
	return 0;
}

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll a,b; cin>>a>>b;
    cout<<(max(a,b)<2*min(a,b) ? "Yay!" : ":(")<<endl;
    return 0;
}

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

using namespace std;

#define MAX_H 55
#define MAX_W 55

int H,W,sx,sy,gx,gy;
bool visited[MAX_H][MAX_W];
char field[MAX_H][MAX_W];
set<char> st;
int dx[] = {-1,0,1,0};
int dy[] = {0,-1,0,1};

void getPos(int x,int y,char ch){
  if(visited[y][x]){ return; }
  visited[y][x] = true;
  if(field[y][x] == ch){
    sx = min(sx,x); gx = max(gx,x);
    sy = min(sy,y); gy = max(gy,y);
  }
  for(int i = 0 ; i < 4 ; i++){
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(0 <= nx && nx < W && 0 <= ny && ny < H){
      getPos(nx,ny,ch);
    }
  }
}

bool remove(char ch){
  for(int i = sy ; i <= gy ; i++){
    for(int j = sx ; j <= gx ; j++){
      if(field[i][j] != ch && field[i][j] != '*'){
        return false;
      }
    }
  }
  return true;
}

void change(){
  for(int i = sy ; i <= gy ; i++){
    for(int j = sx ; j <= gx ; j++){
      field[i][j] = '*';
    }
  }
}

bool check(){
  int N = st.size();
  while(N--){
    for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W ; j++){
        if(field[i][j] == '.'){ continue; }
        if(field[i][j] == '*'){ continue; }
        memset(visited,false,sizeof(visited));
        sx = sy = 1e9; gx = gy = 0;
        getPos(j,i,field[i][j]);
        if(remove(field[i][j])){
          change();
          goto next;
        }
      }
    }
    return false;
  next:;
  }
  return true;
}

int main(){
  int Tc;
  cin >> Tc;
  while(Tc--){
    cin >> H >> W;
    st.clear();
    for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W ; j++){
        cin >> field[i][j];
        if(isupper(field[i][j])){
          st.insert(field[i][j]);
        }
      }
    }
    cout << (check() ? "SAFE" : "SUSPICIOUS") << endl;
  }
  return 0;
}

Measured memory_bytes: 1300
N,K = map(int,input().split())
lis = []
val = 0
ans = 0
s = set()
dub = []

for _ in range(N):
    lis.append(tuple(map(int,input().split())))

lis = sorted(lis,key=lambda x: x[1],reverse=True)

for t,v in lis[:K]:

    if t in s:
        dub.append(v)
    s.add(t)
    val += v

ans = val + len(s) ** 2

for t,v in lis[K:]:
    if len(dub) == 0:
        break
    if t in s:
        continue

    s.add(t)
    r = dub.pop()
    val += v - r
    ans = max(ans,val+len(s) ** 2)

print(ans)

Measured memory_bytes: 19876
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


int main() {
  while(true) {
    int n;
    double x[100], y[100], z[100], r[100];
    vector<pair<double, pair<double, double>>> es;
    cin >> n;
    if(n == 0) break;
    rep(i, n) {
      double a, b, c, d;
      cin >> a >> b >> c >> d;
      x[i] = a;
      y[i] = b;
      z[i] = c;
      r[i] = d;
    }

    UnionFind tree(n);

    for(int i = 0; i < n; i++) {
      for(int j = i+1; j < n; j++) {
        double dist = (x[i]-x[j]) * (x[i]-x[j]) + (y[i]-y[j]) * (y[i]-y[j]) + (z[i]-z[j]) * (z[i]-z[j]);
        dist = sqrt(dist); 
        // cout << dist << endl;
        if(dist <= r[i] + r[j]) {
          tree.unite(i, j);
          continue;
        }
        if(dist > r[i] + r[j]) {
          pair<double, pair<double, double>> p;
          p.first = dist - r[i] - r[j];
          p.second.first = i;
          p.second.second = j;
          es.push_back(p);
          // cout << p.first << " " << i << " " << j << endl;
          // cout << 1 << endl;
        }
      }
    }

    sort(es.begin(), es.end());


    double ans = 0.000;

    for(int i = 0; i < es.size(); i++) {
      int nx, ny;
      nx = es[i].second.first;
      ny = es[i].second.second;
      if(tree.same(nx, ny)) {
        continue;
      } else {
        tree.unite(nx, ny);
        ans += es[i].first;
        // cout << std::fixed << std::setprecision(3) << es[i].first << endl;
      }
    }
    // cout << endl;
    cout << std::fixed << std::setprecision(3) << ans << endl;
    // cout << std::fixed << std::setprecision(3) << es[0].first << endl;
    // cout << std::fixed << std::setprecision(3) << x[0] << endl;
    // cout << std::fixed << std::setprecision(3) << y[0] << endl;
    // cout << std::fixed << std::setprecision(3) << z[0] << endl;
    // cout << std::fixed << std::setprecision(3) << es[0].first << endl;

  }
  return 0;
}


Measured memory_bytes: 3328
str_N, str_K = input().split()
height = input().split()

int_N = int(str_N)
int_K = int(str_K)

for i in range(len(height)):
    height[i] = int(height[i])

k = 0

for j in height:
    if j >= int_K:
        k += 1

print(k)

Measured memory_bytes: 9980
#include<stdio.h>
int a[20],n;
int solve(int,int);

int main(){
  int m,q,i;


  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&a[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(solve(0,m)) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}
int solve(int i,int m){
  int res;

  if(m==0) return 1;
  if(i>=n) return 0;
  res=solve(i+1,m)||solve(i+1,m-a[i]);
  return res;
}



Measured memory_bytes: 2104
package main

import "fmt"

func main() {
	var W, H, x, y, r int
	var flagW, flagH bool
	fmt.Scan(&W, &H, &x, &y, &r)

	if x-r >= 0 && x+r <= W {
		flagW = true
	}

	if y-r >= 0 && y+r <= H {
		flagH = true
	}

	if flagH && flagW {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}



Measured memory_bytes: 1172
import sys

N, M = map(int, input().split())
A = []
B = []

for i in range(0, N):
    Ai = input()
    A.append(Ai)

for i in range(0, M):
    Bi = input()
    B.append(Bi)

found = True
for i_offset in range(0, N-M+1):
    found = True
    j_offset = A[i_offset].find(B[0])
    if j_offset < 0:
        continue
    for i in range(0, M):
        if A[i+i_offset][j_offset:j_offset+M] != B[i][0:M]:
            found = False
            break
    if found:
        print("Yes")
        sys.exit()

print("No")



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
string A,B,C;
int main(){
	cin>>A>>B>>C;
	if(A[A.size()-1]==B[0] && B[B.size()-1]==C[0])cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from math import gcd
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: print('Yes' if b else 'No')
YESNO=lambda b: print('YES' if b else 'NO')

def main():
    K=int(input())
    ans=0
    for i in range(1,K+1):
        for j in range(1,1+K):
            for k in range(1,1+K):
                ans+=gcd(i,gcd(j,k))
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 67764
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

const int N = 111;
int a[N];
int n, m;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    int sum = 0;
    rep(i, 1, n) {
        cin >> a[i];
        sum += a[i];
    }
    int cnt = 0;
    rep(i, 1, n) {
        cnt += 4 * a[i] * m >= sum;
    }
    cout << (cnt >= m ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp make_pair
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define MOD ((int)1e9 + 7)
#define atoi(x) ((x)-'0')
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

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

int n, a, b, minv[2] = { LLONG_MAX, LLONG_MAX }, maxv[2] = { LLONG_MIN, LLONG_MIN };

signed main() {
	fastio;
	cin >> n;
	FOR(i, n) {
		cin >> a >> b;
		minv[0] = min(minv[0], a + b);
		maxv[0] = max(maxv[0], a + b);
		minv[1] = min(minv[1], a - b);
		maxv[1] = max(maxv[1], a - b);
	}
	cout << max(maxv[0] - minv[0], maxv[1] - minv[1]);
}

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;
const int BT=18;
int dp[1<<BT][2]; 

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n; 
	scanf("%d",&n);
	for(int i=0; i<(1<<n); i++)scanf("%d",&dp[i][1]);
	for(int i=0; i<n; i++){
		for(int mask=0; mask < (1<<n); mask++){
			if(!dp[mask][1])continue;
			if(mask>>i&1){
				dp[mask][0]=max(dp[mask][0],dp[mask^(1<<i)][1]);
				if(dp[mask][0]>dp[mask][1])swap(dp[mask][0],dp[mask][1]);
			}
		}
	}
	int res = 0;
	for(int i=1; i<(1<<n); i++){
		res = max(res,dp[i][0]+dp[i][1]);
		cout << res << endl;
	}
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


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

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

  while (true) {
    C -= B;
    if (C <= 0) {
      cout << "Yes" << endl;
      return 0;
    }
    A -= D;
    if (A <= 0) {
      cout << "No" << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3096
import java.util.*;

public class Main {
    static String[] strs = {
        "maerd",
        "remaerd",
        "esare",
        "resare"
    };
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuffer s = new StringBuffer(100000);
        String s_in = sc.next();
        s.append(s_in);
        s.reverse();

        while (true) {
            boolean startsWithStr = false;
            for (String str: strs) {
                if (s.indexOf(str) == 0) {
                    startsWithStr = true;
                    s = s.delete(0, str.length());
                    break;
                }
            }
            if (!startsWithStr) {
                System.out.println("NO");
                break;
            }
            if (s.length() <= 0) {
                System.out.println("YES");
                break;
            }
        }
    }
}

Measured memory_bytes: 27280
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
#include <string.h>
#include <cmath>
#include <map>

using namespace std;

int main(int argc, char* argv[]) {
  int H, W;
  cin >> H >> W;

  int ret = 0;
  char s[H][W];
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      cin >> s[i][j];
      if (s[i][j] == '#')
        ++ret;
    }
  }

  int d[H][W];
  memset(d, -1, sizeof(int) * H * W);
  queue<pair<int, int> > q;
  q.push(make_pair(0, 0));
  while (!q.empty()) {
    pair<int, int> cur = q.front();
    q.pop();
    int cur_x = cur.second;
    int cur_y = cur.first;
    for (int i = -1; i < 2; ++i) {
      for (int j = -1; j < 2; ++j) {
        if (abs(i) == 1 && abs(j) == 1)
          continue;
        int next_x = cur_x + j;
        int next_y = cur_y + i;
        if (next_x >= 0 && next_x < W && next_y >= 0 && next_y < H) {
          if (s[next_y][next_x] == '.' && d[next_y][next_x] == -1) {
            d[next_y][next_x] = d[cur_y][cur_x] + 1;
            q.push(make_pair(next_y, next_x));
          }
        }
      }
    }
  }

  if (d[H - 1][W - 1] == -1) {
    cout << -1 << endl;
    return 0;
  }

  cout << H * W - d[H - 1][W - 1] - ret - 1 << endl;

  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))

XOR=0
for a in A:
    XOR^=a

for i in range(N):
    A[i] &=~XOR
    
USED=[0]*N

for bi in range(60,-1,-1):
    for i in range(N):
        if USED[i]==0 and A[i] & (1<<bi)!=0:
            USED[i]=1
            useind=i
            break
    else:
        continue

    for i in range(N):
        if i==useind:
            continue
        if A[i] & (1<<bi)!=0:
            A[i]^=A[useind]
            
ANS=0
for a in A:
    ANS^=a

print(2*ANS+XOR)


Measured memory_bytes: 16052
import java.io.*;
public class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            int x,a;
            String line = reader.readLine();
            x = Integer.parseInt(line);
            a = x*x*x;
	        System.out.println(a);
        }catch(IOException e){
            System.out.println(e);
        }catch(NumberFormatException e){
System.out.println("The input number was not correct.");
        }
    }
}



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

  int n, k,a;
  ll sum, tmp=0;
  cin >> n >> k;
  queue<int> q;
  rep(i,k)
  {
    cin >> a;
    tmp+=a;
    q.push(a);
  }
  sum=tmp;
  rep(i,n-k)
  {
    cin >> a;
    tmp += a-q.front();
    sum=max(sum,tmp);
    q.pop();
    q.push(a);
  }
  printf("%.7lf", (double)(sum+k)/2);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    int i=0,j=n-1,l=n-2,k=1;
    ll ans=a[j]-a[i];
    while(k<=l){
        if(a[j]-a[k]>a[l]-a[i]){
            ans+=a[j]-a[k];
            j--;
            k++;
        }else{
            ans+=a[l]-a[i];
            i++;
            l--;
        }
    }
    cout<<ans<<endl;
   return 0;   
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<ll>
#define pl pair<ll,ll>
#define TC int t;cin>>t;while(t--)
#define in(n) ll n;cin>>n;
#define inarr(n) ll n;cin>>n;vector<ll>arr;
ll primes[10000007];
int main(void){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    memset(primes,0,sizeof(primes));
    for(int i=1;i<10000007;i++){
        ll temp=1;
        while(i*temp<10000007){
            primes[i*temp]++;
            temp++;
        }
    }
    for(int i=1;i<10000007;i++){
        primes[i]=primes[i]*i+primes[i-1];
    }
    in(n);
    cout<<primes[n]<<endl;
    return 0;
}

Measured memory_bytes: 81760
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#define ll long long
#define re register
using namespace std;
struct ios{
	inline char fchar(){
		static char buf[100000],*p1=buf,*p2=buf;
		return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
	}
//	#define getchar fchar
	template <typename ty> inline ios& operator >> (ty &x)
	{
		register int f=1;x=0;register char c=getchar();
		for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
		for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48);
		x*=f;return *this;
	}
	template <typename ty>  inline ios& operator << (ty x)
	{
		if(x<0) x=-x,putchar('-');
		if(x>9) *this << x/10;
		putchar(x%10+48);
		return *this;
	}
	inline ios& operator << (char x){putchar(x);return *this;}
}io;
const int N = 6e4+5;


int s;
string s2;

int main()
{
	io >> s;
	cin >> s2;
	if(s>=3200) cout << s2;
	else cout << "red";
	return 0;
} 

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

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
const ll MOD = 1e9+7;

/**グローバル変数**/
int n,ans,cnt;
string s;

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

double t,x;
cin >> t >> x;
cout << setprecision(20) << t/x << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF =ll(1e18) +1;

int main() {
    int N,C;
    cin >> N >>C;
    vector<vector<int>> D(C);
    for(int i=0;i<C;i++){
        for(int j=0;j<C;j++){
            int d;
            cin >> d;
            D[i].push_back(d);
        }
    }
    vector<vector<int>> Color(N);

    vector<pair<int,int>> A,B,E;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            int x;
            cin >> x;
            --x;
            Color[i].push_back(x);
            if((i+j)%3==0){
                A.emplace_back(i,j);
            }
            if((i+j)%3 ==1){
                B.emplace_back(i,j);
            }
            if((i+j) %3 ==2){
                E.emplace_back(i,j);
            }
        }
    }
    ll dA[C] ={};
    ll dB[C] = {};
    ll dD[C] ={};
    for(int i=0;i<C;i++){

        for(auto p:A){
            int targetC = Color[p.first][p.second];
            dA[i] += D[targetC][i];
        }
        for(auto p:B){
            int targetC = Color[p.first][p.second];
            dB[i] += D[targetC][i];
        }
        for(auto p:E){
            int targetC = Color[p.first][p.second];
            dD[i] += D[targetC][i];
        }
    }
    ll ans = INF;
    for(int i=0;i<C;i++){
        for(int j=0;j<C;j++){
            if(i ==j){
                continue;
            }
            for(int k =0;k<C;k++){
                
                if(j == k || i ==k){
                    continue;
                }
                
                ans =min(ans,dA[i]+dB[j]+dD[k]);
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 912345678;

int n;

int main()
{
    cin >> n;

    int ans = 0;
    for (int i = 1; i <= n; i += 2)
    {
        int k = 0;
        for (int j = 1; j <= i; ++j)
        {
            i % j == 0 && ++k;
        }
        k == 8 && ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import math

n = int(input())

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

res = 0

for x in a :
    res += x

ans = 0

i = 0

while ans < res//2 :
    ans += a[i]
    i += 1

i -= 1

rmn = res - ans
print(min(ans - rmn, rmn + 2*a[i] - ans))

Measured memory_bytes: 25948
#include "iostream"
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
    int N, Y;
    cin >> N >> Y;

    int x, y, z; 
    for (x = 0; x <= N; x++) {
        for (y = 0; y <= N - x ;y++) {
            z = N - x - y;
            int total = x * 10000 + y * 5000 + z * 1000;
            if (total == Y) {
                cout << x << " " << y << " " << z << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

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

using namespace std;

int main() {
	int M, D; cin >> M >> D;
	int ans = 0;
	for (int m = 1; m <= M; ++m) {
		for (int d = 10; d <= D; ++d) {
			int d_1 = d % 10, d_10 = d / 10;
			if (d_1 >= 2 && d_10 >= 2 && d_1 * d_10 == m) {
				++ans;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
n = gets.to_i
ary = gets.split(' ').map(&:to_i)
neg, s, mx = 0, 0, 0
mi = 10 ** 10
ary.each do |a|
  neg += 1 if a.negative?
  mx = [a.abs, mx].max
  mi = [a.abs, mi].min
  s += a.abs
end
puts neg.even? ? s : s - mi * 2

Measured memory_bytes: 11268
import java.io.*;  

public class Main {
    public static void main(String[] args) throws IOException {
	int hour;                                         
	int min;                                          
	int sec;                                          
    	
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String buf = br.readLine();
    String[] x = buf.split(" ",0);
    	
    	int y = Integer.parseInt(x[0]);
    	//int z = Integer.parseInt(x[1]);
        //int i = Integer.parseInt(x[2]);
    	 //System.out.println(x[0] + ":" + x[1] + ":" + x[2]);
    	 
    	 hour = y /3600;
    	 min = (y%3600)/60;
    	 sec = (y%3600)%60;
    	 System.out.println(hour + ":" + min + ":" + sec); 
    	
	    
    }
    
}

Measured memory_bytes: 24256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] r = new int[n+1];
        int[] c = new int[n+1];
        for(int i = 1; i <= n; i++){
            r[i] = Integer.parseInt(sc.next());
            c[i] = Integer.parseInt(sc.next());
        }
        
        int[][] m = new int[n+1][n+1];
        int[] p = new int[n+1];
        p[0] = r[1];
        for(int i = 1; i <= n; i++){
            p[i] = c[i];
        }
        
        for(int l = 2; l <= n; l++){
            for(int i = 1; i <= n-l+1; i++){
                int j = i+l-1;
                m[i][j] = 1 << 21;
                for(int k = i; k < j; k++){
                    m[i][j] = Math.min(m[i][j], m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j]);
                }
            }
        }
        
        System.out.println(m[1][n]);
    }
}


Measured memory_bytes: 26500
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
int n; int m; int board[9][9][9];
int d1[13] = { 1,0,0,1,1,0,1,0,-1,1,1,-1,1 };
int d2[13] = { 0,1,0,1,0,1,-1,1,0,1,-1,1,1 };
int d3[13] = { 0,0,1,0,1,1,0,-1,1,-1,1,1,1 };
void init(){
	rep(i, 9) {
		rep(j, 9) {
			rep(k, 9) {
				board[i][j][k] = 0;
			}
		}
	}
}
bool safeadd(int x, int y,int col) {
	int z;
	Rep(i,1, n+1) {
		if (board[x][y][i] == 0) {
			z = i;
			board[x][y][i] = col; break;
		}
	}
	rep(i, 13) {
		int cnt = -1;
		rep(j, m) {
			if (col != board[x + j*d1[i]][y + j*d2[i]][z + j*d3[i]]) {
				break;
			}
			cnt++;
		}
		rep(j, m) {
			if (col != board[x - j * d1[i]][y - j * d2[i]][z - j * d3[i]]) {
				break;
			}
			cnt++;
		}
		if (cnt>=m)return false;
	}
	return true;
}
int main() {
	int p;
	while (cin >> n >> m >> p, n) {
		init();
		int x, y;
		bool g = true;
		rep(i, p) {
			cin >> x >> y;
			int col;
			if (i % 2) {
				col = 1;
			}
			else {
				col = 2;
			}
			if (g) {
				if (safeadd(x, y, col))continue;
				if (col == 2) {
					cout << "Black ";
				}
				else {
					cout << "White ";
				}
				cout << i+1 << endl;
				g = false;
			}
		}
		if (g)cout << "Draw" << endl;
	}
	return 0;
}


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

using namespace std;

#define INF 1e9

int main(){
  int P,Q;
  while(cin >> P >> Q, (P | Q)){
    int ind[10];
    int ro[10],rc[10],co[10],cc[10],so[10],sc[10];
    int ro2[10],rc2[10],co2[10],cc2[10],so2[10],sc2[10];
    string s;
    for(int i = 0 ; i < 10 ; i++){
      ind[i] = 0;
      ro[i] = rc[i] = 0;
      co[i] = cc[i] = 0;
      so[i] = sc[i] = 0;
    }
    for(int i = 0 ; i < P ; i++){
      cin >> s;
      bool rd = true;
      for(int j = 0 ; j < (int)s.size() ; j++){
        if(s[j] == '('){ ro[i]++; }
        if(s[j] == ')'){ rc[i]++; }
        if(s[j] == '{'){ co[i]++; }
        if(s[j] == '}'){ cc[i]++; }
        if(s[j] == '['){ so[i]++; }
        if(s[j] == ']'){ sc[i]++; }
        if(s[j] != '.'){ rd = false; }
        if(rd){ ind[i]++; }
      }
    }
    for(int i = 1 ; i < P ; i++){
      ro[i] += ro[i-1];
      rc[i] += rc[i-1];
      co[i] += co[i-1];
      cc[i] += cc[i-1];
      so[i] += so[i-1];
      sc[i] += sc[i-1];
    }
    for(int i = 0 ; i < 10 ; i++){
      ro2[i] = rc2[i] = 0;
      co2[i] = cc2[i] = 0;
      so2[i] = sc2[i] = 0;
    }
    for(int i = 0 ; i < Q ; i++){
      cin >> s;
       for(int j = 0 ; j < (int)s.size() ; j++){
        if(s[j] == '('){ ro2[i]++; }
        if(s[j] == ')'){ rc2[i]++; }
        if(s[j] == '{'){ co2[i]++; }
        if(s[j] == '}'){ cc2[i]++; }
        if(s[j] == '['){ so2[i]++; }
        if(s[j] == ']'){ sc2[i]++; }
      }
    }
    for(int i = 1 ; i < Q ; i++){
      ro2[i] += ro2[i-1];
      rc2[i] += rc2[i-1];
      co2[i] += co2[i-1];
      cc2[i] += cc2[i-1];
      so2[i] += so2[i-1];
      sc2[i] += sc2[i-1];
    }
    vector<int> res(10,INF);
    res[0] = 0;
    for(int i = 1 ; i < Q ; i++){
      vector<int> v;
      for(int R = 1 ; R <= 20 ; R++){
        for(int C = 1 ; C <= 20 ; C++){
          for(int S = 1 ; S <= 20 ; S++){
            bool ok = true;
            for(int j = 1 ; j < P ; j++){
              int rd = ro[j-1]-rc[j-1];
              int cd = co[j-1]-cc[j-1];
              int sd = so[j-1]-sc[j-1];
              if(R*rd+C*cd+S*sd != ind[j]){
                ok = false;
                break;
              }
            }
            if(ok){
              int rd = ro2[i-1]-rc2[i-1];
              int cd = co2[i-1]-cc2[i-1];
              int sd = so2[i-1]-sc2[i-1];
              int val = R*rd+C*cd+S*sd;
              if(res[i] == INF){
                res[i] = val;
              }else{
                if(res[i] != val && res[i] != -1){
                  res[i] = -1;
                }
              }
            }
          }
        }
      }
    }
    for(int i = 0 ; i < Q ; i++){
      if(i){ cout << " "; }
      cout << res[i];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using ld = long double;
using namespace std;

int main(){
	int n, k; cin >> n >> k;
	ld ans = 0;
	// i: サイコロの出た目
	for( int i = 1; i <= n; ++i ){
		int point = i;
		int cnt = 0;
		while( point < k ){
			point *= 2;
			++cnt;
		}
		ans += 1.0/(ld)n * (1.0/(ld)(1<<cnt));
	}
	cout << fixed << setprecision(10) << ans << endl;
	return 0;
}

Measured memory_bytes: 256
s=input()
reverse_s=s[::-1]
n=len(s)
s2=s[:(n-1)//2]
reverse_s2=s2[::-1]
s3=s[(n+3)//2-1:]
reverse_s3=s3[::-1]

if reverse_s==s and reverse_s2==s2 and reverse_s3==s3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//#include <ext/pb_ds/detail/standard_policies.hpp>
#include<set>
#include<map>
#include <unordered_map>
#include <unordered_set>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <strings.h>
#include <fstream>


#define f first
#define s second
#define pb push_back
#define lp(i,a,n) for(int (i)=(a);(i)<=(int)(n);(i)++)
#define lpd(i,n,a) for(int (i)=(n);(i)>=(a);--(i))
#define mp make_pair
#define clr(a, b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define eps 1e-8
#define infi 2e9
#define infll 1e18
#define MX 1000000
#define X real()
#define Y imag()
#define polar(r,t) ((r)* exp(point(0,(t))))
#define length(a) hypot( (a).X , (a).Y )
#define angle(a) atan2( (a).Y , (a).X )
#define vec(a,b) ( (b) - (a) )
#define dot(a,b) (conj(a)*(b)).X
#define cross(a,b) (conj(a)*(b)).Y
#define lengthsqr(a) dot(a,a)
#define reflect(V,M) (conj((V)/(M)) * (M))
//#define rotate(a, theta) (a) * (polar(1.0, (theta) ))
#define normalize(a)   ((a)/length(a))
#define ccw(a,b,c) cross(vec(a,b) , vec(a,c)) > eps
#define cosRule(a,b,c) (acos(((a)*(a)+(b)*(b)-(c)*(c))/(2*(a)*(b))))
#define cosDot(a,b) (acos(dot(a,b)/length(a)/length(b)))
#define EQ(a,b) (fabs((a) - (b)) <= eps) /* equal to */
#define NE(a,b) (fabs((a) - (b)) > eps)  /* not equal to */
#define LT(a,b) ((a) < (b) - eps)        /* less than */
#define GT(a,b) ((a) > (b) + eps)        /* greater than */
#define LE(a,b) ((a) <= (b) + eps)       /* less than or equal to */
#define GE(a,b) ((a) >= (b) - eps)       /* greater than or equal to */
#define mod1 100050001
#define mod2 100030001
#define base1 37
#define base2 31
#define PI acos(-1)
#define sz(a) (int) (a).size()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
typedef complex<long double> point;
typedef pair<point, point> line;
typedef pair<double , point> Circle;
typedef long double ld;


const int N = 200002;
int n, a[N];
ll sum[N], xsum[N], ans;





int main() {
    scanf("%d",&n);
   
    lp(i, 1, n) scanf("%d",&a[i]), sum[i] = sum[i-1] + a[i], xsum[i] = xsum[i-1]^a[i];
    
    
    lp(i, 1, n) {
        int l = i, r = n;
        while (l < r) {
            int mid = (l+r)/2 + 1;
            if((sum[mid] - sum[i-1]) != (xsum[mid] ^ xsum[i-1]))
                r = mid-1;
            else
                l = mid;
        }
        ans += l-i+1;
    
    }
    
    printf("%lld\n",ans);
    
    
    
    return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int maxn=4e5+7;
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a+b+c<=21){
        puts("win");
    }
    else if(a+b+c>21)puts("bust");
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(s: str):
    N = len(s)
    for i in range(N-1):
        if s[i] == s[i+1]:
            print(i+1, i+2)
            return
    for i in range(N-2):
        if s[i] == s[i+2]:
            print(i+1, i+3)
            return
    print(-1, -1)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    solve(s)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5340
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"atcoder"# => r#"acdr"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        s: chars,
    }

    let a:Vec<String> = (0..s.len()).filter(|&i| i % 2 == 0).map(|i| s[i].to_string()).collect();
    a.join("").to_string()
}

Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const int N = 2005;
int n, k, ans;
vector <int> g[N];
bool used[N];

int dfs(int v, int deep){
	int cnt = 1;
	used[v] = 1;
	for(auto to : g[v]){
		if(!used[to] && deep + 1 <= k / 2)
			cnt += dfs(to, deep + 1);
	}
	return cnt;
}

int main(){
	cin >> n >> k;
	for(int i = 1; i < n; ++i){
		int x, y;
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}
	
	for(int i = 1; i <= n; ++i){
		memset(used, 0, sizeof used);
		ans = max(ans, dfs(i, 0));
	}
	if(k & 1){
	for(int i = 1; i <= n; ++i){
		for(auto j : g[i]){
			memset(used, 0, sizeof used);
			used[j] = used[i] = 1;
			ans = max(ans, dfs(i, 0) + dfs(j, 0));
		}
	}
	}
	
	cout << n - ans;
	
	return 0;
}

Measured memory_bytes: 384