akhauriyash/Code-Regression huggingface dataset:
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

int gcd(int a, int b) {
  return (b ? gcd(b, a % b) : a);
}

const int maxn = (int) 1e5 + 5;
int n, m;
string s, t;
char tmp[maxn];

int read() {
  if (scanf("%d%d", &n, &m) < 1) {
    return false;
  }
  scanf("%s", tmp);
  s = tmp;
  scanf("%s", tmp);
  t = tmp;
  return true;
}

void solve() {
  long long k = (long long) n * m / gcd(n, m);
  long long di = k / n, dj = k / m;
  long long pi = 0, pj = 0;
  for (int i = 0, j = 0; i < n; i++, pi += di) {
    while (j < m && pj < pi) {
      j++;
      pj += dj;
    }
    if (j < m && pi == pj && s[i] != t[j]) {
      printf("-1\n");
      return;
    }
  }
  printf("%lld\n", k);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define ll long long
#define int ll
#define eps 1e-7
#define all(x) ((x).begin()),((x).end())
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
typedef pair <int, int> pii;

vector <int> arr;
int n, k;
vector <int> divisor;

bool chk(int x)
{
    int r = 0;
    vector <int> t;
    for (auto it:arr)
    {
        t.push_back(it%x);
        r += (it%x);
    }
    sort(all(t));
    int ss = arr.size();
    int u = r/x;
    int rr = 0;
    for (int i = 0; i<ss-u; i++)
    {
        rr += t[i];
    }/*
    if (rr <= k)
        printf("With %lld operations, %lld is achievable\n",rr,x);*/
    return rr <= k;
}


int32_t main()
{
    usecppio
    cin >> n >> k;
    int sum = 0;
    for (int i = 0; i<n; i++)
    {
        int x;
        cin >> x;
        arr.push_back(x);
        sum += x;
    }
    for (int i = 1; i<=(int)(sqrt(sum)); i++)
    {
        if (sum%i==0)
        {
            divisor.push_back(i);
            divisor.push_back(sum/i);
        }
    }
    int ans = 1;
    for (auto it:divisor)
    {
        if (chk(it))
            ans = max(ans, it);
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,k;
string str;
int main(){
	cin >>n>>k>>str;
	vector<int>vec;
	for(int i=0;i<n;){
		char ch = str[i]; int j = i;
		while(i < n && ch == str[i]) i++;
		vec.pb(i-j);
	}
	int cur = n-vec.size();
	cout << min(n-1,cur+2*k) << endl;
}

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

using namespace std;

int main()
{
    string s;
    int a=0,p=0;
    cin>>s;
    for(int i=0;i<3;i++)
    {
        if(s[i]=='A')
            a++;
        if(s[i]=='B')
            p++;
    }
    if(a>=1&&p>=1)
        cout<<"Yes";
    else
        cout<<"No";
    cout<<"\n";
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<set>
#include<stack>
#include<iomanip>
#include<algorithm>
#include<unordered_map>
#include <numeric>
#include<string_view>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(i) i.begin(),i.end()
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<T>>;
template<typename T =ll,typename U =ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e18;
template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

void a(){
    string S; cin >>S;
    if(S.back()=='s'){
        S.push_back('e');
    }
    S.push_back('s');
    cout << S << endl;
        
}

void b(){

}

void c(){

};


void d(){

}

void e(){

}

void f(){
    
}

int main(void){
    a();
    return 0;
 }


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <string>

using namespace std;

int main() {
    int A, B, C, X;
    int count = 0; 
    cin >> A >> B >> C >> X;
    for(int i = 0; i <= A; i++) {
        for(int j = 0;  j <= B; j++) {
            for(int k = 0; k <= C; k++) {
                int total = 500 * i + 100 * j + 50 * k;
                if(X == total) {
                    count++;
                }
            }
        }
    }
    cout << count << endl;
    return 0;
}

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

int main() {
	// your code goes here
	int n;
	cin >> n;
	while(n>0){
		int dig=n%10;
		if(dig==7){
			cout << "Yes" << endl;
			return 0;
		}
		n/=10;
	}
	cout << "No" << endl;
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    long long int sum = 0;
    for(int i = 0; i < n; i++) sum += a[i];
    long long int snukesum = a[0];
    sum -= a[0];
    long long int ans = abs(sum - snukesum);
    for(int i = 1; i < n-1; i++){
        sum -= a[i];
        snukesum += a[i];
        if(abs(sum - snukesum) < ans) ans = abs(sum - snukesum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define vll vector<ll>
#define sz size()
#define pb emplace_back
#define mp make_pair
#define MOD 1000000007
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL))
const int N = 100005;

int main()
{
	ll m1,d1,m2,d2;
	cin>>m1>>d1>>m2>>d2;
	if(m1==1 && d1==31)
	cout<<"1";
	else if(m1==2 && d1==28)
	cout<<"1";
	else if(m1==3 && d1==31)
	cout<<"1";
	else if(m1==4 && d1==30)
	cout<<"1";
	else if(m1==5 && d1==31)
	cout<<"1";
	else if(m1==6 && d1==30)
	cout<<"1";
	else if(m1==7 && d1==31)
	cout<<"1";
	else if(m1==8 && d1==31)
	cout<<"1";
	else if(m1==9 &&d1==30)
	cout<<"1";
	else if(m1==10 && d1==31)
	cout<<"1";
	else if(m1==11 && d1==30)
	cout<<"1";
	else if(m1==12 && d1==31)
	cout<<"1";
	else 
	cout<<"0";
}

Measured memory_bytes: 256
n=int(input())
lis=list(map(int,input().split()))
ave=0
ans=0
for i in lis:
  ave+=i
ave/=n
if ave>=int(ave)+0.5:
  ave=int(ave)+1
else:
  ave=int(ave)
for i in lis:
  ans+=(i-ave)**2
print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const double PI = acos(-1.0);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int H,W,h,w; cin >> H >> W >> h >> w;

    vector<vector<ll>> S(H+1, vector<ll>(W+1));
    if (h*w==1) {
        cout << "No" << ln;
        return 0;
    }
    int mi = 999999999 / (h*w-1) * (h*w-1) + 1;
    int pr = 999999999 / (h*w-1);
    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j <=W; ++j) {
            if (i%h==0&&j%w==0) S[i][j] = -mi;
            else S[i][j] = pr;
        }
    }

    auto T = S;
    rep(i,H+1) rep(j,W) S[i][j+1] += S[i][j];
    rep(j,W+1) rep(i,H) S[i+1][j] += S[i][j];
    rep(i,H-h+1) {
        rep(j,W-w+1) {
            if (S[i+h][j+w] - S[i][j+w] - S[i+h][j] + S[i][j] >= 0) {
                cout << "No" << ln;
                return 0;
            }
        }
    }
    if (S[H][W] < 0) cout << "No" << ln;
    else {
        cout << "Yes" << ln;
        rep(i,H) {
            rep(j,W) cout << T[i+1][j+1] << " ";
            cout << ln;
        }
    }

}

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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define FOR(i,s,e) for(int i = s; i < e; i++)
#define all(x) (x).begin(),(x).end()
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair

typedef vector<int>       VI;
typedef pair<int, int> pii;
typedef long long ll;


int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    string s;
    cin>>s;
    int length = s.length();
    int count=0;
    for(int i=0;i < length ;i++){
        if(s[i] != s[length-i-1])
            count++;
   }
   cout<<count/2;
    // freopen("out.txt", "w", stdout);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>

#define MAX_N 100000
#define LIMIT 1000000

int main()
{
    int n;
    int a[MAX_N + 1];
    int counter;
    int nextIndex;
    bool isPossible;
    
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
	scanf("%d", &a[i]);
    }

    counter = 0;
    nextIndex = 1;
    isPossible = false;
    while ((isPossible == false) && (counter < LIMIT))
    {
	counter++;
	nextIndex = a[nextIndex];
	if (nextIndex == 2)
	{
	    isPossible = true;
	}
    }

    if (isPossible == true)
    {
	printf("%d\n", counter);
    }
    else
    {
	printf("-1\n");
    }

    return 0;
}


Measured memory_bytes: 512
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
int main()
{
    ll k;
    string s;
    cin>>s>>k;
    int flag=(s[0]==s[s.size()-1]);
    ll ans=0;
    ll x=0,y=0;
    for(int i=0,j=0;i<s.size();i=j)
    {
        while(s[i]==s[j]&&j<s.size())j++;
        ans+=(j-i)/2;
        if(i==0)x=j-i;
        if(j>=s.size())y=j-i;
        if(i==0&&j>=s.size())
        {
            cout<<(ll)s.size()*k/2;
            return 0;
        }
    }
    ans*=k;
    if(flag)
    {
        ans-=(x/2+y/2-(x+y)/2)*(k-1);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = (ll) 1e18;
int main()
{
  ll N,M;
  cin >> N >> M;
  if(N==1){
    if(M==1){
      cout << 1 << endl;
    }
    else{
      cout << M-2 << endl;
    }
    return 0;
  }
  if(M==1){
    cout << N-2 << endl;
    return 0;
  }
  cout << (N-2)*(M-2) << endl;

  return 0;
}

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

void optimize() {
    std::ios::sync_with_stdio(false);
    std::cout.tie(NULL);
    std::cin.tie(NULL);    
}

int main() {
    optimize();
    int n;
    std::cin >> n;
    while(n--) {
        int x;
        std::cin >> x;
        if(x % 2) continue;
        if((x % 3) && (x % 5)) {
            std::cout << "DENIED";
            return 0;
        }
    }
    std::cout << "APPROVED";
    return 0;
}

Measured memory_bytes: 256
//code_sm
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> pseudo_set;
#define ll long long
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define pb push_back
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu ((int)1e9+7)
#define set0(a) memset(a,0,sizeof(a))
#define all(a) a.begin()+1,a.end()
#define endl "\n"
template<typename T,typename U>
bool compare(T x,U y)
{
	if(abs((T)x-y)<=1e-9)
	return 1;
	return 0;
}
//sieve generation begin
vi PRIME;
void sieve(int n)
{
	bool a[n+1];
	memset(a,0,sizeof(a));
	a[0]=1;
	a[1]=1;
	for(int i=2;i*i<=n;i++)
	{
		if(a[i]==0)
		{
			for(int j=i*i;j<=n;j+=i)
			a[j]=1;
		}
	}
	for(int i=2;i<=n;i++)
	{
		if(a[i]==0)
		PRIME.pb(i);
	}
}
//sieve generation end
ll gcd(ll a,ll b)
{
	while(b%a)
	{
		ll c=b;
		b=a;
		a=c%a;
	}
	return a;
}
ll bigpow(ll base, ll exp) {
    ll res=1;
    while(exp>0) {
       if(exp%2==1) res=(res*base)%chotu;
       base=(base*base)%chotu;
       exp/=2;
    }
    return res;
}
ll mulmodin(ll x)
{
	return(bigpow(x,chotu-2)%chotu);
}
ll ncr_mod(ll n,ll r)
{
	ll store[n+1];
	store[1]=1;
	for(ll i=2;i<=n;i++)
	{
		store[i]=(store[i-1]*i)%chotu;
	}
	ll ans=(((store[n]*mulmodin(store[r]))%chotu)*mulmodin(store[n-r]))%chotu;
	return ans;
}
void solve()
{
fastio
int n;
cin>>n;
n=n%10;
if(n==3)
cout<<"bon";
else if(n==0||n==1||n==6||n==8)
cout<<"pon";
else
cout<<"hon";
}
int main()
{
//code
fastio
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}


Measured memory_bytes: 3632
//
//  main.cpp
//  ABC077A

#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    char c[6]={};
    for(int i=0;i<6;i++){
        cin>>c[i];
    }
    string ans="YES";
    if(c[1]!=c[4]) ans="NO";
    if(c[0]!=c[5]) ans="NO";
    if(c[2]!=c[3]) ans="NO";
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3040
#include <bits/stdc++.h>
using namespace std;
/*
vector<string> v(n, string(m,"*"));
vector<vector<int>>
*/
int main() {
	long long s;
	int i,n;
	cin >> n;
	vector<long long> r(n);
	s = 1;
	for (i = 0; i < n; i++) {
		cin >> r[i];
		if (r[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	for (i = 0; i < n; i++) {
		if ((long long)pow((long long)10, 18) / s < r[i]) {
			cout << -1 << endl;
			return 0;
		}
		s *= r[i];
	}
	cout << s << endl;

	return 0;
}

Measured memory_bytes: 4052
def judge(s1, s2)
    if s1.size != s2.size
        return false
    end
    s1.size.times do |i|
        if s1[i] != ?? && s1[i] != s2[i]
            return false
        end
    end
    return true
end
 
s,t=$<.map(&:chomp)
ans = -1
s.size.times do |i|
    if judge(s[i, t.size], t)
        tmp = String.new(s)
        tmp[i, t.size] = t
        s.size.times do |j|
            if tmp[j] == ??
                tmp[j] = ?a
            end
        end
        if ans == -1
            ans = tmp
        else
            ans = [ans, tmp].min
        end
    end
end
puts (ans == -1 ? "UNRESTORABLE" : ans)

Measured memory_bytes: 1788
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//ll dx[4] = {1, 0, -1, 0};
//ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll n, q;
	cin >> n >> q;
	vector<ll> s(n), t(n), x(n), d(q);
	vector<tuple<ll, ll, ll>> a(n);
	vector<ll> ans(q, -1);
	set<P> S;
	for (int i = 0; i < n; i++) {
		cin >> s[i] >> t[i] >> x[i];
		a[i] = tie(x[i], s[i], t[i]);
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < q; i++) {
		cin >> d[i];
		S.insert(P(d[i], i));
	}
	for (int i = 0; i < n; i++) {
		ll x, l, r;
		tie(x, l, r) = a[i];
		l -= x, r -= x;
		auto it = S.lower_bound(P(l, -1));

		while (it != S.end()) {
			if (it->first >= r) break;
			ans[it->second] = x;
			S.erase(it++);
		}
	}
	for (int i = 0; i < q; i++) {
		dump(ans[i]);
	}
	return 0;
}

Measured memory_bytes: 26880
using System;
using System.Linq;
using System.Net.NetworkInformation;
using System.Windows.Markup;

class IDONTKNOWCSHARP
{

    public static void Main()
    {

        string[] values = Console.ReadLine().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);

        int count = 0;
        int A = int.Parse(values[0]);
        int B = int.Parse(values[1]);
        int C = int.Parse(values[2]);
        int[] abc = new int[3];
        abc[0] = A;
        abc[1] = B;
        abc[2] = C;

        while (!(abc[0] == abc[1] && abc[1] == abc[2]))
        {
            Array.Sort(abc);
            if (abc[2] - abc[0] >= 2)
            {
                abc[0] += 2;
                count++;
                continue;
            }

            abc[0]+=1;
            abc[1]+=1;
            count++;
        }

        Console.WriteLine(count);
   //     Console.ReadLine();
    }
}

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

int main()
{
    int n;
    cin >> n;
    int A[n];
    for(int i = 0; i < n; i++)
        cin >> A[i];
    
    int L[n];
    L[0] = A[0];
    int length = 1;
    for(int i = 1; i < n; i++)
    {
        if(L[length - 1] < A[i])
            L[length++] = A[i];
        else
            *lower_bound(L, L + length, A[i]) = A[i];
    }
    cout << length << endl;
}


Measured memory_bytes: 3880
while True:
    (H, W) = [int(x) for x in input().split()]
    if H == W == 0:
        break

    for hc in range(H):
        for wc in range(W):
            if (hc + wc) % 2 == 0:
                print('#', end='')
            else:
                print('.', end='')
        print()
    print()

Measured memory_bytes: 6808
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
set<string> c;
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
map<ll,P> mp;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;cin>>n;
vector<ll> a(n);
ll sum=0;
for(int i=0;i<n;i++){
   cin>>a[i];
   sum+=a[i];
}
if(sum%10!=0){
    cout<<sum<<endl;
}
else{
    sort(all(a));
    for(int i=0;i<n;i++){
        if((sum-a[i])%10!=0){
            cout<<sum-a[i]<<endl;
            return 0;
        }
    }
    cout<<0<<endl;
}
}


Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
using namespace std;
int main(void){
  int a,b;
  int d,r;
  double f;
  cin>>a>>b;
  d=a/b;
  r=a%b;
  f=(double)a/b;
  printf("%d %d %f\n", d,r,f);
    
}



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

using namespace std;
typedef long long ll;

#define pb push_back
#define mp make_pair
#define mem(a) memset(a,0,sizeof(a))

const int mn=1e5+5;
const int mod=1e9+7;

int k;
vector<pair<ll,double> > v;

inline int geti(ll x){
	int s=0;
	while(x){
		s+=x%10;
		x/=10;
	}
	return s;
}

int a[60],c=0;
inline ll getnext(ll i){
	++i;
	if (i<10000) return i;
	ll u=i;c=0;
	while(u){
		a[c]=u%10;
		u/=10;
		c++;
	}
	ll v=0;
	for(int j=c-1;j>=0;j--) {
		if (c-j>3) a[j]=9;
		v*=10;
		v+=a[j];
	}
	return v;
}

int main(){
	scanf("%d",&k);
	for(ll i=1;i<=1e15;i=getnext(i)){
		//if (i>10000) printf("%lld !\n",i);
        auto u=mp(i,1.0*i/geti(i));
        while(!v.empty()&&v.back().second>u.second) v.pop_back();
        v.pb(u);
	}
	for(auto &i:v) {
		printf("%lld\n",i.first);
		k--;
		if (k==0) break;
	}
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<vector<int>> c(10, vector<int> (10));
	for (int i = 1; i <= n; ++i) {
		int na = i;
		int nb = i % 10;
		while (na >= 10) na /= 10;
		c[na][nb]++;
	}
	int ans = 0;
	rep(i, 10)rep(j, 10) {
		ans += c[i][j] * c[j][i];
	}
	cout << ans << endl;
	return 0;
}


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

int main(void) {
  char s[200001] = {0};
  char t[200001] = {0};
  scanf("%s", s);
  scanf("%s", t);
  if(strcmp(s, t) == 0) {
    puts("0");
  } else {
    int count = 0;
   	for (int i = 0, len = strlen(s);i < len;i++) {
      count += (s[i] != t[i]);
    }
    printf("%d\n", count);
  }
  return 0;
}


Measured memory_bytes: 2540
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vll vector<long long>
#define pll pair<long long, long long>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1e18

typedef long long ll;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> o_tree;

void solve()
{
    ll k;
    cin>>k;
    queue<string> q;
    ll i;
    if(k<=9)
    {
        cout<<k<<"\n";
        return;
    }
    for(i=1;i<=9;i++)
    {
        q.push(string(1,char('0'+i)));
    }
    ll si = 9;
    while(si<k)
    {
       string pre = q.front();
       q.pop();
    //    cout<<pre<<"\n";
       ll cc = (int)(pre.back()-'0');
       if(cc==0)
       {
            string temp = pre;
            temp+='0';
            q.push(temp);
            si++;
            if(si==k)break;
            temp=pre;
            temp+='1';
            q.push(temp);
            si++;
       }
       else if(cc==9)
       {
            string temp = pre;
            temp+='8';
            q.push(temp);
            si++;
            if(si==k)break;
            temp=pre;
            temp+='9';
            q.push(temp);
            si++;
       }
       else{
            string temp = pre;
            temp+=char(cc-1+'0');
            q.push(temp);
            si++;
            if(si==k)break;
            temp=pre;
            temp+=char(cc+'0');
            q.push(temp);
            si++;
            if(si==k)break;
            temp=pre;
            temp+=char(cc+1+'0');
            q.push(temp);
            si++;
            // if(si==k)break;
       }
    }
    cout<<q.back()<<"\n";
}

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

    if (fopen("input.txt", "r"))
    {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
    cout << setprecision(20);

    ll t = 1;

    // cin>>t;

    while (t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 5324
//#pragma comment(linker,"/STACK:102400000,102400000")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <ctime>
#include <numeric>
#include <vector>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <complex>
#include <deque>
#include <functional>
#include <list>
#include <map>
#include <string>
#include <sstream>
#include <set>
#include <stack>
#include <queue>
using namespace std;
template<class T> inline T sqr(T x) { return x * x; }
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<PII, int> PIII;
typedef pair<LL, LL> PLL;
typedef pair<LL, int> PLI;
typedef pair<LD, LD> PDD;
#define MP make_pair
#define PB push_back
#define sz(x) ((int)(x).size())
#define clr(ar,val) memset(ar, val, sizeof(ar))
#define istr stringstream
#define FOR(i,n) for(int i=0;i<(n);++i)
#define forIt(mp,it) for(__typeof(mp.begin()) it = mp.begin();it!=mp.end();it++)
const double PI = acos(-1.0);

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define lowbit(u) (u&(-u))

using namespace std;

int m,n,A,B,C,M;

struct Chain{
	int x,y,z,idx;
	bool operator<(const Chain& c) const{
		if(x==c.x){
			if(y==c.y) return z>c.z;
			else return y>c.y;
		}
		return x<c.x;
	}
} p[300005],pa[300005],pb[300005];

int cmp1(const Chain& c1,const Chain& c2){
	return c1.y<c2.y;
}

int r(){
	A = 36969*(A&M)+(A>>16);
	B = 18000*(B&M)+(B>>16);
	return (C&(A<<16)+B)%1000000;
}

int mx[1000005];

void add(int u,int v){
	for(int i = u;i<=1000000;i+=lowbit(i)) mx[i] = max(mx[i],v);
}

int query(int u){
	int ans = 0;
	for(int i = u;i;i-=lowbit(i)) ans = max(ans,mx[i]);
	return ans;
}

void rm(int u){
	for(int i = u;i<=1000000;i+=lowbit(i)) mx[i] = 0;
}

int ret[300005];

int solve(int l,int r){
	if(l==r) return 1;
	int mid = (l+r)>>1;
	int ans = solve(l,mid);
	int c1 = 0,c2 = 0;
	for(int i = l;i<=mid;i++) pa[c1++] = p[i];
	for(int i = mid+1;i<=r;i++) pb[c2++] = p[i];
	sort(pa,pa+c1,cmp1);
	sort(pb,pb+c2,cmp1);
	int j = 0;
	for(int i = 0;i<c2;i++){
		for(;j<c1;j++){
			if(pb[i].y<=pa[j].y) break;
			add(pa[j].z,ret[pa[j].idx]);
		}
		ret[pb[i].idx] = max(ret[pb[i].idx],query(pb[i].z-1)+1);
		ans = max(ans,ret[pb[i].idx]);
	}
	for(int j = 0;j<c1;j++) rm(pa[j].z);
	ans = max(ans,solve(mid+1,r));
	return ans;
}

int main(void){
#ifndef ONLINE_JUDGE
	//freopen("/Users/mac/Desktop/data.in","r",stdin);
#endif
	C = ~(1<<31),M = (1<<16)-1;
	while(scanf("%d %d %d %d",&m,&n,&A,&B),m+n+A+B){
		for(int i = 0;i<m;i++) scanf("%d %d %d",&p[i].x,&p[i].y,&p[i].z);
		for(int i = 0;i<n;i++){
			p[i+m].x = r();
			p[i+m].y = r();
			p[i+m].z = r();
		}
		n+=m;
		for(int i = 0;i<n;i++){
			p[i].idx = i,ret[i] = 1,p[i].z++;
		}
		sort(p,p+n);
		int ans = solve(0,n-1);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 18300
#include<stdio.h>

int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if((b-a)==(c-b))
	{
		printf("YES\n");
	 } 
	 else 
	 printf("NO\n");
	 return 0; 
 } 

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int N;
vector<vector<char>> field;

bool is_sym(const vector<vector<char>>& F, int ch, int cw) {
	for (int i = ch; i < N + ch; i++) {
		for (int j = cw; j < N + cw; j++) {
			if (F[i % N][j % N] != F[(j - cw + ch) % N][(i - ch + cw) % N]) {
				return false;
			}
		}
	}
	return true;
}

int main() {
	cin >> N;
	field.resize(N);
	for (int i = 0; i < N; i++) {
		field[i].resize(N);
		for (int j = 0; j < N; j++)cin >> field[i][j];
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (is_sym(field, 0, i)) {
			ans += (N - i);
		}
	}

	for (int i = 1; i < N; i++) {
		if (is_sym(field, i, 0)) {
			ans += (N - i);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
while que  =  gets
  que.chomp
  stack = []
  que = que.split(" ")
  while que.size>0
    a = que.shift
    if  a == "+"
      x = stack.shift.to_i + stack.shift.to_i
    elsif a == "-"
      x = -stack.shift.to_i + stack.shift.to_i
    elsif a == "*"
      x = stack.shift.to_i * stack.shift.to_i 
    else
      x = a
    end
    stack.unshift(x)
    
    end
    puts stack[0]
end

Measured memory_bytes: 8640
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args)  throws IOException{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        int counter = 0;
        int N = Integer.parseInt(in.readLine());
        int arr[] = Arrays.stream(in.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();

        for(int i = 0; i < N; i++){
            if(i%2==0 && arr[i]%2!=0){
                counter++;
            }
        }
System.out.println(counter);
    }
    
}


Measured memory_bytes: 31388
#include <iostream>
#include <string>
#include <queue>
#include <cmath>
#include <map>

using namespace std;

#define N 3
#define N2 9

struct Puzzle {
  int f[N2];
  int space;
  string path;

  bool operator < (const Puzzle &p) const {
    for(int i = 0;i < N2;i++){
      if(f[i] == p.f[i])
	{
	  continue;
	}
      
      return f[i] > p.f[i];
    }
    
    return false;
  }
};

static const int dx[4] = {-1,0,1,0};
static const int dy[4] = {0,-1,0,1};
static const char dir[4] = {'u','l','d','r'};

bool isTarget(Puzzle p);
string bfs(Puzzle s);

int main(void){
  int i;
  Puzzle in;
  string ans;
  
  for(i = 0;i < N2;i++){
    cin >> in.f[i];
      
    if(in.f[i] == 0){
      in.f[i] = N2;
      in.space = i;
    }
      
  }
  
  ans = bfs(in);
  cout << ans.size() << endl;

  return 0;
}


bool isTarget(Puzzle p){
  for(int i = 0;i < N2;i++){
    if(p.f[i] != (i+1)){
      return false;
    }
  }
  
  return true;
}

string bfs(Puzzle s){
  queue<Puzzle> Q;
  map<Puzzle, bool>V;
  Puzzle u,v;
  
  s.path = "";
  Q.push(s);
  V[s] = true;

  while(!Q.empty()){
    u = Q.front();
    Q.pop();
      
    if(isTarget(u)){
      return u.path;
    }
    
    int sx = u.space/N;
    int sy = u.space%N;
    
    for(int r = 0;r < 4;r++){
      int tx = sx + dx[r];
      int ty = sy + dy[r];
      
      if(tx < 0 || ty < 0 || tx >= N || ty >= N){
	continue;
      }
      v = u;
      
      swap(v.f[u.space] , v.f[tx*N + ty]);
      
      v.space = tx*N + ty;
      
      if(!V[v]){
	V[v] = true;
	v.path += dir[r];
	Q.push(v);
      }
    }
  }

  return "unsolvable";
}

	



Measured memory_bytes: 30636
#include <iostream>

using namespace std;

size_t A[200];

inline bool IsEven(int N) {
  for (int i = 0; i < N; ++i) {
    if (A[i] % 2 != 0)
      return false;
  }
  return true;
}

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; ++i)
    cin >> A[i];

  size_t nops = 0;
  for (;;) {
    if (!IsEven(N))
      break;
    for (int i = 0; i < N; ++i)
      A[i] /= 2;
    ++nops;
  }

  cout << nops << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.HashMap;

public class Main{
//public class abc164_c{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		HashMap<String, Integer> hmap = new HashMap<String, Integer>();
		String s = "";

		for(int i=0; i <n; i++){
			s = scan.next();
			if( ! hmap.containsKey(s)){
				hmap.put(s, 1);
			}

		}

		System.out.println(hmap.size());
	}

}

Measured memory_bytes: 68448
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var sc = new StreamScanner(OpenStandardInput());
        var N = sc.Integer();
        var A = new int[N];
        var s = 0L;
        for (int i = 0; i < A.Length; i++)
        {
            var k = sc.Integer();
            A[i] = k;
            if ((i & 1) == 0) s += k;
            else s -= k;
        }

        var sb = new System.Text.StringBuilder(10 * N);
        sb.Append(s).Append(' ');

        for (int i = 1; i < N; i++)
        {
            s = (A[i - 1] - (s >> 1)) * 2;
            sb.Append(s).Append(' ');
        }
        SetOut(new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        WriteLine(sb);
        Out.Flush();
    }
}

public class StreamScanner
{
    public StreamScanner(System.IO.Stream stream)
    {
        str = stream;
    }

    public readonly System.IO.Stream str;
    private readonly byte[] buf = new byte[1024];
    private int len, ptr;
    public bool isEof;

    public bool IsEndOfStream
    {
        get { return isEof; }
    }

    private byte read()
    {
        if (isEof) return 0;
        if (ptr < len) return buf[ptr++];
        ptr = 0;
        if ((len = str.Read(buf, 0, 1024)) > 0) return buf[ptr++];
        isEof = true;
        return 0;
    }

    public long Long()
    {
        if (isEof) return long.MinValue;
        long ret = 0;
        byte b;
        var ng = false;
        do b = read(); while (b != 0 && b != '-' && (b < '0' || '9' < b));
        if (b == 0) return long.MinValue;
        if (b == '-')
        {
            ng = true;
            b = read();
        }
        for (; ; b = read())
        {
            if (b < '0' || '9' < b)
                return ng ? -ret : ret;
            ret = ret * 10 + b - '0';
        }
    }

    public int Integer()
    {
        return (isEof) ? int.MinValue : (int)Long();
    }
}


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

int N_MAX=8;
int N,A,B,C;
vector<int> l(N_MAX);
const int INF=1000000;

//l[0]からl[i]までを使う
int rec(int i,int a,int b,int c){
  if(i==N){
    if(a==0 || b==0 || c==0) return INF;
    else return abs(A-a)+abs(B-b)+abs(C-c);
  }
  else{
    int res=rec(i+1,a,b,c);
    if(a==0) res=min(res,rec(i+1,a+l[i],b,c));
    else res=min(res,rec(i+1,a+l[i],b,c)+10);
    if(b==0) res=min(res,rec(i+1,a,b+l[i],c));
    else res=min(res,rec(i+1,a,b+l[i],c)+10);
    if(c==0) res=min(res,rec(i+1,a,b,c+l[i]));
    else res=min(res,rec(i+1,a,b,c+l[i])+10);
    return res;
  }
}

int main(){
  cin>>N>>A>>B>>C;
  for(int i=0;i<N;++i) cin>>l[i];
  cout<<rec(0,0,0,0)<<endl;
}


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

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

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;


int main() {
  int x,a,b;
  cin >>x>>a>>b;
  cout << (x-a)%b << endl;
}
  

Measured memory_bytes: 3632
import java.util.*;

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

        int H = sc.nextInt();
        int A = sc.nextInt();

        if(H%A==0){
            System.out.println(H / A);
        }
        else if(H%A!=0){
            System.out.println(H /A + 1);
        }
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
const string YES = "Yes";
const string NO = "No";
   
void solve(long long a, long long b, long long c){
  cout << (4*a*b < (c-a-b)*(c-a-b) && (c-a-b) > 0 ?YES:NO) << endl;
}  

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long c;
    scanf("%lld",&c);
    solve(a, b, c);
}


Measured memory_bytes: 256
n = int(input())
a = [0] * n
b = [0] * n
m = 100000000000000000000
mi = 0
for i in range(n):
    a[i], b[i] = map(int, input().split())
    if b[i] < m:
        m = b[i]
        mi = i
print(a[mi]+b[mi])

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

using namespace std;

typedef long long ll;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  for (int i = 0; i < 1e6; i++) {
    int x = (long double) i * 0.08;
    int y = (long double) i * 0.1;
    if (x == a && y == b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a)  (a).begin(),(a).end()
 
const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;
 
template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}
 
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


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

    ll range = d * 2 +1;

    ll amari = 0;
    if (n%range !=0)amari = 1;
    cerr << range << endl;
    cerr << amari <<endl;

    cout << n/range + amari;


    // string s;
    // cin >> s;




}


Measured memory_bytes: 256
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include <algorithm>
#include<initializer_list>
#include<map>
#include<set>
#include<utility>
#include<tuple>
using namespace std;

int main() {
	string s;
	cin >> s;
	if (s[0] == s[1] && s[1] == s[2] || s[1] == s[2] && s[2] == s[3])cout << "Yes";
	else cout << "No";


	return 0;
}





Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define int long long int
mt19937 rng(chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=3005;
#define M 998244353
#define double long double
#define BINF 10000000000001
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 5000004
#define deb(x) cout << #x << " " << x << "\n";
const int LG = 22;

bool f(string s){
    int l = s.length();
    for(int i = 0; i < l / 2; i++){
        if(s[i] != s[l - i - 1])
            return false;
    }
    return true;
}

#undef int 
int main() {
#define int long long int
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0);


    string s;
    cin >> s;
    int n = s.length() / 2;
    if(f(s) and f(s.substr(0, n)) and f(s.substr(n + 1, n)))
        cout << "Yes\n";
    else
        cout << "No\n";
    
    

return 0;  
}


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

int main() {
  int N, K, M = 1e9+7;
  cin >> N >> K;
  vector<vector<int>> G(N);
  for (int a, b; cin >> a >> b;) {
    a--, b--;
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }

  auto dfs = [&](auto f, int pre, int v) -> long {
    long ret = 1;
    int k = (pre == -1) ? K : K - 1;
    for (auto next : G.at(v)) {
      if (next == pre) continue;
      ret *= --k;
      ret %= M;
      ret *= f(f, v, next);
      ret %= M;
    }
    return ret;
  };

  cout << dfs(dfs, -1, 0) * K % M << "\n";
}


Measured memory_bytes: 16804
IDENTIFICATION DIVISION.
PROGRAM-ID. A-Eating.
 
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP.
   03 IN-S  PIC X(1) OCCURS 4. 
01 C-P      PIC 9(1). 
01 C-M      PIC 9(1).
01 I        PIC 9(1).
01 OUT-N    PIC -9.
 
PROCEDURE DIVISION.
MAIN-001.
  ACCEPT INP.

  MOVE 0    TO C-P C-M.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > 4
    IF (IN-S(I) = '+')
      ADD 1 TO C-P
    ELSE
      ADD 1 TO C-M
    END-IF
  END-PERFORM.

  COMPUTE OUT-N = C-P - C-M.
  DISPLAY OUT-N.
 
MAIN-EXIT.
  STOP RUN.

Measured memory_bytes: 764
import math
A,B,N = map(int,input().split())

if A == 1:
    print(0)
    exit()

if N < B:
    print(math.floor((A*N)/B) - A * math.floor(N/B))
else:
    print(math.floor((A*(B-1))/B) - A * math.floor((B-1)/B))

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

const ll MOD = 1000000007;
const ll MAX = 100100;
const double PI = 3.1415926;

#define vll vector<ll>
#define max_heap priority_queue<int>
#define min_heap priority_queue<int , vector<int>, greater<int> >
#define pb push_back
#define all(container) container.begin(), container.end()
// #define traverse( container, it) for( typeof(container.begin()) it = container.begin(); it!=container.end(); it++)
ll n;
ll arr[MAX][4];
ll dp[MAX][4];

ll fill(ll s, ll x)
{
	if (s == 0)
		return 0;

	if (x == 1)
	{
		ll fi,se;
		if (dp[s - 1][2] != -1)
			fi = dp[s - 1][2];
		else
			fi = fill(s - 1, 2);

		if (dp[s - 1][3] != -1)
			se = dp[s - 1][3];
		else
			se = fill(s - 1, 3);

		dp[s][1] = max(fi,se) + arr[s][1];
		return dp[s][1];
	}
	if (x == 2)
	{
		ll fi,se;
		if (dp[s - 1][1] != -1)
			fi = dp[s - 1][1];
		else
			fi = fill(s - 1, 1);

		if (dp[s - 1][3] != -1)
			se = dp[s - 1][3];
		else
			se = fill(s - 1, 3);

		dp[s][2] = max(fi,se) + arr[s][2];
		return dp[s][2];
	}
	if (x == 3)
	{
		ll fi,se;
		if (dp[s - 1][2] != -1)
			fi = dp[s - 1][2];
		else
			fi = fill(s - 1, 2);

		if (dp[s - 1][1] != -1)
			se = dp[s - 1][1];
		else
			se = fill(s - 1, 1);

		dp[s][3] = max(fi,se) + arr[s][3];
		return dp[s][3];
	}
	return max(fill(s - 1, 1), max(fill(s - 1, 2), fill(s - 1, 3)));
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	memset(dp,-1,sizeof(dp));
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> arr[i][1] >> arr[i][2] >> arr[i][3];
	cout << fill(n + 1,-1) << endl;
	return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <algorithm>
#include<stdio.h>
#include<functional>
using namespace std;
typedef long long ll;
int main() {
    int N;
    int A;
    int B;
    cin >> N>>A>>B;
    int all;
    int ans;
    all=N*A;
    ans=min(all,B);
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n;
    long a[10000], b[10000];
    scanf("%d", &n);
    int i;
    long d = 0;
    for (i = 0; i < n; i++)
        scanf("%ld", &a[i]);
    for (i = 0; i < n; i++)
        scanf("%ld", &b[i]);
    for (i = 0; i < n; i++)
    {
        if (a[i] < b[i])
            d += ((b[i] - a[i]) / 2);
        else
            d -= (a[i] - b[i]);
    }
    if (d<0)
    {
        printf("No\n");
        return 0;
    }
    else
    {
        printf("Yes\n");
        return 0;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
main(void){
    int n, a=0;
    cin >> n;
    int b[n-1];
    int aa[n];
    for(int i=0;i<n-1;i++) cin >> b[i];
    for(int i=0;i<n;i++) aa[i] = 1000000;
    for(int i=0;i<n-1;i++){
        
        if(aa[i] > b[i]){
            aa[i] = b[i];
        }
        if(aa[i+1] > b[i]){
            aa[i+1] = b[i];
        }
    }
    for(int i=0;i<n;i++){
        a += aa[i];
    }
    
    cout << a << endl;
}


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


using namespace std;

int main(){
    long N,ans=0;
    long A,B;
    cin>>N;
    vector<long> v(N);

    for (auto &&x : v)
    {
        cin>>x;
    }
    
    for (int i = 0; i < N; i++)
    {
        for (int k = i+1; k < N; k++)
        {
            ans+=v[i]*v[k];
        }
        
    }
    

    cout<<ans<<endl;
}

Measured memory_bytes: 256
package main

import (
    "fmt"
    "os"
    "bufio"
    "strconv"
    // "sort"
)
var sc = bufio.NewScanner(os.Stdin)


func main() {
    sc.Split(bufio.ScanWords)
    // code goes here
    A, B, X := nextInt(), nextInt(), nextInt()
    
    if A <= X && X <= A + B {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }
}



func nextInt() int {
    sc.Scan()
    v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}
func nextInt64() int64 {
    sc.Scan()
    v, e := strconv.ParseInt(sc.Text(), 10, 64)
    if e != nil { panic(e) }
    return v
}
func nextString() string {
    sc.Scan()
    return sc.Text()
}
func nextFloat() float64 {
    sc.Scan()
    v, e := strconv.ParseFloat(sc.Text(), 64)
    if e != nil { panic(e) }
    return v
}

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

int main() {
  int N , M ; 
  cin >> N >> M ; 
  int max_L = 0 ; 
  int min_R = 5+ 10e5 ; 
  
  for(int i = 0 ; i < M ; i++ ){
    int L , R ; 
    cin >> L >> R ; 
    max_L = max(max_L , L);
    min_R = min(min_R , R);
  }
  min_R++ ; 
  if(min_R > max_L){
  	cout << min_R - max_L << endl ; 
  }
  else{
    cout << 0 << endl ;
  }
  
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(){
  int n;
  int p[10002];
  fill(p,p+10002,1);
  p[0]=p[1]=0;
  for(int i = 0 ; i*i < 10002 ; i++ ){
    if(p[i])for(int j = i*2 ; j < 10002 ; j+=i)p[j]=0;
  }

  while( cin >> n ){
    if(n == 0)break;
    int cnt = 0;
    for(int i = 1 ; i <= n ; i++ ){
      if(p[i] == 1 && p[n+1-i] == 1)cnt++; 
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 1196