akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll N, E, T;
ll x[100050];
ll dp[100050];
int main() {
    //cout.precision(10);
    cin >> N >> E >> T;
    for(int i = 1; i <= N; i++) {
        dp[i] = 1e17;
        cin >> x[i];
    }
    x[0] = 0;
    int before = 1;
    ll now = 1e17;
    for(int i = 1; i <= N; i++) {
        now += 3 * (x[i] - x[i - 1]);
        while(2 * (x[i] - x[before]) >= T) {
            now = min(now, dp[before - 1] + (x[i] - x[before - 1]) + 2 * (x[i] - x[before]));
            //cout << i << " " << before << " " << now << endl;
            before++;
        }
        //cout << i << " " << dp[i] << endl;
        //dp[i] = dp[i - 1] + x[i] - x[i - 1] + T;
        //cout << i << " " << dp[i - 1] << " " << x[i] << " " <<x[i - 1] << " " << T << endl;
        //cout << i << " " << dp[i - 1] + x[i] - x[i - 1] + T << endl;
        //cout << i << " " << dp[i] << endl;
        //if(before < i - 1) dp[i] = min(dp[i], dp[before] + 2 * T + x[i] - x[before]);
        dp[i] = min(dp[i], dp[before - 1] + (x[before] - x[before - 1]) + T + x[i] - x[before]);
        //cout << i << " " << min(dp[i], dp[before - 1] + (x[before] - x[before - 1]) + T + x[i] - x[before]) << endl;
        //cout << i << " " << dp[i] << endl;
        dp[i] = min(dp[i], now);
        //cout << i << " " << now << endl;
        //cout << i << " " << dp[i] << endl;
    }
    cout << dp[N] + E - x[N] << endl;
    return 0;
}


Measured memory_bytes: 1920
def query(val):
    print ('?', val)
    ans = input()
    if ans == 'Y':
        return True
    return False
LIMIT = 10 ** 9
import sys
if __name__ == "__main__":
    if (query(LIMIT)):
        res = 1
        while (True):
            if(query(2 * res)):
                print ('!', res)
                sys.exit()
            res *= 10
    digit = 10
    res = LIMIT
    while (True):
        if (query(res)):
            break
        res = res // 10
        digit -= 1
    query = 10 ** (digit)
    keta = 0
    while (keta < digit):
        low = query
        high = query * 10
        left = -1
        right = 10
        while (right - left > 1):
            med = (right + left) // 2
            if med < 0:
                left = med
                continue
            if med > 9:
                right = med
                continue
            if keta == 0 and med == 0:
                left = med
                continue
            val1 = list(str(low))
            val1[keta] = str(med)
            val1 = int("".join(val1))
            print ("? %d" %(val1))
            ans = input()
            if (ans == "Y"):
                if (keta == digit - 1):
                    query = val1
                right = med
                continue
            else:
                if (keta < digit - 1):
                    query = val1
                left = med
                continue
        keta += 1
    query = query // 10
    print ("! %d" % (query))


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

using namespace std;

const int N=200005;
int n,m,a[N],cnt[N],tot[N],ans;
void inc(int x,int u){
	if(x<1)return;
	if(!tot[x])ans--;
	tot[x]+=u;
	if(!tot[x])ans++;
}

int main(){
	scanf("%d%d",&n,&m);ans=n;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),inc(a[i]-cnt[a[i]],1),cnt[a[i]]++;
	for(int i=1,x,y;i<=m;i++){
		scanf("%d%d",&x,&y);
		cnt[a[x]]--,inc(a[x]-cnt[a[x]],-1);
		a[x]=y;
		inc(a[x]-cnt[a[x]],1),cnt[a[x]]++;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 3712
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>

using namespace std;

vector<int> poles;


int main(int argc, char* argv[]){
    int N;
    cin >> N;
    poles.resize(N, 0);

    for(int i = 0; i < N; ++i){
        cin >> poles.at(i);
    }

    std::sort(poles.begin(), poles.end(), greater<int>());

    long long area = 0;
    int count = 0;
    int prev = -1;

    for(int i = 0; i < poles.size(); ++i){
        if(poles[i] == prev){
            ++count;
            if(count == 1){
                area = prev;
            }
            else{
                area *= prev;
                cout << area;
                return 0;
            }
            prev = -1;
        }
        else{
            prev = poles[i];
        }
    }


    cout << 0;
}


Measured memory_bytes: 640
import java.util.stream.*;
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        Map<Integer, Integer>[] connect = IntStream.range(0, n).mapToObj(i -> new HashMap<>()).toArray(HashMap[]::new);
        for (int i = 0; i < n - 1; i++) {
            int a = scanner.nextInt() - 1;
            int b = scanner.nextInt() - 1;
            int c = scanner.nextInt();
            connect[a].put(b, c);
            connect[b].put(a, c);
        }

        int q = scanner.nextInt();
        int k = scanner.nextInt() - 1;

        long[] dist2 = new long[n];
        Deque<Integer> deque = new ArrayDeque<>();
        deque.add(k);

        while (!deque.isEmpty()) {
            int i = deque.poll();
            for (Map.Entry<Integer, Integer> entry : connect[i].entrySet()) {
                if (dist2[entry.getKey()] == 0) {
                    dist2[entry.getKey()] = dist2[i] + entry.getValue();
                    deque.add(entry.getKey());
                }
            }
        }

        for (int i = 0; i < q; i++) {
            int x = scanner.nextInt() - 1;
            int y = scanner.nextInt() - 1;
            System.out.println(dist2[x] + dist2[y]);
        }
    }
}

Measured memory_bytes: 194748
#include <stdio.h>

int main(void){
    int n,k,q;
scanf("%d %d %d",&n,&k,&q);
int a[n];
for(int i=0;i<n;i++)
{a[i]=k-q;}
for(int j=0;j<q;j++)
{int c=0;
    scanf("%d",&c);
    {a[c-1]++;}
}
for(int i=0;i<n;i++)
{if(a[i]>0)
    printf("Yes\n");
    else
    printf("No\n");
}

return 0;    

}

Measured memory_bytes: 896
using System;
using System.Linq;

class DebtHell 
{
    static void Main()
    {
        var debt = 100000m;
        var q =
            from _ in Enumerable.Range( 0, int.Parse( Console.ReadLine() ) )
            select debt = Math.Ceiling( debt * 0.00105m ) * 1000;
        Console.WriteLine( q.Last() );
    }
  
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    for(int i=0; i<n; i++){
        cin >> h[i];
    }

    vector<int> good(n, 1);

    // vector<vector<int>> path(n, vector<int>(n, 0));
    for(int i=0; i<m; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if(h[a] >= h[b]) good[b] = 0;
        if(h[a] <= h[b]) good[a] = 0;
    }

    int ans = 0;
    for(int i=0; i<n; i++){
        ans += good[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4764
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <functional>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int MAXN=1e5+10;
const int MAX=1e4+10;
const double eps=1e-6;



int main(){
    #ifdef ONLINE_JUDGE
    #else
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    #endif

    ll s[100];
    s[1]=2;s[2]=1;
    for(int i=3;i<=90;i++)
    	s[i]=s[i-1]+s[i-2];
    int n;
    cin>>n;
    cout<<s[n+1]<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define INF LONG_LONG_MAX
#define pb push_back
#define mp make_pair
#define MAXN 1000009
#define MOD 1000000007
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define left(x) x<<1
#define right(x) (x<<1)|1
#define PI acos(-1.0)
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef map<string,ll> msi;
typedef set<ll> si;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> 
ordered_set;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> 
ordered_multiset;
 
ll solve(){
    int n;
    cin>>n;
    if(n%2)
        cout<<2*n;
    else
        cout<<n;
    return 0;
}
 
int main(){
    
    int T=1;
    //scanf("%d",&T);
    for(int i=1;i<=T;++i){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int N = scanner.nextInt();
        int[] x = new int[N];
        int[] y = new int[N];


        for (int i = 0 ; i < N ; i++) {
            x[i] = scanner.nextInt();
            y[i] = scanner.nextInt();
        }

        double[][] dist = new double[N][N];
        double totalDist = 0.0;
        for (int i = 0 ; i < N ; i++) {
            for (int j = i + 1 ; j < N ; j++) {
                dist[i][j] = Math.sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
                totalDist += dist[i][j];
            }
        }

        System.out.println(totalDist * 2.0 / N);
    }
}


Measured memory_bytes: 35516
package main

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

var sc = bufio.NewScanner(os.Stdin)

func trace(A []string, N int) {
	for i := 0; i < N; i++ {
		if i != 0 {
			fmt.Printf(" ")
		}
		fmt.Printf("%s", A[i])
	}
	fmt.Printf("\n")
}

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

func BubbleSort(A []string, N int) []string {
	bs := append([]string{}, A...)
	for i := 0; i < N; i++ {
		for j := N - 1; j > i; j-- {
			num1 := getNumberOfCard(bs[j])
			num2 := getNumberOfCard(bs[j-1])
			if num1 < num2 {
				bs[j], bs[j-1] = bs[j-1], bs[j]
			}
		}
	}
	return bs
}

func SelectionSort(A []string, N int) []string {
	ss := append([]string{}, A...)
	for i := 0; i < N; i++ {
		minj := i
		for j := i; j < N; j++ {
			num1 := getNumberOfCard(ss[j])
			num2 := getNumberOfCard(ss[minj])
			if num1 < num2 {
				minj = j 
			}
		}
		ss[i], ss[minj] = ss[minj], ss[i]
	}
	return ss
}

func getNumberOfCard(card string) int {
	num, _ := strconv.Atoi(card[1:])
	return num
}

func isStable(in, out []string, N int) {
	for i := 0; i < N; i++ {
		for j := i+1; j < N; j++ {
			for a :=0; a < N; a++ {
				for b := a+1; b < N; b++ {
					num1 := getNumberOfCard(in[i])
					num2 := getNumberOfCard(in[j])
					if num1 == num2 && in[i] == out[b] && in[j] == out[a] {
						fmt.Println("Not stable")
						return 
					}
				}
			}
		}
	}
	fmt.Println("Stable")
	return 
}

func main() {
	sc.Split(bufio.ScanWords)
	ns := nextString()
	length, _ := strconv.Atoi(ns)

	array := make([]string, length)
	for i := 0; i < length; i++ {
		array[i] = nextString()
	}
	bubbleSorted := BubbleSort(array, length)
	selectionSorted := SelectionSort(array, length)

	trace(bubbleSorted, length)
	isStable(array, bubbleSorted, length)
	trace(selectionSorted, length)
	isStable(array, selectionSorted, length)
}


Measured memory_bytes: 1136
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S, T;
  cin >> S >> T;
  vector<char> ST(26, ' ');
  vector<char> TS(26, ' ');
  bool flg = true;
  for (int i = 0; i < S.size(); i++){
    if (ST[S[i] - 'a'] == ' '){
      ST[S[i] - 'a'] = T[i];
    } else if (ST[S[i] - 'a'] != T[i]){
      flg = false;
    }
    if (TS[T[i] - 'a'] == ' '){
      TS[T[i] - 'a'] = S[i];
    } else if (TS[T[i] - 'a'] != S[i]){
      flg = false;
    }
  }
  cout << (flg ? "Yes" : "No");
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define getchar gc
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int B=32000,N=10000005,mod=1e9+7;
int qq,q[N];
ll F[B+1],G[B+1];
PI f[N];
PI operator +(PI a,PI b){
	return mp((ll)a.fi*b.fi%mod,((ll)a.fi*b.se*2+(ll)a.se*b.fi*2+(ll)a.se*b.se+(ll)a.fi*b.fi*2)%mod);
}
ll pw(int h){
	return F[h%B]*G[h/B]%mod;
}
void del(PI &x,int h){
	x.fi=x.fi*pw(h)%mod;
}
int main(){
	For(i,F[0]=1,B)F[i]=F[i-1]*2%mod;
	For(i,G[0]=1,B)G[i]=G[i-1]*F[B]%mod;
	int n=read();
	For(i,1,n){
		int h=read();
		PI zs=mp(1,0);
		if(qq&&q[qq]>=h){
			while(q[qq-1]>=h){
				del(f[qq],q[qq]-q[qq-1]); 
				f[qq-1]=f[qq-1]+f[qq]; qq--;
			}
			del(f[qq],q[qq]-h);
			q[qq]=h; f[qq]=f[qq]+zs;
		}else{
			q[++qq]=h;
			f[qq]=zs;
			
		}
	}
	q[0]=1;
	//For(i,1,qq)cout<<f[i].fi<<" "<<f[i].se<<endl;
	while(qq){
		del(f[qq],q[qq]-q[qq-1]); qq--;
		if(qq)f[qq]=f[qq]+f[qq+1];
	}
	cout<<((ll)f[1].fi*2+f[1].se)%mod<<endl;
}
/*
3
1 2 2

*/

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

#include<bits/stdc++.h>
using namespace std;


int main()
{

    int a,b,c,d;
    cin>>a>>b>>c>>d;

    int cnt=0,cnt1=0;

    while(1){
        c=c-b;
        cnt++;
        if(c<=0){
            break;
        }
    }
    while(1){
        a-=d;
        cnt1++;
        if(a<=0){
        break;
        }
    }


    if(cnt<=cnt1) cout<<"Yes"<<endl;
    else    cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3600
S = input()
flag = True

if S.count('a') >= 2:
  flag = False
elif S.count('b') >= 2:
  flag = False
elif S.count('c') >= 2:
  flag = False
elif S.count('d') >= 2:
  flag = False
elif S.count('e') >= 2:
  flag = False
elif S.count('f') >= 2:
  flag = False
elif S.count('g') >= 2:
  flag = False
elif S.count('h') >= 2:
  flag = False
elif S.count('i') >= 2:
  flag = False
elif S.count('j') >= 2:
  flag = False
elif S.count('k') >= 2:
  flag = False
elif S.count('l') >= 2:
  flag = False
elif S.count('m') >= 2:
  flag = False
elif S.count('n') >= 2:
  flag = False
elif S.count('o') >= 2:
  flag = False
elif S.count('p') >= 2:
  flag = False
elif S.count('q') >= 2:
  flag = False
elif S.count('r') >= 2:
  flag = False
elif S.count('s') >= 2:
  flag = False
elif S.count('t') >= 2:
  flag = False
elif S.count('u') >= 2:
  flag = False
elif S.count('v') >= 2:
  flag = False
elif S.count('w') >= 2:
  flag = False
elif S.count('x') >= 2:
  flag = False
elif S.count('y') >= 2:
  flag = False
elif S.count('z') >= 2:
  flag = False

if flag:
  print("yes")
else:
  print("no")

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

using namespace std;

const int N = 100007;
const int INF = 1000000007;

int h[N], dp[N];

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

  for(int i = 0; i < n; ++i) cin >> h[i];

  for(int i = 0; i <= k; ++i) dp[i] = abs(h[i] - h[0]);
  for(int i = k + 1; i < n; ++i) {
    dp[i] = INF;
    for(int j = i - k; j < i; ++j) {
      dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
    }
  }

  cout << dp[n - 1] << "\n";
  return 0;
}


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

long search(long A[], long n, long key){
	long i = 0;
	A[n] = key;
	while (A[i] != key) i++;
	return i != n;
}

int main(){
	long n, A[10001], q, key, sum = 0;
	cin >> n;
	for (long i = 0; i < n; i++) cin >> A[i];
	cin >> q;
	for (long i = 0; i < q; i++){
		cin >> key;
		if (search(A, n, key)) sum++;
	}
	cout << sum << endl;
	return 0;
}

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

using namespace std;
#define INF 0x3f3f3f3f
typedef long long LL;
typedef unsigned long long ULL;
const int MAX_N = 500 + 5;
const int MAX_M = 1000000;
const double PI = acos(-1.0);

struct node{
    double x, y;
} p[MAX_N];
int f[MAX_N];
int main()
{
    int n;
    scanf("%d",&n);
    for (int i = 0; i < n; i++)
        scanf("%lf%lf",&p[i].x, &p[i].y);
    double R = 1e11;
    double alpha = 2.0 * PI / MAX_M;
    int pos;double mdist, dist;
    for (int i = 0; i < MAX_M; i++){
        double x = R * sin(i * alpha);
        double y = R * cos(i * alpha);
        pos = 0;
        mdist = sqrt((x - p[0].x)*(x - p[0].x) + (y - p[0].y)*(y - p[0].y));
        for (int j = 1; j < n; j++){
            dist = sqrt((x - p[j].x)*(x - p[j].x) + (y - p[j].y)*(y - p[j].y));
            if (dist < mdist) {
                pos = j;
                mdist = dist;
            }
        }
        f[pos]++;
    }
    for (int i = 0; i < n; i++)
        printf("%.7f\n", 1.0 * f[i] / MAX_M);
    return 0;
}


Measured memory_bytes: 384
def main():
    N,K=map(int,input().split())
    R,S,P=map(int,input().split())
    T=input()

    res=0
    T_=[]
    for i in range(N):
        if T[i]=="r":
            res+=P
            T_.append("p")
        elif T[i]=="s":
            res+=R
            T_.append("r")
        else:
            res+=S
            T_.append("s")
    for i in range(N):
        if i>=K:
            if T_[i-K]==T_[i]:
                if T_[i]=="r":
                    res-=R
                elif T_[i]=="s":
                    res-=S
                else:
                    res-=P
                T_[i]="#"

    print(res)

if __name__=="__main__":
    main()


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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    int n = input();
    bool f = false;
    range(i, 0, n) {
        char c = input<char>();
        if (c == 'Y') f = true;
    }

    cout << (f ? "Four" : "Three") << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int Inf = (1<<30);
ll inf = (1LL<<60);
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main(){
	int n;
	cin >> n;
	vector<int> ans(110000, 0);
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a != 0) ans[a - 1]++;
		if (a != 100000) ans[a + 1]++;
		ans[a]++;
	}
	int MAX = 0;
	for (int i = 0; i <= 100000; i++) {
		MAX = max(MAX, ans[i]);
	}
	cout << MAX;
	return(0);
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>

using namespace std;

int n, m;
int sum;
int t[105], p[105], x[105];

int main()
{
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &t[i]);
        sum += t[i];
    }
    scanf("%d", &m);
    for(int i = 0; i < m; i++)
    {
        scanf("%d%d", &p[i], &x[i]);
        printf("%d\n", sum - t[p[i] - 1] + x[i]);
    }
    return 0;
}


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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define debug(v) {for (auto x : v) cerr << x << ' '; cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n, m;
	scanf("%d%d", &n, &m);
	vi cnt(m+1);
	for (int i = 0; i < n; i++) {
		int k, x;
		for (scanf("%d", &k); k > 0; k--) {
			scanf("%d", &x);
			cnt[x]++;
		}
	}
	int ans = 0;
	for (int i = 1; i <= m; i++)
		if (cnt[i] == n) ans++;
	printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int h, w, k;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> h >> w >> k;
  char g[6][6];
  int sum = 0;
  REP(i, h) REP(j, w) {
    cin >> g[i][j];
    if(g[i][j] == '#') sum++;
  }

  ll ans = 0;

  REP(i, 1 << h) {
    vector<int> hs;
    int t_sum = 0;
    REP(j, h) {
      if(i & (1 << j)) {
        hs.push_back(j);
        REP(k, w) if(g[j][k] == '#') t_sum++;
      }
    }

    REP(j, 1 << w) {
      vector<int> ws;
      int tt_sum = t_sum;
      REP(k, w) {
        if(j & (1 << k)) {
          ws.push_back(k);
          REP(l, h) if(g[l][k] == '#') tt_sum++;
        }
      }

      REP(k, hs.size()) REP(l, ws.size()) {
        if(g[hs[k]][ws[l]] == '#') tt_sum--;
      }
      if(sum - tt_sum == k) ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Here your code !
    //GREATER、A<B のときLESS、A=B のときEQUAL

    std::string str1,str2;
    cin >> str1 >> str2;
    
    if(str1.size() > str2.size()){
        cout << "GREATER" << endl;
    }else if(str1.size() < str2.size()){
        cout << "LESS" << endl;
    }else{
        if(str1 == str2){
            cout << "EQUAL" << endl;
        }else{
            for(int i = 0; i < str1.size(); i++ ){
                if(str1[i] > str2[i]){
                    cout << "GREATER" << endl;
                    return 0;
                }else if(str1[i] < str2[i]){
                    cout << "LESS" << endl;
                    return 0;
                }
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ABS(a) (((a)>0)?(a):(-(a)))
int X;
bool check(int mv){
	int cur=0,xb;
	for(xb=mv;xb>0;xb--){
		int n1=cur-xb,n2=cur+xb;
		if(ABS(n1-X)>ABS(n2-X)) n1=n2;
		if(ABS(n1-X)<xb) return 1;
		if(ABS(n1-X)<ABS(cur-X)) cur=n1;
	}
	return 0;
}
int main(){
	scanf("%d",&X);
	int low=0,mid,hgh=1000000;
	while(low<hgh){
		mid=(low+hgh)>>1;
		if(check(mid)) hgh=mid; else low=mid+1;
	}
	printf("%d\n",low);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define int int64_t
#define rep(i, N) for(int i=0; i<N; i++)
#define repr(i, N) for(int i=N-1; i>=0; --i)
#define all(v) v.begin(),v.end() 
using namespace std;
//using pr = pair<int, int>;
using tup  = tuple<int, int, int>;
using vec  = vector<int>;
using vvec = vector<vec>;

//プロトタイプ宣言
//int myfunc(int, vvec);

//グローバル変数
//int N, M;
//vvec data(N, vec(M));



signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a,b;
	cin>>a>>b;
	if(a<10&&b<10){
		cout<<a*b<<endl;
	}
	else{
		cout<<-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int m = sc.nextInt();

    boolean[][] s = new boolean[m][n];
    int[] p = new int[m];
    int[] cnt = new int[m];
    int res = 0;
    boolean acc;

    for (int i = 0; i < m; i++) {
      int k = sc.nextInt();
      for (int j = 0; j < k; j++) {
        s[i][sc.nextInt() - 1] = true;
      }
    }

    for (int i = 0; i < m; i++) {
      p[i] = sc.nextInt();
    }

    for (int bit = 0; bit < Math.pow(2, n); bit++) {
      Arrays.fill(cnt, 0);
      acc = true;
      for (int i = 0; i < n; i++) {
        if ((1 & (bit >> i)) == 1) { // i が bit に入るかどうか
          for (int j = 0; j < m; j++) {
            if (s[j][i]) {
              cnt[j]++;
            }
          }
        }
      }

      for (int i = 0; i < m; i++) {
        if (cnt[i] % 2 != p[i]) {
          acc = false;
          break;
        }
      }

      if (acc) {
        res++;
      }
    }

    System.out.println(res);

  }

}

Measured memory_bytes: 23252
quit() = exit(0)
in_1() = parse(Int, readline())
in_a() = parse.(Int, split(readline()))

function main()
  N, K = in_a()
  n = 0
  for k in K:N+1
    n += sum(N-k+1:N) - sum(0:k-1) + 1
    n = mod(n, 10^9+7)
  end
  println(n)
end

main()


Measured memory_bytes: 177172
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MAX_N = 5005;
const int MAX_M = 10005;
const ll INF = 1000000000000000000LL;

struct edge
{
	int a, b;
	ll cost;
};

int n, m;
ll p;
edge edges[MAX_M];
vector<pair<int, ll>> g[MAX_N];
ll d[MAX_N];
ll dp[MAX_N][MAX_M];
bool used[MAX_N][MAX_N];

void dfs(int s, int u)
{
	used[s][u] = true;
	for (const auto& e : g[u])
		if (!used[s][e.first])
			dfs(s, e.first);
}

int main()
{
	ios::sync_with_stdio(false);

	cin >> n >> m >> p;
	for (int i = 0; i < m; i++)
	{
		int a, b; ll c;
		cin >> a >> b >> c;
		a--; b--;
		c -= p;
		edges[i].a = a; edges[i].b = b; edges[i].cost = -c;
		c += p;
		g[a].emplace_back(b, c);
	}

	for (int i = 0; i < n; i++)
		dfs(i, i);

	ll x = -1;
	bool found = false;
	for (int i = 0; i < n; i++)
	{
		x = -1;
		for (int j = 0; j < m; j++)
		{
			const auto& e = edges[j];
			if (!used[0][e.a] || !used[e.a][n - 1])
				continue;
			if (d[e.a] + e.cost < d[e.b])
			{
				d[e.b] = d[e.a] + e.cost;
				x = e.b;
			}
		}
	}
	
	found = x != -1;

	if (found)
	{
		cout << "-1" << endl;
		return 0;
	}

	for (int i = 0; i < n; i++)
		for (int j = 0; j < MAX_M; j++)
			dp[i][j] = -INF;
	dp[0][0] = 0;

	for (int j = 0; j < MAX_M - 1; j++)
	{
		for (int i = 0; i < n; i++)
		{
			for (const auto& e : g[i])
			{
				ll val = dp[i][j] + e.second;
				dp[e.first][j + 1] = max(dp[e.first][j + 1], val);
			}
		}
	}

	ll result = 0;
	for (int j = 0; j < MAX_M; j++)
		result = max(result, dp[n - 1][j] - j * p);
	cout << result << endl;
}

Measured memory_bytes: 213632
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n;
	cin >> n;

	int ans = 180 * (n - 2);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
 public static void main(String[] args) {
  // 標準入力からデータを読み込む準備
  Scanner sc = new Scanner(System.in);
  // 2つの文字の固まりをそれぞれ整数値と想定して読み込む
  int a = sc.nextInt();
  int b = sc.nextInt();
  int area = a*b /* ここを変えて面積を求めよう */;
  int length = a*2+b*2/* ここを変えて周囲の長さを求めよう */;
  System.out.println(area + " " + length);
  }
}


Measured memory_bytes: 26152
n, m = map(int, input().split())
sc = []
for i in range(m):
    sc.append(list(map(int, input().split())))


for i in range(10**n):
    s = str(i)
    if len(s) == n and all([s[sc[j][0]-1] == str(sc[j][1]) for j in range(m)]):
        print(s)
        exit(0)


print('-1')


#
# for i in range(1, n+1):
#    if list(zip(*sc))[0].count(i) > 1:
#        print('-1')
#        exit(0)
#
#
# if min(list(zip(*sc))[0]) != 1:
#    print('-1')
#    exit(0)
#
# for i in sc:
#    if i[0] == 1 and i[1] == 0 and n > 1:
#        print('-1')
#        exit(0)
#
#ans = [0, 0, 0]
# for i in sc:
#    ind, val = i[0]-1, i[1]
#    if ans[ind] != 0:
#        ans[ind] = min(ans[ind], val)
#    else:
#        ans[ind] = val
#
#print(''.join(list(map(str, ans))))


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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;

int main() {
  int N;
  cin>>N;
  int t = N%10;
  if(t==2||t==4||t==5||t==7||t==9)cout<<"hon"<<endl;
  if(t==0||t==1||t==6||t==8) cout<<"pon"<<endl;
  if(t==3) cout<<"bon"<<endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

int main(){
	
	int N;
	cin>>N;
	
	vector<pair<int,int>> P;
	
	for(int i=0;i<N;i++){
		int X,L;
		cin>>X>>L;
		
		P.emplace_back(X+L,X-L);
	}
	
	sort(P.begin(),P.end());
	
	int now = -Inf;
	int ans = 0;
	
	for(int i=0;i<N;i++){
		if(P[i].second >= now){
			now = P[i].first;
			ans ++;
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	string S;
	cin >> S;

	int N = S.size();

	vector<long long> a(N + 1, 0);
	
	for (int i = 0; i < N; i++)
	{
		if (S[i] == '<')
		{
			a[i + 1] = max(a[i + 1], a[i] + 1);
		}
	}

	for (int i = N - 1; i >= 0; i--)
	{
		if (S[i] == '>')
		{
			a[i] = max(a[i], a[i + 1] + 1);
		}
	}

	cout << accumulate(a.begin(), a.end(), 0LL);

	return 0;
}


Measured memory_bytes: 4764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
double eps=1e-8;
int main()
{
    ll a;cin>>a;
   ll x=100;
    for(ll i=1;i<=3760;i++){
        x=x+x/100;
        //ll ans=ll(x);
        if(x>=a) {cout<<i;break;}
       // if(i==1706)cout<<x<<endl;
    }
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	int N;
	string s,t;
	cin>>N>>s>>t;
	rep(i,N+1){
		if(s.substr(i)==t.substr(0,N-i)){
			cout<<N+i<<endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

func main() {
	// sc.Split(bufio.ScanWords)

	// S := strings.Split(nextLine(), "")
	var S string
	fmt.Scan(&S)

	field := make([]int, len(S))
	right := 0
	left := 0

	for i := 0; i < len(S)-1; i++ {
		if S[i] == 'R' && S[i+1] == 'R' {
			field[i] = 0
			right++
		}

		if S[i] == 'R' && S[i+1] == 'L' {
			field[i] = right/2 + 1
			field[i+1] = right/2 + right%2 + 1
			right = 0
		}
	}

	for i := len(S) - 1; i > 0; i-- {
		if S[i-1] == 'L' && S[i] == 'L' {
			field[i] += 0
			left++
		}

		if S[i-1] == 'R' && S[i] == 'L' {
			field[i-1] += left/2 + left%2
			field[i] += left / 2
			left = 0
		}
	}

	for _, f := range field {
		fmt.Printf("%d ", f)
	}

	fmt.Println()

	// for i := 0; i < len(S); i++ {
	// 	field[i] = 1
	// }

	// for l := 0; l < len(S)-1; l++ {

	// 	if S[l] == "R" && S[l+1] == "R" {
	// 		field[l]--
	// 		field[l+1]++
	// 	}

	// 	if S[l] == "R" && S[l+1] == "L" {
	// 		field[l]++
	// 		field[l+1]--
	// 	}

	// }

	// for r := len(S) - 1; r >= 1; r-- {

	// 	if S[r] == "L" && S[r-1] == "L" {
	// 		field[r]--
	// 		field[r-1]++
	// 	}

	// 	if S[r-1] == "R" && S[r] == "L" {
	// 		field[r-1]--
	// 		field[r]++
	// 	}
	// }

	// fmt.Println(field)

	// for i := 0; i < len(S)-1; i++ {
	// 	if S[i] == "R" && S[i+1] == "L" {
	// 		tmp := field[i]
	// 		field[i] = field[i+1]
	// 		field[i+1] = tmp
	// 	}
	// }

	// fmt.Println(field)
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define int long long
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

double calcdist(double vi, double vf, double vm, double T){
    double dist;
    double vm2 = (T + vi + vf) / 2.0;
    if(vm2 > vm){
        dist = (vm + vi) * (vm - vi) / 2.0 + (vm + vf) * (vm - vf) / 2.0 + vm * (T - 2.0 * vm + vi + vf);
    }else{
        dist = (vm2 + vi) * (vm2 - vi) / 2.0 + (vm2 + vf) * (vm2 - vf) / 2.0;
    }
    return dist;
}

signed main(){

    int N;
    cin >> N;
    vector<int> t(N), v(N), T(N + 1);
    readvec(t);
    readvec(v);

    vector<Pii> v_max(N + 1);
    v_max[0] = Pii(0, 0);
    FOR(i, 1, N){
        v_max[i] = Pii(min(v[i - 1], v[i]), i);
    }
    v_max[N] = Pii(0, N);
    SORT(v_max);

    T[0] = 0;
    REP(i, N){
        T[i + 1] = T[i] + t[i];
    }

    #define INF 1000000000000000
    vector<int> v_max_f(N + 1, INF);
    REP(i, N + 1){
        int vtmp = v_max[i].first;
        int itmp = v_max[i].second;

        REP(j, N + 1){
            v_max_f[j] = min(v_max_f[j], vtmp + llabs(T[j] - T[itmp]));
        }
    }

    double ans = 0.0;
    REP(i, N){
        ans += calcdist((double)v_max_f[i], (double)v_max_f[i + 1], (double)v[i], (double)t[i]);
    }

    cout << setprecision(10) << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int n;
double dp[301][301][301];

double solve(int i, int j, int k) {
	if (dp[i][j][k] >= 0) return dp[i][j][k];
	if (i == 0 && j == 0 && k == 0) return 0;
	double ans = 0;
	if (i > 0) ans += solve(i - 1, j, k) * i;
	if (j > 0) ans += solve(i + 1, j - 1, k) * j;
	if (k > 0) ans += solve(i, j + 1, k - 1) * k;
	ans += n;
	ans *= 1.0 / (i + j + k);

	return dp[i][j][k] = ans;
}

int main() {
	cin >> n;
	int x = 0, y = 0, z = 0;
	for (int i = 0; i < n; ++i) {
		int a; cin >> a;
		if (a == 1) x++;
		else if (a == 2) y++;
		else z++;
	}
	memset(dp, -1, sizeof(dp));
	printf("%.10f\n", solve(x, y, z));

	return 0;
}

Measured memory_bytes: 213376
// After Contest

#include <bits/stdc++.h>
using namespace std;

int dp[101][4][2];

int main()
{
    string S;
    int K;
    cin >> S >> K;
    dp[0][0][0] = 1;
    for (int i = 0; i < S.length(); i++)
    {
        for (int j = 0; j <= K; j++)
        {
            for (int k = 0; k < 2; k++)
            {
                int digit = S[i] - '0';
                for (int d = 0; d < 10; d++)
                {
                    int ni = i + 1, nj = j, nk = k;
                    if (d != 0)
                    {
                        if (j >= K)
                            continue;
                        nj++;
                    }
                    if (k == 0)
                    {
                        if (d < digit)
                            nk = 1;
                        if (d > digit)
                            continue;
                    }
                    dp[ni][nj][nk] += dp[i][j][k];
                }
            }
        }
    }
    cout << (dp[S.length()][K][0] + dp[S.length()][K][1]) << endl;
}


Measured memory_bytes: 256
N = int(input())

ans = "No"
for i in range(N // 4 + 1):
    for j in range(N // 7 + 1):
        total = (4 * i) + (7 * j)
        if total == N:
            ans = "Yes"
            break
    else:
        continue
    break

print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void vprint(vector<ll> A){
    ll L = A.size();
    FOR(i, 0, L){
        if(i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
}

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

    // input
    ll A, B, C;
    cin >> A >> B >> C;

    ll space = A-B;
    ll rest = max(0LL, C-space);
    p(rest);    
    return 0;
}

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

typedef long long       ll;
const int MOD=1000000007;
const int MAX=2e5+9;

int n, k;
ll fact[MAX];

ll fastPow(ll a, ll b){
    if (!b) {
        return 1;
    }

    ll sq=fastPow(a, (b>>1LL));
    sq*=sq;

    if (b&1) {
        sq%=MOD;
        sq*=a;
    }

    return sq%MOD;
}

ll inv(ll a) {
    return fastPow(a, MOD-2);
}

ll C(ll n, ll k) {
    return fact[n]*inv(fact[k])%MOD*inv(fact[n-k])%MOD;
}

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

    cin >> n >> k;
    fact[0]=1;
    for (int i=1; i<=n; ++i) {
        fact[i]=fact[i-1]*i%MOD;
    }

    ll ans=0;
    for (int can=0; can<=min(n-1, k); ++can) {
        ans+=C(n, can)*C(n-can+(can-1), can)%MOD;
        ans%=MOD;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h> // {{{
// clang-format off
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define USE1(T) template <typename T> inline
#define USE2(T, U) template <typename T, typename U> inline
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)

template <typename T> using duo = std::pair<T, T>;
template <typename T> using vec = std::vector<T>;
using ll = long long;
using pii = duo<int>;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;std::cin>>x;return x;}
USE1(T=int)vec<T>in(int n){vec<T>v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE1(T)vec<std::pair<T,int>>zipi(const vec<T>&x,int s=0){int N=x.size();vec<std::pair<T,int>>v;v.reserve(N);rep(i,N)v.pb(x[i],s+i);return v;}
USE1(T)vec<T>ndvec(T v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts)void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
USE1(T=int)T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
USE1(T=int)void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(10);
    std::cerr.precision(10);
  }
} iosetup; //}}}
using namespace std;
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

signed main() {
  auto cards = in<string>(3);
  int turn = 0;
  while (cards[turn] != "") {
    int nxt = cards[turn][0] - 'a';
    cards[turn] = cards[turn].substr(1);
    turn = nxt;
  }
  pr("ABC"[turn]);
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3", "unroll-loops")
#include <bits/stdc++.h>

using namespace std;
set<int> s;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n, ans = 1;
	cin >> n;
	s.insert(n);
	while (true) {
		if (n % 2 == 0)
			n >>= 1;
		else
			n = 3 * n + 1;
		ans++;
		if(*s.lower_bound(n) == n) {
			cout << ans << '\n';
			return 0;
		}
		s.insert(n);
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
constexpr double pi=3.14159265358979;

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

bool visited[10005],visited2[10005];
int p,sum;
vector<int>c,d;
vector<vector<int>>g;

void dfs(int v){
    visited[v]=true;
    d[v]=c[p];
    ++p;
    for(auto x:g[v]){
      if(!visited[x]){
        dfs(x);
      }
    }
}

void dfs2(int v){
  visited2[v]=true;
  for(auto x:g[v]){
    if(!visited2[x]){
      sum+=min(d[v],d[x]);
      dfs2(x);
    }
  }
}
void solve(){
  int n;
  cin>>n;
  vector<int>cnt(n);
  c.resize(n);d.resize(n);
  g.resize(n);
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    --a;--b;
    g[a].pb(b);
    g[b].pb(a);
    cnt[a]++;
    cnt[b]++;
  }
  rep(i,n)cin>>c[i];
  sort(c.rbegin(),c.rend());
  int ans=0,root;
  rep(i,n){
    if(chmax(ans,cnt[i]))root=i;
  }
  d[root]=c.front();
  dfs(root);
  dfs2(root);
  cout<<sum<<"\n";
  rep(i,n){
    if(i)cout<<" ";
    cout<<d[i];
  }
  cout<<"\n";
  return;
}

signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n;
	cin >> n;
	
	vector<ll> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	
	vector<ll> fsum(n + 1, 0), bsum(n + 1, 0);
	for(int i = 0; i < n; ++i) {
		fsum[i + 1] = fsum[i] + a[i];
		bsum[i + 1] = bsum[i] + a[n - i - 1];
	}
	
	
	ll ans = 1LL << 61;
	for(int i = 0; i < n + 1; ++i) {
		if( i == 0 || i == n ) continue;
		
		ans = min(ans, abs(fsum[i] - bsum[n - i]));
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 8016
/*
...........__________    							 |										    ___  __
.............|       |     						     |											 |   /
.............|       |     						     |									  		 |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
.........  __|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int 				long long
#define ull 				unsigned long long int
#define ld 					long double
#define vi 					vector<int>
#define vii 				vector<pair<int,int>>
#define vvi 				vector<vector<int>>
#define pf 					push_front
#define popb 				pop_back
#define pb 					push_back
#define eb 					emplace_back
#define pii 				pair<int,int>
#define prec(x) 			fixed<<setprecision(15)<<x
#define all(x) 				x.begin(),x.end()
#define rall(x) 			x.rbegin(),x.rend()
#define mset(a,b) 			memset(a,b,sizeof(a))
#define mcpy(a,b) 			memcpy(a,b,sizeof(a))
#define fo0(i,n) 			for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) 			for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) 			for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)			for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)			for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define inf 1e18
const int mod=1e9+7;
const int N=4e5+10;
bool palindrome(string s){
	string t=s;
	reverse(all(t));
	if(s==t)
		return true;
	return false;
}
void raushan_kumar(){
	string s;cin>>s;
	int n=s.length();
	string t1=s.substr(0,n/2);
	string t2=s.substr(n/2+1,n/2);
	if(palindrome(s) and palindrome(t1) and palindrome(t2)){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
}

int32_t main()
{
	fast;int t=1;
	//cin>>t;
	while(t--){
		raushan_kumar();
	}

}

Measured memory_bytes: 256