akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

int main(){
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    vector<pair<double,double>> y(N);

    // rep(i,N){
    //     cin >> x[i].first >> x[i].second;
    // }

    // sort(ALL(x));

    rep(i,N){
        int a,b;
        cin >> a >> b;
        y[i].second = a - b;
        y[i].first = a + b;
    }

    sort(ALL(y));  //左端でソート

    ll ans = 0, t = -MAX;
    rep(i,N)
    {
        if(t <= y[i].second){
            ans++;
            t = y[i].first;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 1792
S = input()

five_letters = ["dream", "erase"]

found = False

while True:
    if len(S) == 0:
        found = True
        break

    if S[-5:] in five_letters:
        S = S[:-5]

    elif S[-6:] == "eraser":
        S = S[:-6]

    elif S[-7:] == "dreamer":
        S = S[:-7]

    else:
        break

if found:
    print("YES")

else:
    print("NO")

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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define pli pair<long long,int>
#define pil pair<int,long long>
#define ll long long
#define el '\n'

using namespace std;

const int N = 2e5 + 10;

int n;
int ar[N];

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

    cin >> n;
    int temp = 0;
    for (int i=1;i<=n;i++){
        cin >> ar[i];
        temp = (temp ^ ar[i]);
    }
    for (int i=1;i<=n;i++){
        cout << (ar[i] ^ temp) << " ";
    }
    cout << el;

    return 0;
}

Measured memory_bytes: 4436
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// check if it is judged online
inline ll read() {
	ll ret = 0, op = 1;
	char c = getchar();
	while (!isdigit(c)) {
		if (c == '-') op = -1;
		c = getchar();
	}
	while (isdigit(c)) {
		ret = ret * 10 + c - '0';
		c = getchar();
	}
	return ret * op;
}
const int N = 2e5 + 10;
int n;
ll m;
ll a[N], f[N];
int check(ll lim) {
	ll sum = 0;
	for (int i = 1; i <= n; ++i) {
		if (a[i] * f[i] > lim) {
			sum += a[i] - lim / f[i];
		}
		if (sum > m) return 0;
	}
	if (sum > m) return 0;
	return 1;
}
bool cmp(ll x, ll y) {
	return x > y;
}
int main() {
	n = read(), m = read();
	for (int i = 1; i <= n; ++i) a[i] = read();
	for (int i = 1; i <= n; ++i) f[i] = read();
	sort(a + 1, a + n + 1, cmp);
	sort(f + 1, f + n + 1);
	ll l = 0, r = a[1] * f[n];
	ll ans = 1ll << 60;
	while (l <= r) {
		ll mid = l + r >> 1;
		if (check(mid)) {
			ans = mid;
			r = mid - 1;
		}
		else l = mid + 1;
	}
	reverse(f + 1, f + n + 1);
	l = 0, r = a[1] * f[1];
	while (l <= r) {
		ll mid = l + r >> 1;
		if (check(mid)) {
			ans = min(ans, mid);
			r = mid - 1;
		}
		else l = mid + 1;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>

int
main(void)
{
  int a, b, c, x, y, z;
  scanf("%d %d %d", &a, &b, &c);
  if (a > b) {
    x = a;
    a = b;
    b = x;
    if (b > c) {
      y = b;
      b = c;
      c = y;
      if (b < a) {
        z = a;
        a = b;
        b = z;
      }
     }
    printf("%d %d %d\n", a, b, c);
  }
  else if (a < b) {
    if (b > c) {
      z = b;
      b = c;
      c = z;
    }
    printf("%d %d %d\n", a, b, c);
  }
  return 0;
}  

Measured memory_bytes: 596
#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 s, w;
    cin >> s >> w;
    if(s <= w){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
return 0;}

Measured memory_bytes: 3596
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdio>
#include <list>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecstr vector<string>
#define vecch vector<char>
#define vecpii vector<pii>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}

int h,w,n,sx,sy;
string s,t;
bool f(){
    int L=0,R=0,U=0,D=0,LL=0,RR=0,UU=0,DD=0;
    rep(i,n){
        char ss=s.at(i),tt=t.at(i);
        L+=ss=='L'?1:0;
        R+=ss=='R'?1:0;
        D+=ss=='D'?1:0;
        U+=ss=='U'?1:0;
        if(sy+RR-L<=0) return false;
        if(sy+R-LL>w) return false;
        if(sx+DD-U<=0) return false;
        if(sx+D-UU>h) return false;
        LL+=tt=='L'?1:0;
        LL=min(LL,sy+R-1);
        RR+=tt=='R'?1:0;
        RR=min(RR,w+L-sy);
        DD+=tt=='D'?1:0;
        DD=min(DD,h+U-sx);
        UU+=tt=='U'?1:0;
        UU=min(UU,sx+D-1);
    }
    return true;
}
int main(){
    h=in();
    w=in();
    n=in();
    sx=in();
    sy=in();
    s=stin();
    t=stin();
    string ans=f()?"YES":"NO";
    cout<<ans<<endl;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
#define F first
#define S second
#define endl "\n"
#define Endl "\n"
#define lop(i,n) for(i=0;i<n;i++)
#define lop1(i,n) for(i=1;i<=n;i++)
#define lopxy(i,x,y) for(i=x;i<y;i++)
#define ll long long
#define vl vector<long long>
#define pll pair<long long,long long>
#define sl set<long long>
#define uset unordered_set<long long>
#define umap unordered_map
#define prq priority_queue
#define pqll priority_queue<ll> 
#define hell 1000000007
#define mod 998244353
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define N 100000
#define N2 200000
#define bpc(x) __builtin_popcount(x)
#define inf 1e16
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<endl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
using namespace std;
ll power(ll x, ll y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return (power(x, y / 2) * power(x, y / 2)) % mod;
    else
        return ((x * power(x, y / 2)) % mod * power(x, y / 2)) % mod;
}
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;  
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
  
// Returns n^(-1) mod p 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
  
// Returns nCr % p using Fermat's little theorem. 
ll fac[N+1]; 
void pre(ll p){
    fac[0] = 1; 
    for (ll i=1 ; i<=N; i++) 
        fac[i] = (fac[i-1]*i)%p; 
}
ll nCrModPFermat(ll n, ll r, ll p) 
{ 
   if (r==0) 
      return 1; 
    if(r>n)
      return 0;
    return (fac[n]* modInverse(fac[r], p) % p * modInverse(fac[n-r], p) % p) % p; 
}
int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt.txt","r",stdin);
    freopen("output.txt.txt","w",stdout);
    freopen("error.txt","w",stderr);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
   ll n,i,j,ans;
   cin>>n;
   ll d[n+1][2];
   for(i=1;i<=n;i++)
        cin>>d[i][0]>>d[i][1];
    for(i=3;i<=n;i++){
        if(d[i][0]==d[i][1]&&d[i-1][0]==d[i-1][1]&&d[i-2][0]==d[i-2][1]){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";

    cerr<<(1000*clock())/CLOCKS_PER_SEC<<"ms";
    return 0;
}


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

typedef long long ll;

int t = 1;
#define N 100001

void solve() {
	ll n, q, sum = 0; cin >> n;
	vector<ll> f (N);
	set<ll> numbers;
	for (int i = 0; i < n; i++) {
		 ll a; cin >> a;
		 sum += a;
		 if (numbers.count(a) < 1) {
			numbers.insert(a);
			f[a] = 1;
		 }else {
			f[a]++;
		 }
	 }
	cin >> q;
	for (ll i = 0; i < q; i++) {
		ll b, c, a; cin >> b >> c;
		a = f[b];
		f[c] += a;
		f[b] = 0;
		sum += (a*c - a*b);
		cout << sum << endl;
	}
}

int main() 
{ 
	ios::sync_with_stdio(0);
	cin.tie(0);
	//freopen("data.in", "r", stdin);
	
	//cin >> t;
	while (t--) solve();
	
    return 0; 
}

























Measured memory_bytes: 6844
N=int(input())
AC=0
WA=0
TLE=0
RE=0
for i in range(N):
  IN=input()
  if IN=='AC':
    AC+=1
  if IN=='WA':
    WA+=1
  if IN=='TLE':
    TLE+=1
  if IN=='RE':
    RE+=1
print('AC x ',AC)
print('WA x ',WA)
print('TLE x ',TLE)
print('RE x ',RE)

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

typedef long long ll;

int main(){
	int r[3],n;
	cin >> r[0] >> r[1] >> r[2] >> n;
	
	ll dp[3002] = {};
	dp[0] = 1;
	for(int i = 0 ; i < 3 ; i ++){
		for(int j = 0 ; j+r[i] < 3002 ; j ++){
			dp[j+r[i]] += dp[j];
		}
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 256
from collections import Counter

def solve():
    N = int(input())
    As = list(map(int, input().split()))

    cnt = Counter(As)

    dp = [[[0.0]*(N+1) for j in range(N+1)] for i in range(N+1)]
    for k in range(N+1):
        for j in range(N+1):
            if j+k > N:
                break
            for i in range(N+1):
                if i+j+k > N:
                    break
                expe = 0.0
                if i > 0:
                    expe += i/N * dp[i-1][j][k]
                if j > 0:
                    expe += j/N * dp[i+1][j-1][k]
                if k > 0:
                    expe += k/N * dp[i][j+1][k-1]
                if i+j+k:
                    expe = (expe+1)*N/(i+j+k)
                dp[i][j][k] = expe

    ans = dp[cnt[1]][cnt[2]][cnt[3]]
    print(ans)


solve()


Measured memory_bytes: 255880
import java.util.*;
public class Main{
  static long gcd (long a, long b) {
	long r;
	while((r = a%b)!=0) {
		a = b;
		b = r;
	}
	return b;
}
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int K=sc.nextInt();
    long x=0;
    for(int i=1;i<K+1;i++){
      for(int j=1;j<K+1;j++){
        for(int k=1;k<K+1;k++){
          long t =gcd(j,k);
           x =x+gcd(i,t);
        }
      }
    }
    System.out.println(x);
  }
}

Measured memory_bytes: 35748
#include <stdio.h>
int main(int argc, char *argv[])
{
	int a[7]={1,3,5,7,8,10,12};
	int b[5]={4,6,9,11};
	int c[1]={2};
	int x,y;
	scanf("%d %d",&x,&y);
	int i,j,flag=0;
	if(x==y)printf("Yes");
	else{
		
	
	for(i=0;i<sizeof(a);i++)
	{
		for(j=i;j<sizeof(a);j++)
		{
			if(x==a[i]&&y==a[j])
			{
					flag=1;
                    break;
			}
		
		}
	}
	for(i=0;i<sizeof(b);i++)
	{
		for(j=i;j<sizeof(b);j++)
		{
			if(x==b[i]&&y==b[j])
			{
					flag=1;
                    break;
			}
		
		}
	}
		if(flag==1)printf("Yes");
		else printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	int x,y;
	cin>>x>>y;
	int a=(y-2*x)/2;
	int b=x-a;
	if(a*4+b*2==y&&a>=0&&b>=0){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	re 0;
}

Measured memory_bytes: 3628
'use strict'
function main(input: String) {
    const n: number = parseInt(input.split('\n')[0], 10);
    const hs: number[] = input.split('\n')[1].split(' ').map(h => parseInt(h, 10));
    let r: number = 0;
    let tmp = 0;
    for (let i = 0; i < n; i++) {
        if (hs[i] >= hs[i+1]) {
            tmp++;
        } else {
            r = Math.max(tmp, r);
            tmp = 0;
            continue;
        }
    }
    console.log(r);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {
	long long s,c;
	cin>>s>>c;
	
	if(s>=c)
	    cout<<c/2;
	else{
	    long long t=0;
    	if(c>=2*s){
    	    c-= 2*s;
    	    t+=s;
    	    t+= c/4;
    	}else if(c>=s){
    	    t+= c/2;
    	    
    	}else
    	    t+= c/4;
    	
    	cout<<t;
	}
	return 0;
} //24690


Measured memory_bytes: 256
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, k, s = 0;
    cin >> n >> k;
    vector<ll> a(n);
    for (ll &e : a)
        cin >> e;
    sort(a.begin(), a.end());
    for (ll i = 0; i < n - k; i++)
        s += a[i];
    cout << s;
    return 0;
}

Measured memory_bytes: 1792
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	pf := primeFuctorize(N)
	// if len(pf) <= 1 {
	// 	fmt.Println(len(pf))
	// 	return
	// }
	cnt := map[int]int{}
	for i := 1; i <= 40; i++ {
		tmp := 0
		for j := 1; j <= 9; j++ {
			tmp += j
			if i < tmp {
				cnt[i] = j - 1
				break
			}
		}
	}
	// fmt.Println(cnt)
	var ans int
	// fmt.Println(pf)
	for _, v := range pf {
		ans += cnt[v]
	}
	fmt.Println(ans)
}

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

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

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

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 1852
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 1e-9;

long long int N, M, K, H, W, L, R;

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

	cin >> H >> W >> K;
	vector<int>ans;
	int six[] = { 1,6,36,216,1296 };
	int dir[] = { 1,0,-1,0,1 };
	while (H) {
		vector<vector<int>>v(H, vector<int>(W));
		int ret = 0;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cin >> v[i][j];
			}
		}
		for (int i = 0; i < 6 * 6 * 6 * 6; i++) {
			auto field = v;
			for (int j = 0; j < 4; j++) {
				int c = (i%six[j + 1]) / six[j];
				c++;
				queue<pair<int, int>>Q;
				vector<vector<bool>>used(H, vector<bool>(W));
				Q.push({ 0,0 });
				int bc = field[0][0];
				used[0][0] = true;
				while (!Q.empty()) {
					int cy = Q.front().first;
					int cx = Q.front().second;
					field[cy][cx] = c;
					Q.pop();
					for (int k = 0; k < 4; k++) {
						int ny = cy + dir[k];
						int nx = cx + dir[k + 1];
						if (ny < 0 || nx < 0 || ny >= H || nx >= W)continue;
						if (used[ny][nx])continue;
						if (field[ny][nx] == bc) {
							Q.push({ ny,nx });
							used[ny][nx] = true;
						}
					}
				}
			}
			queue<pair<int, int>>Q;
			Q.push({ 0,0 });
			int bc = field[0][0];
			vector<vector<bool>>used(H, vector<bool>(W));
			while (!Q.empty()) {
				int cy = Q.front().first;
				int cx = Q.front().second;
				field[cy][cx] = K;
				Q.pop();
				for (int k = 0; k < 4; k++) {
					int ny = cy + dir[k];
					int nx = cx + dir[k + 1];
					if (ny < 0 || nx < 0 || ny >= H || nx >= W)continue;
					if (used[ny][nx])continue;
					if (field[ny][nx] == bc) {
						Q.push({ ny,nx });
						used[ny][nx] = true;
					}
				}
			}
			int box = 0;
			Q.push({ 0,0 });
			field[0][0] = 0;
			while (!Q.empty()) {
				box++;
				int cy = Q.front().first;
				int cx = Q.front().second;
				Q.pop();
				for (int k = 0; k < 4; k++) {
					int ny = cy + dir[k];
					int nx = cx + dir[k + 1];
					if (ny < 0 || nx < 0 || ny >= H || nx >= W)continue;
					if (field[ny][nx] == K) {
						field[ny][nx] = 0;
						Q.push({ ny,nx });
					}
				}
			}
			ret = max(ret, box);
		}
		ans.push_back(ret);
		cin >> H >> W >> K;
	}
	for (auto i : ans)cout << i << endl;
	return 0;
}



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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


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

    vector<vector<int>> dp(N+1, vector<int>(N+1,0));

    REP(i,N){
        REP(j,N){
            if(S[i] == S[j]){
                dp[i+1][j+1] = min(dp[i][j]+1, abs(i-j));
            }
        }
    }

    int ans = 0;
    REP(i,N+1){
        REP(j,N+1){
            ans = max(ans, dp[i][j]);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 101176
import bisect
N = int(input())
X = [sorted(list(map(int,input().split()))) for i in range(3)]
def nmb(i):
	left = bisect.bisect_left(X[0],i)
	right = bisect.bisect_right(X[2],i)
	return left*(len(X[2])-right)

ans = 0
for i in X[1]:
	ans += nmb(i)

print(ans)

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

int main(){
  ll A,B,C,D; cin >>A>>B>>C>>D;
  ll c = B/C - (A-1)/C;
  ll d = B/D - (A-1)/D;
  ll cdl = lcm(C,D);
  //cerr << "cdl: " << cdl <<endl;
  ll cd = B/(cdl) - (A-1)/(cdl);
  //cerr << c <<" " << d <<endl;
  
  ll ans = (B-A+1) - c- d + cd;
  cout << ans << endl;
}


Measured memory_bytes: 3616
import java.util.*;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        double result = b / a;
        int intResult = (int)result;

        if(result > c){
            System.out.println(c);
        }else if(result < c){
            System.out.println(intResult);
        }else if(intResult == c){
            System.out.println(c);
        }
    }
}

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

int main(){
  int x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int a = x2 - x1, b = y2 - y1;
  
  cout << x2 - b << " ";
  cout << y2 + a << " ";
  cout << x2 - b - a << " ";
  cout << y2 + a - b << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc =new Scanner(System.in);
	int N=sc.nextInt();
	int[] d=new int[N];
	for(int i=0;i<N;i++) {
		d[i]=sc.nextInt();
	}
	int ans=0;
	for(int i=0;i<N;i++) {
		for(int j=i+1;j<N;j++) {
			ans+=d[i]*d[j];
		}
	}
	System.out.println(ans);
}
}

Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
using namespace std;
double factorial(int n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
}

double dist(pair<int,int> a,pair<int,int> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll n,count=0,x=0;
    cin>>n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%4==0){
            count++;
        }
        else if(a[i]%2==0){
            x++;
        }
    }
    count+=x/2;
    if(count>=n/2){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

    
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
inline string read_s(){string s="";char c=getchar();while(c<'!'||c>'~'){c=getchar();}while(c>='!'&&c<='~'){s+=c;c=getchar();}return s;}
void Main(){
    int N = read(), K = read();
    printf("%d\n", K == 1 ? 0 : N-K);
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,p,q,r,a;
	for(;scanf("%d",&n),n;)
	for(;n--;)
	{
		scanf("%d%d%d",&p,&q,&r);
		a=(p+q+r)/3;
		if(p==100||q==100||r==100||p+q>=180||a>=80)
			puts("A");
		else if(a>=70||(a>=50&&(p>=80||q>=80)))
			puts("B");
		else
			puts("C");
	}
	return 0;
}

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

#define rep(ver,n) rep2(ver,0,n)
#define rep2(ver,m,n) for(int ver=m;ver<(n);ver++)
#define dup(x,y) (((x)+(y)-1)/(y))
#define vecadd emplace_back

typedef long long ll;

int main(){
  string str;
  cin>>str;
  
  if(str=="Sunny"){
    cout<<"Cloudy"<<endl;
  }
  else if(str=="Cloudy"){
    cout<<"Rainy"<<endl;
  }
  else{
    cout<<"Sunny"<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <math.h>

using namespace std;

typedef long long int ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
const int MOD = 1000000007;
const int INF = INT_MAX;



int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    int a[n];
    for (int i=0; i < n; i++){
        cin >> a[i];
    }


    int cnt = 0;
    int num = 1;
    for (int i=0; i < n; i++){
        if (a[i] == num){
            num++;
        }
        else {
            cnt++;
        }
    }

    if (num == 1){
        cout << -1 << endl;
    }
    else {
        cout << cnt << endl;
    }

    



    return 0;
}




//              g++ -std=c++1z  

Measured memory_bytes: 1024
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <vector>
#include <string>
using namespace std;

int main() {
  string s;
  cin >> s;
  int Count0=0;
  int Count1=0;
  int diff=0;

  for(int i=0;i<s.length();i++){
    if(i%2==0){
          if(s[i]=='0'){
            Count1++;
           }
          else{
             Count0++;
           }
    }
    else
    {
          if(s[i]=='0'){
            Count0++;
           }
          else{
             Count1++;
           }
    }
  }

  cout << std::min(Count0,Count1) << endl;

  
  return 0;
}

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

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

    int ans = 0;
    int maxc = 0;
    for(int i = 0; i < 2; i++){
        maxc = max(A, B);
        ans += maxc;
        if(maxc == A){
            A--;
        }else{
            B--;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int d, t, s;
    cin >> d >> t>> s;
    if(d/s < t){
        cout << "Yes" << endl;
    }
    else if(d/s == t && d%s==0){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3640
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;
constexpr double EPS = 1e-10;
#pragma endregion

void solve() {
    int n;
    cin >> n;
    vector<vector<int>> cnt(10, vector<int>(10));
    for (int i=1; i<=n; i++) {
        string s = to_string(i);
        cnt.at(s.front()-'0').at(s.back()-'0')++;
    }
    int res = 0;
    for (int i=1; i<=9; i++) {
        for (int j=i; j<=9; j++) {
            if (i == j) res += cnt.at(i).at(j) * cnt.at(j).at(i);
            else res += cnt.at(i).at(j) * cnt.at(j).at(i) * 2;
        }
    }
    cout << res << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m,x;cin>>n>>m>>x;
  vector<vector<int> > a(n,vector<int>(m));
  vector<int> c(n);
  for(int i=0;i<n;i++)
  {
    cin>>c[i];
    for(int j=0;j<m;j++)
    	cin>>a[i][j];
  }
  long long v=pow(2,n);
  long long min1=INT_MAX;
  for(int i=1;i<=v;i++)
  {
    long long curr=0;
    vector<int> sum(m,0);
    for(int j=0;j<n;j++)
    {
      if((1<<j)&i)
      {
        curr+=c[j];
        for(int k=0;k<m;k++)
          sum[k]+=a[j][k];
      }
    }
    bool check=true;
    for(int i=0;i<m;i++)
      if(sum[i]<x)
      {
        check=false;
        break;
      }
    if(check)
      min1=min(min1,curr);
  }
  if(min1>1e8)
    cout<<-1<<endl;
  else
    cout<<min1<<endl;
  return 0;
}
        

Measured memory_bytes: 4112
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 998244353
#define NUM 200010

void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}
int GCD(int a,int b){int c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
int LCM(int a,int b){return a*b/GCD(a,b);}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
int icmp(const void* a,const void* b){return *(int*)a-*(int*)b;}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
LL fac[NUM],finv[NUM],inv[NUM];
void comi(){int i;fac[0]=fac[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fac[i]=fac[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
int com(int n,int k){if(n<k||n<0||k<0)return 0;return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;}


int pid=0,pnum=0,rpid[NUM];
LL cost[NUM],rcost[NUM],cpid[NUM],que[NUM];
int judge(int a,int b){
  if(pnum<b||b==1)return 0;
  return cpid[que[a]]>cpid[que[b]]?1:0;
}
void push(LL a,int n){
  int i=++pid,j=++pnum;
  rpid[i]=n,cpid[i]=a,que[j]=i;
  while(judge(j/2,j))que[j]=que[j/2],que[j/=2]=i;
}
int pop(){
  int ans=rpid[que[1]],i=1,j;
  LL n=que[pnum--];
  que[1]=n;
  while(judge(i,j=i*2+judge(i*2,i*2+1)))que[i]=que[j],que[i=j]=n;
  return ans;
}
void Dijkstra(int v,int e,int* a,int* b,int* l,int ver){
  int i,flag[NUM]={0},pre[e+1],last[e+1];
  FOR(i,1,v+1)cost[i]=LNF,last[i]=-1;
  cost[ver]=0;
  FOR(i,0,e)pre[i]=last[a[i]],last[a[i]]=i;
  while(flag[ver]==0){
    flag[ver]++;
    for(i=last[ver];i+1;i=pre[i])if(cost[b[i]]>cost[ver]+l[i]){
      cost[b[i]]=cost[ver]+l[i];
      push(cost[b[i]],b[i]);
    }
    while(flag[ver]&&pnum)ver=pop();
  }
}

int main(){
  int N,M,i,ans=0;
  scanf("%d%d",&N,&M);
  int L[N+M-1],R[N+M-1],C[N+M-1];
  FOR(i,0,N-1)L[i]=i+2,R[i]=i+1,C[i]=0;
  FOR(i,N-1,N+M-1)scanf("%d%d%d",&L[i],&R[i],&C[i]);
  Dijkstra(N,N+M-1,L,R,C,1);

  printf("%lld\n",cost[N]<LNF?cost[N]:-1);
	return 0;
}


Measured memory_bytes: 10752
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//using graph = vector<vector<ll>>;


int main() {
	ll l,mem,ans=-1;
	stack<int> c;
	vector<bool> kanri(100, false);
	cin >> l;
	for (ll i = 0; i < l; i++) {
		cin >> mem;
		if (mem > 0&&kanri[mem]==false) {
			c.push(mem);
			kanri[mem] = true;
		}
		else if (mem>0&&kanri[mem]==true) {
			ans = i + 1;
			break;
		}
		else if(mem<0 && c.empty()==true){
			ans = i + 1;
			break;
		}
		else if (mem < 0 && c.top() == -mem) {
			c.pop();
			kanri[-mem] = false;
		}
		else if (mem < 0 && c.top() != -mem) {
			ans = i + 1;
			break;
		}
		else if (mem < 0 && kanri[-mem] == false) {
			ans = i + 1;
			break;
		}
	}
	if (ans == -1) {
		cout << "OK" << endl;
	}
	else {
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
const int MOD = 1000000007;

const int max_a = 20005;

int main(){
    int N; cin >> N;
    vector<int> a(N);
    rep(i,N) cin >> a[i];

    int ans = 0;
    int current = 1;
    rep(i,N){
        if (current == a[i]){
            current++;
        }
        else{
            ans++;
        }
    }
    if (current == 1) ans = -1;
    cout << ans << endl;
}


Measured memory_bytes: 4048
#include <iostream>

using namespace std;

int main() {
    int n;
    int m = 0;
    char op = '+';
    while (true) {
        cin >> n;
        switch (op) {
            case '+':
                m += n;
                break;
            case '-':
                m -= n;
                break;
            case '*':
                m *= n;
                break;
            case '/':
                m /= n;
                break;
        }
        cin >> op;
        if (op == '=') {
            cout << m << endl;
            return 0;
        }
    }
}

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

#define all(s) s.begin(), s.end()
#define pb push_back
#define ii pair<int, int>
#define x first
#define y second
#define bit(x, y) ((x >> y) & 1)
#define sz(s) ((int) (s).size())

int cnt[2][2][100005];

int main() {
    ios::sync_with_stdio(false); cin.tie(0); 
    cout.tie(0);
    string s[2];
    cin >> s[0] >> s[1];
    for (int i = 0; i < 2; i++) {
        s[i] = " " + s[i];
        for (int j = 0; j < 2; j++) {
            for (int k = 1; k < sz(s[i]); k++) {
                cnt[i][j][k] = cnt[i][j][k - 1] + (s[i][k] - 'A' == j);
            }
        }
    }
    int q;
    cin >> q;
    while (q--) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        int foo = cnt[0][1][b] - cnt[0][1][a - 1] - (cnt[0][0][b] - cnt[0][0][a - 1]);
        int baz = cnt[1][1][d] - cnt[1][1][c - 1] - (cnt[1][0][d] - cnt[1][0][c - 1]);
        if ((foo - baz) % 3 == 0) cout << "YES\n";
        else cout << "NO\n";
    }
    return 0;
}

Measured memory_bytes: 2540
n=int(input())
ans=0
dic={}
for i in range(1,n+1):
    s=str(i)
    d=(s[0],s[-1])
    if d not in dic.keys():
        dic[d] = 1
    else:
        dic[d] += 1

for a in dic.keys():
    b = (a[1],a[0])
    if b in dic.keys():
        ans += dic[a]*dic[(a[1],a[0])]

print(ans)

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

using namespace std;
#define ll long long int
const int MAXN = 2 * 1e5 + 5;

void solve(){
    ll n , a, b;
    cin >> n >> a >> b;
    ll times = n / (a + b);
    ll ans = 0;
    ans += times * a;
    ll left = n % (a + b);
    ans += min( left, a);
    cout << ans << '\n';
    
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
	//int t; cin >> t;
	//while(t--)
		solve();
}







Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Mon Oct  8 10:17:39 2018

@author: maezawa
"""

from itertools import permutations

#フロイド・ワーシャル
def warshall_floyd(glath):
	
	for k in range(len(glath)):
		for i in range(len(glath)):
			for j in range(len(glath[i])):
				if glath[i][j] > glath[i][k] + glath[k][j]:
                                   glath[i][j] = glath[i][k] + glath[k][j]
                                   glath[j][i] = glath[i][k] + glath[k][j]				
	return glath

N, M ,R= [int(x) for x in str(input()).split()]  #グラフの大きさ 
r=[int(x) for x in str(input()).split()]
graph=[[float("inf")]*N for i in range(N)]


for i in range(M):
	a,b,c=[int(x) for x in str(input()).split()]
	#if a in r and b in r:
	graph[a-1][b-1]=c
	graph[b-1][a-1]=c

#all_cost=warshall_floyd(select_graph)
all_cost=warshall_floyd(graph)


max_count=float("inf")
for i in permutations(r):
        cost=0
        for j in range(len(i)-1):                
                cost+= all_cost[i[j]-1][i[j+1]-1]       
        max_count=min(max_count,cost)

print(max_count)    
  


Measured memory_bytes: 4596
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>
#include <sstream>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

/*
0のアスキー　"48"
*/

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) x.begin(),x.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))


int main(){
    string S,T;
    cin >> S >> T;

    int res = 0,max = -1,t_pos=0;
    for(ll i = 0;i < S.size() - T.size()+1;i++){
        t_pos = 0;
        res = 0;
        for(ll j = i;j < T.size()+i;j++){
            if(S.at(j) == T.at(t_pos))
                res++;
            t_pos++;
        }
        if(res > max)
            max = res;
    }

    cout << T.size() -  max << endl;


}





    

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

int w,h;
int xs,ys;
int xg,yg;
int n;
vector<int> c(200);
vector<int> d(200);
vector<int> x(200);
vector<int> y(200);
vector<vector<bool>> visited(200,vector<bool>(200,0));
vector<vector<int>> maze(200,vector<int>(200,0));

void dfs(int x,int y){

    if(visited[x][y]) return ;
    if(maze[xs][ys]!=maze[x][y]) return ;
 
    visited[x][y]=true;

    if(x<w) dfs(x+1,y);
    if(x>1) dfs(x-1,y);
    if(y<h)dfs(x,y+1);
    if(y>1)dfs(x,y-1);

}

int main(){
    while(true){
        cin>>w>>h;
        if(w==0&&h==0) break;
        cin>>xs>>ys;
        cin>>xg>>yg;
        cin>>n;
        
        c=vector<int>(200,0);
        d=vector<int>(200,0);
        x=vector<int>(200,0);
        y=vector<int>(200,0);
        visited=vector<vector<bool>>(200,vector<bool>(200,0));
       
        for(int i=0;i<n;i++){
            cin>>c[i]>>d[i]>>x[i]>>y[i];
            if(d[i]){
                for(int j=0;j<4;j++)
                for(int k=0;k<2;k++)
                maze[x[i]+k][y[i]+j]=c[i];
            }else{
                for(int j=0;j<2;j++)
                for(int k=0;k<4;k++)
                maze[x[i]+k][y[i]+j]=c[i];
            }
        }
        dfs(xs,ys);
        if(visited[xg][yg]&&maze[xs][ys]) cout<<"OK"<<endl;
        else cout<<"NG"<<endl;
        
    }

    return 0;
}


Measured memory_bytes: 3336
n = int(input())
a = list(map(int,input().split()))
b = [x-1 if x != 1 else 1 for x in a]

for i in range(n-1):
    a[i+1] = a[i+1] if abs(a[i]-a[i+1]) < abs(a[i]-b[i+1]) else b[i+1]
    if a[i+1] < a[i]:
        print('No')
        quit()

print('Yes')

Measured memory_bytes: 14396
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            String S = in.next();
            int N = S.length();
            boolean ans = true;
            String S2 = S.substring(0, (N - 1) / 2);
            String S3 = S.substring((N + 3) / 2 - 1, N);
            for (int i = 0; i < N && ans; i++) {
                ans = S.charAt(i) == S.charAt(N - i - 1);
            }
            N = S2.length();
            for (int i = 0; i < N && ans; i++) {
                ans = S2.charAt(i) == S2.charAt(N - i - 1);
            }
            N = S3.length();
            for (int i = 0; i < N && ans; i++) {
                ans = S3.charAt(i) == S3.charAt(N - i - 1);
            }
            out.println(ans ? "Yes" : "No");
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 22740
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
typedef long long  ll;
typedef long double lb;
using namespace std;
int main() {
	int n;
	cin >> n;
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			int a = max(i, j);
			int b = min(i, j);
			int r = a % b;
			while (r != 0) {
				a = b;
				b = r;
				r = a % b;
			}
			for (int l = 1; l <= n; l++) {
				int c = max(b, l);
				int d = min(b, l);
				int x = c % d;
				while (x != 0) {
					c = d;
					d = x;
					x = c % d;
				}
				sum += d;
			}
		}
	}
	cout << sum << endl;
}






Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    ll n;
    cin >> n;
    
    vector<ll> a(n);
    rep(i, n)cin >> a[i];
    reverse(ALL(a));

    vector<ll> dp(n);
    fill(ALL(dp), INF);

    rep(i, n){
        ll pos = upper_bound(ALL(dp), a[i]) - dp.begin();

        dp[pos] = a[i];
    }

    ll ans = lower_bound(ALL(dp), INF) - dp.begin();

    cout << ans << endl;
}

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

#define fast ios_base::sync_with_stdio(false); cin.tie(nullptr); cin.tie(nullptr);
#define endl '\n'
#define int long long
#define pb emplace_back
#define range(v) v.begin(),v.end()
#define ff first
#define ss second
#define mod (int)(1e9 + 7)
#define inf (int)(1e15)
#define N (int)(2e6 + 10)

using namespace std;


int solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int &i : a) cin >> i;
	sort(range(a));
	vector<bool> p(N, false);
	int cnt = 0;
	for (int idx = 0; idx < n; idx++) {
		int i = a[idx];
		if (idx != n - 1 and a[idx] == a[idx + 1]) {
			p[i] = true;
			continue;
		}
		bool f = true;
		for (int j = 1; j * j <= i; j++) {
			if (i % j == 0) {
				int d1 = j, d2 = (i / j);
				if (p[d1] or p[d2]) {
					f = false;
					break;
				}
			}
		}
		if (f) cnt++;

		p[i] = true;
	}
	return cnt;
}

int32_t main() {
	fast
	int t_c = 1;
	// cin >> t_c;
	while (t_c--) {
		auto ans = solve();
		cout << ans << endl;
	}
}

Measured memory_bytes: 4988
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001



int main() {
    int N; cin >> N;
    cout << N * N * N << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#define MAX 500010
int mem[MAX]={0};
int gcd(int p,int q){
	while(q!=0){
		int r=p%q;
		p=q;
		q=r;
	}
	return p;
//	if(p%q ==0 ) return q;
//	return gcd(q,p%q);
}
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	int sum=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				sum+=gcd(gcd(i,j),k);
			}
		}
	}
	printf("%d",sum);
	return 0;
} 

Measured memory_bytes: 3760
import sys
read = sys.stdin.read
def main():
    n, *a = map(int, read().split())
    r = 0
    for ea in a:
        while True:
            if ea % 2 == 0:
                r += 1
                ea //= 2
            else:
                break
    print(r)


if __name__ == '__main__':
    main()

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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if((C+B-1)/B <= (A+D-1)/D){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3552
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		int e = scan.nextInt();
		int k = scan.nextInt();

		if(k >= e - a) {
			System.out.println("Yay!");
		}else {
			System.out.println(":(");
		}
	}
}

Measured memory_bytes: 21844
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double ld;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)


int main() {
    ll X,K,D;
    cin >> X >> K >> D;

    // Xの絶対値を求める
    X = abs(X);

    // ll a = K*D; これだとオーバーフローする。よって式変形で工夫する

    ll ans = 0;
    // X >= D * K （式変形） →　(X/D) >= K
    if((X/D) >= K){
        // ans = ((X/D) - K)*D;
        ans = X - D*K;
    }else{
        ll e = X/D;
        K -= e;
        X -= e*D;
        if(K%2 == 0){
            ans = X;
        }else{
            ans = abs(X-D);
        }
    }

    cout << ans << endl;
    

    
}




Measured memory_bytes: 3608
n,y=map(int,input().split())
for i in range(2001):
    if ((y//1000 - n - 4*i)/9) % 1 == 0 and (y//1000 - n - 4*i)/9>=0 and n-(y//1000 - n - 4*i)/9-i>=0:
        print(int((y//1000 - n - 4*i)/9),i,int(n-(y//1000 - n - 4*i)/9-i))
        exit()
print(-1,-1,-1)

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

int main(){
    int n, ans = 0;
    string s;
    cin >> s;
    n = s.size();
    for(int i=0;i<n-1;i++){
        if(s[i] != s[i+1]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, count=0;
  string S;
  cin >> N >> S; 
  for (int i=0; i<N-2; i++){
    if (S.at(i) == 'A'){
      if (S.at(i+1) == 'B')
        if (S.at(i+2) == 'C')
          count++;
     else
       continue;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import java.io.*;

class Main{

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

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String tmp;
	
	while((tmp = br.readLine()) != null){
	    String[] input = tmp.split(" ");
	    int a = Integer.parseInt(input[0]);
	    String op = input[1];
	    int b = Integer.parseInt(input[2]);
	    int result = 0;

	    if(op.equals("?")){
		break;
	    }
		
	    if(op.equals("+")){
		result = a + b;
	    }else if(op.equals("-")){
		result = a - b;
	    }else if(op.equals("*")){
		result = a * b;
	    }else if(op.equals("/")){
		result = a / b;
	    }else{
		System.out.println("error");
	    }

	    System.out.printf("%d\n", result);
	}
	
    }

}

Measured memory_bytes: 16956
import std.stdio, std.conv, std.string, std.algorithm,
       std.math, std.array, std.container, std.typecons;

int[] p, q;
int a, b, n, count=0;

void solve(bool[] used, int[] array, int depth=0) {
  if(depth==n) {
    count++;
    if(array==p) a = count;
    if(array==q) b = count;
    return;
  }
  for(int i=0; i<n; i++) {
    if(!used[i]) {
      auto dup = array.dup;
      dup[depth] = i+1;
      auto du = used.dup;
      du[i] = true;
      solve(du, dup, depth+1);
    }
  }
}

void main() {
  n = readln.chomp.to!int;
  p = readln.chomp.split.to!(int[]);
  q = readln.chomp.split.to!(int[]);
  auto used = new bool[n];
  auto array = new int[n];
  solve(used, array);
  writeln(abs(a-b));
}



Measured memory_bytes: 1276