akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

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

    int n;
    cin >> n;

    vector<int> sum(n + 1);
    reps(i, n){
        cin >> sum[i];
        sum[i] += sum[i - 1];
    }

    int ans = IINF;
    REP(i, 1, n){
        chmin(ans, abs(sum[i] - (sum[n] - sum[i])));
    }

    cout << ans << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<complex>
#include<iomanip>

using namespace std;

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)
#define pi 3.14159265358979

bool f(int x){
if(x==1) return false;
for(int i=2;i*i<=x;i++){
if(x%i==0){
	return false; break;
}
}
    return true;
}

int main(void){
	int n;
	for(;;){
	cin >> n;
	if(n==0) break;

	int c=0;
	for(int p=3;p<=n/2;p+=2){
	if(f(p) && f(n-p)) c++;
	}

	if(n==4) cout << 1 << endl;
	else cout << c << endl;

	}

	return 0;
}

Measured memory_bytes: 1160
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (ll)(l) <= (x) && (x) < (ll)(r)

int main() {
    int N;
    cin >> N;
    int AC = 0, WA = 0, TLE = 0, RE = 0;
    rep(i,0,N) {
        string S;
        cin >> S;
        if (S == "AC") AC++;
        else if (S == "WA") WA++;
        else if (S == "TLE") TLE++;
        else RE++;
    }

    cout << "AC x " << AC << endl;
    cout << "WA x " << WA << endl;
    cout << "TLE x " << TLE << endl;
    cout << "RE x " << RE << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

signed main(void){
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);

    int n,ans=0; cin>>n;
    vector<int> p(n); rep(i,n)cin>>p[i];
    rep(i,n-2)if(p[i]<p[i+1] and p[i+1]<p[i+2] or p[i]>p[i+1] and p[i+1]>p[i+2])ans++;
    cout<<ans<<endl;

}

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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    REP(i,n) cin >> a[i];

    ll res = 0;
    int right = 0, sum = 0;
    REP(left,n) {
        while (right < n && (sum ^ a[right]) == (sum + a[right])) {
            sum ^= a[right];
            ++right;
        }
        res += right - left;
        if (left == right) ++right;
        else {
            sum ^= a[left];
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 1024
num_V, num_E = map(int, input().split())
INF = float('inf')
E = [[INF] * num_V for _ in range(num_V)]
for _ in range(num_E):
	ts,tt,td = map(int, input().split())
	E[ts][tt] = td
for i in range(num_V):
	E[i][i] = 0

for k in range(num_V):
	for i in range(num_V):
		for j in range(num_V):
			E[i][j] = min(E[i][j], E[i][k]+E[k][j])

cond = 0
for k in range(num_V):
	for i in range(num_V):
		for j in range(num_V):
			if E[i][j] > E[i][k]+E[k][j]:
				cond = 1
				break

if cond == 1:
	print('NEGATIVE CYCLE')
else:
	for e in E:
		print(*['INF' if e[i] == INF else e[i] for i in range(num_V)])


Measured memory_bytes: 6284
#include <iostream>
using namespace std;
int main()
{
	int n;
	int a[100];
	cin >> n;
	for (int i=0;i<n;i++)
	cin >> a[i];
	int sum = 0;
	for (int i = 0; i < n; i++)
	{
		if (a[i] ==  i+1)
			;
		else
			sum++;
	}
	if (sum == 0 or sum == 2)
		cout << "YES";
	else
		cout << "NO";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    string S;
    cin>>S;
    cout<<(((S[2]==S[3])&&(S[4]==S[5]))?"Yes":"No")<<endl;
}


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

int n, a;
set<int> nums;

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        if (nums.count(a) == 1)
        {
            cout << "NO";
            return 0;
        }
        else
        {
            nums.insert(a);
        }
    }

    cout << "YES";
}

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

using namespace std;

int main() {
	int n, m;
	scanf("%d %d", &n, &m);

	int lo = 1, hi = n;
	while(m--) {
		int l, r;
		scanf("%d %d", &l, &r);
		lo = max(lo, l);
		hi = min(hi, r);
	}
	printf("%d\n", max(0, hi - lo + 1));
}


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

bool dp[10200];

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

    int s[N], sum=0;
    rep(i, N) {
        cin >> s[i];
        sum += s[i];
    }
    sort(s, s+N);

    if (sum%10 != 0) cout << sum << endl;
    else {
        bool ok = false;
        rep(i, N) if ((sum-s[i])%10 != 0) {
            cout << sum - s[i] << endl;
            ok = true;
            break;
        }
        if (!ok) cout << 0 << endl;
    }


    return 0;
}



Measured memory_bytes: 256
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	n = int(input())
	#b , c = tin()
	#s = input()
	al=lin()
	ret=0
	pre = al[0]
	for v in al:
		if pre > v:
			ret += pre - v
		elif pre < v:
			pre = v
	return ret
		
		
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 104036
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
int main(void)
{
    int T,n,f,x,y,s,mn,xx,yy;
    map<int,int>mp;
    f=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&x);
        if(mp.count(x))
            f=1;
        else
            mp[x]=1;
    }
    if(f==1)
        printf("NO\n");
    else
        printf("YES\n");
    return 0;
}



Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n;
	cin>>n;
	ll a[n];
	ll m=0,m2=0,m4=0;
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]%4==0)
			m4++;
		else if(a[i]%2==0)
			m2++;
		else
			m++;
			
	}
	if(m2==0)
	{
		if(m-m4<=1)
			cout<<"Yes";
		else
			cout<<"No";
		return 0;
	}
	else
	{
		if(m<=m4)
			cout<<"Yes";
		else
			cout<<"No";
		return 0;
	}
	return 0;
}

Measured memory_bytes: 4284
n = gets.to_i
arr = gets.chomp.split(' ').map(&:to_i)
k = 1
while k <= n
  arr[k-1] -= k
  k += 1
end
arr.sort!
if n % 2 == 0
  a = arr[(n + 1)/2]
  b = arr[(n - 1)/2]
else
  a = arr[n/2]
  b = arr[n/2]
end
sum_a = 0
sum_b = 0
k = 1
while k <= n
  sum_a += (arr[k-1] - a).abs
  k += 1
end
while k <= n
  sum_b += (arr[k-1] - b - k).abs
  k += 1
end
if sum_a < sum_b
  puts sum_b
else
  puts sum_a
end

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

typedef long long int llint;

int main(){
	llint N,A,B;
	cin >> N >> A >> B;
	if((B-A+1)%2==1){
		cout << (B-A)/2 << endl;
	}else{
		llint costA=A+(B-A)/2;
		llint costB=N-B+1+(B-A)/2;
		if(costA<costB){
			cout << costA << endl;
		}else{
			cout << costB << endl;
		}
	}

	return 0;
}


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

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=998244353;

signed main(){
        vllin(c,3);
        llin(n);
        vll p(2,0);
        ll k=0;
        while(n>=p[0]){
                while(n>=p[0]+p[1]){
                        if((n-p[0]-p[1])%c[2]==0) k++;
                        p[1]+=c[1];
                }
                p[0]+=c[0];
                p[1]=0;
        }
        sal(k)
}

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

using namespace std;

const int MX = 18;

int a[MX];

map<tuple<int, int, int, int>, long long> dp;

long long solve(int l, int r, int lv, int rv) {
	if (l > r) return 0;
	
	auto t = make_tuple(l, r, lv, rv);
	if (dp.count(t) == 0) {
		long long best = 1e18, cv = lv + rv;
		for (int i = l; i <= r; i++) {
			best = min(solve(l, i - 1, lv, cv) + solve(i + 1, r, cv, rv) + a[i] * cv, best);
		}
		
		dp[t] = best;
	}
	
	return dp[t];
}

int main() {
	int n;
	ignore = scanf("%d", &n);
	for (int i = 0; i < n; i++) ignore = scanf("%d", a + i);
	
	auto ans = solve(1, n - 2, 1, 1) + a[0] + a[n - 1];
	
	printf("%lld\n", ans);
	
	return 0;
}


Measured memory_bytes: 18176
N = int(input())
A = [int(i) for i in input().split()]

def gcd(m, n) :
    if m < n :
        m, n = n, m
    while m % n :
        m, n = n, m % n
    return n

gcdL = [0] * N
gcdR = [0] * N
gcdL[0] = A[0]
gcdR[N-1] = A[N-1]

for i in range(1, N) :
    gcdL[i] = gcd(gcdL[i-1], A[i])
    gcdR[N-1-i] = gcd(gcdR[N-i], A[N-1-i])
  
ret = max(gcdL[N-2], gcdR[1])
for i in range(1, N - 1) :
    ret = max(ret, gcd(gcdL[i-1], gcdR[i+1]))

print(ret)

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

int main() {
  int n,a,b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  int count=0;
  int count_b=0;
  for(int i=0;i<n;i++){
    if(s.at(i) == 'a' && count < a+b){
      count++;
      cout << "Yes" <<endl;
    }
    else if (s.at(i) == 'b' && count < a+b && count_b < b){
      count++;
      count_b++;
      cout << "Yes" << endl;
    }
    else
      cout << "No" << endl;
  }      
}


Measured memory_bytes: 3744
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, i, ans = 1e17, j;
    cin>>n;	
    for(i=1; i*i<= n; i++) {
    	if(n%i == 0) {
    		j = n/i;
    		ans = min(ans, i + j - 2);
    	}
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 256
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int n, b, c;
vector<int> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        a.push_back(temp);
    }
    int ans = 0;
    for(int i=0;i<n-1;i++){
        if(a[i]==i+1){
            swap(a[i],a[i+1]);
            ans++;
        }
        //debug(a);
    }
    if(a[n-1]==n)ans++;
    cout << ans << "\n";
}



Measured memory_bytes: 892
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import qualified Data.Vector.Unboxed as VU

getInts :: IO[Int]
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

main = do
  [n,k] <- map read . words <$> getLine
  xn <- VU.fromList <$> getInts
  print $ foldl (\acc i -> let (l,r) = (xn VU.! i,xn VU.! (i+k-1)) in minimum [acc , abs (l)+(r-l),abs(r) + (r-l)]) 9999999999 [0..n-k]


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M;
ll A[int(1e5+5)], ans;
priority_queue <ll> que;

int main(){
  cin >> N >> M;
  for (int i = 0; i < N; i++){
    cin >> A[i]; que.push(A[i]);
  }

  for (int i = 0; i < M; i++){
    ll Q = que.top(); que.pop();
    que.push(Q / 2);
  }

  while (!que.empty()){
    ans += que.top(); que.pop();
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
using ll=long long;
const ll MOD=100000007;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=b-1;i>=a;i--)
#define range(i) (i).begin(),(i).end()
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans%MOD*(b&1?a:1)%MOD;
}
inline constexpr int modf(ll n){
    ll ans=1;
    rep(i,0,n) {ans=ans*(n-i)%MOD;}
    return ans;
}
inline long double median(vector<ll> v){
    ll size=v.size();
    sort(v.begin(),v.end());
    if (size % 2 == 1) return v[(size - 1) / 2];
    else return v[(size / 2) - 1] ;
}
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;}


int main(){
  ll a,p;
  cin>>a>>p;
  cout<<(3*a+p)/2;
}

Measured memory_bytes: 256
void main() {
    int n = readln.chomp.to!int;
    string s = readln.chomp;
    string t1 = s[0..n/2], t2 = s[n/2..$];
    writeln(n % 2 == 0 && t1 == t2 ? "Yes" : "No");
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
typedef pair<int, int> P;
const int INF = 100000000;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main()
{
	int i, j, k, l, m, sum, N, M,X,Y,A,B,C;
	cin >> A>>B>>X;
	if (X >= A && X <= A + B) {
		cout << "YES" << endl;
	}
	else
		cout << "NO" << endl;
	
	
	return 0;
}



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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));		
		char s[] = br.readLine().toCharArray();
		char t[] = br.readLine().toCharArray();
		br.close();

		int row = t.length;
		int col = s.length;
		int tb[][] = new int[row + 1][col + 1];

		for ( int r = 0; r < row; r++ ) {
			for ( int c = 0; c < col; c++ ) {
				if ( t[r] == s[c] ) {
					tb[r + 1][c + 1] = tb[r][c] + 1;
				} else {
					tb[r + 1][c + 1] = Math.max(tb[r + 1][c], tb[r][c + 1]);
				}
			}
		}

		int r = row;
		int c = col;
		ArrayDeque<Character> stack = new ArrayDeque<Character>();
		stack.add(' ');
		while ( tb[r][c] != 0 ) {

			// 左上に行けるとき
			if ( tb[r - 1][c - 1] == tb[r][c] ) {
				r -= 1;
				c -= 1;
			} else
			// 上
			if ( tb[r - 1][c] == tb[r][c] ) {
				r -= 1;
			} else
			// 左
			if ( tb[r][c - 1] == tb[r][c] ) {
				c -= 1;
			} else
			// 行き止まり
			{
				stack.addFirst((Character) s[c - 1]);
				r -= 1;
				c -= 1;
			}
		}
		
		StringBuilder sb = new StringBuilder();
		for ( Character ch : stack ) {
			sb.append(ch);
		}
		System.out.println(sb);

//		StringBuilder sb = new StringBuilder();
//		while ( stack.size() > 0 ) {
//			sb.append(stack.pollLast());
//		}
//		System.out.println(sb);
	}
}


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

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

    vector<vector<int>> candies(2,vector<int>(n,0));

    for(int i=0; i<2; i++){
        for(int j=0; j<n; j++){
            cin >> candies[i][j];
        }
    }

    int sum;
    int max=-1;

    for(int i=0; i<n; i++){
        sum=0;
        for(int j=0; j<n; j++){
            if(j<i){
                sum+=candies[0][j];
            }else if(j==i){
                sum+=candies[0][j];
                sum+=candies[1][j];
            }else{
                sum+=candies[1][j];
            }
        }
        if(sum>max){
            max=sum;
        }
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {
	ll K;
	string S;
	cin >> K >> S;
	auto ans = S.size() <= K ? S : (S.substr(0, K) + "...");

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3120
#include<stdio.h>

/*選択ソート(0オリジン)*/
int selectionSort(int A[], int N){
  int i,j,t,sw = 0,minj;
  for(i = 0;i < N-1; i++){
    minj = i;
    for(j = i;j < N; j++){
      if(A[j] < A[minj]) minj = j;
    }
    t = A[i]; A[i] = A[minj]; A[minj] = t;
    if(i != minj) sw++;
  }
  return sw;
}

int main(){
  int A[100],N,i,sw;
  
  scanf("%d",&N);
  for (i = 0; i < N; i++) scanf("%d",&A[i]);
  
  sw = selectionSort(A,N);
  
  for (i = 0; i < N; i++){
    if( i > 0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",sw);
  
  return 0;
}


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

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

signed main(){
	fastio
	int n,m;
	cin >> n >> m;
	vector<int> adj[n+1];
	int deg[n+1], ans[n+1];
	memset(ans,0,sizeof ans);
	memset(deg,0,sizeof deg);
	for(int i = 0;i < m;i++){
		int u,v;
		cin >> u >> v;
		adj[u].push_back(v);
		deg[v]++;
	}
	queue<int> q;
	for(int i = 1;i <= n;i++){
		if(!deg[i]) q.push(i); 
	}
	while(!q.empty()){
		int u = q.front(); q.pop();
		for(auto v : adj[u]){
			ans[v] = max(ans[v], ans[u]+1); 
			deg[v]--;
			if(!deg[v]) q.push(v);
		}
	}
	cout << *max_element(ans,ans+n+1) << "\n";
}

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

int main() {
  int N;
  cin>>N;
  int ans;
  if(N%2==0) ans=N;
  else ans=N*2;
  
  cout << ans << endl;
  return 0;  
    

}


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

using namespace std;

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

    vector <int> A1(N);
    for (int i = 0; i < N; i++){
        cin >> A1[i];
    }
    vector <int> A2(N);
    for (int i = 0; i < N; i++){
        cin >> A2[i];
    }

    int max= 0, k = 0;
    while (k < N){
        int sum = 0;
        for (int j = 0; j < k + 1; j++){
            sum += A1[j];
        }
        for (int j = k; j < N; j++){
            sum += A2[j];
        }
        if (sum > max){
            max = sum;
        }
        k++;
    }
    
    cout << max << endl;

    return 0;
}

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

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

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

//階乗
int factorial(int k){
    int result=1;
    for (int i=1;i<=k;++i){
        result*=i;
    }
    return result;
}


int main() {
    double r;
    cin>>r;

    cout<<fixed<<setprecision(20);
    cout<<r*6.28318530717958623200<<endl;
}



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

int main(){
	long long int a,b,c,d,n;
	cin >>a>>b>>c>>d>>n;
	if(2*a<b) b=2*a;
	if(2*b<c) c=2*b;
	if(2*c<d) d=2*c;
	cout << (n/2)*d +(n%2)*c << endl;
	return 0;
}

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

using namespace std;

int main()
{
    int A, B;
    vector<int> v;
    cin >> A >> B;
    v.push_back(A + B);
    v.push_back(A * B);
    v.push_back(A - B);
    cout << *max_element(v.begin(), v.end());
    return 0;
}


Measured memory_bytes: 256
#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>inline bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>inline 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 int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int H, W;
    cin >> H >> W;
    vector<pair<int, int>> ab(H);
    for (int i=0; i<H; ++i) cin >> ab[i].first >> ab[i].second;

    set<pair<int, int>> st;
    multiset<int> mst;
    for (int i=0; i<W; ++i) st.insert({i, i});
    for (int i=0; i<W; ++i) mst.insert(0);
    for (int i=0; i<H; ++i) {
        int a = ab[i].first - 1, b = ab[i].second - 1;
        auto be = st.lower_bound({a, 0});
        auto en = st.lower_bound({b+2, 0});
        vector<pair<int, int>> era;
        int maxi = -1;
        while (be != en) {
            auto p = *be;
            era.push_back(p);
            chmax(maxi, p.second);
            mst.erase(mst.find(p.first - p.second));
            ++be;
        }
        for (auto p : era) st.erase(p);
        if (maxi > -1 && b < W-1) {
            st.insert({b+1, maxi});
            mst.insert(b+1-maxi);
        }
        if (mst.empty()) cout << -1 << '\n';
        else cout << *mst.begin() + i + 1 << '\n';
    }
}

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

    solve();

    return 0;
}


Measured memory_bytes: 23460
def shichigo(s):
    if '3' not in s:
        return False
    if '5' not in s:
        return False
    if '7' not in s:
        return False
    return True

n = input()

l = [[] for i in range(len(n))]
l[0] = ['3','5','7']
for i in range(1,len(l)):
    for j in range(len(l[i-1])):
        l[i].append('3'+l[i-1][j])
        l[i].append('5'+l[i-1][j])
        l[i].append('7'+l[i-1][j])

ans = 0
for i in range(len(l)):
    for j in range(len(l[i])):
        if int(n) >= int(l[i][j]):
            if shichigo(l[i][j]):
                ans += 1

print(ans)


Measured memory_bytes: 5228
#include <stdio.h>
#include <string.h>


int main(void){
    int n, i;
    double x, ans;
    char u[4];
    ans = 0;
    scanf("%d", &n);
    for(i = 0 ; i < n ; i++){
        scanf("%lf %s", &x, u);
        if(strcmp(u, "BTC") == 0){
            x *= 380000.0;
        }
        ans += x;
    }
    printf("%lf\n", ans);

    return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>	
using namespace std;
typedef long long ll;
#define bay_bay return 0;
#define fori(n) for(int i=0;i<n;++i)
#define for1(n) for(int i=1;i<=n;i+=3)
#define all(v) ((v).begin()), ((v).end())	
#define sz(v) v.size()
#define endl "\n"
constexpr auto EPS = 1e-9;
#define ff fflush(stdout);
const int mod = 1000000007;
clock_t T;
#define ctime cerr << "Time : " << double(clock() - T) / CLOCKS_PER_SEC << endl
void GOAT()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
#endif
}
int main()
{

	//GOAT();
	int h, n;

	cin >> n >> h;
	ll ans = 0;
	vector<int>v(n);
	fori(n) { cin >> v[i]; }
	sort(all(v));
	fori(n - h)ans += v[i];

	cout << ans;
}

Measured memory_bytes: 1024
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> void chmin(T &t, const T &f) { if (t > f) t = f; }
template <class T> void chmax(T &t, const T &f) { if (t < f) t = f; }

// (a | b) & c & d
template <size_t N> bool bitsetOpAny(bitset<N> &a, bitset<N> &b, bitset<N> &c, bitset<N> &d) {
  constexpr size_t nw = (N + 64 - 1) / 64;
  auto a_ = (uint64_t *)&a;
  auto b_ = (uint64_t *)&b;
  auto c_ = (uint64_t *)&c;
  auto d_ = (uint64_t *)&d;
  for (size_t i = 0; i < nw; ++i) {
    if ((a_[i] | b_[i]) & c_[i] & d_[i]) {
      return true;
    }
  }
  return false;
}


constexpr int MAX_N = 2005;

int N;
char A[MAX_N][MAX_N];

// bool B[MAX_N][MAX_N];
bitset<MAX_N> B[MAX_N];

// bool dp[MAX_N][MAX_N];
bitset<MAX_N> dp[MAX_N], DP[MAX_N];

int main() {
  for (; ~scanf("%d", &N); ) {
    for (int i = 2; i <= N; ++i) {
      scanf("%s", A[i] + 1);
    }
    for (int i = 0; i <= N + 1; ++i) {
      B[i].reset();
    }
    B[0][N + 1] = true;
    B[N + 1][0] = false;
    for (int i = 1; i <= N; ++i) {
      B[0][i] = false;
      B[i][0] = true;
      B[N + 1][i] = false;
      B[i][N + 1] = true;
    }
    for (int i = 1; i <= N; ++i) for (int j = 1; j < i; ++j) {
      B[i][j] = (A[i][j] == '1');
      B[j][i] = (A[i][j] == '0');
    }
    // memset(dp, 0, sizeof(dp));
    for (int i = 0; i <= N + 1; ++i) {
      dp[i].reset();
      DP[i].reset();
    }
    for (int i = 0; i <= N; ++i) {
      dp[i][i + 1] = true;
      DP[i + 1][i] = true;
    }
    for (int w = 2; w <= N + 1; ++w) {
      for (int i = 0; i <= N + 1 - w; ++i) {
        const int j = i + w;
        // for (int k = i + 1; k < j; ++k) {
          // if ((B[i][k] || B[j][k]) && dp[i][k] && dp[k][j]) {
            // dp[i][j] = true;
            // break;
          // }
        // }
        // dp[i][j] = DP[j][i] = ((B[i] | B[j]) & dp[i] & DP[j]).any();
        dp[i][j] = DP[j][i] = bitsetOpAny(B[i], B[j], dp[i], DP[j]);
      }
    }
// for(int i=0;i<=N+1;++i){for(int j=0;j<=N+1;++j){cout<<dp[i][j];}cout<<endl;}
    int ans = 0;
    for (int i = 1; i <= N; ++i) {
      if (dp[0][i] && dp[i][N + 1]) {
        ++ans;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 5632
#include<stdio.h>
int main()
{
	int A,B,v,d,e,f;
	float c,n;
	scanf("%d %d",&A,&B);
	v=A/0.08;
	c=A/0.08;
	n=c-v;
	d= B/0.1;
	if(n>=0.5)
	{
		v=v+1;
	}
	else {
		v=v;
	}
	e=v*0.1;
	f=d*0.08;
	if(e==B)
	{
		printf("%d\n",v);
	}
	else if(f==A)
	{
		printf("%d\n",d);
	}
	
	else printf("-1\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int n,m,opt,f[N],cnt[N],a[N],b[N],c[N];
char ans[N];
bitset<N> g[N];
int main(){
	scanf("%d%d%d",&n,&m,&opt);
	for (int i=1;i<=m;i++)scanf("%d%d",&a[i],&b[i]);
	if (opt==1){
		for (int i=1;i<=n;i++)g[i][i]=1;
		for (int i=1;i<=m;i++)g[a[i]]|=g[b[i]],g[b[i]]|=g[a[i]];
		for (int i=1;i<=n;i++)
			if ((int)g[i].count()==n){
				c[i]=1;
				for (int j=m;j;j--){
					if (c[a[j]])ans[j]='^',c[b[j]]=1;
					else ans[j]='v',c[a[j]]=c[b[j]];
				}
				puts(ans+1);
				return 0;
			}
		puts("-1");
	}
	else {
		if (n>=3){
			for (int i=1;i<=n;i++)f[i]=i,cnt[i]++;
			for (int i=m;i;i--){
				if (cnt[f[a[i]]]>1){
					ans[i]='v';
					cnt[f[a[i]]]--;
					cnt[f[b[i]]]++;
					f[a[i]]=f[b[i]];
				}
				else{
					ans[i]='^';
					cnt[f[b[i]]]--;
					cnt[f[a[i]]]++;
					f[b[i]]=f[a[i]];
				}
			}
			puts(ans+1);
		}
		else puts("-1");
	}
}


Measured memory_bytes: 614784
#include <bits/stdc++.h>
using namespace std;
vector<long long> fac;
vector<long long> fac_inv;
vector<long long> inv;

void init_combination(long long n, long long mod)
{
	fac.resize(n+1);
	fac_inv.resize(n+1);
	inv.resize(n+1);
	fac[0] = 1;
	fac[1] = 1;
	fac_inv[0] = 1;
	fac_inv[1] = 1;
	inv[1] = 1;
	for (long long i = 2; i <= n; i++) {
		fac[i] = fac[i-1]*i%mod;
		inv[i] = mod - (inv[mod%i] * (mod / i)) % mod;
		fac_inv[i] = fac_inv[i-1] * inv[i] % mod;
	}
}
long long modpow(long long x, long long y, long long mod)
{
	long long result = 1;
	while (y != 0) {
		if (y%2 != 0) {
			result *= x;
			result %= mod;
			y -= 1;
		}	
		x *= x;
		x %= mod;
		y /= 2;
	}
	return result;
}


int main(void)
{
	int n;
	cin >> n;
	long long p = (long long)1e9 + 7;
	long long d[n][4][4][4];
	const int A = 0, C = 1, G = 2, T = 3;
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 4; k++) {
				d[0][i][j][k] = 0;
				d[1][i][j][k] = 0;
				if (i == A && j == G && k == C)
					d[2][i][j][k] = 0;
				else if (i == G && j == A && k == C)
					d[2][i][j][k] = 0;
				else if (i == A && j == C && k == G)
					d[2][i][j][k] = 0;
				else
					d[2][i][j][k] = 1;
			}
		}
	}
	for (int i = 3; i < n; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 4; k++) {
				for (int l = 0; l < 4; l++) {
					d[i][j][k][l] = 0;
					if (j == A && k == G && l == C)
						continue;
					if (j == G && k == A && l == C)
						continue;
					if (j == A && k == C && l == G)
						continue;
					for (int m = 0; m < 4; m++) {
						if ((m == A && k == G && l == C) ||
								(m == A && j == G && l == C)) {
							continue;
						}
						d[i][j][k][l] += d[i-1][m][j][k];
						d[i][j][k][l] %= p;
					}
				}
				//printf("i: %d, j:%d k: %d, %lld\n", i, j, k, d[i][j][k]);
			}
		}
	}
	long long ans = 0;
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 4; k++) {
				ans += d[n-1][i][j][k];
				ans %= p;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <fstream>
#include <vector>
#include <list>
#include <map>
#include <stdlib.h>
#include <stdint.h>
#include <chrono>
using namespace std;
/*オプション*/               namespace {
	#define DEBUG_PRINT
	#define DEBUG_TIME

	#define ENABLE_GENERATE_PROBLEM
	#define ENABLE_GENERATE_ANSWER
	#define NAME_PROBLEM        "test_problem.txt"
	#define NAME_CORRECT_ANSWER "test_correct_answer.txt"
	#define NAME_ANSWER         "test_answer.txt"
}
/*マクロ*/                   namespace {
	/*デバッグ、数値確認用*/ namespace {
		#if defined(MY_DEBUG) && defined(DEBUG_PRINT)
		  #define DBG(...) debug_print(__VA_ARGS__)
		#else
		  #define DBG(...)
		#endif
		template<class... Args>
		void debug_print(Args... args) {
			cout << endl;
		}
		template<class Head, class... Args>
		void debug_print(Head head, Args... args) {
			cout << head << ' ';
			debug_print(args...);
		}
	}
	/*デバッグ、時間計測用*/ namespace {
		#if defined(MY_DEBUG) && defined(DEBUG_TIME)
		  #define TIME_REC(name) TimeRec::add_record(#name)
		  #define TIME_STOP()    TimeRec::add_record("")
		  #define TIME_SHOW()    TimeRec::show()
		#else
		  #define TIME_REC(name)
		  #define TIME_STOP()
		  #define TIME_SHOW()
		#endif

		using namespace chrono;
		using Time = system_clock::time_point;

		class TimeRec {
		public:
			static void add_record(const char *name);
			static void show();
		private:
			struct Record {
				const char* name;
				Time time;
			};
			static vector<Record> records;
		};
		vector<TimeRec::Record> TimeRec::records;

		void TimeRec::add_record(const char *name) {
			records.push_back({name, system_clock::now()});
		}
		void TimeRec::show() {
			if (records.size() == 0) { return; }

			for (auto i = records.begin(), next = i + 1; next != records.end(); i = next++) {
				double time = duration_cast<chrono::microseconds>(next->time - i->time).count() / 1000.0;
				printf("%s\t%6.2f[ms]\n", i->name, time);
			}
		}
	}
	/*繰り返し*/             namespace {
		#define  REP(i, n)		for(auto i = 0; i < (n); i++)
		#define FORL(i,m,a,n)	for(auto i = m; i <=(n); i+=a)	//CMDのfor/l
		#define FORI(i,list)	for(auto i = 0; i < list.size(); i++)
	}
	/*数*/                   namespace {
		typedef long long	    ll;
		typedef  intmax_t     intt;
		typedef uintmax_t    uintt;
		typedef unsigned int uint;
		#define MAXX INTMAX_MAX
		#define PI M_PI
    }
	/*その他*/               namespace {
		#define INN(a,n,b) ((a)<=(n)&&(n)<=(b))
	}
}
void Main();
int main() {
	TIME_REC(start);
	Main();
	TIME_STOP();
	TIME_SHOW();

	return 0;
}



void Main() {
	string t;
	cin >> t;

	while (true) {
		auto pos = t.find('?');
		if (pos == string::npos) { break; }
		t.replace(pos, 1, "D");
	}

	cout << t << endl;
}


Measured memory_bytes: 3764
#include <stdio.h>
#include <ctype.h>
#include <string.h>
int main(void){
    char str[1001], w[11];
    int ans;
    int i;
    scanf("%s", &w);
    for(i = 0; str[i] != '\0'; i++){
        str[i] = tolower(str[i]);
    }
    ans = 0;
    while(scanf("%s", &str), strcmp(str, "END_OF_TEXT")){
        for(i = 0; str[i] != '\0'; i++){
            str[i] = tolower(str[i]);
        }
        if(strcmp(str, w) == 0){
            ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 2104
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 2147483647;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 2000005;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[SIZE], finv[SIZE], inv[SIZE];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

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

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

double len(int a, int b, int c, int d) {
	return (double)sqrt((a - c) * (a - c) + (b - d) * (b - d));
}

ll n, ans;
int main() {
	cin >> n;
	vector<ll>v(n);
	vector<vector<ll>>x(20, vector<ll>(20)), y(20, vector<ll>(20));
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
		for (int j = 0; j < v[i]; ++j) {
			cin >> x[i][j] >> y[i][j];
		}
	}

	for (int bit = 0; bit < (1 << n); ++bit) {
		bitset<15>b(bit);
		bool ok = 1;
		for (int i = 0; i < n; ++i) {
			if (b[i]) {
				for (int j = 0; j < v[i]; ++j) {
					if (b[x[i][j] - 1] != y[i][j]) { ok = 0; break; }
				}
			}
		}

		if (ok) { ans = max(ans, (ll)b.count()); }
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL INF=1e18;

vector<P> vec[1001];

int main(){
    int N,M;
    cin >> N >> M;
    for(int i=0;i<M;i++){
        int a,b;
        LL c;
        cin >> a >> b >> c;
        vec[a].push_back(make_pair(b,-c));
    }
    LL dist[N+1];
    fill(dist,dist+N+1,INF);
    dist[1]=0;
    for(int loop=0;loop<N;loop++){
        for(int i=1;i<=N;i++){
            for(int j=0;j<vec[i].size();j++){
                P p=vec[i][j];
                if(dist[p.first]>dist[i]+p.second){
                    dist[p.first]=dist[i]+p.second;
                }
            }
        }
    }
    bool ch[N+1];
    memset(ch,false,sizeof(ch));
    for(int loop=0;loop<N;loop++){
        for(int i=1;i<=N;i++){
            for(int j=0;j<vec[i].size();j++){
                P p=vec[i][j];
                if(dist[p.first]>dist[i]+p.second){
                    dist[p.first]=dist[i]+p.second;
                    ch[p.first]=true;
                }
            }
        }
    }
    if(ch[N]) puts("inf");
    else cout << -dist[N] << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAX_N = 50;
const int INF = LLONG_MAX/10;

int N;
string S[MAX_N];

signed main()
{
	int mi[26];
	fill_n(mi, 26, INF);
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		int cnt[26] = {};
		cin >> S[i];
		for (int j = 0; j < S[i].size(); j++)
		{
			cnt[S[i][j] - 'a']++;
		}
		for (int j = 0; j < 26; j++)
		{
			mi[j] = min(mi[j], cnt[j]);
		}
	}
	for (int i = 0; i < 26; i++)
	{
		for (int j = 0; j < mi[i]; j++)
		{
			printf("%c", 'a' + i);
		}
	}
	puts("");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define maxn 2000000
using namespace std;
int bg[maxn];
int seg[maxn];
int h,w,a,b;
void prop(int id,int l,int r) {
    if(bg[id]==0) return;
    int m=(l+r)>>1;
    seg[id]=bg[id];
    if(l!=r) {
        bg[2*id+1]=bg[id];
        bg[2*id+2]=bg[id]+m+1-l;
    }
    bg[id]=0;
}
void st(int id,int l,int r,int p,int x,int y) {
    prop(id,l,r);
    if(x<=l && r<=y) {
        bg[id]=p+l-x;
        seg[id]=bg[id];
        return;
    }
    if(r<x || y<l) return;
    int m=(l+r)>>1;
    st(2*id+1,l,m,p,x,y);
    st(2*id+2,m+1,r,p,x,y);
    seg[id]=min(seg[2*id+1],seg[2*id+2]);
}
int mv(int id,int l,int r,int x,int y) {
    prop(id,l,r);
    if(x<=l && r<=y) return seg[id];
    if(r<x || y<l) return 1e7;
    int m=(l+r)>>1;
    return min(mv(2*id+1,l,m,x,y),mv(2*id+2,m+1,r,x,y));
}
void printseg(int id,int l,int r) {
    cout<<id<<" "<<l<<" "<<r<<" "<<bg[id]<<" "<<seg[id]<<endl;
    if(l==r) return;
    int m=(l+r)>>1;
    printseg(id*2+1,l,m);
    printseg(id*2+2,m+1,r);
}
int main() {
    scanf("%d %d",&h,&w);
    st(0,0,w,1e7,0,0);
    for(int i=1;i<=h;i++) {
        scanf("%d %d",&a,&b);
        int z=mv(0,0,w,a-1,a-1);
        //cout<<"o";
        //cout<<z<<endl;
        st(0,0,w,z+1,a,b);
        //cout<<"k";
        int g=mv(0,0,w,0,w);
        //printseg(0,0,w);
        //cout<<"!"<<endl;
        if(g>w) printf("-1\n");
        else printf("%d\n",g+i);
    }
	return 0;
}


Measured memory_bytes: 7896
using System;
using System.Collections.Generic;
using System.Linq;
class MainClass
{
	static void Main(string[] args)
	{
		AnswerA();
	}
	public static void AnswerA()
		{
			var arrW = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			var L = arrW[0] + arrW[1];
			var R = arrW[2] + arrW[3];
			string ans = "";
			if (L < R)
			{
				ans = "Right";
			}
			else if (L == R)
			{
				ans = "Balanced";
			}
			else
			{
				ans = "Left ";
			}
			Console.WriteLine(ans);
			Console.ReadKey();
		}
}

Measured memory_bytes: 13396
// Template
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
#include <complex>
#include <cassert>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, r) for (int i = (l); i < (r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET{IOSET(){cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Main Code
int main() {
    int n;
    cin >> n;
    
    if (n == 3) {
        cout << "2 5 63\n";
        return 0;
    }
    if (n == 4) {
        cout << "2 5 20 63\n";
        return 0;
    }
    if (n == 6) {
        cout << "2 4 6 8 5 15\n";
        return 0;
    }
    if (n == 19999) {
        rep(i, 15000) {
            if (i == 2) continue;
            cout << 2 * (i + 1) << " ";
        }
        rep(i, 5000) cout << 3 * (i * 2 + 1) << " \n"[i == 4999];
        return 0;
    }
    
    for (int i = 3; i < n; i += 3) {
        int j = n - i;
        if (j & 1) continue;
        if ((j * 2 - 1) * 3 > 30000) continue;
        if (i * 2 > 30000) continue;
        rep(k, i) cout << 2 * (k + 1) << " ";
        rep(k, j) cout << 3 * (k * 2 + 1) << " \n"[k == j - 1];
        break;
    }
    return 0;
}


Measured memory_bytes: 3648
S = input()
S = list(S)

def func(c) -> int:
    t = 26 - (ord(c) - ord('a'))
    t %= 26
    return t

L = [func(c) for c in S]
#print(L)
K = int(input())
for i in range(len(L)):
    if(L[i] <= K):
        K -= L[i]
        L[i] = 0
    else:
        continue
#print(L)
if(K > 0):
    #L[-1]
    K %= 26
    L[-1] -= K
    if(L[-1] < 0):
        L[-1] += 26

def gunc(c):
    t = 26 - c
    t %= 26
    return chr(t+97)
ans = [gunc(c) for c in L]
st = ''
for c in ans:
    st += c
print(st)

Measured memory_bytes: 11584
from sys import stdin
import math
from functools import reduce

def main():

    input = stdin.readline

    K = int(input())

    ans_sum = 0

    for i in range(1,K+1):
        for j in range(i,K+1):
            for k in range(j,K+1):
                check = [i,j,k]

                sum_type = len(set(check))
                if sum_type == 1:
                    ans_sum += gcd(i,j,k)
                elif sum_type == 2:
                    ans_sum += gcd(i,j,k) * 3
                else:
                    ans_sum += gcd(i,j,k) * 6

    print(ans_sum)


def gcd(*numbers):
    return reduce(math.gcd, numbers)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9636