akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.CodeFestival2016Final
{
    class A
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            var array = new int[n * 2][];
            for (int i = 0; i < n; i++)
            {
                array[i] = new int[2] { ReadInt(), 0 };
            }
            for (int i = 0; i < n; i++)
            {
                array[n + i] = new int[2] { ReadInt(), 1 };
            }
            Array.Sort(array, (a, b) => a[0] - b[0]);

            long mask = 1000000000 + 7;
            long res = 1;
            long aCnt = 0;
            long bCnt = 0;
            for(int i = 0; i < 2 * n; i++)
            {
                if (array[i][1] == 0)
                {
                    if (bCnt == 0)
                    {
                        aCnt++;
                    }
                    else
                    {
                        res = MultiMod(res, bCnt, mask);
                        bCnt--;
                    }
                }
                else
                {
                    if (aCnt == 0)
                    {
                        bCnt++;
                    }
                    else
                    {
                        res = MultiMod(res, aCnt, mask);
                        aCnt--;
                    }
                }
            }
            WriteLine(res);
        }

        static long MultiMod(long a, long b, long mask)
        {
            return ((a % mask) * (b % mask)) % mask;
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n,m; cin >> n >> m;
  int sum = (n-m)*100 + m*1900;
  cout << (int)pow(2,m)*sum << endl;
}



Measured memory_bytes: 4068
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define ll long long
using namespace std;
int n,cnt;
ll a[100001],minn=INF,ans;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for (int i=0;i<n;++i)
	{
		cin>>a[i];
		if (a[i]<0) cnt++;
		minn=min(minn,abs(a[i]));
		ans+=abs(a[i]);
	}
	if (cnt%2==0) cout<<ans;
	else cout<<ans-2*minn;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int H,W; cin>>H>>W;
    vector<vector<int>> A(H,vector<int>(W));
    rep(h,0,H)rep(w,0,W) cin>>A.at(h).at(w);

    vector<vector<int>> Ans;
    rep(h,0,H){
        rep(w,0,W){
            if(h==H-1 && w==W-1) break;

            int X=h,Y,nextX=h,nextY;
            if(w==W-1) nextX++;
            if(h%2){
                Y=W-w-1;
                nextY=max(0,Y-1);
            }else{
                Y=w;
                nextY=min(W-1,Y+1);
            }

            if(A.at(X).at(Y)%2){
                A.at(X).at(Y)--;
                A.at(nextX).at(nextY)++;
                Ans.push_back(vector<int>{X+1,Y+1,nextX+1,nextY+1});
            }
        }
    }

    cout<<Ans.size()<<endl;
    for(auto ans:Ans){
        cout<<ans[0]<<" "<<ans[1]<<" "<<ans[2]<<" "<<ans[3]<<endl;
    }
}

Measured memory_bytes: 11144
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long  i = 0; i < (long long)(n); i++)






int main() {
	int a, b, c;
	cin >> a >> b >> c;
	set <int> d;
	d.insert(a);
	d.insert(b);
	d.insert(c);
	string s = "No";
	if (d.size() == 2) {
		s = "Yes";
	}

	cout << s << endl;
}

Measured memory_bytes: 256
n = int(input())
aList = list(map(int, input().split()))
aLen = len(aList)
aSet = sorted(list(set(aList)))
aSum = 0
for a in aSet:
    aCount = aList.count(a)
    if aCount > a:
        aSum += aCount - a
    if aCount < a:
        aSum += aCount
    aLen -= aCount
    if a > aLen:
        aSum += aLen
        break

print(aSum)


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

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

    int counter = 0;
    for(int i = 1; i <= N; i++) {
        if (1 <= i && i <= 9) {
            counter++;
            continue;
        }
        if (100 <= i && i <= 999) {
            counter++;
            continue;
        }
        if (10000 <= i && i <= 99999) {
            counter++;
            continue;
        }
    }
    cout << counter << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
#define ll long long
using namespace std;
const int N=3005,mo=1e9+7,mo2=mo+1>>1;
int n,q,x,y,p[N];
int f[N][N],ans,xs;
int r[N],c[N];
int main(){
	cin>>n>>q;
	fo(i,1,n)cin>>p[i];
	fo(i,1,n)fo(j,1,n)
		if(p[i]<p[j])f[i][j]=1;
	for(xs=1;q--;xs=(ll)xs*2%mo){
		cin>>x>>y;
		fo(i,1,n){
			r[i]=(ll)(f[x][i]+f[y][i])*mo2%mo;
			c[i]=(ll)(f[i][x]+f[i][y])*mo2%mo;
		}
		fo(i,1,n)f[x][i]=f[y][i]=r[i],f[i][x]=f[i][y]=c[i];
		f[x][x]=f[y][y]=0;
		f[x][y]=f[y][x]=(f[x][y]+f[y][x])%mo;
	}
	fo(i,1,n)fo(j,1,i-1)ans=(ans+f[i][j])%mo;
	cout<<(ll)ans*xs%mo;
}

Measured memory_bytes: 35456
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>  
#include <string>  
using namespace std;

int main()
{
	int x;
	cin >> x;
	if (x % 2 == 0)
		cout << 0.5000000000;
	else
		cout << ((double)(x + 1) / 2) / x;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
   
  int N, a;
  cin >> N >> a;
  
  int x = 1;
  for(int i = 0; i < N; i ++){
   		
    int y = x * 2;
    int z = x + a;
    x = min(y,z);
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <cmath>

using namespace std;

int main(){

    bool n = false;
    bool w = false;
    bool s = false;
    bool e = false;

    string S;
    cin >> S;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == 'N') n = true;
        if(S[i] == 'W') w = true;
        if(S[i] == 'S') s = true;
        if(S[i] == 'E') e = true;
    }

    if(n == s && e == w){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}

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

int main(){
  int k;
  int antenna[5];
  for (int i = 0; i < 5; i++) cin >> antenna[i];
  cin >> k;
  for (int i = 0; i < 5; i++){
    for (int j = 0; j < 5; j++){
      if(antenna[j] - antenna[i] > k){
        cout << ":(" << endl;
        return 0;
      }
    }
  }
  cout << "Yay!" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int n, sol;
string a, b;
int main()
{
    cin >> n;
    cin >> a >> b;
    int k = 0;
    for(int i = 0; i <= a.size(); i++)
    {
        for(int j = 0; j <= b.size(); j++)
        {
            if(a[i] == b[j])
            {
                k = 0;
                while(a[i + k] == b[j + k] && i + k < a.size() && j + k < b.size())
                {
                    k++;
                }
                sol = max(sol, k);
            }
        }
    }
    cout << 2 * n - sol;
    return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left, bisect_right

N = int(input())

# 二分探索するためにソートしておく
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

ans = 0

for i in range(N):
    # Bから一つ選ぶ
    b = B[i]
    # bisect_left(ソート済リスト、挿入したい値)
    # leftなので既に値が存在ししていたら既存の左に挿入
    a_ix = bisect_left(A, b)
    # rightも同様
    c_ix = bisect_right(C, b)
    # ex. A = [1, 3, 5], C = [2, 4, 6], b = 5の場合
    # a_ix=2（1と3が可能）, c_ix=2（6が可能）
    # c_ixについては　(全体-ダメな場合の個数)=OKな個数
    ans += a_ix * (N - c_ix)

print(ans)


Measured memory_bytes: 29344
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp makepair
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define all(v) (v).begin(),(v).end()
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//  freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
 	ll n,j,k,R,G,B,ans=0;
 	string s;
 	cin>>n>>s;
 	s='!'+s;
 	ll r[n+1],g[n+1],b[n+1];
 	ll i=1;
 	r[0]=g[0]=b[0]=0;
 	while(i<=n)
 	{
 		r[i]=r[i-1];
 		g[i]=g[i-1];
 		b[i]=b[i-1];
 		if(s[i]=='R')
 			r[i]++;
 		else if(s[i]=='B')
 			b[i]++;
 		else
 			g[i]++;
 		i++;
 	}
 	i=1;
 	while(i<=n)
 	{
 		k=i+2;
 		while(k<=n)
 		{
 			if(s[i]!=s[k])
 			{
 				R=G=B=0;
 				if(s[i]=='R'||s[k]=='R')
 					R=1;
 				if(s[i]=='B'||s[k]=='B')
 					B=1;
 				if(s[i]=='G'||s[k]=='G')
 					G=1;
 				if(R&&G)
 				{
 					ans+=(b[k-1]-b[i]);
 					if((i+k)%2==0&&s[(i+k)/2]=='B')
 						ans--;
 				}
 				else if(R&&B)
 				{
 					ans+=(g[k-1]-g[i]);
 					if((i+k)%2==0&&s[(i+k)/2]=='G')
 						ans--;
 				}
 				else
 				{
 					ans+=(r[k-1]-r[i]);
 					if((i+k)%2==0&&s[(i+k)/2]=='R')
 						ans--;
 				}
 			}
 			k++;
 		}
 		i++;
 	}
 	deb(ans);
}

Measured memory_bytes: 3656
#include <iostream>
#include <queue>
using namespace std;
char S[105][105];
int N, M;
queue <pair<int, int> > Q;
int C[105][105];
int DP[2][105][105];
bool Used[105][105];
void Read(){
    cin >> N >> M;
    cin.get();
    for(int i = 1; i <= N; i++)
        cin.getline(S[i] + 1, 105);
    for(int i = 1; i <= N; i++)
        for(int j = 1; j <= M; j++)
            C[i][j] = (S[i][j] == '.') ? 0 : 1;
}
inline bool Valid(int x, int y){
    return x > 0 && y > 0 && x <= N && y <= M;
}
void BFS(int line, int col, int color){
    for(int i = 1; i <= N; i++)
        for(int j = 1; j <= M; j++)
            Used[i][j] = 0;
    Q.push(make_pair(line, col));
    Used[line][col] = 1;
    while(!Q.empty()){
        int x = Q.front().first;
        int y = Q.front().second;
        Q.pop();
        if(C[x][y] != color)
            continue;
        DP[color][line][col] = min(DP[color][line][col], DP[1 - color][x - 1][y] + 1);
        DP[color][line][col] = min(DP[color][line][col], DP[1 - color][x][y - 1] + 1);
        DP[color][line][col] = min(DP[color][line][col], DP[color][x][y - 1]);
        DP[color][line][col] = min(DP[color][line][col], DP[color][x - 1][y]);
        DP[1 - color][line][col] = min(DP[1 - color][line][col], DP[color][x - 1][y] + 1);
        DP[1 - color][line][col] = min(DP[1 - color][line][col], DP[color][x][y - 1] + 1);
        DP[1 - color][line][col] = min(DP[1 - color][line][col], DP[1 - color][x - 1][y] + 1);
        DP[1 - color][line][col] = min(DP[1 - color][line][col], DP[1 - color][x][y - 1] + 1);
        if(Valid(x - 1, y) && !Used[x - 1][y]){
            Used[x - 1][y] = true;
            Q.push(make_pair(x - 1, y));
        }
        if(Valid(x, y - 1) && !Used[x][y - 1]){
            Used[x][y - 1] = true;
            Q.push(make_pair(x, y - 1));
        }
    }
}
void Solve(){

    for(int i = 0; i <= N; i++)
        DP[0][i][0] = DP[1][i][0] = 1000000000;
    for(int i = 0; i <= M; i++)
        DP[0][0][i] = DP[1][0][i] = 1000000000;
    DP[0][1][0] = DP[1][1][0] = DP[0][0][1] = DP[1][0][1] = 0;
    DP[C[1][1]][1][1] = 0;
    DP[1 - C[1][1]][1][1] = 1;
    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= M; j++){
            if(i == 1 && j == 1)
                continue;

            int color = C[i][j];
            DP[color][i][j] = DP[1 - color][i][j] = 1000000000;
            BFS(i, j, color);
            /*C[i][j] = 1 - color;
            BFS(i, j, 1 - color);
            DP[1 - color][i][j]++;*/
            //C[i][j] = color;
            DP[color][i][j] = min(DP[color][i][j], DP[1 - color][i][j] + 1);
            DP[1 - color][i][j] = min(DP[1 - color][i][j], DP[color][i][j] + 1);
        }
    }
    cout << DP[0][N][M] << '\n';
}
int main()
{
    Read();
    Solve();
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

void yes(){
   cout<<"Yes"<<endl;
   //exit (0);
}
void no(){
   cout<<"No"<<endl;
   //exit (0);   
}

int n, a[N];
string s, t;

int32_t main(){_
   
   cin >> n;
   int l, r;
   cin >> l >> r;

   for (int i = l; i <= r; ++i)
   {
      if (i % n == 0){
         cout<<"OK";
         return 0;
      }
   }

   cout<<"NG";

   return 0;
}

Measured memory_bytes: 3656
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void Calc()
    {
        cin = new Scanner();

        int a1 = cin.nextInt();
        int a2 = cin.nextInt();
        int a3 = cin.nextInt();

        WriteLine((a1+a2+a3 >= 22)? "bust" : "win");
    }
}

public static class StringExtension
{
    public static char GetChar1(this string str, int indexOneBase)
    {
        return str[indexOneBase - 1];
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n, m;
  long long int tmp1, tmp2;
  cin >> n >> m;
  pair<long long int, long long int> a[100000];
  for(int i=0; i<n; i++){
    cin >> tmp1 >> tmp2;
    a[i] = make_pair(tmp1, tmp2);
  }
  sort(a, a+n);
  int cnt = 0;
  int index = 0;
  long long int money = 0;
  while(cnt < m){
      // 店にストックがあれば
      if(a[index].second > 0){
          // 購入
          cnt ++;
          money += a[index].first;
          a[index].second --;
      }
      // 店にストックが無ければ次の店へ
      else{
          index ++; 
      }
  }
  cout << money << endl;
  return 0;
}
    

Measured memory_bytes: 1792
import scala.collection.mutable.ArrayBuffer
import scala.io.StdIn

object Main extends App {
  val n = StdIn.readInt()
  val s = StdIn.readLine()
  if (s.length <= n) println(s) else println(s.take(n) + "...")


  def readIntPair: (Int, Int) = {
    val Array(x, y) = StdIn.readLine().split(" ").map(_.toInt)
    (x, y)
  }

  def readIntArr = StdIn.readLine().split(" ").map(_.toInt)
}






Measured memory_bytes: 54564
package main

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

type sta struct {
	c, s, f int
}

func main() {
	n := getInt()
	ss := make([]sta, n-1)
	for i := range ss {
		ss[i].c, ss[i].s, ss[i].f = getInt(), getInt(), getInt()
	}

	ans := make([]int, n)
	ans[n-1] = 0
	for i, s := range ss {
		time := s.s + s.c
		for j := i + 1; j < n-1; j++ {
			ns := ss[j]

			if ns.s >= time {
				time = ns.s + ns.c
			} else {
				f := (ns.f - time%ns.f) % ns.f
				time += f + ns.c
			}
		}
		ans[i] = time
	}

	for _, a := range ans {
		fmt.Println(a)
	}
}

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

ll dp[2][5];
int main() {
    init();

    int n; cin >> n;
    VL a(n); cin >> a;

    FOR(i, 0, 2)FOR(j, 0, 5)dp[i][j] = LLINF;
    dp[0][0] = 0;
    FOR(i, 0, n){
        FOR(j, 0, 5)dp[(i + 1) & 1][j] = LLINF;
        FOR(j, 0, 5)FOR(k, j, 5) {
            ll cost;
            if (k == 2)cost = (a[i] + 1) % 2;
            else if (k & 1) {
                if (a[i] == 0)cost = 2;
                else cost = a[i] % 2;
            }
            else cost = a[i];
            chmin(dp[(i + 1) & 1][k], dp[i & 1][j] + cost);
        }
    }

    ll ans = LLINF;
    FOR(i, 0, 5)chmin(ans, dp[n & 1][i]);
    cout << ans << "\n";
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
 
#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000001
 
using namespace std;
 
 
 
int main(void) {
   string s;
   int count=700;
   
   cin>>s;
   FOR(i,0,2){
     if(s[i]=='o')count+=100;
   }
   cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #define int         long long
    #define pb          push_back
    #define pii         pair<int,int>
    #define vi          vector<int>
    #define all(a)      (a).begin(),(a).end()
    #define F           first
    #define S           second
    #define hell        1000000007
    #define rn          return
    #define INF LONG_MAX
    #define rep(i, a, b) for(int i = a; i<b; i++)
    using namespace std;
    using namespace __gnu_pbds;
    typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
    void solve();
    int absval(int x){
        if(x>=0) rn x;
        else rn -1*x;
    }
    int power(int n, int m, int mod = hell){
        if(m==0) rn 1;
        int x = power(n,m/2,mod)%mod;
        if(m%2) rn (((x*x)%mod)*n)%mod;
        else rn (x*x)%mod;
    }
    signed main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int TESTS=1;
        // cin>>TESTS;
        while(TESTS--)
        {
            solve();
            
        }
        return 0;
    }
    const int N = 1e3 + 5, K = 12;
    void solve(){
        int n;
        cin>>n;
        set<int> s;
        map<int,int> m;
        while(n%2==0){
            s.insert(2);
            n /= 2;
            m[2]++;
        }
        for(int i = 3; i<= sqrtl(n); i+=2){
            while(n%i==0){
                s.insert(i);
                n /= i;
                m[i]++;
            }
        }
        if(n>2){
            s.insert(n);
            m[n]++;  
        } 
        int ans = 0;
        for(int x : s){
            // cout<<x<<" "<<m[x]<<endl;
            int t = sqrtl(2*m[x]);
            if(t*(t+1) > 2*m[x]) t--;
            ans += t;
        }
        cout<<ans<<endl;
    }   


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

#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout if (false) cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vec(v, n) vector<int> v(n, 0);
#define vecll(v, n) vector<ll> v(n, 0);
#define vecvec(v,n,m) vector<vector<int>> v(n, vector<int>(m));
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力

#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define next asdnext
#define prev asdprev
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"

#ifdef _TEST
void test();
#endif

void Main()
{
	int N;
	cin>>N;
	vector<string> S(N);
	vin(S);
	int c[4]={};
	rep(i,N){
		if(S[i]=="AC")c[0]++;
		if(S[i]=="WA")c[1]++;
		if(S[i]=="TLE")c[2]++;
		if(S[i]=="RE")c[3]++;
	}

	cout<<"AC x "<<c[0]<<_n;
	cout<<"WA x "<<c[1]<<_n;
	cout<<"TLE x "<<c[2]<<_n;
	cout<<"RE x "<<c[3]<<_n;
}



int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
#ifndef _TEST
	Main();
#else
#endif
	return 0;
}

#ifdef _TEST
int test(){

}
#endif

Measured memory_bytes: 6364
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstring>
#include<complex>
#include<stack>
#include<queue>
#include<unordered_map>
#include<map>
using namespace std;

int main(void) {
  long long int lucas[87];
  int n;
  cin >> n;

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


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

#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VL vector<long long>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVL vector<vector<ll>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<ll,ll>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;
constexpr ll MOD = 1000000007;
using std::cout;
using std::endl;
using std::cin;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::set;
using std::unordered_set;
using std::multiset;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, ll b) {
	ll ans = 1;
	while (b > 0) {
		if (b % 2 == 1) {
			ans *= a;
			ans %= MOD;
		}
		b /= 2;
		a *= a;
		a %= MOD;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a - b < b) { return comb(a, a - b); }
	ll c = 1;
	FOR(i, a - b + 1, a + 1) {
		c *= i;
		c %= MOD;
	}
	ll k = 1;
	FOR(i, 2, b + 1) {
		k *= i;
		k %= MOD;
	}
	c *= pow(k, MOD - 2);
	return c % MOD;
}
multiset<ll> prime_decomposition(ll n) {
	ll i = 2;
	multiset<ll> table{};
	while (i * i <= n) {
		while (n % i == 0) {
			n /= i;
			table.emplace(i);
		}
		++i;
	}
	if (n > 1) {
		table.emplace(n);
		return table;
	}
	return table;
}

int main() {
	string str;
	ll x, y;
	cin >> str >> x >> y;
	list<ll> a, b;
	{
		bool flg = true;
		ll count = 0;
		REPC(c, str) {
			if (c == 'T') {
				if (flg) {
					a.emplace_back(count);
				} else {
					b.emplace_back(count);
				}
				flg = !flg;
				count = -1;
			}
			++count;
		}
		if (flg) {
			a.emplace_back(count);
		} else {
			b.emplace_back(count);
		}
	}

	{
		vector<vector<bool>> dp(a.size() + 1, vector<bool>(16002, false));
		dp[0][8000] = true;
		ll i = 1;
		REPC(x, a) {
			REP(j, 16002) {
				if (j - x >= 0 && dp[i - 1][j - x]) {
					dp[i][j] = true;
				}
				if (j + x < 16002 && dp[i - 1][j + x] && !(i == 1 && str[0] == 'F')) {
					dp[i][j] = true;
				}
			}
			++i;
		}
		if (!dp[a.size()][x + 8000]) {
			cout << "No" << endl;
			return 0;
		}
	}
	{
		vector<vector<bool>> dp(b.size() + 1, vector<bool>(16002, false));
		dp[0][8000] = true;
		ll i = 1;
		REPC(x, b) {
			REP(j, 16002) {
				if (j - x >= 0 && dp[i - 1][j - x]) {
					dp[i][j] = true;
				}
				if (j + x < 16002 && dp[i - 1][j + x]) {
					dp[i][j] = true;
				}
			}
			++i;
		}
		if (!dp[b.size()][y + 8000]) {
			cout << "No" << endl;
		} else {
			cout << "Yes" << endl;
		}
	}
}

Measured memory_bytes: 8448
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)


int main(){
	int n,l;
	cin>>n>>l;
	string s = "";
	
	vector<string> vs(n);
	rep(i,n)cin>>vs[i];
	
	sort(all(vs));
	
	rep(i,vs.size())s+=vs[i];
	
	cout<<s<<endl;
}

Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline().rstrip('\n')

def make_a(n, M, L):
    if n == 0:
        return L
    W = len(L[0])
    newL = []
    for l in L:
        for i in range(l[W - 1], M + 1):
            newL += [list(l + [i])]
    return make_a(n - 1, M, newL)

def calc(N, M, Q, R):
    result = 0
    for A in make_a(N - 1, M, [[1]]):
        score = 0
        for a, b, c, d in R:
            score += (d if A[b - 1] - A[a - 1] == c else 0)
        result = max(score, result)
    return result


(N, M, Q) = tuple([int(s) for s in input().split()])
R = [tuple([int(s) for s in input().split()]) for _ in range(Q)]
print(calc(N, M, Q, R))

Measured memory_bytes: 81448
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
 
int main() {
    int n;
  	ll k;
    cin >> n >> k;
    map<ll, ll> m;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        m[a] += b;
    }
 
    ll cnt = 0;
    for (auto x : m) {
        cnt += x.second;
        if (cnt >= k) {
            cout << x.first << endl;
            return 0;
        }
    }
 
    return 0;
}

Measured memory_bytes: 4224
import  java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        String s = cin.next();
        if(s.charAt(2)==s.charAt(3) && s.charAt(4)==s.charAt(5)) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using li = unsigned long long int;
using namespace std;

int main() {
    fastIO;
    int h, w;
    cin >> h >> w;
    vector<string> str(h);
    rep(i, h) cin >> str.at(i);

    rep(i, w + 2) cout << "#";
    cout << endl;
    rep(i, h) cout << "#" << str.at(i) << "#" << endl;
    rep(i, w + 2) cout << "#";
    cout << endl;
}

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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

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

int main(int argc, char **argv)
{
	ll N, K; cin >> N >> K;
	string S; cin >> S;

	ll left{0}, right{0};
	ll cnt{0};

	if (S[left] == '0') cnt = 1;
	while (right < N && cnt <= K)
	{
		if (S[right] == '1' && S[right+1] == '0') ++cnt;
		++right;
	}
	if (left + 1 == N)
	{
		std::cout << N << std::endl;
		return 0;
	}



	ll res{right - left};
	while (left < N && right < N)
	{
		++right;
		while (right < N && (S[right-1] != '1' || S[right] != '0')) {++right;}
		++left;
		while (left < N && (S[left-1] != '0' || S[left] != '1')) {++left;}

		// std::cout << "left : "  << left << std::endl;
		// std::cout << "right : " << right << std::endl;
		res = max(res, right - left);
	}

	std::cout << res << std::endl;
}


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

int main(){
  int n,m,a;
  set<int> s,t;
  cin >> n;
  while(n--){
    cin >> a;
    s.insert(a);
  }
  cin >> m;
  while(m--){
    cin >> a;
    t.insert(a);
  }
  vector<int> v;
  set_symmetric_difference(s.begin(),s.end(),t.begin(),t.end(),back_inserter(v));
  r(i,v.size()){
    cout << v.at(i)<<endl;
  }
}


Measured memory_bytes: 23684
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split(" ");
	const S = parseInt(input[0]);
  const W = parseInt(input[1]);

  if(S <= W) {
    console.log("unsafe");
  } else {
    console.log("safe");
  }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29608
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

int main(){
   int n;
   cin >> n ;
   vector<int> a(n);
   rep(i,n){
      int aa;
      cin >> aa;
      a[aa-1] = i+1;
   }
   rep(i,n) cout << a[i] << " ";

   cout << endl;
   return 0;
}


Measured memory_bytes: 1152
#include <cstdio>
#include <algorithm>

int main() {
  int a[3];
  for (int i=0; i<3; ++i)
    scanf("%d", &a[i]);

  std::sort(a, a+3);

  int res=0;
  do {
    res = std::max(res, a[0]*10+a[1]+a[2]);
  } while (std::next_permutation(a, a+3));
  printf("%d\n", res);
}

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

int hexToDec(char x){
    if('0' <= x && x <= '9'){
        return x-'0';
    }else{
        return 10 + (x - 'a');
    }
}

int data[8][3] = { {0, 0, 0}   , 
                   {0, 0, 255} , 
                   {0, 255, 0} ,
                   {0, 255, 255} , 
                   {255, 0, 0} , 
                   {255, 0, 255} ,
                   {255, 255, 0} , 
                   {255, 255, 255}};

string color[8] = {"black", "blue", "lime", "aqua", "red", "fuchsia", "yellow", "white"};

int main(){
    while(1){
        string s;
        cin >> s;

        if(s == "0")    break;
    
        int r, g, b;
        r = 16 * hexToDec(s[1]) + hexToDec(s[2]);
        g = 16 * hexToDec(s[3]) + hexToDec(s[4]);
        b = 16 * hexToDec(s[5]) + hexToDec(s[6]);

        double dist = DBL_MAX;
        int ans;

        for(int i = 0; i < 8; i++){
            double tmp = sqrt(pow(r - data[i][0], 2.0) + pow(g - data[i][1], 2.0) + pow(b - data[i][2], 2.0));
            if(tmp < dist){
                dist = tmp;
                ans = i;
            }
        }

        cout << color[ans] << endl;
    }

    return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define pb push_back
#define tam 5120
#define offset 320000
#define se second
#define fi first
#define pitem item*
#define forr(i,p,n) for(ll i=p;i<n;i++)
using namespace std;
typedef long long ll;
const ll MOD=1000000009 ;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
typedef pair<string,int> ii;
typedef pair<int,int> II;
vector<int> on[tam];
int cond[tam];
int main()
{
    int n,m,val,cuanto;
    cin>>n>>m;
    forr(i,0,m)
    {
        cin>>cuanto;
        forr(k,0,cuanto){
            cin>>val;
            val--;
            on[i].pb(val);
        }
    }
    forr(i,0,m)
    cin>>cond[i];
    int tot=0;
    forr(mask,0,(1<<n))
    {
        int c=0;
        forr(i,0,m)
        {
            int auxt=0;
            forr(j,0,on[i].size())
            {
                if (mask&(1<<on[i][j]))
                    auxt++;
            }
//            cout<<mask<<" "<<auxt%2<<" "<<cond[i]<<" "<<i<<endl;
            if (auxt%2==cond[i]%2)
                c++;
        }
  //      cout<<endl;
        if (c==m)
            tot++;
    }
    cout<<tot<<endl;
}

Measured memory_bytes: 384
import sys
import copy
import heapq
from collections import deque
import decimal

# sys.setrecursionlimit(100001)
INF = sys.maxsize


# ===CODE===
def main():
    class UnionFind():
        def __init__(self, n):
            self.n = n
            self.parents = [-1] * n

        def find(self, x):
            if self.parents[x] < 0:
                return x
            else:
                self.parents[x] = self.find(self.parents[x])
                return self.parents[x]

        def union(self, x, y):
            x = self.find(x)
            y = self.find(y)

            if x == y:
                return

            if self.parents[x] > self.parents[y]:
                x, y = y, x

            self.parents[x] += self.parents[y]
            self.parents[y] = x

        def size(self, x):
            return -self.parents[self.find(x)]

        def same(self, x, y):
            return self.find(x) == self.find(y)

        def members(self, x):
            root = self.find(x)
            return [i for i in range(self.n) if self.find(i) == root]

        def roots(self):
            return [i for i, x in enumerate(self.parents) if x < 0]

        def group_count(self):
            return len(self.roots())

        def all_group_members(self):
            return {r: self.members(r) for r in self.roots()}

        def __str__(self):
            return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    def calc_dist(x1, y1, z1, r1, x2, y2, z2, r2):
        tmp = ((float(x1) - float(x2)) ** 2 + (float(y1) - float(y2)) ** 2 + (float(z1) - float(z2)) ** 2) ** (1 / 2)
        tmp = max(0, tmp - float(r1) - float(r2))
        return tmp

    while True:
        n = int(input())
        if n == 0:
            exit(0)
        tree = UnionFind(n)

        data = [input().split() for i in range(n)]

        edges = []
        for i in range(n):
            for j in range(i + 1, n):
                edges.append((calc_dist(data[i][0], data[i][1], data[i][2], data[i][3], data[j][0], data[j][1],
                                        data[j][2], data[j][3]), i, j))

        edges.sort()

        ans = 0
        for d, s, t in edges:
            if not tree.same(s, t):
                tree.union(s, t)
                ans += d

        print("{:.3f}".format(ans))


# ===main===
if __name__ == '__main__':
    main()



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

int main()
{
  int N, M, X = 0;
  cin >> N >> M;
  vector<int> Q(M, 0);
  for (int i = 0; i < N; i = i + 1)
  {
    int K;
    cin >> K;
    for (int j =0; j < K; j = j + 1)
    {
      int A;
      cin >> A;
      A = A - 1;
      ++Q[A];
    }
  }

  for (int A = 0; A < M; A = A + 1)
  {
    if(Q[A] == N)
    {
      X = X +1;
    }

  }
  cout << X << endl;

  return 0;

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <set>

using namespace std;

int main()
{
    int N;
    if (scanf("%d", &N) < 1) return 0;

    set<int> s;

    for (int i = 0; i < N; i++)
    {
        int tmp;
        if (scanf("%d", &tmp) < 1) return 0;
        s.insert(tmp);
    }

    printf("%d\n", s.size());
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


class Main {


   public static void main(String args[]) throws IOException{

	   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	   int n = Integer.parseInt( br.readLine() );
	   String[] string =  br.readLine().split(" ");
       int[] S = new int[n];


       for(int i = 0; i < n; i++ ){

    	   S[i] = Integer.parseInt( string[i] );

       }

       int q = Integer.parseInt( br.readLine() );
	   String[] stringq =  br.readLine().split(" ");
       int[] T = new int[q];


       for(int i = 0; i < q; i++ ){

    	   T[i] = Integer.parseInt( stringq[i] );

       }


       int answer = 0;

       for(int i = 0; i < q ; i++ ){
    	   for(int j = 0; j < n ;  j++ ){
    		   if( S[j] == T[i]  ){
    			   answer++;
    			   break;
    		   }
    	   }

       }

     System.out.println(answer);


   }


}

Measured memory_bytes: 46876
#include<iostream>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(b-a == c-b){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()

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

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int main() { 
    string S;
    cin >> S;
    bool flag = true;
    int N = S.size();
    REP(i, S.size()) {
        if (S[i] == S[N - i - 1]) continue;
        flag = false;
    }
    for (int i = 0; i < (N - 1) / 2; i++) {
        if (S[i] == S[(N - 1) / 2 - i - 1]) continue;
        flag = false;
    }
    for (int i = (N + 3) / 2 - 1; i < N; i++) {
        if (S[i] == S[N - i - 1]) continue;
        flag = false;
    }
    if (flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
        
    }
    return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF=1LL<<60;


int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	string s;
	cin>>s;
	cout<<s[0]<<s.length()-2<<s[s.length()-1]<<endl;
	
	
	
	
	
	
	return 0;
}

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

int main() {
	// your code goes here
	string s;
	cin>>s;
	int sum=0;
	for(int i=0;i<s.length();i++)
	{
		sum=sum+(s[i]-'0');
	}
	if(sum%9==0)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
    i64 sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    i64 dx = tx - sx, dy = ty - sy;
    cout << string(dy, 'U') << string(dx, 'R');
    cout << string(dy, 'D') << string(dx, 'L');
    cout << "L" << string(dy + 1, 'U') << string(dx + 1, 'R') << "D";
    cout << "R" << string(dy + 1, 'D') << string(dx + 1, 'L') << "U";
    cout << endl;
    return 0;
}


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

using namespace std;

template <typename T>
T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T>
T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  long x,y;
  cin >> x >> y;
  int cnt = 0;
  while (x <= y){
    cnt++;
    x *= 2;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <functional> 
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <stdio.h>
#include <string.h>
using namespace std;
typedef pair<int,int> pii;
#define fast   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define ld              long double
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define in              insert
#define ff              first
#define ss              second
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define sz(c)           (ll)c.size()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define rev             reverse
#define Y               "YES"
#define N               "NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << endl;
const ll inf = 1e18;  
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll MAX = 2e5 + 1;
//priority_queue<pii, vector<pii>, greater<pii> > pq;



inline ll add(ll a,ll b) {return ((a % mod) + (b % mod)) % mod;}
inline ll sub(ll a,ll b) {return ((a % mod) - (b % mod) + mod) % mod;}
inline ll mul(ll a,ll b) {return ((a % mod) * (b % mod)) % mod;}
ll pwr(ll x,ll n){
    if(n == 0){
        return 1;
    }
    if(n&1){
        return mul(x, pwr(mul(x, x), (n - 1) / 2));
    } else {
        return pwr(mul(x, x), n / 2);
    }
}
ll modInv(ll n){ 
    return pwr(n, mod - 2); 
}
ll gcd(ll a,ll b) {
    if(b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

/**

 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode() : val(0), left(nullptr), right(nullptr) {}
 *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
 *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
 * };
 */

int main(){
    string str;
    cin>>str;
    int n=str.size()-1;
    if(str[n]=='s') cout<<str+"es"<<endl;
    else cout<<str+"s"<<endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	string s; 
	cin >> s;
	int l = (int)s.length()+1;
	int low[l] = {0};
	int cs = 0;
	REP(i, 1, l){
		if(s[i-1] == '<'){
			low[i-1] = cs;
			++cs;
			if(i == l-1)low[i]= cs;
		}
		else{
			low[i-1] = cs;
			cs = 0;
		}
	}
	
	cs = 0;
	ll ans = 0;
	for(int i = l-1; i >= 1; i--){
		if(s[i-1] == '>'){
			ans+= max(low[i], cs);
			++cs;
			if(i == 1) ans+= max(low[i-1], cs);;
		}
		else{
			ans+= max(low[i], cs);
			cs = 0;
		}
	}
	cout << ans;
}


Measured memory_bytes: 2820
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
using namespace std;
//start
const int limit = 2e5 + 1;
int k;
vector<int> g[limit];
bool vis[limit];

void dfs(int s,int k){
    if(k >= 2) return;

    for(auto it:g[s]){
        if(!vis[it]){
            vis[it] = true;
            dfs(it, k+1);
        } 
    }
}


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

    int a[n][d];

    REP(i,n){
        REP(j,d){
            cin >> a[i][j];
        }
    }
    int sum =0, ans =0;
    REP(i,n){
    REP(k,n){
        if(i == k)continue;
        else{
            REP(j,d){
                sum += abs(a[i][j] - a[k][j])*abs(a[i][j] - a[k][j]);

            }
            double sq = sqrt(sum);
            int s = sqrt(sum);
            if(s == sq) ans++;
            sum =0;
        }
    }
    }
    cout <<ans/2 <<endl;
}


Measured memory_bytes: 4992