akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

#include<unistd.h>
char buff[1 << 22];
template <int size>
struct Buffer{
    int idx = 0;
    Buffer(){ read(0, buff, size); }
    void next(int& ret){
        // int ret = 0;
        ret = 0;
        // while(!(buff[idx] & 0x10)){ idx++; }
        while(buff[idx] & 0x10){ ret = ret * 10 + buff[idx++] - '0'; }
        idx++;
        // while(!isdigit(buff[idx])){ idx++; }
        // while(isdigit(buff[idx])){ ret = ret * 10 + buff[idx++] - '0'; }
        // return ret;
    }
};
struct FastInput {
    Buffer<1 << 22> buf;
    template <class T>
    FastInput& operator >> (T& num) { buf.next(num); return *this; }
    // FastInput& operator >> (T& num) { num = buf.next(); return *this; }
    void tie(int){ }
    template <class S, class T>
    friend FastInput& operator >> (FastInput& in, pair<S, T>& p){ return in >> p.first >> p.second; }
    template <class T>
    friend FastInput& operator >> (FastInput& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
};
FastInput fin;
#define cin fin

enum { SIZE = 1 << 20 };
char buf[SIZE];
int accs[512][512];
pair<int, int> pqs[100000];
int main(){
    int n, m, q;
    cin >> n >> m >> q;
    for(int i = 0; i < m; i++){
        int l, r;
        cin >> l >> r;
        accs[1][r]++;
        accs[l + 1][r]--;
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            accs[i + 1][j] += accs[i][j];
            accs[i][j] += accs[i][j - 1];
        }
    }
    int idx = SIZE;
    for(int i = 0; i < q; i++){
        cin >> pqs[i].first >> pqs[i].second;
    }
    for(int i = q - 1; i >= 0; i--){
        int p = pqs[i].first, q = pqs[i].second;
        buf[--idx] = '\n';
        div_t num2;
        num2.quot = accs[p][q];
        do{
            num2 = div(num2.quot, 10);
            buf[--idx] = num2.rem + '0';
        }while(num2.quot);
    }
    write(1, buf + idx, SIZE - idx);
}


Measured memory_bytes: 6784
N=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))
def f(n):
  if n==1:
    return 1
  else:
    return n*f(n-1)
t1=[0 for i in range(N)]
t2=[0 for i in range(N)]
for i in range(1,N):
  for j in range(i):
    if P[i] > P[j]:
      t1[i]=t1[i]+1
    if Q[i] > Q[j]:
      t2[i]=t2[i]+1 
a=0
b=0
S=f(N)
for i in range(N):
  S=S/(N-i)
  a=a+(P[i]-1-t1[i])*S
  b=b+(Q[i]-1-t2[i])*S
print(int(abs(a-b)))

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

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//------------------------------------------------------------------

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

  ll ans=-2e18;
  chmax(ans, a*c);
  chmax(ans, a*d);
  chmax(ans, b*c);
  chmax(ans, b*d);
  prt(ans);
}


Measured memory_bytes: 3632
def gcd(a, b):
    if a < b:
        a, b = b, a
    return b if a%b == 0 else gcd(b, a%b)

def solve(a, b, c, d):
    ans = b - a + 1
    for p in [c, d]:
        ans -= b // p - (a-1) // p
    for p in [c*d//gcd(c,d)]:
        ans += b // p - (a-1) // p
    return ans

a, b, c, d = map(int, input().split())
print(solve(a, b, c, d))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define mem0(s) memset(s,0,sizeof(s))
#define meminf(s) memset(s,0x3f,sizeof(s))
#define mp_insert(a,b,c) mp.insert(map<pair<int,int>,int>::value_type(make_pair(a,b),c))
double pi=acos(-1);
typedef long long ll;
typedef unsigned long long ull;
inline ll lowbit(ll x){return x&(-x);}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll max(ll a,ll b){return a>b?a:b;}
const int INF=0x3f3f3f3f,max_n=100005,mod=1e9+7;
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
inline ll pow(ll a,ll b,ll mod){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

int dad[max_n];
int deep[max_n];
int people[max_n];
int find(int x)
{
    if(dad[x]==x)return x;
    return dad[x]=find(dad[x]);
}
void link(int x,int y)
{
    x=find(x);
    y=find(y);
    if(x==y)
    {
        return;
    }
    else if(deep[x]<deep[y])
    {
        dad[x]=y;people[y]+=people[x];
    }
    else if(deep[x]>deep[y])
    {
        dad[y]=x;people[x]+=people[y];
    }
    else if(deep[x]==deep[y])
    {
        dad[x]=y;
        deep[y]++;
        people[y]+=people[x];
    }
}
struct Edge
{
    int from,to;
}e[100005];
int V,E,q;
int cnt;
int x;
int tt;
vector<int>v1;
long long ans;
int peng[100005];
int feng[100005];
int main()
{
	int V,m,k;cin>>V>>m>>k;int a,b;
    for(int i=0;i<V;i++)
    {
        dad[i]=i;people[i]=1;
    }
    for(int i=1;i<=m;i++)
    {
    	cin>>a>>b;
    	peng[a-1]++;
    	peng[b-1]++;
    	link(a-1,b-1);
	}
	for(int i=1;i<=k;i++)
	{
		cin>>a>>b;
		if(find(a-1)==find(b-1))
		{
			feng[a-1]++;
			feng[b-1]++;
		}

	}
    for(int i=0;i<V;i++)
    {
        if(dad[i]==i)
        {
            cnt++;
            v1.push_back(people[find(i)]);
        }
	}
    for(int i=0;i<V;i++)
    {
    	cout<<people[find(i)]-peng[i]-feng[i]-1<<' ';
	}
}

Measured memory_bytes: 2944
import sys
sys.setrecursionlimit(1000000)
def z_algo(S):
    N = len(S)
    A = [0]*N
    i = 1; j = 0
    A[0] = l = len(S)
    while i < l:
        while i+j < l and S[j] == S[i+j]:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k
    return A
def solve():
  n = int(input())
  s = input()
  ans = 0
  for i in range(n):
    a = z_algo(s[i:])
    for j in range(i,n):
        ans = max(ans, min(j-i, a[j-i]))
  print(ans)
solve()

Measured memory_bytes: 48476
#include <bits/stdc++.h>
#define il inline
#define ri register int
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define mid ((l+r)>>1)
#define MAXN 
#define MAXM
#define mod
#define inf (1<<25)
#define eps (1e-6)
#define alpha 0.75
#define rep(i, x, y) for(ri i = x; i <= y; ++i)
#define repd(i, x, y) for(ri i = x; i >= y; --i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, int> pli;
typedef pair <int, ll> pil;
typedef pair <ll, ll> pll;
template <typename T> inline bool chkmin(T &x, T y) {return x > y ? x = y, 1 : 0;}
template <typename T> inline bool chkmax(T &x, T y) {return x < y ? x = y, 1 : 0;}
il void read(int &x) {
	char ch = getchar(); int f = 1; x = 0;
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = x*10+ch-'0', ch = getchar();
	x *= f;
}
int x, d[4], cnt;
int main() {
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	rep(i, 1, 6) read(x), d[x]++;
	rep(i, 1, 4) if(d[i] & 1) cnt++;
	if(cnt <= 2) cout<<"YES";
	else cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
using System;

namespace CodingForces
{
    static class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            int[] nbrs = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            long staminaSum = 0;
            double coordinateSum = 0;

            for (int i = 0; i < nbrs.Length; i++)
            {
                coordinateSum += nbrs[i];
            }

            double pos = Math.Round(coordinateSum / nbrs.Length);

            for (int i = 0; i < nbrs.Length; i++)
            {
                staminaSum += (long)Math.Pow(nbrs[i] - pos, 2);
            }

            Console.WriteLine(staminaSum);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>
#include <type_traits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
constexpr long long MOD = 1e9 + 7;
constexpr long long MAX = 1000000;

//long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

ll h, w;
vector<ll> dx = { -1, 0, 1, 0 };
vector<ll> dy = { 0, -1, 0, 1 };


bool isInField(ll x, ll y) {
    bool f = x >= 0 && x < w && y >= 0 && y < h;
    return f;
}

bool compare_first(pair<ll, ll> x, pair<ll, ll> y)
{
    if (x.first != y.first) {
        return x.first < y.first;
    }
    else {
        return x.second < y.second;
    }
}

bool compare_second(pair<ll, ll> x, pair<ll, ll> y)
{
    if (x.second != y.second) {
        return x.second < y.second;
    }
    else {
        return x.first < y.first;
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<bool> isExist(1000000100, false);

    for (ll i = 0; i < n; ++i) {
        ll a;
        cin >> a;
        if (isExist[a]) {
            cout << "NO" << "\n";
            return 0;
        }
        isExist[a] = true;
    }

    cout << "YES" << "\n";
    return 0;
}



Measured memory_bytes: 122368
#include <stdio.h>

int N;
int A[114514];

int main(void) {
	int i;
	int min;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}
	min = N;
	for (i = 1; i < N; i++) {
		if (A[i - 1] < A[i]) min--;
	}
	printf("%d\n%d\n", min, N);
	return 0;
}



Measured memory_bytes: 2236
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
#define vcin(a)                          \
    for (int i = 0; i < (a).size(); i++) \
        cin >> (a)[i];

int main()
{
    string Sa, Sb, Sc;
    cin >> Sa;
    cin >> Sb;
    cin >> Sc;
    char start = 'a';
    char ans;
    while (Sa.size() * Sb.size() * Sc.size() >= 0)
    {
        switch (start)
        {
        case 'a':
            if (Sa.empty())
            {
                ans = 'A';
                goto L;
            }
            start = Sa.front();
            Sa.erase(Sa.begin());

            break;
        case 'b':
            if (Sb.empty())
            {
                ans = 'B';
                goto L;
            }
            start = Sb.front();
            Sb.erase(Sb.begin());

            break;
        case 'c':
            if (Sc.empty())
            {
                ans = 'C';
                goto L;
            }
            start = Sc.front();
            Sc.erase(Sc.begin());

            break;
        default:
            break;
        }
    }
L:;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

int n, m, t;
struct vertice {
	int s, c, id;
	bool operator<(const vertice &v)const {
		if (s != v.s)return s > v.s;
		return vector<int>{c, id} > vector<int>{v.c, v.id};
	}
};
struct edge {
	int c,to, cost;
};
vector<edge> G[101][101];
int dist[101][101];
void solve() {
	rep(i, n + 1) {
		rep(j, n + 1) {
			G[i][j].clear();
			dist[i][j] = mod;
		}
	}
	dist[0][0] = 0;
	rep(i, m) {
		int a, b; cin >> a >> b; a--; b--;
		int c; cin >> c;
		rep(j, n) {
			G[j][a].push_back({ j + 1,b,0 });
			//G[j][b].push_back({ j + 1,a,0 });
		}
		rep(j, n + 1) {
			G[j][a].push_back({ j,b,c });
			//G[j][b].push_back({ j,a,c });
		}
	}
	priority_queue<vertice> q; q.push({ 0,0,0 });
	while (!q.empty()) {
		vertice v = q.top(); q.pop();
		int c = v.c, id = v.id;
		rep(j, G[c][id].size()) {
			edge &e = G[c][id][j];
			int ns = v.s + e.cost;
			if (ns < dist[e.c][e.to]) {
				dist[e.c][e.to] = ns;
				q.push({ dist[e.c][e.to],e.c,e.to });
			}
		}
	}
	rep(i, n + 1) {
		if (dist[i][n - 1] < t) {
			cout << i << endl; return;
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(9);
	while (cin >>n>>m>>t,n) {
		solve();
	}
	//stop
	return 0;
}


Measured memory_bytes: 7532
n=int(input())
s=input()

ans=0

for i in range(0,n-1):
    s1=set([])
    s2=set([])
    for j in range(0,i+1):
        s1.add(s[j])
    for j in range(i+1,n):
        s2.add(s[j])
    
    s1=s1.intersection(s2)
    ans=max(ans,len(s1))

print(ans)
    

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64, i64> P;
#define rep(i, s, e) for (int i = (s); i <= (e); i++)

int a, b, c;

int main()
{
    cin >> a >> b >> c;
    if(a <= c && c <= b)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

void rotate(char *str) {
  int iterator;
  char temp = str[0];
  for(iterator = 1; iterator < strlen(str); iterator++) {
    str[iterator-1] = str[iterator];
  }
  str[iterator-1] = temp;
  return;
}

int main() {
  int i;
  char str_a[101], str_b[101];
  scanf("%s", str_a);
  scanf("%s", str_b);
  for(i = 0; i < strlen(str_a); i++) {
    if(strcmp(str_a, str_b) == 0) {
      printf("Yes\n");
      break;
    } else {
      rotate(str_a);
    }
  }
  if(i == strlen(str_a)) printf("No\n");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <queue>
using namespace std;

int main(){
	int N,K,T,U,V,L;
	cin >> N >> K >> T >> U >> V >> L;	
	queue<int> q;
	for(int i=0; i<N; i++){
		int pos;
		cin >> pos;
		q.push(pos);
	}
	
	int stock = 0;
	int nowpos = 0;
	double time = 0;
	while(1){
		if(stock==0){
			if(!q.empty() && nowpos+U >= q.front()){
				time += (q.front()-nowpos)/(double)U;
				nowpos = q.front();
				q.pop();
				stock++;
			}else if(nowpos+U >= L){
				time += (L-nowpos)/(double)U;
				nowpos = L;
				break;
			}else{
				time +=	1;
				nowpos += U;
			}
		}else{
			stock--;
			if(nowpos+T*V >= L){
				time += (L-nowpos)/(double)V;
				nowpos = L;
				break;
			}else{
				time += T;
				nowpos += T*V;
				int last;
				while(!q.empty() && nowpos >= q.front()){
					stock++;
					last = q.front();
					q.pop();
				}
				if(stock > K){
					stock = K+1;
					time -= (nowpos-last)/(double)V;
					nowpos = last;
				}
			}
		}
	}
	
	cout << fixed;
	cout << setprecision(10);
	cout << time << endl;
	return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    string ab(b,'a');
    string ba(a,'a');
    //cout << "initial " << ab << " " << ba << endl;
    for(int i=0; i<b; i++){
        ab[i] = '0' + a;
    }
    for(int i=0; i<a; i++){
        ba[i] = '0' + b;
    }
    if( a<b ){
        cout << ab << endl;
    }else{
        cout << ba << endl;
    }

    return 0;
}

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

using namespace std;

int Calculate(double, double, double, double, double, double);
double GetDistance(double, double, double, double);

int main(){
  int i, n;
  double xa, ya, ra, xb, yb, rb;

  cin >> n;
  for(i=0; i<n; ++i){
    cin >> xa >> ya >> ra >> xb >> yb >> rb;
    cout << Calculate(xa, ya, ra, xb, yb, rb) << endl;
  }
  return 0;
}

int Calculate(double xa, double ya, double ra,
	      double xb, double yb, double rb){
  double r;
  r = GetDistance(xa, ya, xb, yb);
  if(ra > rb && ra > r + rb) return 2;
  if(ra < rb && rb > r + ra) return -2;
  if(r <= ra + rb) return 1;
  return 0;
}

double GetDistance(double xa, double ya, double xb, double yb){
  double x, y;
  x = xa - xb;
  y = ya - yb;
  return sqrt(x*x + y*y);
}

Measured memory_bytes: 1232
#include <iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

struct point{
  int x,y,b=0;
};

bool cmp(point p,point q){
  if(p.b == q.b)
    return p.x > q.x ;
  return p.b < q.b ;
}

bool cmp_(point p,point q){
  if(p.b == q.b)
    return p.y > q.y ;
  return p.b < q.b ;
}

bool cmp2(point p,point q){
  return p.x<q.x ;
}

bool cmp3(point p,point q){
  return p.y<q.y ;
}

point red[200],blue[200];
int chk[200],n,tmp;

int solve(){
  int ans=0;
  for(int i=0;i<n;i++){
    chk[i] = 0;
  }

  for(int i=n-1;i>=0;i--){
    tmp=-1;
    for(int j=0;j<n;j++){
      if(blue[j].x>red[i].x&&blue[j].y>red[i].y&&!chk[j]){
        //printf("%d %d %d %d\n",red[i].x,red[i].y,red[i].b,blue[j].x);
        //if(tmp!=-1){
        //  if(blue[j].b>blue[tmp].b)
        //    continue;
        //}
        ans++;
        chk[j]=1;
        break;
      }
    }
  }
  return ans;
}

int main() {
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d%d",&red[i].x,&red[i].y);
  }
  for(int i=0;i<n;i++){
    scanf("%d%d",&blue[i].x,&blue[i].y);
    
    for(int j=0;j<n;j++){
      if(blue[i].x>red[j].x&&blue[i].y>red[j].y)
        red[j].b++;
        blue[j].b++;
    }
  }
  int ans=0;
  /*
  sort(red,red+n,cmp);
  sort(blue,blue+n,cmp2);
  ans = max(ans,solve());
  sort(red,red+n,cmp_);
  sort(blue,blue+n,cmp2);
  ans = max(ans,solve());
  sort(red,red+n,cmp);
  sort(blue,blue+n,cmp3);
  ans = max(ans,solve());
  */
  sort(red,red+n,cmp3);
  sort(blue,blue+n,cmp2);
  ans = max(ans,solve());
  printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main() {
    int N;
    scanf("%d",&N);
    N=N%100;
    N=N%10;
    if(N==2||N==4||N==5||N==7||N==9)
    {
        printf("hon\n");
    }
    else if(N==0||N==1||N==6||N==8)
    {
        printf("pon\n");
    }
    else
    {
        printf("bon\n");
    }
    return 0;
}

Measured memory_bytes: 1644
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << "\n";
    os << *it;
  }
  return os;
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

vector<string> b3 = {
  "aa.",
  "..b",
  "..b"
};
vector<string> b4 = {
  "abcc",
  "abdd",
  "eegh",
  "ffgh"
};
vector<string> b5 = {
  ".aabc",
  "d..bc",
  "d.eef",
  "ggh.f",
  "iihjj"
};
vector<string> b6 = {
  "aabcc.",
  "d.b..f",
  "dee..f",
  "gg.hhi",
  "..jk.i",
  "..jkll"
};
vector<string> b7 = {
  "abbcc..",
  "a.dee..",
  "ffd..gg",
  "hi...jj",
  "hi...kk",
  "..lmn..",
  "..lmn.."
};

void fill(int k, int x, vector<string> &board) {
  if (k == 4) rep(i, 4) rep(j, 4) board[x+i][x+j] = b4[i][j];
  if (k == 5) rep(i, 5) rep(j, 5) board[x+i][x+j] = b5[i][j];
  if (k == 6) rep(i, 6) rep(j, 6) board[x+i][x+j] = b6[i][j];
  if (k == 7) rep(i, 7) rep(j, 7) board[x+i][x+j] = b7[i][j];
}

int main() {
  int n; cin>>n;
  vector<string> board(n, string(n, '.'));

  if (n == 2) {
    print(-1);
  } else if (n == 3) {
    print(b3);
  } else {
    int r = n % 4 + 4;
    int m = (n - r) / 4;
    rep(i, m) fill(4, i*4, board);
    fill(r, m*4, board);
    print(board);
  }

  return 0;
}

Measured memory_bytes: 2304
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

ll gcd(ll a,ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g =gcd(a,b);
    return a/g*b;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    ll t[110];
    REP(i,N) cin >>t[i];
    ll ans=t[0];
    REP(i,N){
        ans =lcm(ans,t[i]);
    }
    cout << ans << endl;
    return 0;
}


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

#define loop(v, f, l) for(int v = (f), v##_ = (l); v < v##_; ++v)

using namespace std;

typedef long long int lint;
static inline int in(){ int x; scanf("%d", &x); return (x); }
static inline lint inl(){ lint x; scanf("%lld", &x); return (x); }

int memo[1000000];

int getNumOfCollatzsProcess(int num)
{
	if( num == 1 )return 0;
	if( memo[num - 1] != 0 )return memo[num - 1];
	if( num % 2 == 0 )return 1 + getNumOfCollatzsProcess(num / 2);
	return 1 + getNumOfCollatzsProcess(num * 3 + 1);
}

int main()
{
	int n;
	while( true )
	{
		n = in();
		if( n == 0 )break;
		printf("%d\n", getNumOfCollatzsProcess(n));
	}
	return (0);
}

Measured memory_bytes: 1188
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<stdbool.h>
#include<math.h>
#include<time.h>
#define ll long long
#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))

int n, k, h[111111], x[111111][111];

int nyan(int i, int j){
    if(x[i][j] >= 0)return x[i][j];
    if(j == 0 && i < n){
        return x[i][j] = abs(h[i-k] - h[i]) + nyan(i+1,k-1);
    }
    if(i >= n-1){
        return x[i][j] = abs(h[i-(k-j)] - h[n-1]);
    }
    return x[i][j] = min(nyan(i+1, j-1), abs(h[i-(k-j)] - h[i]) + nyan(i+1, k-1));
}

int main(){
    scanf("%d%d", &n, &k);
    for(int i = 0; i < n; i++){
        scanf("%d", &h[i]);
    }
    for(int i=0; i<111111; i++){
        for(int j=0; j<111; j++){
            x[i][j] = -1;
        }
    }
    printf("%d\n", nyan(0, k));
    return 0;
}

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

int main() {
    int n;
    int s = 0;
    cin >> n;
    vector<int> w (n);
    for(int i=0; i<n; i++){
        cin >> w.at(i);
        s += w.at(i);
    }
    int t,L,R,mi;
    L = 0;
    mi = 10100;
    for(int t=0; t<n-1; t++){
        L += w.at(t);
        R = s - L;
        if(pow(pow((L - R),2),0.5) < mi) mi = pow(pow((L - R),2),0.5);
    }
    cout << mi << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b;
    scanf("%d %d",&a,&b);
    if(a+b == 15) printf("+\n");
    else if(a*b == 15) printf("*\n");
    else printf("x\n");
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using pll = pair<ll, ll>;
 
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair

void solve() {
    int n; cin >> n;
    vi x(n), y(n);
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
    ll INF = 2e9 + 100;
    ll res = 0;
    for (int it = 0; it < 2; it++) {
        ll m1 = INF, M1 = -INF;
        for (int i = 0; i < n; i++) {
           m1 = min(m1, x[i] + y[i]);
            M1 = max(M1, x[i] + y[i]);
        }
        res = max(res, M1 - m1);
        for (int i = 0; i < n; i++) x[i] *= -1;
    }
    cout << res;

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

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

int main(){
  char s[1001], order[8], ch[1001];
  int i, j, n, a, b;

  scanf("%s\n%d", s, &n);  //命令,回数

  for(i=0; i<n; i++){
    scanf("%s %d %d", order, &a, &b);
    
    if(!strcmp(order, "reverse")){
      for(j=a; j<=b; j++)
        ch[b-j] = s[j];
      for(j=a; j<=b; j++)
        s[j] = ch[j-a];
    }

    if(!strcmp(order, "replace")){
      scanf("%s", ch);
      for(j=0; ch[j]!='\0'; j++)
        s[a+j] = ch[j];
    }

    if(!strcmp(order, "print")){
      for(j=a; j<=b; j++)
        printf("%c", s[j]);
        printf("\n");
    }
  }
  return 0;
}



  




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

using namespace std;

int main() {
  int h, w, k;
  cin >> h >> w >> k;

  vector<vector<int>> c(h, vector<int>(w));
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      char ch;
      cin >> ch;
      c[i][j] = ch == '.' ? 0 : 1;
    }
  }

  int comb = 0;
  for (int bit = 0; bit < (1 << h); ++bit) {
    for (int bjt = 0; bjt < (1 << w); ++bjt) {
      int cnt = 0;
      for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
          if (bit & (1 << i) || bjt & (1 << j)) continue;
          if (c[i][j]) cnt++;
        }
      }
      if (cnt == k) comb++;
    }
  }

  cout << comb << endl;
}


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

using namespace std;
using ll = unsigned long long;
using P = pair<int, int>;

const ll INF64 = 1LL << 60;
const int INF = 1 << 29;
const ll MOD = 998244353;

const int CASES = 3;

void solve() {
    int n; string s;
    cin >> n >> s;
    if(n % 2 == 1){
        cout << "No" << endl;
        return ;
    }
    int half = n/2;
    for(int i = 0; i < half; ++i){
        if(s[i] != s[i+half]){
            cout << "No" << endl;
            return ;
        }
    }
    cout << "Yes" << endl;
    return ;
}

int main() {
    #ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
    #else

    solve();

    #endif
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC129A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c, p, q, r;

            var word = Console.ReadLine().Split(' ');
            p = int.Parse(word[0]);
            q = int.Parse(word[1]);
            r = int.Parse(word[2]);

            a = p + q;
            b = q + r;
            c = p + r;

            if ((a < b) && (a < c))
                Console.WriteLine(a);
            else if ((b < a) && (b < c))
                Console.WriteLine(b);
            else if ((c < a) && (c < b))
                Console.WriteLine(c);

            else if ((a == b) && (a < c))
                Console.WriteLine(a);
            else if ((a == b) && (a > c))
                Console.WriteLine(c);

            else if ((a == c) && (a < b))
                Console.WriteLine(a);
            else if ((a == c) && (a > b))
                Console.WriteLine(b);

            else if ((c == b) && (a < c))
                Console.WriteLine(a);
            else if ((c == b) && (a > c))
                Console.WriteLine(c);

            else if ((a == b) && (b == c))
                Console.WriteLine(a);

            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define pb push_back
#define MOD 1000000007
#define INF 1000000000
#define EPS 0.0000000001
typedef long long ll;

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

    
    string s,t;
    cin>>s>>t;
    int c=0;
    rep(i,3){
        if(s[i]==t[i]){
            c++;
        }
    }
    cout<<c<<endl;
}

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

int a, b, c, ans = 0;

int main()
{
    cin >> a >> b >> c;
  
  	if( !c ) {
    	cout << b << endl; return 0;
    }

  	c --; ans ++; 
  	int temp = min( b, c );
    ans += temp << 1;
  	b -= temp; c -= temp;
  
    if( !b ) ans += min( a, c );
    else ans += b;
  
    cout << ans << endl;
  
	return 0; 
}

Measured memory_bytes: 256
from functools import reduce
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

def solve():
    maxA = 10**6

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

    def getMinPFs(n):
        isPrimes = [False]*2 + [True]*(n-1)
        minPFs = [1] + list(range(1, n+1))
        for d in range(2, int(n**0.5)+1):
            if isPrimes[d]:
                minPFs[d] = d
                for x in range(d*d, n+1, d):
                    isPrimes[x] = False
                    if minPFs[x] == x:
                        minPFs[x] = d
        return minPFs

    def getPrimeFactors(x, minPFs):
        anss = set()
        while minPFs[x] > 1:
            anss.add(minPFs[x])
            x //= minPFs[x]
        return anss

    minPFs = getMinPFs(maxA)

    useds = [0] * (maxA+1)
    for A in As:
        PFs = getPrimeFactors(A, minPFs)
        for PF in PFs:
            if useds[PF]:
                break
            useds[PF] = 1
        else:
            continue
        break
    else:
        print('pairwise coprime')
        return

    def gcd(a, b):
        while b:
            a, b = b, a%b
        return a

    g = reduce(gcd, As)

    if g == 1:
        print('setwise coprime')
    else:
        print('not coprime')


solve()


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

int main(){
  int a, b;
  cin >> a >> b;
  
  int ans = 0;
  if(a == 1 && b == 2){
    ans = 3;
  }else if(a == 1 && b == 3){
    ans = 2;
  }else if(a == 2 && b == 1){
    ans = 3;
  }else if(a == 2 && b == 3){
    ans = 1;
  }else if(a == 3 && b == 1){
    ans = 2;
  }else{
    ans = 1;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

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

        //x^2+y^2+z^2+xy+yz+zx=n;
        int[] ans = new int[n+1];
        for(int x=1; x<=(int)Math.sqrt(n); x++) {
            for(int y=1; y<=(int)Math.sqrt(n); y++) {
                for(int z=1; z<=(int)Math.sqrt(n); z++) {
                    int rst = x*x+y*y+z*z+x*y+y*z+z*x;
                    if(rst <= n) {
                        ans[rst]++;
                    }
                }
            }
        }
        for(int i=1; i<ans.length; i++) {
            System.out.println(ans[i]);
        }
    }
}


Measured memory_bytes: 39200
// Author: Mrigank
/* Science is what we understand well enough to explain to a computer, 
    Art is everything else we do - Donald E. Knuth */

#include <bits/stdc++.h>
#include <iostream>
#include <unordered_map>
#include <map>
#include <queue>
#include <stack>
#include <unordered_set>
#include <set>
#include <string> 
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<ll, int> PLI;
typedef pair<int, int> PII;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < pair < ll , ll > > vpl;
typedef vector < pair < ll , bool > > vpb;
typedef vector < vector < int > > vvi;
typedef vector < vector < ll > > vvl;


#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define pi pair < ll , ll >
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x , val) memset(x , val , sizeof(x))
#define deb(x) cout<<#x<<" :: "<<x<<"\n"
#define deb2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n"
#define deb3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n"
#define all(x) x.begin() , x.end()
#define alls(x , y) x.begin() , x.end() , y
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl "\n"

const ll mxsize = 5e6 + 5;
const ll linf = 1e9;
const ld inf = 10000000000.0;
const ll mod = 1e9 + 7;
 
/******************************************** CODE STARTS FROM HERE *************************************************/ 

int main()
{
    fastIO;
    ll n , k;
    cin >> n >> k;
    vl pre(n + 1 , 0);
    vl suff(n + 1 , 0);
    pre[0] = 0;
    ll i;
    Fo(i , 1 , n + 1)
    {
        pre[i] = pre[i - 1] + i;
    }
    suff[n] = n;
    for(i = n - 1 ; i >= 0 ; i--)
    {
        suff[i] = suff[i + 1] + i;
    }
    ll ans = 0;
    for(int i = k - 1 ; i <= n ; i++)
    {
        //deb2(pre[i] , suff[n - i]);
        ll val = suff[n - i] - pre[i] + 1;
        ans = (ans % mod + val % mod) % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6300
N,T = map(int,input().split())
A = list(map(int,input().split()))

M = [0 for _ in range(N-1)] + [A[N-1]]
for i in range(N-2,-1,-1):
  M[i] = max(A[i],M[i+1])

ans = 0
maxp = -(10**9)
for i in range(N):
  #print(M[i],A[i],maxp)
  if M[i]-A[i] > maxp:
    maxp = M[i]-A[i]
    ans = 1
  elif M[i]-A[i] == maxp:
    ans += 1
print(ans)

Measured memory_bytes: 64876
// AtCoder template
// 最近sabaがかまってくれないからキレて暴れてる
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

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


    // 入力
    int n; ll k; cin >> n >> k;
    vector<int> a(n); rep(i,n){
        cin >> a[i];
        a[i]--;
    }

    // サイクル検出
    vector<bool> visited(n, false);
    int now = 0;
    int start;
    while(true){
        if(visited[now]){
            start = now;
            break;
        }
        visited[now] = true;
        now = a[now];
    }

    // サイクル長を求める
    ll cycle_d = 0;
    now = start;
    visited.assign(n,false);
    vector<int> cycle;
    while(true){
        if(visited[now]){
            break;
        }
        cycle.push_back(now);
        visited[now] = true;
        now = a[now];
        cycle_d++;
    }

    // 0からサイクル始点までの距離を求める
    ll dist = 0;
    now = 0;
    while(true){
        if(now == start){
            break;
        }
        now = a[now];
        dist++;
    }

    // 計算

    // 出力
    if(k >= dist) cout << cycle[(k-dist)%cycle_d]+1 << endl;
    else{
        now = 0;
        while(k){
            now = a[now];
            k--;
        }
        cout << now+1 << endl;
    }
}

Measured memory_bytes: 5032
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;

int main(){
  prep();
  string s;
  cin >> s;
  if (s[0] == '1'){
      for (int i=0; i<s.size(); i++){
          if (s[i] == '1'){
              s[i] = '0';
          }else{
              s[i] = '1';
          }
      }
  }
  int n = s.size();
  vector<int> intervals;
  int white[n] = {0};
  int black[n] = {0};
  for (int i=0; i<n; i++){
      if (i == 0){
          if (s[i] == '0'){
              white[i] = 1;
          }else{
              black[i] = 1;
          }
      }else{
          if (s[i] == '0'){
              white[i] += 1+white[i-1];
              if (white[i-1] == 0){
                  intervals.push_back(black[i-1]);
              }
          }else{
              black[i] += 1+black[i-1];
              if (black[i-1] == 0){
                  intervals.push_back(white[i-1]);
              }
          }
      }
  }
  if (s[n-1] == '0'){
      intervals.push_back(white[n-1]);
  }else{
      intervals.push_back(black[n-1]);
  }
  multiset<int> sizes;
  int sum = n;
  vector<int> order;
  for (int i=0; i<intervals.size(); i++){
      sizes.insert(sum);
      order.push_back(sum);
      sum -= intervals[i];
      
  }
  int maxest = *(sizes.begin());
  sum = n;
  for (int i=intervals.size()-1; i>=0; i--){
      sizes.insert(n);
      sizes.insert(sum-intervals[i]);
      sizes.erase(sizes.find(order[i]));
      maxest = max(maxest, *(sizes.begin()));
      sum -= intervals[i];
  }
  cout << maxest;
  return 0; 
}

Measured memory_bytes: 6220
N, M = list(map(int, input().split()))
L = []
R = []
for i in range(M):
	l, r = list(map(int, input().split()))
	L.append(l)
	R.append(r)

L_max = max(L)
R_min = min(R)
if R_min >= L_max:
	print(R_min - L_max +1)
else:
	print(0)

Measured memory_bytes: 56664
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N, Y = mi()
Y /= 1000

for i in range(N+1):
    for j in range(N+1-i):
        k = N - j - i
        if i * 10 + j * 5 + k == Y:
            print(i, j, k)
            exit()

print(-1, -1, -1)

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

using namespace std;

int main() {
    string s; cin >> s;
    
    int is = 1;
    for (int i = 0, j = (s.size()-1)/2-1; i <= j; i++, j--) {
        if (s[i] != s[j]) {is = 0; break;}
    }
    
    for (int i = (s.size()+3)/2-1, j = s.size()-1; i <= j; i++, j--) {
        if (s[i] != s[j]) {is = 0; break;}
    }
    
    for (int i = 0; i < s.size()/2; i++) {
        if (s[i] != s[s.size()-i-1]) {is = 0; break;}
    }
    
    if (is) cout << "Yes\n";
    else cout << "No\n";
    
    
    return 0;
}

Measured memory_bytes: 256
/*
 *  Author : H_Tatsuhiro ( Tatsuhiro Hashimoto )
 *  Created : 2020/08/29 21:14:55
 */

#include <bits/stdc++.h>
#include <boost/multiprecision//cpp_int.hpp>
using namespace std;

namespace mp = boost::multiprecision;
using Booint = mp::cpp_int;

#define endl "\n"
#define FSP(n) cout << fixed << setprecision(n);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define ilMAX 2147483647;
#define llMAX 9223372036854775807;
#define ullMAX 18446744073709551615;
#define SORT(v) sort((v).begin(), (v).end());
#define REV(v) reverse((v).begin(), (v).end());
#define prepare cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);

void solve() {
    int z; cin >> z;
    if (z == 0) cout << 1 << endl;
    else cout << 0 << endl;
}

signed main() {
    prepare
    solve();
}

Measured memory_bytes: 3616
from typing import List


def calc_hash(tab: List[List[int]], row_num: int, col_num: int) -> None:
    global hash_table, R, C, baes1, base2, mask
    tmp_table = [[0] * col_num for _ in range(row_num)]
    diff_row, diff_col = row_num - R, col_num - C

    bit_mask = 1
    for _ in range(C):
        bit_mask = (bit_mask * base1) & mask
    for r in range(row_num):
        hash_v = 0
        for c in range(C):
            hash_v = hash_v * base1 + tab[r][c]
        for dc in range(diff_col):
            tmp_table[r][dc] = hash_v
            hash_v = (hash_v * base1 - bit_mask * tab[r][dc] + tab[r][dc + C]) & mask
        tmp_table[r][diff_col] = hash_v

    bit_mask = 1
    for _ in range(R):
        bit_mask = (bit_mask * base2) & mask
    for c in range(diff_col + 1):
        hash_v = 0
        for r in range(R):
            hash_v = hash_v * base2 + tmp_table[r][c]
        for dr in range(diff_row):
            hash_table[dr][c] = hash_v
            hash_v = (hash_v * base2 - bit_mask * tmp_table[dr][c]
                      + tmp_table[dr + R][c]) & mask
        hash_table[diff_row][c] = hash_v


if __name__ == "__main__":
    base1 = 1009  # The first prime number over 1000.
    base2 = 1013  # The second prime number over 1000.
    mask = (1 << 32) - 1  # Mask.

    H, W = map(lambda x: int(x), input().split())
    region = [[0] * W for _ in range(H)]
    for row in range(H):
        region[row] = [ord(s) for s in input()]

    R, C = map(lambda x: int(x), input().split())
    pattern = [[0] * C for _ in range(R)]
    for row in range(R):
        pattern[row] = [ord(s) for s in input()]

    if H >= R and W >= C:
        hash_table = [[0] * W for _ in range(H)]
        calc_hash(pattern, R, C)  # Calc the target hash and save it into hash_table[0][0]
        key = hash_table[0][0] & mask
        calc_hash(region, H, W)
        for r in range(H - R + 1):
            for c in range(W - C + 1):
                if key == hash_table[r][c] & mask:
                    print(f"{r} {c}")



Measured memory_bytes: 94372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

const int mod = 1e9+7;

int main() {
    int n;
    cin >> n;
    int k = 1000 - n % 1000;
    if (k == 1000) {
        k = 0;
    }
    cout << k << endl;
}




Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

ll modpow(ll a, ll N) {
  ll ans = 1;
  ll tmp = a;
  while(N > 0) {
    if(N % 2 == 1) (ans *= tmp) %= mod;
    (tmp *= tmp) %= mod;
    N /= 2;
  }
  return ans;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<ll> cnt(K+1);
  for(int k=K; k>=1; k--) {
    cnt[k] = modpow(K/k, N);
    for(int j=2; k*j<=K; j++) {
      (cnt[k] += mod - cnt[k*j]) %= mod;
    }
  }
  ll ans = 0;
  for(int k=1; k<=K; k++) {
    (ans += k * cnt[k]) %= mod;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3996
#include<cstdio>
#include<cmath>
#include<iostream>
#define RI register int
#define CI const int&
using namespace std;
const int N=200005,P=200003;
struct Complex
{
	double x,y;
	inline Complex(const double& X=0,const double& Y=0) { x=X; y=Y; }
	friend inline Complex operator + (const Complex& A,const Complex& B)
	{
		return Complex(A.x+B.x,A.y+B.y);
	}
	friend inline Complex operator - (const Complex& A,const Complex& B)
	{
		return Complex(A.x-B.x,A.y-B.y);
	}
	friend inline Complex operator * (const Complex& A,const Complex& B)
	{
		return Complex(A.x*B.x-A.y*B.y,A.x*B.y+A.y*B.x);
	}
	inline void operator /= (const double& p)
	{
		x/=p; y/=p;
	}
}b[P<<2]; int n,a[N],g,lg[N],rg[P],cnt,cur; long long ans;
inline int quick_pow(int x,int p,int mul=1)
{
	for (;p;p>>=1,x=1LL*x*x%P) if (p&1) mul=1LL*mul*x%P; return mul;
}
inline int getroot(CI x=P)
{
	RI i,j; for (i=2;i<=x-2;++i) if ((x-1)%i==0) rg[++cnt]=i;
	for (i=2;;++i)
	{
		bool flag=1; for (j=1;j<=cnt;++j)
		if (quick_pow(i,rg[j])==1) { flag=0; break; }
		if (flag) return i;
	}
}
namespace Poly
{
	const double pi=acos(-1);
	int lim,p,rev[P<<2];
	inline void init(CI n)
	{
		for (lim=1,p=0;lim<=n;lim<<=1,++p);
		for (RI i=0;i<lim;++i) rev[i]=(rev[i>>1]>>1)|((i&1)<<p-1);
	}
	inline void FFT(Complex *f,CI opt)
	{
		RI i,j,k; for (i=0;i<lim;++i) if (i<rev[i]) swap(f[i],f[rev[i]]);
		for (i=1;i<lim;i<<=1)
		{
			Complex D(cos(pi/i),sin(pi/i)*opt);
			for (j=0;j<lim;j+=(i<<1))
			{
				Complex W(1,0); for (k=0;k<i;++k,W=W*D)
				{
					Complex x=f[j+k],y=f[i+j+k]*W;
					f[j+k]=x+y; f[i+j+k]=x-y;
				}
			}
		}
		if (!~opt) for (i=0;i<lim;++i) f[i]/=lim;
	}
};
int main()
{
	RI i; for (g=getroot(P),cur=1,i=0;i<P-1;++i,(cur*=g)%=P) lg[cur]=i;
	for (scanf("%d",&n),i=1;i<=n;++i) scanf("%d",&a[i]),a[i]&&(b[lg[a[i]]].x+=1.0);
	for (Poly::init(P<<1),Poly::FFT(b,1),i=0;i<Poly::lim;++i) b[i]=b[i]*b[i];
	for (Poly::FFT(b,-1),i=1;i<P;++i) ans+=1LL*i*(long long)(b[lg[i]].x+b[lg[i]+P-1].x+0.5);
	for (i=1;i<=n;++i) ans-=1LL*a[i]*a[i]%P; return printf("%lld",ans>>1LL),0;
}

Measured memory_bytes: 20220
import sys
import collections

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    C = collections.Counter(A)

    ans = 0
    for k in range(10 ** 5 + 1):
        ans = max(ans, sum([C[k], C[k + 1], C[k - 1]]))

    print(ans)


    
    

if __name__ == '__main__':
    main()



Measured memory_bytes: 14500