akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main(){
  long long p,q,t=1,gc;
  cin >> p >> q;
  gc = gcd(p,q);
  p /= gc;
  q /= gc;
  for(int i=2;i*i<=q;i++){
    if(q%i==0){
      t*=i;
      while(q%i==0) q/=i;
    }
  }
  t*=q;
  cout << t << endl;
}



Measured memory_bytes: 3108
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	int W, a, b;
	cin >> W >> a >> b;
	int d = 0;
	if (b > a) d = max(0, b - (a + W));
	else d = max(0, a - (b + W));
	cout << d << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int h[200005];
int main(){
    int n, k;
    long long sum=0;
    cin>>n>>k;
    for(int i=0; i<n; ++i) cin>>h[i];
    sort(h, h+n);
    for(int i=0; i<n-k; ++i) sum+=h[i];
    cout<<sum;
    return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()

int n, m, ans = 0;
vector<bool> passed;
vector<vector<int>> vec;

void dfs(int now, int cnt)
{
	if (passed[now])return;
	if (cnt == n)
	{
		++ans;
		return;
	}
	passed[now] = true;
	for (int x : vec[now])
	{
		dfs(x, cnt + 1);
	}
	passed[now] = false;
	return;
}

int main()
{
	cin >> n >> m;
	vec.resize(n + 1);
	rep(i, 1, m)
	{
		int a, b; cin >> a >> b;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	passed.resize(n + 1);
	dfs(1, 1);
	cout << ans << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::cmp::min;

fn main() {
    let n: usize = read();
    let a: usize = read();
    let b: usize = read();
    let c: usize = read();
    let l: Vec<usize> = (0..n).map(|_| read()).collect();

    let mut ans = 1 << 31;
    let po = 4_usize.pow(n as u32);
    for i in 0..po {
        let mut la = 0;
        let mut lb = 0;
        let mut lc = 0;
        let mut sum = 0;
        let mut nya = i;
        for j in 0..n {
            match nya % 4 {
                1 => {
                    sum += if la == 0 { 0 } else { 10 };
                    la += l[j];
                },
                2 => {
                    sum += if lb == 0 { 0 } else { 10 };
                    lb += l[j];
                },
                3 => {
                    sum += if lc == 0 { 0 } else { 10 };
                    lc += l[j];
                },
                _ => {},
            }
            nya /= 4;
        }
        if la == 0 || lb == 0 || lc == 0 {
            continue;
        }
        sum += if la < a { a - la } else { la - a };
        sum += if lb < b { b - lb } else { lb - b };
        sum += if lc < c { c - lc } else { lc - c };
        ans = min(ans, sum);
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

fours = 0
twos = 0
ones = 0
for i in range(N):
    if A[i] % 4 == 0:
        fours += 1
    elif A[i] % 2 == 0:
        twos += 1
    else:
        ones += 1

if twos:
    ones += 1

if ones <= fours + 1:
    print('Yes')
else:
    print('No')
 

Measured memory_bytes: 63472
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
#include<cmath>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
#define __int64 long long
ll n,k;
ll ans;
ll zero=0;
int main(){
	cin>>n>>k;

	for(ll b=1;b<=n;b++){
		ll one=max(zero,b-k);
		ans+=one*((n+1)/b);
		ans+=max((n+1)%b-k,zero);
		//cout<<b<<" "<<one*(n+1)/b<<" "<<max(zero,(n+1)%b-k)<<endl;
	}
	if(k==0)ans-=n;
	cout<<ans<<endl;
	return 0;
}


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

int N,K;
int main(){
  cin>>N>>K;
  vector<int> data(N);
  vector<int> dp(N);
  vector<int> comp(K);
  for(int i=0;i<N;i++){
    cin>>data[i];
    for(int j=0;j<K;j++){
      if(i-j<1){
        comp[j]=2147483640; continue;
      }
      comp[j]=abs(data[i]-data[i-1-j])+dp[i-1-j];
    }
    sort(comp.begin(),comp.end());
    dp[i]=comp[0];
    if(i==0) dp[i]=0;
  }
  cout << dp[N-1]<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;
const ll MAX = 2 * 100010;

int N;
ll A[MAX];

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

    for (int i=0; i<N; i++) {
        A[i+1] += A[i];
    }

    ll answer = 1e18;
    for (int i=2; i<N; i++) {
        int left = 0;
        int right = i;
        while (1 < right - left) {
            int mid = (right + left)/2;
            if (A[mid] < A[i] - A[mid]) {
                left = mid;
            } else {
                right = mid;
            }
        }
        ll B = A[left];
        ll C = A[i] - A[left];
        ll B2 = A[right];
        ll C2 = A[i] - A[right];
        ll lmin = min(B,C);
        ll lmax = max(B,C);
        if (abs(B2-C2) < abs(B-C)) {
            lmin = min(B2,C2);
            lmax = max(B2,C2);
        }

        left = i;
        right = N;
        while (1 < right - left) {
            int mid = (right + left)/2;
            if (A[mid] - A[i] < A[N] - A[mid]) {
                left = mid;
            } else {
                right = mid;
            }
        }
        ll D = A[left] - A[i];
        ll E = A[N] - A[left];
        ll D2 = A[right] - A[i];
        ll E2 = A[N] - A[right];
        ll rmin = min(D,E);
        ll rmax = max(D,E);
        if (abs(D2-E2) < abs(D-E)) {
            rmin = min(D2,E2);
            rmax = max(D2,E2);
        }
        answer = min(answer, max(lmax, rmax) - min(lmin, rmin));
    }
    cout << answer << endl;
}


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

int main(){
    int n,m=0,c=0,a=1;
    cin>>n;
    for(int i=1;i<=n;i++){
        for(int j=i;;j>>=1){
            if(j%2!=0) break;
            c++;
        }
        if(m<c){
            m=c;
            a=i;
        }
        c=0;
    }
    cout<<a<<endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int t[110000], x[110000], y[110000]; //0だらけの配列を宣言
  t[0] = x[0] = y[0] = 0; //初期状態
  for (int i=0; i<N; i++) cin >> t[i+1] >> x[i+1] >> y[i+1];
  bool can = true;
  for (int i=0; i<N; i++) {
    int dt = t[i+1] - t[i]; //移動にかけられるステップ数
    int dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i]); //移動すべき距離(絶対値)
    if (dt < dist) {
      can = false;
    }
    if ((dist % 2) != (dt % 2)) { //dtとdistの偶奇が一致する必要がある
      can = false;
    }
  }
    
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 4760
// Problem : A - Plural Form
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 200005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
void solve()
{	
	string s;
	cin >> s;
	if(s.back() != 's')
	{
		s += 's';
		cout << s ;
	}
	else{
		s += 'e';
		s += 's';
		cout << s;
	}
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3680
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    ll x;
    string str;
    cin>>n>>m>>x;
    vector<vector<ll>> v(n,vector<ll> (m));
    vector<ll> cost(n);
    rep(i,n){
        cin>>cost[i];
        rep(j,m){
            cin >> v[i][j];
        }
    }
    for (int bit = 0; bit < (1 << n); ++bit) {
        int sum[m];
        ll karisum=0;

        rep(i,m) sum[i]=0;
        for (int i = 0; i < n; ++i) {
            if (bit & (1 << i)) {
                rep(j,m){
                sum[j] += v[i][j];
                }
                karisum+=cost[i];

            }
        }
        //cout<<bit<<" ";
        //rep(i,m) cout<<sum[i]<<" ";
        //cout<<endl;
        // 判定
        f=1;
        rep(i,m){
            if(sum[i]<x) f=0;
            //karisum+=cost[i];
        }
        //cout<<karisum<<endl;
        if(f==1) mini=min(mini,karisum);
    }
    if(mini==INF) cout<<-1<<endl;
    else cout<<mini<<endl;

    return 0;
}


Measured memory_bytes: 3664
#include <cstdio>
#include <cctype>
#include <utility>
#include <string>
#include <algorithm>
using namespace std;

const auto gcu = getchar_unlocked;
const auto pcu = putchar_unlocked;
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _ot _il void out
#define _ol _il void outl
_ot(bool b) {pcu('0'+b);}
_ot(const char *s){while(*s)pcu(*s++);}
_ot(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_ot(string s){for(char c:s)pcu(c);}
#endif
_T _ot(T n){static char buf[20];char *p=buf;if(n<0)pcu('-'),n*=-1;
	if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10; while (p!=buf)pcu(*--p);}
_ol(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _ot(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _ot(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _ol(T&&... t){out(move(t)...);outl();}

int main() {
	for (char c; c = gcu(), c != '0';) {
		string s; scan(s);
		int A = count(s.begin(), s.end(), 'A'),
			B = s.size() - A;
		(A > B ? A : B)++;
		outl(A, ' ', B);
	}
}


Measured memory_bytes: 2628
program main
  implicit none
  integer :: A, B, K
  integer :: ndiv, ndiv_b
  integer,allocatable  :: divisor(:)
  integer,allocatable  :: divisor_b(:)
  integer :: i,j 
  read (*,*) A, B, K
  !
  ndiv = 0
  do i = 1, A
     if ( mod(A,i) == 0) then
        ndiv = ndiv + 1
     end if
  end do
  allocate( divisor(ndiv) )
  ndiv = 0
  do i  = 1, A
     if ( mod(A,i) == 0) then
        ndiv = ndiv + 1
        divisor(ndiv) = i
     end if
  end do
  !
  ndiv_b = 0
  do i = 1, B
     if ( mod(B,i) == 0) then
        ndiv_b = ndiv_b + 1
     end if
  end do
  allocate( divisor_b(ndiv_b) )
  ndiv_b = 0
  do i  = 1, B
     if ( mod(B,i) == 0) then
        ndiv_b = ndiv_b + 1
        divisor_b(ndiv_b) = i
     end if
  end do
  !
  if ( ndiv > ndiv_b ) then
     ndiv_b = 0
     do i = ndiv,1,-1
        if ( mod(B,divisor(i)) == 0)then
           ndiv_b = ndiv_b + 1
           if (ndiv_b == K ) then
              write(*,'(i0)') divisor(i)
              stop
           end if
        end if
     end do
  else
     ndiv = 0
     do i = ndiv_b,1,-1
        if ( mod(A,divisor_b(i)) == 0)then
           ndiv = ndiv + 1
           if (ndiv == K ) then
              write(*,'(i0)') divisor_b(i)
              stop
           end if
        end if
     end do
  end if
  deallocate( divisor, divisor_b )
end program main


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

int main() {
	long long n;

	std::cin >> n;

	long long ans = n - 1;

	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0) {
			ans = std::min(ans, (i - 1) + (n / i - 1));
		}
	}

	std::cout << ans << std::endl;

	return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, x);
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

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

int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(void) {
  string a, b, c;
  cin >> a >> b >> c;
  transform(all(a), a.begin(), ::toupper);
  transform(all(b), b.begin(), ::toupper);
  transform(all(c), c.begin(), ::toupper);
  char aa = a.at(0);
  char bb = b.at(0);
  char cc = c.at(0);
  cout << aa << bb << cc << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    ll N;
    cin>>N;
    ll ans=LONG_MAX;
    for(ll i=1;i<=sqrt(N);i++){
        if(N%i){
            continue;
        }
        ll temp=N/i;
        //cout<<temp<<endl;
        ll d=abs(i-1)+abs(temp-1);
        ans=min(ans,d);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
A,B,C = map(int,input().split())

ans = 0
while not(A%2 or B%2 or C%2):
    A,B,C = B//2+C//2, A//2+C//2, A//2+B//2
    if(A == B == C):
        print(-1)
        exit()
    ans += 1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll a,b;
    cin>>a>>b;
    if(a==b)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp std::make_pair

typedef std::pair<int,int> pi;

const int N=200005;
const int inf=1e9;

int n,a[N],b[N],tot,id1[N],id2[N],cnt,last[N],s,t,cur[N],dis[N],val[N];
bool vis[N];
struct edge{int to,next,c;}e[N*10];
std::queue<int> que;

void addedge(int u,int v,int c)
{
    e[++cnt].to=v;e[cnt].c=c;e[cnt].next=last[u];last[u]=cnt;
    e[++cnt].to=u;e[cnt].c=0;e[cnt].next=last[v];last[v]=cnt;
}

bool bfs()
{
    for (int i=s;i<=t;i++) dis[i]=0;
    while (!que.empty()) que.pop();
    dis[s]=1;que.push(s);
    while (!que.empty())
    {
        int u=que.front();que.pop();
        for (int i=last[u];i;i=e[i].next)
            if (e[i].c&&!dis[e[i].to])
            {
                dis[e[i].to]=dis[u]+1;
                if (e[i].to==t) return 1;
                que.push(e[i].to);
            }
    }
    return 0;
}

int dfs(int x,int maxf)
{
    if (x==t) return maxf;
    int ret=0;
    for (int &i=cur[x];i;i=e[i].next)
        if (e[i].c&&dis[e[i].to]==dis[x]+1)
        {
            int f=dfs(e[i].to,std::min(e[i].c,maxf-ret));
            e[i].c-=f;
            e[i^1].c+=f;
            ret+=f;
            if (maxf==ret) break;
        }
    return ret;
}

int dinic()
{
    int ans=0;
    while (bfs())
    {
        for (int i=s;i<=t;i++) cur[i]=last[i];
        ans+=dfs(s,inf);
    }
    return ans;
}

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),a[i]++;
	for (int i=1;i<=n;i++) scanf("%d",&b[i]),b[i]++;
	for (int i=1;i<=n;i++)
	{
		if (vis[i]) continue;
		tot++;
		int x=i;
		while (!vis[x]) vis[x]=1,id1[x]=tot,x=a[x];
	}
	int tmp=tot;
	memset(vis,0,sizeof(vis));
	for (int i=1;i<=n;i++)
	{
		if (vis[i]) continue;
		tot++;
		int x=i;
		while (!vis[x]) vis[x]=1,id2[x]=tot,x=b[x];
	}
	s=0;t=tot+1;cnt=1;
	int ans=n;
	for (int i=1;i<=n;i++)
		if (a[i]==b[i]&&a[i]==i) ans--;
		else if (a[i]==i) val[id2[i]]++;
		else if (b[i]==i) val[id1[i]]++;
		else if (a[i]!=b[i]) addedge(id1[i],id2[i],1);
		else addedge(id1[i],id2[i],1),addedge(id2[i],id1[i],1);
	for (int i=1;i<=tmp;i++) addedge(i,t,val[i]);
	for (int i=tmp+1;i<=tot;i++) addedge(s,i,val[i]);
	printf("%d\n",ans-dinic());
	return 0;
}

Measured memory_bytes: 15104
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define MOD 1000000007

using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

void add(i64 &a,i64 b)
{
  a+=b;
if(a>=MOD)
a-=MOD;
}
void mul (i64 &a,i64 b)
{
  a*=b;
  a%=MOD;
}
  int main()
  {
ios::sync_with_stdio(false);
    cin.tie(nullptr);

    // ifstream fin(".in");
    // ofstream fout(".in");
i64 n;
string s;
cin>>n;
cin>>s;
vi64 dp(n+1,0);
i64 count[26];
memset(count,0LL,sizeof(count));
dp[0]=1;
count[s[0]-'a']++;
for1(i,n-1)
{
  dp[i]=dp[i-1];


  i64 len=1;
  forn(j,26)
  {
    if(j!=s[i]-'a')
    mul(len,count[j]+1);
  }
  add(dp[i],len);
  count[s[i]-'a']++;


}

cout<<dp[n-1];


    return 0;
  }


Measured memory_bytes: 1232
import math
n = int(input())
li = list(map(int,input().split()))#[1, 2, 3]
snum = sum(li[1:])
#li.append(0)
#print(snum)
mod = (10**9+7)
res = 0
ren = 1

for v in li:
    res += (v*snum)
    if ren < len(li):
        snum-=li[ren]
        ren+=1
print(res%mod)

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

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

bool check (string a, string b) {
  for (int i = 0; i < a.size(); ++i) {
    if (a[i] != '?' && a[i] != b[i]) return false;
  }
  return true;
}

int main() {
  string s, t;
  while (cin >> s >> t) {
    int a = s.size();
    int b = t.size();
    bool ok = false;
    string ans = string(a, '{');

    for (int i = 0; i + b <= a; ++i) {
      if (check(s.substr(i, b), t)) {
        string k = s.substr(0, i) + t + s.substr(i + b);
        ans = min(ans, k);
      }
    }

    for (int i = 0; i < a; ++i) if (ans[i] == '?') ans[i] = 'a';
    cout << (ans[0] == '{' ? "UNRESTORABLE" : ans) << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

// 3
// 1 0 0

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

  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }

  vector<int> r(n + 1);

  vector<int> ans;

  for (int i = n; i >= 1; i--) {
    ll sum = 0;
    for (int j = i; j <= n; j += i) {
      sum += r[j];
    }

    // cout << sum << endl;

    bool even1 = (sum % 2 == 0);
    bool even2 = a[i] == 0;

    // cout << "i:" << i << endl;
    // cout << "a[i]:" << a[i] << endl;

    if (even1 != even2) {
      r[i] = 1;
      ans.emplace_back(i);
    }
  };

  // for (int i = 1; i < a.size(); i++) {
  //   cout << a[i] << endl;
  // }

  // cout << "====" << endl;

  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    if (i > 0) {
      cout << " ";
    }
    cout << ans[i];
  }
}


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

int main()
{
	long long n;
	cin>>n;
	int sum=0;
	int x=n;
	while(x>0){
		sum+=x%10;
		x/=10;
	}
	if (n%sum==0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;

int main(){
  int n,a,b;
  scanf("%d%d%d",&n,&a,&b);
  cout << min(n*a,b) << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int N, T;
vector<pair<int, int>> ab;

vector<long long> a0;

int dp[200001][32];


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

	cin >> N >> T;
	rep(i,N) {
		int a, b;
		cin >> a >> b;
		if (a == 0)a0.push_back(b);
		else ab.emplace_back(a, b);
	}
	sort(all(a0));
	if(!a0.empty()) a0[0]++;
	for (int i = 1; i < a0.size(); i++) a0[i] += a0[i - 1] + 1;

	sort(all(ab), [](pair<int, int> x, pair<int, int> y) {
		return (long long)x.first* (y.second + 1) > (long long)y.first * (x.second + 1); }
	);

	rep(i, N + 1)rep(j, 32)dp[i][j] = T + 1;
	dp[0][0] = 0;

	int ans = (int)(upper_bound(all(a0), T) - a0.begin());
	rep(i, ab.size())rep(j, 32) if(dp[i][j] != T + 1) {
		int t = dp[i][j];

		dp[i + 1][j] = min(dp[i + 1][j], t);
		long long nt = t + 1 + (long long)ab[i].first * (t + 1) + ab[i].second;
		if (T < nt)continue;
		assert(j < 31);

		dp[i + 1][j + 1] = min(dp[i + 1][j + 1], (int)nt);
		ans = max(ans, j + 1 + (int)(upper_bound(all(a0), T - nt) - a0.begin()));
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 26992
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    
    //Declaration
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] L = new int[N];
    for(int i=0; i<N; i++) {
      L[i] = sc.nextInt();
    }
    int cnt=0;
    
    //a+b>c is absolutely required for making Triangle;
    if(N==2){
            System.out.println(0);
            return;
           }
    
    for(int i=0; i<N; i++){
      for(int j=i+1; j<N; j++){
        for(int k=j+1; k<N; k++){
          if(L[i]+L[j]>L[k]&&L[i]+L[k]>L[j]&&L[j]+L[k]>L[i]&&L[i]!=L[j]&&L[i]!=L[k]&&L[j]!=L[k])
           {
            cnt++;
           } 
          }
        }
      }
    System.out.println(cnt);
  }
}

Measured memory_bytes: 36640
#include <cstdio>
#include <cstring>
using namespace std;
char s[105];
int n;
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=(n+1)/2,j=(n+1)/2;i>0;--i,++j)
	{
		if(s[i]!=s[j])
		{
			printf("No");
			return 0;
		}
	}
	for(int i=1,j=(n-1)/2;i<=j;++i,--j)
	{
		if(s[i]!=s[j])
		{
			printf("No");
			return 0;
		}
	}
	for(int i=(n+3)/2,j=n;i<=j;++i,--j)
	{
		if(s[i]!=s[j])
		{
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 128
x, y = map(int, input().split())

A = [1, 3, 5, 7, 8, 10, 12]
B = [4, 6, 9, 11]
C = [2]

if x in A and y in A:
    print("Yes")
elif x in B and y in B:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
import numpy as np
 
n, m, c = map(int, input().split())
 
b = list(map(int, input().split()))
num = 0
 
for i in range(n):
  A = list(map(int, input().split()))
  npb = np.array(b)
  npA = np.array(A)
  if np.dot(npA.T, npb) + c > 0:
    num += 1
    
print(num)

Measured memory_bytes: 21148
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    H,W = inputMap()
    C = []
    for i in range(H):
        c = input()
        C.append(c)
        
    for i in C:
        print(i)
        print(i)
    
if __name__ == "__main__":
	main()


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

int main(){
  int L,R;
  cin>>L>>R;
  int ans=0;
  for(int a=1;a<10;a++){
    for(int b=0;b<10;b++){
      for(int c=0;c<10;c++){
        int x=10001*a+1010*b+100*c;
        if(x>=L && x<=R){
          ans++;
        }
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout.precision(20);

  vector<int> a(5);
  REP(i,5) cin >> a[i];
  
  vec b(5);
  REP(i,5) b[i] = (a[i] % 10 != 0 ? 10 - (a[i] % 10) : 0);

  auto it = *max_element(b.begin(), b.end());

  int ans = 0;
  REP(i,5){
    ans += a[i] + b[i];
  }

  cout << ans - it << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> k(m),p(m);
    vector<vector<int>> s(m);
    rep(i,m) {
        cin >> k[i];
        s[i].resize(k[i]);
        rep(j,k[i]) cin >> s[i][j];
        rep(j,k[i]) s[i][j]--;
    }
    rep(i,m) cin >> p[i];
    int ans = 0;
    rep(i,1<<n) {
        bool ok = true;
        rep(j,m) {
            int cnt = 0;
            for(int ns : s[j]) if(i & 1<<ns) cnt++;
            if(cnt%2 != p[j]) ok = false;
        }
        if(ok) ans++;
    }
    cout << ans << endl;
}

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

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

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long a = in.nextLong();
            long b = in.nextLong();

            long[] h = in.nextLongArray(n);
            long high = (long) 1e9;
            long low = 0;
            while (high - low > 1) {
                long mid = (high + low) / 2;

                long sum = 0;
                for (int i = 0; i < n; i++) {
                    if (h[i] > mid * b) {
                        sum += (h[i] - mid * b + (a - b) - 1) / (a - b);
                    }
                }

                if (sum <= mid) {
                    high = mid;
                } else {
                    low = mid;
                }
            }

            out.println(high);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public long nextLong() {
            return Long.parseLong(nextString());
        }

        public long[] nextLongArray(int n) {
            long[] res = new long[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextLong();
            }
            return res;
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 36936
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int ans = 0, sum = 0;
  rep(i, n) {
    if (a[i] == 0) {
      ans += sum / 2;
      sum = 0;
    }
    sum += a[i];
  }
  ans += sum / 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef  unsigned long long ull;
ull p=1e18;
int main()
{
  ull n,sum=1,i,x,c=0,flag=0;
 
  cin>>n;
  
  for(i=0;i<n;i++)
  {
    cin>>x;
    
    if(x>0 && !c)
    {
    if(x<=p/sum)
      sum*=x;
    else
      flag=1;
    }
    else
      c=1;
  }
 
    if(c)
      cout<<0;
   else if(flag)
      cout<<-1;
    else
      cout<<sum;
   return 0;
}

Measured memory_bytes: 3648
def solve():
    list_of_abc = read()
    result = think(list_of_abc)
    write(result)


def read():
    n = read_int(1)[0]
    list_of_abc = []
    for i in range(n):
        list_of_abc.append(read_int(3))
    return list_of_abc


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(list_of_abc):
    dp = [[0 for abc in range(3)] for n in range(len(list_of_abc))]
    dp[0][0] = list_of_abc[0][0]
    dp[0][1] = list_of_abc[0][1]
    dp[0][2] = list_of_abc[0][2]

    for i in range(1, len(list_of_abc)):
        dp[i][0] = max(dp[i - 1][1] + list_of_abc[i][0], dp[i - 1][2] + list_of_abc[i][0])
        dp[i][1] = max(dp[i - 1][0] + list_of_abc[i][1], dp[i - 1][2] + list_of_abc[i][1])
        dp[i][2] = max(dp[i - 1][0] + list_of_abc[i][2], dp[i - 1][1] + list_of_abc[i][2])

    return max(dp[-1][0], dp[-1][1], dp[-1][2])


def write(result):
    print(result)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 44484
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(){
	kaijo[0]=1;
	for(int i=1;i<=2000000;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}

int comb(int a,int b){
	if(!kaijo[0])init_fact();
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
	x=modpow(x,MOD-2);
	return x;
}

double dist(double ax,double ay,double bx,double by){
	return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}
signed main(){
	int n,a[200010];
	int sum=0,cnt=0,ans=INF;
	cin>>n;
	rep(i,n){
		cin>>a[i];
		sum+=a[i];
	}
	rep(i,n){
		ans=min(ans,abs(sum-cnt));
		sum-=a[i],cnt+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define f first
#define s second
#define endl "\n"
#define M 1000000007
#define pb push_back
#define pf push_front
#define eb emplace_back
#define MM_PI 3.14159265358979323846
#define TEST_CASE int t;cin>>t;while(t--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
template<typename T> T pow(T a, T b, long long m) {T ans = 1; while (b > 0) { if (b % 2 == 1) ans = (ans * a) % m; b /= 2; a = (a * a) % m; } return ans % m; }

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;

const int maxn = 1e5 + 10;
int bp[3003][3003];
int dp[3003 + 10][3003 + 10];
string ans = "";
string str1, str2;
void fun(int i, int j) {
	if (i == 0 or j == 0)return;
	if (str1[i - 1] == str2[j - 1]) {
		ans += str1[i - 1];
		fun(i - 1, j - 1);
	}
	else if (dp[i - 1][j] >= dp[i][j - 1]) {
		fun(i - 1, j);
	}
	else {
		fun(i, j - 1);
	}

}
void solve() {
	//string str1, str2;
	cin >> str1;
	cin >> str2;
	int n = str1.length(), m = str2.length();

	for (int i = 0; i <= n; i++)
		dp[i][0] = 0;
	for (int i = 0; i <= m; i++)
		dp[0][i] = 0;

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (str1[i - 1] == str2[j - 1]) {
				dp[i][j] = dp[i - 1][j - 1] + 1;
				bp[i][j] = 3;
			}
			else {
				if (dp[i - 1][j] > dp[i][j - 1]) {
					bp[i][j] = 2;
					dp[i][j] = dp[i - 1][j];
				}
				else {
					bp[i][j] = 1;
					dp[i][j] = dp[i][j - 1];
				}
			}
		}
	}
	// for (int i = 0; i <= n; i++) {
	// 	for (int j = 0; j <= m; j++) {
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	// cout << endl;
	// for (int i = 0; i <= n; i++) {
	// 	for (int j = 0; j <= m; j++) {
	// 		cout << bp[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	fun(n, m);
	reverse(ans.begin(), ans.end());
	cout << ans << endl;

}
int main() {

	//IOS
	//make();
	//TEST_CASE
	solve();
	return 0;
}



Measured memory_bytes: 70912
module Array = ArrayLabels
module List = ListLabels

let inf = 10000000000
let (>>=) x f = List.map f x |> List.concat

let () =
  Scanf.scanf "%d" @@ fun n ->
  let xyds = Array.init n (fun _ -> Scanf.scanf " %d %d %s" (fun x y d -> 2*x, 2*y, d)) in

  let find_edges axis dir =
    Array.fold_left xyds ~init:(inf, -inf) ~f:(fun (minv, maxv) (x, y, d) ->
      let v = match axis with `X -> x | `Y -> y in
      if d = dir then (min minv v, max maxv v) else (minv, maxv))
  in 
  let exs =
    [("R", 1); ("L", -1); ("U", 0); ("D", 0)]
    |> List.map ~f:(fun (d, m) -> let x1, x2 = find_edges `X d in (x1, x2, m)) in
  let eys =
    [("R", 0); ("L", 0); ("U", 1); ("D", -1)]
    |> List.map ~f:(fun (d, m) -> let y1, y2 = find_edges `Y d in (y1, y2, m)) in

  let area_of_time (t : int) =
    let xm, xM = List.fold_left exs ~init:(inf, -inf) ~f:(fun (xm, xM) (x1, x2, mul) ->
      (min xm (x1 + mul * t), max xM (x2 + mul * t))) in
    let ym, yM = List.fold_left eys ~init:(inf, -inf) ~f:(fun (ym, yM) (y1, y2, mul) ->
      (min ym (y1 + mul * t), max yM (y2 + mul * t))) in
    (xM - xm) * (yM - ym)
  in

  let ts =
    (exs @ eys) >>= fun (va1, va2, da) ->
    (exs @ eys) >>= fun (vb1, vb2, db) ->
      if da = db then []
      else
        [va1; va2] >>= fun va ->
        [vb1; vb2] >>= fun vb ->
          if abs va + abs vb >= inf then []
          else [abs @@ (va - vb) / (da - db)] in

  let ans =
    List.map area_of_time ts
    |> List.fold_left ~f:min ~init:(area_of_time 0) in
  Printf.printf "%.11f\n" (float_of_int ans /. 4.)


Measured memory_bytes: 8704
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
	int n;
	cin >> n;
	int sum = 0;
	int tmp;
	REP(i, n){
		cin >> tmp;
		sum += tmp - 1;
	}

	cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n; cin >> n;
	map<int, int> mp;
	REP(i, n)
	{
		int a; cin >> a;
		mp[a]++;
	}
	int ans = 0;
	FOR(i, 1, 111111)
	{
		chmax(ans, mp[i] + mp[i - 1] + mp[i + 1]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5504
#include <iostream>

using namespace std;


int main()
{
	int N, X, T;
	cin >> N >> X >> T;

	int sum_ = 0;
	while (N > 0)
	{
		sum_ += T;
		N = N - X;
	}
	cout << sum_ << endl;
	return 0;
}

Measured memory_bytes: 3136
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <cmath>
#include <map>
using namespace std;
#define LL long long

int n, m;
char s[105][105];

int main()
{
    while(cin >> n >> m)
    {
        map<char, int> mapp;
        int flag = 1;
        for(int i = 0; i < n; ++i)
        {
            for(int j = 0; j < m; ++j)
            {
                cin >> s[i][j];
                mapp[s[i][j]]++;
            }
        }
        int sum4 = 0, sum2 = 0, sum1 = 0;
        for(int i = 'a'; i <= 'z'; ++i)
        {//cout << mapp[i] << endl;
            if(mapp[i] >= 4)
            {
                sum4 += mapp[i] / 4;
                sum2 += (mapp[i] % 4) / 2;
                sum1 += (mapp[i] % 2);
            }
            else if(mapp[i] >= 2)
            {
                sum2 += (mapp[i]) / 2;
                sum1 += (mapp[i] % 2);
            }
            else sum1 += mapp[i];//cout << sum4 << ".." << sum2 << ".." << sum1 << endl;
        }
        sum4 -= (m / 2) * (n / 2);
        if(sum4 < 0) flag = 0;
        sum2 += sum4 * 2; //cout << sum2 << endl;
        sum4 = 0;
        if(n % 2 == 1 && m % 2 == 0)
        {
            sum2 -= m / 2;
            if(sum4 != 0 || sum2 != 0 || sum1 != 0)
                flag = 0;//cout << sum4 << ".." << sum2 << ".." << sum1 << endl;
        }
        else if(n % 2 == 0 && m % 2 == 1)
        {
            sum2 -= n / 2;
            if(sum4 != 0 || sum2 != 0 || sum1 != 0)
                flag = 0;
        }
        else if(n % 2 && m % 2)
        {
            sum2 -= (n / 2 + m / 2);
            sum1--;
            if(sum4 != 0 || sum2 != 0 || sum1 != 0)
                flag = 0;
        }
        if(flag) printf("Yes\n");
        else printf("No\n");
    }
}


Measured memory_bytes: 256
import java.io.IOException;

public class Main {
	public static void main(String[] args) throws IOException {
		StringBuilder ans = new StringBuilder();
		int[] index = new int[] {-1, -1, -1, -1};
		int cha;
		int counter =0;
		while ( (cha = System.in.read()) != -1) {
			if (cha == '0') {
				counter++;
			} else if (cha == '1') {
				counter++;
				for (int i=0; i < 4; i++) {
					if (index[i] == -1) {
						index[i] = counter;
						break;
					}
				}
			}

			if (counter == 64) {
				ans.append(getans(index) + "\n");
				index = new int[] { -1, -1, -1, -1 };
				counter = 0;
			}
		}

		System.out.print(ans);
	}

	public static String getans(int[] index) {
		if (index[0]+1 == index[1]) {
			if (index[1]+1 == index[2]) {
				return "C";
			} else if (index[1]+7 == index[2]) {
				return "A";
			} else if (index[1]+8 == index[2]) {
				return "E";
			} else if (index[1]+6 == index[2]) {
				return "G";
			}
		} else if (index[0]+7 == index[1]) {
			return "D";
		} else if (index[0]+8 == index[1]) {
			if (index[1]+1 == index[2]) {
				return "F";
			} else {
				return "B";
			}
		}
		return "hoge";
	}
}

Measured memory_bytes: 23900
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
ll a[100];
ll C(int x,int y){
    ll ret=1;
    for(int i=1;i<=y;i++)
        ret=ret*(x-i+1)/i;
    return ret;
}
int main(){
    int n,l,r,bk,ss,i,j;
    double ans=0;
    ll sum=0;
    scanf("%d %d %d",&n,&l,&r);
    for(i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+n+1,greater<ll>());
    bk=n+1;
    for(i=2;i<=n;i++) if(a[i]!=a[i-1]){bk=i;break;}
    ss=bk-1;
    ans=0;
    for(i=1;i<=l;i++) ans+=a[i];
    ans/=l;
    printf("%.6lf\n",ans);
    for(i=l;i&&a[i]==a[l];i--);i++;
    for(j=l;j<=n&&a[j]==a[l];j++);j--;
    sum=C(j-i+1,l-i+1);
    for(i=l+1;i<=r&&i<bk;i++) sum+=C(ss,i);
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;

void solve(){
    int n, m, p, num_ac=0, num_wa=0;
    string s;
    cin >> n >> m;
    map<int, int> wa;
    map<int, bool> ac;
    for(int i=0; i<m; i++){
        cin >> p >> s;
        if(ac[p]) continue;
        else if(s == "WA"){
            wa[p]++;
        }else{
            ac[p] = true;
            num_ac++;
            num_wa += wa[p];
        }
    }
    cout << num_ac << ' ' << num_wa << endl;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(16);
    
    solve();

    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x 2.0)
// vector<vector<int>> data(i, vector<int>(j))
// vector<vector<vector<char>>> data(N, vector<vector<char>>(3, vector<char>(3)))


int main() {
  vector<int> v(3);
  cin >> v[0] >> v[1] >> v[2];
  sort(v.begin(), v.end());
  if((v[1]==v[0] && v[1] != v[2])||(v[1] == v[2] && v[0] != v[1])){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}


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

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

    int maxMat = 0;
    for (int i = 0; i <= S.size() - T.size(); i++) {
        int match = 0;
        for (int j = 0; j < T.size(); j++) {
            if (S[i + j] == T[j]) {
                match++;
            }
        }
        maxMat = max(match, maxMat);
    }
    cout << T.size() - maxMat;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define deb(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;

typedef long double ll;
typedef string str;

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

void fast(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main ()
{
	ll t,n,m=0,k,i,a,b,j;
	cin >> n >> k;
	for(i=0;i<n;i++)
	{
		cin >> a >> b;
		a*=a;
		a+=(b*b);
		if(sqrtl(a)<=k)
			m++;
	}
	cout << m << "\n";
	return 0;
}

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

int main(){
    int m,n;
    while(1){
        cin>>m;
        if(m==0) break;
        set<pair<int,int> > starset;
        int dx[205],dy[205],x,y,xax = 0,yax = 0;
        for(int i=0; i<m; i++){
            cin>>x>>y;
            if(i){
                dx[i]=x-xax;
                dy[i]=y-yax;
            }else{xax=x; yax=y;}
        }
        cin>>n;
        int Nx[1001],Ny[1001];
        for(int i=0; i<n; i++){
            cin>>Nx[i]>>Ny[i];
            starset.insert(make_pair(Nx[i],Ny[i]));
        }
        for(int i=0; i<n; i++){
            int j;
            for(j=1; j<m; j++){
                if(starset.find(make_pair(Nx[i]+dx[j],Ny[i]+dy[j]))==starset.end()) break;
            }
            if(j==m) {cout<<Nx[i]-xax<<" "<<Ny[i]-yax<<endl; break;}
        }
    }
}

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

/* 
この問題は、異なる値がいくつあるか、と捉えられる。
setで重複なしの集合が作れるので、その集合のサイズを出力すれば良い。
*/

int main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  
  set<int> values;
  for (int i = 0; i < N; i++) {
    values.insert(A.at(i));
  }
  
  cout << values.size() << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main() {

int a,b,c[110][110],e,f;
   cin >> a>>b;
  
 if(a%(2*b+1) == 0){
  cout << a/(2*b+1) << endl;
 }
  
  else{
    cout <<a/(2*b+1)+1 << endl;
  }
}

Measured memory_bytes: 256