akhauriyash/Code-Regression huggingface dataset:
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = getLine >> breads >>= print . solve 

solve :: [Int] -> Int
solve = calc . fst . foldl' ff ((0, 0), True) . sortBy (flip compare)
    where
        ff ((acc, bcc), f) n
            | f = ((acc + n, bcc), False)
            | otherwise = ((acc, bcc + n), True)
        calc (acc, bcc) = acc - bcc

breads :: IO [Int]
breads = unfoldr uff <$> B.getLine
    where
        uff b = check <$> B.readInt b
        check (a, b)
            | B.null b = (a, b)
            | otherwise = (a, B.tail b)

Measured memory_bytes: 508
c=1
M=10**9+7
*I=s=j=0
eval"N,K,*A="+`dd`.split*?,
A.sort!
K.upto(N){|i|s+=c.*A[i-1]-A[-i]
c=c*i*(I[j+=1]=j<2?1:M/j*-I[M%j])%M}
p s%M

Measured memory_bytes: 36288
S = input()
cond = True
for i in range(0,len(S),2):
	if S[i] == "L":
		cond = False
for i in range(1,len(S),2):
	if S[i] == "R":
		cond = False

if cond == True:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		TreeMap<String, ArrayList<Integer>> index = new TreeMap<String, ArrayList<Integer>>();
		String word, page;

		while ((line = br.readLine()) != null) {

			int delm = line.indexOf(' ');
			word = line.substring(0, delm);
			page = line.substring(delm + 1);

			if (!index.containsKey(word)) {
				index.put(word, new ArrayList<Integer>());
				index.get(word).add(Integer.valueOf(page));
			} else {
				index.get(word).add(Integer.valueOf(page));
			}
		}

		StringBuilder sb = new StringBuilder();
		for (String k : index.keySet()) {
			sb.append(k + "\n");
			Integer[] pages = index.get(k).toArray(new Integer[] {});
			Arrays.sort(pages);
			for (int i = 0; i < pages.length; i++) {
				if (i != pages.length - 1) {
					sb.append(pages[i] + " ");
				} else {
					sb.append(pages[i] + "\n");
				}
			}
		}
		System.out.print(sb.toString());
	}
}

Measured memory_bytes: 16904
/*
* Note: This template uses some c++11 functions , so you have to compile it with c++11 flag.
*       Example:-   $ g++ -std=c++11 c++Template.cpp
*
* Author : Akshay Pratap Singh
* Handle: code_crack_01
*
*/
 
/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for(int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for(int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
typedef long long int ll;
typedef unsigned long long int  ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main(){

  int ans = 0;
  vi d(3); cin >> d[0] >> d[1] >> d[2];
  int n_even = 0;

  REP(i, 3){
    if( d[i]%2 == 0 ) n_even++;
  }

  if( n_even == 1 ){
    REP(i, 3){
      if( d[i]%2 == 1 ) d[i]++;
    }
    ans++;
  } else if ( n_even == 2 ) {
    REP(i, 3){
      if( d[i]%2 == 0 ) d[i]++;
    }
    ans++;
  }

  sort(d.begin(), d.end());
  ans += (2*d[2]-d[1]-d[0])/2;

  cout << ans << endl;

  return 0;
}



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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef unsigned long long int ull;
const ll mod = 1000000007;
const ll linf = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = (m); i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<>()
#define SUM(a) accumulate((a).begin(), (a).end(), 0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define vec vector<int>
#define vecb vector<bool>
#define vecd vector<double>
using str = string;
const double PI = 3.14159265359;
template <typename T>
int len(T tmp)
{
	int res = 0;
	while (tmp > 0)
	{
		res++;
		tmp /= 10;
	}
	return res;
}
template <typename T>
T gcd(T a, T b)
{
	T t;
	while (b != 0)
	{
		t = a % b;
		a = b;
		b = t;
	}
	return a;
}
template <typename T>
T recfact(T start, T n)
{
	T i;
	if (n <= 16)
	{
		T r = start;
		for (i = start + 1; i < start + n; i++)
			r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
template <typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}
template <typename T>
T fct(T n)
{
	return recfact<T>(1, n);
}
template <typename T>
T ncm(T n, T m)
{
	if (n < m)
		return 0;
	T x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr)
{
	if (firstItr < 0 || secondItr > int(str.size() - 1))
		return str;
	while (firstItr < secondItr)
	{
		swap(str[firstItr], str[secondItr]);
		firstItr++;
		secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str)
{
	int itr = 0;
	std::string res;
	while (itr < int(str.size()))
	{
		char tmp = str[itr++];
		int length = 1;
		while (itr < int(str.size()) && str[itr] == tmp)
		{
			++itr;
			++length;
		}
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
str split(str str, size_t first_itr, size_t second_itr)
{
	string tmp;
	for (size_t i = first_itr; i < second_itr + 1; i++)
	{
		tmp.push_back(str.at(i));
	}
	return tmp;
}

int main(void)
{
	int n;
	cin >> n;
	int pre = n / 100;
	int post = n % 100;
	if(1<=pre && pre <=12){
		if(1<=post && post<=12){
			cout << "AMBIGUOUS" << endl;
		}
		else{
			cout << "MMYY" << endl;
		}
	}
	else{
		if(1<=post && post<= 12){
			cout << "YYMM" << endl;
		}
		else{
			cout << "NA" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  int n;
  cin>>n;
  vector<pair<int,int>> p;
  REP(i,n){
    int a,v;
    cin>>a>>v;
    p.PB(MP(v,a));
  }
  sort(ALL(p));
  int maxi=p.back().FR;
  int par=p.back().SC;
  for(int i=p.size()-1;i>=0;i--){
    if(p[i].FR==maxi){
      par=min(par,p[i].SC);
    }
  }
  cout<<par<<' '<<maxi<<endl;
  return 0;
}



Measured memory_bytes: 3080
cat - | sed '1d' | tr ' ' '\n' |  awk 'BEGIN{p1=-1;p2=-1;c=0} {if(p2>=0&&((p2<p1&&p1<$0)||(p2>p1&&p1>$0))){c++}p2=p1;p1=$0} END{print c}'

Measured memory_bytes: 1056
#include<iostream>

int n;
int p;
bool isprime[50001];
int prime[50001];
int flg[25000001];

void sieve( int x )
{
 	p = 0;
	
	isprime[0] = isprime[1] = false;
	for( int i = 2; i <= x; i++ ) isprime[i] = true;
	
	for( int i = 2; i <= x; i++ ){
	 	if( isprime[i] ){
			prime[p++] = i;
			
			for( int j = i * 2; j <= x; j += i ) isprime[j] = false;
		}
	}
}

int main()
{
	sieve( 50000 );

	for( int i = 0; i < p; i++ ){
		for( int j = i; j < p; j++ ){
			flg[ prime[i] + prime[j] ]++;
		}
	}

	while( 1 ){
		std::cin >> n;
		if( !n ) break;
		
		std::cout << flg[n] << std::endl;
	}
	
 	return 0;
}

Measured memory_bytes: 1624
#include<stdio.h>
#include<stdlib.h>
#define MAX 10000
#define NIL -1

struct Node{
  int parent;
  int left;
  int right;
};

  struct Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u,int d){
  if(u==NIL) return;
  D[u] = d;
  setDepth(T[u].left,d+1);
  setDepth(T[u].right,d+1);
}

int setHeight(int u){
  int h1=0,h2=0;
  if(T[u].left!=NIL) h1=setHeight(T[u].left)+1;
  if(T[u].right!=NIL) h2=setHeight(T[u].right)+1;
  return H[u] = (h1 > h2 ? h1 : h2);
}


int getSibling(int u){
  if(T[u].parent==NIL) return NIL;

  if(T[T[u].parent].left!=u && T[T[u].parent].left!=NIL) return T[T[u].parent].left;
  if(T[T[u].parent].right!=u && T[T[u].parent].right!=NIL) return T[T[u].parent].right;

  return NIL;
}


void p(int u){
  printf("node %d: ",u); 
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  
  int deg=0;

  if( T[u].left != NIL )  deg++;
 
  if( T[u].right != NIL )   deg++;
  
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

 if( T[u].parent == NIL ){
   printf("root\n");
 }

 else if( T[u].left == NIL && T[u].right == NIL ){
   printf("leaf\n");
 }

 else{
   printf("internal node\n");
 }
}


 int main(){

   int v,l,r,root=0,i;
   
   scanf("%d",&n);
   
   for(i=0; i<n; i++ ){
      T[i].parent = NIL;
   }

   for( i=0; i<n; i++ ){
     scanf("%d %d %d",&v,&l,&r);
 
     T[v].left=l;
     T[v].right=r;
  
     if( l != NIL ) T[l].parent = v;
     if( r != NIL) T[r].parent = v;

   }


   for( i=0; i<n; i++ )
     if( T[i].parent == NIL )  root=i;
   
   setDepth(root,0);
   setHeight(root);
   

   for( i=0; i<n; i++ )  p(i);
   return 0;
 }





Measured memory_bytes: 2048
(declaim (optimize (speed 3) (debug 0) (safety 0)))
(defun input (n)
  (let ((a (make-array 1 :element-type 'fixnum
                       :fill-pointer 0
                       :adjustable t))
        (b (make-array 1 :element-type 'fixnum
                       :fill-pointer 0
                       :adjustable t)))
    (dotimes (i n)
      (progn
        (vector-push-extend (read) a)
        (vector-push-extend (read) b)))
    (values a b)))

(let ((n (read))
      (c 0))
  (multiple-value-bind (an bn) (input n)
    (loop for i from 0 below n
        for a = (aref an (- n i 1)) for b = (aref bn (- n i 1)) 
        do (setq c (+ (mod (- b (mod (+ a c) b)) b) c))))
  (format t "~A~%" c))

Measured memory_bytes: 69480
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define mod 1000000007
#define inf 9999999999999999ll
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    string s;
    cin>>n>>s;
    if(n%2==0)
    {
        ll i=0;
        ll j=n/2;
        bool p=true;
        while(j<n)
        {
            if(s[i]!=s[j])
            {
                p=false;
                break;
            }
            i++;
            j++;
        }
        if(p)
        {
            cout<<"Yes\n";
        }
        else
            cout<<"No\n";
    }
    else
        cout<<"No\n";
}


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

int main() {
  int N = 0, x = 0, count = 0;
  cin >> N;
  
  vector<int> a(N);
  
  for(int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  
  x = a.at(0);
  
  for(int i = 0; i < N; i++) {
    if(x == 2) {
      count++;
      break;
    }
    
    x = a.at(x - 1);
    count++;
    
    if(i == N - 1) {
      count = -1;
      break;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 640
//BadWaper gg
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define fr first
#define sd second
#define N 200010
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
int n;
int a[N],num;ll ans;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read();for(register int i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+n+1);num=n-1;
	for(register int i=n;i>=1;i--){if(i==n)ans+=a[i],num--;else if(num>=2)ans+=a[i]*2,num-=2;else ans+=a[i]*num,num=0;if(!num)break;}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 4540
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <list>
#include <numeric>
using namespace std;

int main(){    
  long long N,M;
  cin >> N >> M;
  if(N<=M){
   cout << "Yes" << endl;
  }
   else{
   cout << "No" << endl;
   }
}


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

int main() {
  int k;
  cin >> k;
  if (k % 2 == 0 || k % 5 == 0) {
    cout << -1 << endl;
    return 0;
  }

  int seven = 7, cnt = 1;
  while (seven % k != 0) {
    seven = (seven % k) * 10 + 7;
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;

char s[101];

int main() {
    int n, k, i, j;
    
    scanf("%s", s);
    scanf("%d", &k);
    
    n = strlen(s);
    
    if (s[0] != s[n - 1]) {
        long long sum = 0;
        
        for (i = 0, j = 0; i < n; ) {
            for (; j < n; j++) {
                if (s[i] != s[j]) break;
            }
            
            sum += (j - i) / 2;
            
            i = j;
        }
        
        printf("%lld\n", sum * k);
    } else {
        vector <int> v;
        
        for (i = 0, j = 0; i < n; ) {
            for (; j < n; j++) {
                if (s[i] != s[j]) break;
            }
            
            v.push_back(j - i);
            
            i = j;
        }
        
        if (v.size() == 1) {
            printf("%lld\n", (long long)n * k / 2);
        } else {
            long long sum = 0;
            
            for (i = 1; i < v.size() - 1; i++) sum += v[i] / 2;
            sum *= k;
            
            sum += v[0] / 2;
            sum += v.back() / 2;
            sum += (long long)(v[0] + v.back()) / 2 * (k - 1);
            
            printf("%lld\n", sum);
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

		String input = sc.next();
		char[] charArray = input.toCharArray();
		for (int i = 0; i < 4; i++) {
			System.out.print(charArray[i]);
		}
		System.out.print(" ");
		for (int i = 4; i < charArray.length; i++) {
			System.out.print(charArray[i]);
		}
		System.out.println();
	}

}

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

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

const long INF = 1L << 60;

int weight[110];
int value[110];
long dp[2][1100000];

int main(){
	int n, w;
	scanf("%d%d", &n, &w);
	for(int i = 0; i < n; i++) {
		scanf("%d%d", &weight[i], &value[i]);
	}
	for(int i = 1; i < 1100000; i++) dp[0][i] = INF;
	for(int i = 1; i <= n; i++) {
		int t = i % 2;
		for(int j = 0; j < 1100000; j++) dp[t][j] = INF;
		for(int j = 0; j < 1100000; j++) {
			chmin(dp[t][j], dp[!t][j]);
			if(j - value[i-1] >= 0)
				chmin(dp[t][j], dp[!t][j-value[i-1]] + weight[i-1]);
		}
	}
	long ret = 0;
	for(int i=0; i < 1100000; i++)
		if(dp[n%2][i] <= w) ret = i;
	printf("%ld", ret);
}


Measured memory_bytes: 17408
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>
#include <atcoder/dsu>

using namespace std;
using namespace atcoder;

int main(){

    int N, Q;
    cin >> N >> Q;
    
    dsu d(N);
    
    for(int i = 0; i < Q; i++){
        int t, u, v;
        cin >> t >> u >> v;
        if(t == 0){
            d.merge(u, v);
        }
        else{   // t == 1
            if(d.same(u, v)){
                cout << 1 << endl;
            }
            else{
                cout << 0 << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 4068
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	cout << min(A, B) + min(C, D) << endl;

	return 0;
}


Measured memory_bytes: 256
N, M = list(map(int, input().split()))
tableA= [[] for j in range(N)]
tableB = []

for i in range(N):
    tableA[i] = list(map(int, input().split()))

for i in range(M):
    tableB.append(int(input()))
    
for i in range(N):
    answer = 0
    for j in range(M):
        answer += tableA[i][j] * tableB[j] 
    print(f"{answer}")

    


Measured memory_bytes: 6024
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

ll mod = 1e9 + 7;

int nCrModp(int n, int r, int p) 
{
    if(n<r)
        return 0;
    // The array C is going to store last row of 
    // pascal triangle at the end. And last entry 
    // of last row is nCr 
    int C[r+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1; // Top row of Pascal Triangle 
  
    // One by constructs remaining rows of Pascal 
    // Triangle from top to bottom 
    for (int i = 1; i <= n; i++) 
    { 
        // Fill entries of current row using previous 
        // row values 
        for (int j = min(i, r); j > 0; j--) 
  
            // nCj = (n-1)Cj + (n-1)C(j-1); 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
}

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    vector<vector<ll>> pascal (2e3 + 5, vector<ll>(2e3 + 5));
    pascal[0][0] = 1;
    FOR(i, 1, pascal.sz())
    {
        pascal[i][0] = 1;
        FOR(j, 1, i + 1)
        {
            pascal[i][j] = (pascal[i - 1][j] + pascal[i - 1][j - 1])%mod;
        }   
    }
    ll n, k;
    cin >> n >> k;
    FOR(i,1,k+1)
    {
        if(i-1>k-1 || i>n-k+1)
            cout << 0 << endl;
        else
            cout << (pascal[k-1][i-1]*pascal[n-k+1][i])%mod << endl;
    }

    return 0;
}


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

int main() {
  int H, W;
  cin>>H>>W;
  
  vector<bool> row(H, false);
  vector<bool> col(W, false);
  
  vector<string> a(H);
  
  for(int i=0;i<H;i++){
    cin >> a[i];
  }
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(a[i][j]=='#'){
        row[i]=true;
        col[j]=true;
      }
    }
  }
  
  for(int i=0;i<H;i++){
    if(row[i]){
      for(int j=0;j<W;j++){
        if(col[j]){
          cout<<a[i][j];
        }
      }
      cout<<endl;
    }
  }
}

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


int main() {
    ll N; cin >> N;
    vector<ll> A(N), B(N); for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) B[i] = A[i];
    sort(A.begin(), A.end());
    map<ll, int> M;
    for(int i = 0; i < N; i++) M[A[i]] = i;
    ll ans = 0;
    for(int i = 0; i < N; i++) {
        //cout << i << " "  << M[B[i]] << endl;
        if(abs(i - M[B[i]])%2 == 1) ans++;
    }
    cout << ans/2 << endl;
    
}

Measured memory_bytes: 8064
#include<stdio.h>
int main()
{
  int month,date,ans;
  while(1)
    {
      scanf("%d%d",&month,&date);
      if((month==0)&&(date==0)) break;
      ans=date;
      switch(month)
	{
	case 12:
	  ans+=30;
	case 11:
	  ans+=31;
	case 10:
	  ans+=30;
	case 9:
	  ans+=31;
	case 8:
	  ans+=31;
	case 7:
	  ans+=30;
	case 6:
	  ans+=31;
	case 5:
	  ans+=30;
	case 4:
	  ans+=31;
	case 3:
	  ans+=29;
	case 2:
	  ans+=31;
	}
      ans%=7;
      switch(ans)
	{
	case 0:
	  printf("Wednesday\n");
	  break;
	case 1:
	  printf("Thursday\n");
	  break;
	case 2:
	  printf("Friday\n");
	  break;
	case 3:
	  printf("Saturday\n");
	  break;
	case 4:
	  printf("Sunday\n");
	  break;
	case 5:
	  printf("Monday\n");
	  break;
	case 6:
	  printf("Tuesday\n");
	  break;
	}	  	  	  	  
    }
  return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define gc getchar
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x1 uvuvwevwevwe
#define y1 onyetenyevwe
#define x2 ugwemubwem
#define y2 ossas
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
template <typename T> void scan(T &angka){
	angka=0;char input=gc();T kali=1;
	while(!(48<=input&&input<=57)){	if(input=='-')	kali=-1;input=gc();}
	while(48<=input&&input<=57)	angka=(angka<<3)+(angka<<1)+input-48,input=gc();angka*=kali;
}
template <typename T1,typename T2> void scan(T1 &angka1,T2 &angka2){
	scan(angka1);scan(angka2);
}
int panjang;
string input;
vector <char> tanpax;
vector <int> jarak;
template <typename T> int ispalin(vector <T> daftar){
	int l,r,ret=0;
	l=((daftar.size()+1)/2)-1;
	r=l;
	if((daftar.size()&1)==0)
		r++;
	while(l>=0)
	{
		ret+=abs(daftar[l]-daftar[r]);
		l--;r++;
	}
	return ret;
}
int main()
{
	cin>>input;
	panjang=input.length();
	for(int i=0;i<panjang;i++)
	{
		if(input[i]=='x')
			continue;
		tanpax.pb(input[i]);
	}
	if(ispalin(tanpax)!=0)
	{
		printf("-1\n");
		return 0;
	}
	//buat jarax
	int temp=0;
	for(int i=0;i<panjang;i++)
	{
		if(input[i]=='x')
			temp++;
		else
		{
			jarak.pb(temp);
			temp=0;
		}
	}
	jarak.pb(temp);
	cout<<ispalin(jarak)<<endl;
}

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

int main(){
  int n;
  int d;

  cin >> n >> d;

  int yen;
  int sum=0;
  
  for(int i=0;i < n;i++){
    cin >> yen;
    if( yen > d){
      sum += yen - d;
    }
  }
  
  if(sum == 0){
    cout << "kusoge" << endl;
  }
  else{
    cout << sum << endl;
  }
  return 0;
}



Measured memory_bytes: 3108
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll n;
int main(){
	scanf("%lld",&n);
	ll ans=0;
	ll M=0;
	rep(i,0,n){
		ll t;
		scanf("%lld",&t);
		if(M<=t)ans++;
		M=max(M,t);
	}
	printf("%lld",ans);
}

Measured memory_bytes: 128
#include <cstdio>

int main()
{
	for (unsigned int i = 1; i <= 9; i++)
	{
		for (unsigned int j = 1; j <= 9; j++)
		{
			std::printf("%ux%u=%u\n", i, j, i * j);
		}
	}
	return 0;
}


Measured memory_bytes: 2604
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N = int(input())
    A = sorted(list(map(int, input().split())), reverse=True)

    # print(A)

    ans = 0

    for i in range(1, 2 * N, 2):
        ans += A[i]

    # for i in range(N):
    #     ans += A[i + N]

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 42048
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

N = I()
abc = LIR(N-1)
Q, K = LI()
xy = LIR(Q)


K = K

utov = [[] for i in range(N+1)]
for a, b, c in abc:
    utov[a].append((b,c))
    utov[b].append((a,c))

bfs_map = [-1]*(N+1)

q = deque()
q.append(K)
bfs_map[K] = 0

while q:
    u = q.popleft()
    for v, cost in utov[u]:
        if (bfs_map[v] == -1) or (bfs_map[v] > bfs_map[u]+cost):
            bfs_map[v] = bfs_map[u] + cost
            q.append(v)


for x, y in xy:
    print(bfs_map[x]+bfs_map[y])


Measured memory_bytes: 90032
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <numeric>
#include <array>
#include <float.h>
#include <memory>
#include <functional>
#include <iomanip>
#include <random>
#include <map>
#include <set>
#include <boost/lexical_cast.hpp>

using namespace std;


using ULL = decltype(0ull);
constexpr auto DIV = 1000000007ull;
constexpr auto MAX = numeric_limits<ULL>::max();

int main() {
  string str[3];
  cin >> str[0] >> str[1] >> str[2];
  cout << "A" << str[1].front() << "C" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lint = long long ;
using ldouble = long double;

void err(istream_iterator<string> _it) {}
template<typename T,typename... Args>
void err(istream_iterator<string> _it, T a,Args... args) {cerr<<"\n"<<*_it<<" is "<<a<<endl;err(++_it,args...);}

//#define __debug true; // c++17
const bool _debug = true;
#define cerr if(_debug)cerr
#define eb emplace_back
#define error(args...) if(_debug){string _s = #args; replace(_s.begin(),_s.end(),',',' ');stringstream _ss(_s); istream_iterator<string> _itt(_ss);err(_itt,args);} 

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, x, t;
    cin >> n >> x >> t;
    //cout << t * ceil((double)n/x) << "\n";
    int temp = n/x;
    if (temp * x != n) cout << (temp + 1) * t << "\n";
    else cout << temp * t << "\n";
    return 0;
}



Measured memory_bytes: 3568
#include <iostream>
#include <cstdio>
using namespace std;
int n, q, l, r, c[100005];
string s;
int main() {
	cin>>n>>q>>s;
	s = '.' + s;
	for(int i=1; i<n; i++) {
		c[i] = c[i-1];
		if(s[i]=='A' && s[i+1]=='C') c[i]++;
	}
	while(q--) {
		scanf("%d%d", &l, &r);
		printf("%d\n", c[r-1] - c[l-1]);
	}
	return 0;
}

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

int N;
char S[1010];

int main()
{
    scanf("%s",S);
    N = strlen(S);
    bool f1,f2,f3,f4;
    f1 = f2 = f3 = f4 = false;
    for(int i = 0; i < N; i++)
    {
        if(S[i] == 'S')f1 = true;
        if(S[i] == 'N')f2 = true;
        if(S[i] == 'W')f3 = true;
        if(S[i] == 'E')f4 = true;
    }

    if(!(f1 ^ f2) && !(f3 ^ f4))printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n,s=0,a=10;
    cin>>n;
    if(n%2==1){
        cout<<0;
    }
    else{
        while(a<=n){
            s+=n/a;
            a*=5;
        }
        cout<<s;
    }
}


Measured memory_bytes: 256
#problemD: D - Brick Break
N = int(input())
a =  list(map(int, input().split()))

def counter(a):
    count = 0
    i = 1
    for row in a:
        if row != i:
            count = count + 1
            i = i
        else:
            count  = count
            i = i + 1
    return count

if 1 in a:
    print(counter(a))
else:
    print('-1')

Measured memory_bytes: 26012
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt(),b = scanner.nextInt(),c = scanner.nextInt(),d = scanner.nextInt();
		int max = Math.max(a, c);
		int min = Math.min(b, d);
		int result = Math.max(0, min-max);
		System.out.println(result);
	}

}


Measured memory_bytes: 22484
abc = list(map(int, input().split()));

five, seven = 0, 0;

for i in range(3):
    if abc[i] == 5:
        five += 1;
    elif abc[i] == 7:
        seven += 1;
    else:
        continue;

if five == 2 and seven == 1:
    print("YES");
else:
    print("NO");

Measured memory_bytes: 3060
#include <stdio.h>

int main(){

	int data[3000][2];
	int i,j;
	int swap;
	
	for(i=0;i<3000;i++){						///??\???
	
		scanf("%d %d",&data[i][0],&data[i][1]);
		
		if(data[i][0]==0&&data[i][1]==0){break;}
	}
	j=i;
	
	for(i=0;i<j;i++){							//??\???????????¨??¨???
	
		if(data[i][0]>data[i][1]){
			swap=data[i][0];
			data[i][0]=data[i][1];
			data[i][1]=swap;
		}
	
		
		printf("%d %d\n",data[i][0],data[i][1]);
	
	}
	
	return 0;
}

Measured memory_bytes: 624
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
template<typename T> T ctmax(T &x, const T &y){ return x = max(x, y); }
template<typename T> T ctmin(T &x, const T &y){ return x = min(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n;
	cin >> n;
	vector<vector<int>> a(n, vector<int>(3));
	for(auto i = 0; i < n; ++ i){
		for(auto j = 0; j < 3; ++ j){
			cin >> a[i][j];
		}
	}
	vector<vector<int>> dp(n + 1, vector<int>(3));
	for(auto i = 0; i < n; ++ i){
		for(auto j = 0; j < 3; ++ j){
			for(auto k = 0; k < 3; ++ k){
				if(j != k){
					ctmax(dp[i + 1][k], dp[i][j] + a[i][k]);
				}
			}
		}
	}
	cout << *max_element(dp[n].begin(), dp[n].end());
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 11264
import java.util.*;
public class Main {
	
	private static List<String> hateList = new ArrayList<String>();
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String in = sc.nextLine();
		char[] inArray = in.toCharArray();
		StringBuffer buf = new StringBuffer();
		for (int i = 0 ; i < inArray.length; i++) {
			String key = Character.toString(inArray[i]);
			if (!key.equals("B")) {
				buf.append(key);
			} else {
				if(buf.length() != 0) {
					buf.delete(buf.length()-1, buf.length());
				}
			}
		}
		System.out.println(buf.toString());
 
	}
}

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

int main(){
  int n;
  cin >> n;
  int a[n];
  
  for(int i=0;i<n;i++){
    cin >> a[i];
    cout << a[i];
    if(i!=n-1) cout << " ";
  }
  cout << endl;
  
  for(int i=1;i<n;i++){
    int v = a[i];
    int j=i-1;
    while (j>=0 && a[j]>v){
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;

    for(int k=0;k<n;k++){
      cout << a[k];
      if(k!=n-1) cout << " ";
    }
    cout << endl;
  }
}




Measured memory_bytes: 3100
#include<stdio.h>
int isPrime(int x){
    int i;
    if(x<2) return 0;
    else if(x==2) return 1;
    if(x%2 == 0) return 0;
    for(i=3;i*i<=x; i+=2){
        if(x%i ==0) return 0;
    }
    return 1;
}

int main(){
    int n,x,i;
    int cnt;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&x);
        if(isPrime(x)) cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}


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

int main(){
    int num;
    char ans;
    vector<int> vec(26);
    string str;
    cin >> str;

    for(int i=0;i<str.size();i++){
        num = str.at(i);
        vec.at(num-97)+=1;
    }

    for(int j=0;j<26;j++){
        if(vec.at(j)==0){
            ans = j+97;
            cout << ans << endl;
            return 0;
        }
    }
    cout << "None" << endl;

  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<ld> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 1000000009;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[] = { -1,-2,1,-2,2,-1,2,1 }, ddy[] = { -2,-1,-2,1,-1,2,1,2 };

int main() {
	ll a,b,n;
	scanf("%lld%lld%lld",&a,&b,&n);
	if(n>=b-1)
	{
		return !printf("%lld\n",a*(b-1)/b-(b-1)/b*a);
	}
	return !printf("%lld\n",a*n/b-n/b*a);
}

Measured memory_bytes: 3812
#include <cstdio>
#define MAXN 200005

char s[MAXN];
int cnt[MAXN];

int main() {
  using ll = long long;
  int n, p;
  ll res = 0;
  scanf("%d%d%s", &n, &p, s);

  if (p == 2 || p == 5) {
    for (int i = 0; s[i]; ++i)
      if ((s[i] - 48) % p == 0) res += i + 1;
  } else {
    int t = 0, x = 1;
    for (int i = n - 1; i >= 0; --i) {
      ++cnt[t];
      t += (s[i] - 48) * x;
      t %= p;
      res += cnt[t];
      x = x * 10 % p;
    }
  }

  printf("%lld\n", res);

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  vector<pair<ll,pair<ll,ll>>> d(n);
  for(int i = 0;i < n;i++){
    cin >> d[i].second.first >> d[i].second.second;
    d[i].first = d[i].second.first + d[i].second.second;
  }
  sort(d.rbegin(),d.rend());
  ll t = 0;
  ll a = 0;
  for(int i = 0;i < n;i++){
    if(i % 2 == 0)t += d[i].second.first;
    else a += d[i].second.second;
  }
  cout << t - a << endl;
}

Measured memory_bytes: 5616
class Problem
  attr_accessor *(?a..?z).to_a.map(&:to_sym)
  def initialize
    @s = gets.chomp
  end

  def solve
    s.tr("?","D")
  end

  def show(ans)
    puts ans
  end
end

Problem.new.instance_eval do
  show(solve)
end

Measured memory_bytes: 14832
int h[11];

solve(int n,int w){
  int i=0,x,m=0,k=0;
  double d=0.01;
  for(;i<n;i++){
    scanf("%d",&x);
    h[x/w]++;
    if(k<x)k=x;
  }
  for(i=0;i<11;i++)
    if(m<h[i])m=h[i];
  for(i=0;i<k/w;i++){
    d += h[i]/(double)m * (k/w-i)/(double)(k/w);
  }
  printf("%.6lf\n",d);
}

main(){
  int n,w;
  while(scanf("%d%d",&n,&w),n){
    memset(h,0,sizeof(h));
    solve(n,w);
  }
exit(0);}

Measured memory_bytes: 640
#include <stdio.h>

int main(){
	int N, A, B, i;
    int a,b,c,d,e;
  	int sum=0;
	scanf("%d%d%d",&N, &A, &B);

  	for(i=1; i <= N; i++){
      a = i % 10;
      b = (i % 100)/10;
  	  c = (i % 1000)/100;
      d = (i % 10000)/1000;
      e = (i % 100000)/10000;
      if(A <= a+b+c+d+e && a+b+c+d+e <= B) sum = sum+i; 
    }

  printf("%d", sum);
  
return 0;  
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 1e6+1;
ll dp[N][4];
signed main(){
  ll n;
  cin>>n;
  ll a[n+1],b[n+1],c[n+1];
  for(ll i=1;i<=n;i++){
    cin>>a[i]>>b[i]>>c[i];
  }
  for(ll i=1;i<=n;i++){
     dp[i][1] = max(dp[i-1][2]+a[i],dp[i-1][3]+a[i]);
     dp[i][2] = max(dp[i-1][1]+b[i],dp[i-1][3]+b[i]);
     dp[i][3] = max(dp[i-1][1]+c[i],dp[i-1][2]+c[i]);
  }
  cout << max(dp[n][1],max(dp[n][2],dp[n][3])) << '\n';











return 0;
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using P=pair<int,int>;
using G=vector<vector<int>>;
using ll=long long;




int main(){
	ll a,b,n; cin>>a>>b>>n;

	
	ll x=min(n,b-1);
	ll l=floor(a*x/b);
	ll r=-a*floor(x/b);
	cout<<l+r<<endl;
	/*
	for(int x=1;x<100;x++){
		ll xx=floor(a*x/b);
		ll yy=-a*floor(x/b);

		cout<<x<<" "<<xx+yy<<endl;
	}*/

}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pll pair<ll,ll>
#define vi vector < int >
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define s(x) scanf("%d",&x)
#define sll(x) scanf("%lld",&x)
#define pf(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define flash ios_base::sync_with_stdio(false);cin.tie(0)
#define goog(x) cout << "Case #" << x << ": "
#define MAX5 200005
#define MAX6 2000005
#define MLOG 18
#define limit 1e18
#define mod 1000000007   
void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int power(int x, int y, int p){
    int res = 1;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}


int dp[100][100];
void solve(){
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0; i < n; i++) dp[i][i] = 1;
    for(int l = 0; l < n-1; l++){
        if(s[l] == s[l+1]){
            dp[l][l+1] = 1;
        }
    }
    for(int l = 3; l <= n; l++){
        for(int i = 0; i < n; i++){
            int j = i + l - 1;
            if(j < n && dp[i+1][j-1] == 1 && s[i] == s[j]) dp[i][j] = 1;
        }
    }
    // for(int i = 0; i < n; i++){
    //     for(int j = 0; j < n; j++){
    //         cout <<  dp[i][j] << " "; 
    //     }
    //     cout << endl;
    // }
   // cout << dp[0][(n-1)/2] << n-1 << endl;
    if(dp[0][n-1] == 1 && dp[0][(n-2)/2] == 1 && dp[(n+2)/2][n-1] == 1) cout << "Yes" << endl;
    else cout << "No" << endl;
}

signed main(){  
//  freopen("ii.txt", "w", stdin);
    flash;
    int t = 1;
    // cin >> t;  
    for(int tc = 1; tc <= t; tc++){
    //goog(tc);
        solve();
    }
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    ll n,ans=0;
    cin>>n;
    ans=(n+1)*n/2;
    ll m3=n-(n%3);
    ll m5=n-(n%5);
    ll m15=n-(n%15);
    
    ll kou3=(m3-0)/3;
    ll sum3=kou3*(3+m3)/2;

    ll kou5=(m5-0)/5;
    ll sum5=kou5*(5+m5)/2;

    ll kou15=(m15-0)/15;
    ll sum15=kou15*(15+m15)/2;

    ans=ans-sum3-sum5+sum15;

    //cout<<ans<<" "<<sum3<<" "<<sum5<<" "<<sum15<<endl;
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long int
#define v vector<ll>
#define vv vector<v>
using namespace std;
ll MOD=1e9+7;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    v arr(n+1,-1);
    for (int i=1; i<=n; i++)
        cin>>arr[i];
    vv dp(n+1,v(k+1,0));
    dp[0][0]=1;
    for (int i=1; i<=n; i++)
    {
        for (int j=0; j<=k; j++)
        {
            if (j>=arr[i]+1)
                dp[i][j]=(MOD+dp[i-1][j]-dp[i-1][j-arr[i]-1])%MOD;
            else
                dp[i][j]=(MOD+dp[i-1][j])%MOD;
            if (j>0)
                dp[i][j]=(dp[i][j]+dp[i][j-1])%MOD;
        }
    }
    cout<<dp[n][k];
	return 0;
}

Measured memory_bytes: 80256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var ABC = Sarray();
            Array.Sort(ABC);
            var A = ABC[0];
            var B = ABC[1];
            var C = ABC[2];
            if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0)
            {
                WriteLine(0);
                return;
            }
            WriteLine(A * B);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 11476
import math
a,b,h,m=map(int,input().split())
time= 60*h + m
H=time*0.5
M=(time*6) % 360
angle=abs(H-M)
ans=(a**2 + b**2 - 2*a*b*math.cos(math.radians(angle)))**(1/2)
print(ans)

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

int main() {
    int H, W;
    cin >> H >> W;
    
    vector<string> a(H);
    for (int i = 0; i < H; i++) {
        cin >> a.at(i);
    }
    
    for (int i = 0; i < W + 2; i++) cout << '#';
    cout << endl;
    
    for (int i = 0; i < H; i++) {
        cout << '#' << a.at(i) << '#' << endl;
    }
    
    for (int i = 0; i < W + 2; i++) cout << '#';
    cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main (void)
{
    int N=0,A=0;
    
    scanf("%d",&N);
    scanf("%d",&A);
    //
    if(N%500<=A)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin>>N;
    string s[N];
    int t[N];
    for(int i =0; i<N;i++)
        cin>>s[i]>>t[i];
    string X;
    int flag =0,time=0;
    cin>>X;
    for(int i =0;i<N;i++)
    {
        if(flag!=1)
        {
            if(s[i]==X)
                flag =1;
        }
        else
        {
            time = time + t[i];
        }
    }
    cout<<time<<endl;
}


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

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  double result = 0;
  for (int i = 1; i <= N; i++) {
    int mul = i;
    int den = 1;
    while (mul < K) {
      mul *= 2;
      den *= 2;
    }
    if (den == 0) {
      result += 1/(double)N;
    } else {
      result += 1/(double)N * 1/(double(den));
    }
  }

  cout << setprecision(10) << result << endl;
  return 0;
}


Measured memory_bytes: 256
h, w = gets.chomp.split().map(&:to_i)
grid = []
h.times do
  grid.push gets.chomp.split(//)
end

scount = 0
grid.each do |line|
  line.each do |c|
    if c == '#'
      scount +=1
    end
  end
end

q = [[0,0,1]]
while true
  y, x, count = q.shift

  if y == h-1 && x == w-1
    ans = h * w - count - scount
    break
  end

  #p [y, x]
  #p q
  if 0 < y && grid[y-1][x] == '.'
    grid[y-1][x] = 'a'
    q.push([y-1,x, count+1])
  end
  if y < h-1 && grid[y+1][x] == '.'
    grid[y+1][x] = 'a'
    q.push([y+1,x, count+1])
  end
  if 0 < x && grid[y][x-1] == '.'
    grid[y][x-1] = 'a'
    q.push([y,x-1, count+1])
  end
  if x < w-1 && grid[y][x+1] == '.'
    grid[y][x+1] = 'a'
    q.push([y,x+1, count+1])
  end

  if q.empty?
    ans = -1
    break
  end
end

puts ans


Measured memory_bytes: 2172
#![allow(unused_imports)]
#![allow(dead_code)]
use std::io::prelude::*;
use std::cmp::{max, min};
use std::collections::BinaryHeap;

const MOD: i64 = 1e9 as i64 + 7; 

fn main(){
    let n: usize = read();
    let ans = n * (n - 1) / 2;
    println!("{}", ans);
}

fn read<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#define FOR(i, a, b)  for(int i=a; i<b; ++i)
#define rFOR(i, a, b) for(int i=a-1; i>=b; --i)
#define REP(i, n) for(int i=0; i<n; ++i)
#define rREP(i, n) for(int i=n-1; i>=0; --i)
#define all(a)  a.begin(), a.end()
#define MAXNUM 100000
using namespace std;
typedef long long ll;

int main(){
  int n;  cin >> n;
  int p[MAXNUM], sum=0;
  p[0] = 0; p[n+1]=0;
  REP(i, n) {
    cin >> p[i+1];
  }
  FOR(i, 1, n+2)  sum += abs(p[i]-p[i-1]);
  FOR(i, 1, n+1){
    cout << sum + abs(p[i+1]-p[i-1]) - (abs(p[i+1]-p[i])+abs(p[i]-p[i-1])) << endl;
  }
  return 0;
}

Measured memory_bytes: 1664