akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>

using namespace std;

template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}

template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}
#define int long long
#define left left228
#define right right228
#define prev prev228
#define mp make_pair
#define all(v) v.begin(), v.end()
#define forn(i, n) for (int i = 0; i < (int)n; ++i)
#define firn(i, n) for (int i = 1; i < (int)n; ++i)
#define x first
#define y second

const int N = 228, INF = 1e9 + 228;

bool c[N][N];
vector<int> g[N];
int d[N];

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			char C;
			cin >> C;
			c[i][j] = C - '0';
			if (C == '1') {
				g[i].push_back(j);
			}
		}
	}
	int res = -1;
	for (int s = 1; s <= n; ++s) {
		for (int i = 1; i <= n; ++i) d[i] = INF;
		d[s] = 0;
		vector<int> q; q.push_back(s);
		for (int i = 0; i < (int)q.size(); ++i) {
			int v = q[i];
			for (int to : g[v]) {
				if (d[v] + 1 < d[to]) {
					d[to] = d[v] + 1;
					q.push_back(to);
				}
			}
		}
		bool OK = 1;
		for (int i = 1; i <= n; ++i) {
			for (int j = i + 1; j <= n; ++j) {
				if (c[i][j]) {
					if (abs(d[i] - d[j]) != 1) {
						OK = 0;
						break;
					}
				}
			}
			if (!OK) break;
		}
		if (OK) {
			for (int i = 1; i <= n; ++i) {
				uax(res, d[i] + 1);
			}
		}
	}
	cout << res << '\n';
    return 0;
}


Measured memory_bytes: 768
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here

        Scanner sc = new Scanner(System.in);

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

        long[][] dp = new long[n + 1][maxW + 1];

        for (int i = 1; i <= n; i++) {
            int w = sc.nextInt();
            int v = sc.nextInt();
            dp[i] = dp[i - 1].clone();
            for (int j = 0; j <= maxW - w; j++) {
                if (dp[i - 1][j + w] == 0) {
                    dp[i][j + w] = dp[i - 1][j] + v;
                } else {
                    dp[i][j + w] = Math.max(dp[i - 1][j + w], dp[i - 1][j] + v);
                }
            }
        }

        System.out.println(dp[n][maxW]);
    }
}

Measured memory_bytes: 229076
from math import sqrt, ceil

cache = {3}
primes = {2,3}
def isprime(n):
    if n in primes:
        return True
    for i in range(3, ceil(sqrt(n))+1, 2):
        if n % i == 0:
            return False
    primes.add(n)
    return True

def prepare():
    l = 5
    r = 10**5-1
    for n in range(l, r+1, 4):
        if n in cache:
            continue
        m = (n - 1) // 2
        if isprime(m+1) and isprime(n):
            cache.add(n)

def solve(l, r):
    cnt = 0
    if l <= 3 <= r:
        cnt = 1
        l = 5
    if l % 4 == 3:
        l += 2
    for n in range(l, r+1, 4):
        if n in cache:
            cnt += 1
            continue
        m = (n - 1) // 2
        assert n % 4 == 1
        if isprime(m+1) and isprime(n):
            cache.add(n)
            cnt += 1
    return cnt

def main():
    global cache
    from bisect import bisect_left, bisect_right
    cache = sorted(cache)
    Q = int(input())
    for _ in range(Q):
        l, r = map(int, input().split())
        i = bisect_left(cache, l)
        j = bisect_right(cache, r)
        print(j-i)

prepare()
main()


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

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

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main()
{
    ll a;
    double b;
    cin >> a >> b;
    ll nb = b*100+0.5;
    cout << (a * nb) / 100 << endl;
    
    return 0;
}


Measured memory_bytes: 3680
N = int(input())
S = [list(input()) for _ in range(N)]
san = [0]*5
san[0] = sum([S[i1][0]=="M" for i1 in range(N)])
san[1] = sum([S[i2][0]=="A" for i2 in range(N)])
san[2] = sum([S[i3][0]=="R" for i3 in range(N)])
san[3] = sum([S[i4][0]=="C" for i4 in range(N)])
san[4] = sum([S[i5][0]=="H" for i5 in range(N)])

ans = 0
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1, 5):
            ans += san[i]*san[j]*san[k]
print(ans)

Measured memory_bytes: 21168
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vll = vector<long long>;
using vpi = vector<pair<int, int>>;
using pii = pair<int, int>;
using pll = pair<long long, long long>;

#define F first
#define S second
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define F0R(i, a) for (int i = 0; i < (a); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)

const char nl = '\n';
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

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

    int n, w; cin >> n >> w;
    vi a(n), b(n);
    F0R (i, n) cin >> a[i] >> b[i];
    
    vector<vll> dp(w + 1, vll(n + 1, 0));
    FOR (i, 1, w) {
        FOR (j, 1, n) {
            if (a[j - 1] <= i) {
                dp[i][j] = max(dp[i][j - 1], b[j - 1] + dp[i - a[j - 1]][j - 1]);
            } else {
                dp[i][j] = dp[i][j - 1];
            }
        }
    }
    cout << dp[w][n] << endl;
    return 0;
}


Measured memory_bytes: 82304
#include<iostream>
#include <vector>
#include <algorithm>
#include <map>

#define ll long long

using namespace std;

int main() {
	ll n, m;

	cin >> n >> m;

	vector<pair<ll, ll> > pairs(n);

	for (ll i = 0; i < n; i++) {
		ll a, b;
		cin >> a >> b;
		pairs[i] = make_pair(a, b);
	}

	// firstが小さい順、secondが小さい順にソート
	sort(pairs.begin(), pairs.end());

	ll ans = 0;

	for (int i = 0; i < n; i++)
	{
		if (pairs[i].second < m) {
			m -= pairs[i].second;
			ans += pairs[i].first * pairs[i].second;
		}
		else {
			ans += m * pairs[i].first;
			cout << ans << endl;
			return 0;
		}
	}

	
}

Measured memory_bytes: 1792
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) for(int sz=0;sz<int(vec.size());sz++) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

using PI = P<int, int>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, n; cin >> h >> n;
    V<PI> ab(n);
    for (int i = 0; i < n; i++) cin >> ab[i].first >> ab[i].second;
    V< V<int> > dp(2, V<int>(h + 1, INF));
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
        dp[1] = V<int>(h + 1, INF);
        for (int j = 0; j <= h; j++) {
            chmin(dp[1][j], dp[0][j]);
            chmin(dp[1][min(j + ab[i].first, h)], dp[1][j] + ab[i].second);
        }
        swap(dp[0], dp[1]);
    }
    cout << dp[0][h] << '\n';
    return 0;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define mod2 998244353
#pragma GCC optimize ("-O2")
#define mod3 127
#define mod 1000000007
#define MAXN 1000000000
#define v32 vector<int>
#define v64 vector<lli>
#define v1024 vector <vector <int>>
#define v4096 vector <vector <lli>>
#define vt vector
#define f(x, y, z) for (lli x = y; x < z; x++)
#define fd(x, y, z) for (lli x = y; x > z; x--)
#define lb lower_bound
#define ld long double
#define m64 map<lli,lli>
#define m32 map<int,int>
#define m64it map<lli,lli>::iterator
#define m32it map<int,int>::iterator
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ist insert
#define endl "\n"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define p_q priority_queue 
#define min_p_q priority_queue <int,vt <int>,greater <int>>
using namespace std;
using namespace __gnu_pbds; 
template <typename T> 

void DEBUG_ARR(vt<T> a)
{
	f(i,0,a.size())cout<<a[i]<<" ";
	cout<<"\n";
}
lli dp[5000][5000];
lli dp2[5000][5000];
lli power[5001],power2[5001];
int n;
bool ok(int len){
    map <int,v32> mp;
    v32 temp;
    f(i,0,n-len+1){
        if(mp.find(dp[i][i+len-1])==mp.end()){
            mp.insert({dp[i][i+len-1],temp});
            mp[dp[i][i+len-1]].pb(i);
        }
        else if(dp2[i][i+len-1]==dp2[mp[dp[i][i+len-1]][0]][mp[dp[i][i+len-1]][0]+len-1])mp[dp[i][i+len-1]].pb(i);
    }
    for(auto it:mp){
        if(it.second.size()==1)continue;
        if(it.second.back()-it.second[0]>=len)return 1;
    }
    return 0;
}
int main() 
{ 
  power[0]=1;
  f(i,1,5001)power[i]=(power[i-1]*mod2)%mod;
  f(i,1,5001)power2[i]=(power2[i-1]*mod3)%mod;
  fastio;
  cin>>n;
  string s;
  cin>>s;
  f(i,0,n){
      dp[i][i]=(s[i]-'a');
      f(j,i+1,n){
          dp[i][j]=((dp[i][j-1]+(s[j]-'a')*power[j-i])%mod+mod)%mod;
      }
  }
  f(i,0,n){
      dp2[i][i]=(s[i]-'a');
      f(j,i+1,n){
          dp2[i][j]=((dp2[i][j-1]+(s[j]-'a')*power2[j-i])%mod+mod)%mod;
      }
  }
  int l=0,r=n/2;
  while(l!=r){
    int len=(l+r)>>1;
    if(ok(len)){
        if(ok(len+1))l=len+1;
        else{
            l=len;
            break;
        }
    }
    else r=len;
  }
  cout<<l<<"\n";
  return 0; 	
}


Measured memory_bytes: 390144
#include <bits/stdc++.h>
#define Task        "test"
#define pb          emplace_back
#define fi          first
#define se          second
#define mp          make_pair
#define ll          long long
//#define int         int64_t

using namespace std;

typedef pair<ll, ll> pii;
const int N = (int)2e3 + 2;

template<typename T> class mincost_maxflow {
    struct edge {
        int to;
        T cf, cost;
    };
    int s, t;
    vector<vector<int>> adj;
    vector<edge> edges;
    vector<T> dist, trace;
    vector<bool> inq;
public:
    const T inf = numeric_limits<T>::max();
    mincost_maxflow(int n, int s, int t):
        s(s), t(t), adj(n), dist(n), inq(n), trace(n) {}
   inline void add(int u, int v, const T& cap, const T& cost) {
        adj[u].push_back(edges.size()); edges.push_back({v, cap, cost});
        adj[v].push_back(edges.size()); edges.push_back({u, 0, -cost});
   }
   bool spfa() {
        fill(dist.begin(), dist.end(), inf);
        fill(inq.begin(), inq.end(), 0);
        queue<int> q; q.push(s);
        inq[s] = 1; dist[s] = 0;
        while(q.size()) {
           int u = q.front();
           inq[u] = 0; q.pop();
           for(int i: adj[u]) {
               edge& e = edges[i];
               if(e.cf > 0 && dist[e.to] > dist[u] + e.cost) {
                  dist[e.to] = dist[u] + e.cost, trace[e.to] = i;
                  if(!inq[e.to]) q.push(e.to), inq[e.to] = 1;
               }
           }
        }
        return dist[t] < inf;
   }
   pair<T, T> get() {
       T cost = 0, flow = 0;
       while(spfa()) {
         T delta = inf;
         for(int u = t, i; u != s; u = edges[i ^ 1].to) {
            i = trace[u];
            delta = min(delta, edges[i].cf);
         }
         for(int u = t, i; u != s; u = edges[i ^ 1].to) {
            i = trace[u];
            edges[i].cf -= delta, edges[i ^ 1].cf += delta;
         }
         cost += dist[t] * delta, flow += delta;
       }
       return make_pair(cost, flow);
   }
};

int n, s, t, x, y, c, d[4];
/// rx bx ry by
pii db[] = {mp(-1, -1), mp(-1, 1), mp(1, -1), mp(1, 1)};
pii dr[] = {mp(1, 1), mp(1, -1), mp(-1, 1), mp(-1, -1)};

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    /// s -> n -> 4 -> n -> t
    cin >> n; s = 0, t = 2 * n + 5;
    d[0] = 2 * n + 1, d[1] = 2 * n + 2, d[2] = 2 * n + 3, d[3] = 2 * n + 4;
    mincost_maxflow<ll> flow(2 * n + 6, s, t);
    for(int i = 1; i <= n; ++i) {
        cin >> x >> y >> c;
        flow.add(s, i, c, 0);
        for(int j = 0; j < 4; ++j) flow.add(i, d[j], c, x * db[j].fi + y * db[j].se);
    }
    for(int i = 1; i <= n; ++i) {
        cin >> x >> y >> c;
        flow.add(i + n, t, c, 0);
        for(int j = 0; j < 4; ++j) flow.add(d[j], i + n, c, x * dr[j].fi + y * dr[j].se);
    }
    cout << -flow.get().fi;
}


Measured memory_bytes: 1304
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>

int main() {
	int n, m;
	std::cin >> n >> m;

	std::vector<std::vector<int>> edges(n);
	for (int i = 0; i < m; ++i) {
		int s, t;
		std::cin >> s >> t;
		--s, --t;

		edges[s].push_back(t);
	}

	for (auto&& vec : edges)
		std::sort(vec.begin(), vec.end());

	double ans = n + 1;
	
	std::vector<double> dp(n);
	for (int i = 0; i < n - 1; ++i) {
		std::fill(dp.begin(), dp.end(), 0);

		for (int j = n - 2; j >= 0; --j) {
			auto&& es = edges[j];
			if (es.size() == 1)
				dp[j] = dp[es[0]] + 1;
			else {
				double max = 0;
				int maxIdx = -1;
				for (int k = 0; k < es.size(); ++k) {
					if (dp[es[k]] > max) {
						max = dp[es[k]];
						maxIdx = k;
					}
				}
				for (int k = 0; k < es.size(); ++k)
					if (i != j || k != maxIdx)
						dp[j] += (dp[es[k]] + 1) / (es.size() - (i == j));
			}
		}

		if (dp[0] < ans)
			ans = dp[0];
	}

	std::cout << std::setprecision(10);
	std::cout << ans << std::endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>

using namespace std;

int main(){
	int n,m;
	cin >> n >> m;
	vector<long long> a(n),b(n),c(m),d(m),ans(n);
	
	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i];
	}
	
	for(int i=0;i<m;i++){
		cin >> c[i] >> d[i];
	}
	
	int min_dst;
	for(int i=0;i<n;i++){
		min_dst=1000000009;
		for(int j=0;j<m;j++){
			if(min_dst>abs(c[j]-a[i])+abs(d[j]-b[i])){
				min_dst=abs(c[j]-a[i])+abs(d[j]-b[i]);
				ans[i]=j+1;
			}
		}
	}
	
	for(int i=0;i<n;i++){
		cout << ans[i] << endl;
	}
	return 0;
	
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
D = {}
for i in range(N):
	i+=1
	D.update([(A[i-1], i)])

ans = []
for i in range(1, N+1):
	ans.append(D[i])

str_ans = list(map(str, ans))
print(' '.join(str_ans))

Measured memory_bytes: 30000
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TestApp
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var str = int.Parse(Console.ReadLine());
                var str2 = int.Parse(Console.ReadLine());
                var i = Math.Pow(str, 2);
                var j = Math.Pow(Math.Pow(str2, 2) + Math.Pow(0.5*str, 2),0.5) * str * 0.5;
                if (str == 0 && str2 == 0)
                    break;
                Console.WriteLine(i + 4*j);
            }
        }
        
    }

}


Measured memory_bytes: 9348
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
typedef long long ll;
const int maxn=200010,INF=0x3f3f3f3f;
template <typename Tp> inline int getmin(Tp &x,Tp y){return y<x?x=y,1:0;}
template <typename Tp> inline int getmax(Tp &x,Tp y){return y>x?x=y,1:0;}
template <typename Tp> inline void read(Tp &x)
{
    x=0;int f=0;char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') f=1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    if(f) x=-x;
}
struct Edge{
	int u,v;ll w;
	Edge(const int _u=0,const int _v=0,const ll _w=0ll){u=_u;v=_v;w=_w;}
	bool operator < (const Edge &b)const{return w<b.w;}
};
struct data{int v,w,nxt;}edge[maxn<<1];
int n,p,sn,rt,top,a[maxn],head[maxn],sz[maxn],mx[maxn],vis[maxn],stk[maxn];
ll ans,sum[maxn];
vector<Edge> G;
vector<Edge>::iterator itr;
struct Dsu{
	int f[maxn];
	void init(int n){for(int i=1;i<=n;i++) f[i]=i;}
	int find(int x){return f[x]==x?x:f[x]=find(f[x]);}
	int merge(int x,int y)
	{
		int fx=find(x),fy=find(y);
		if(fx==fy) return 0;
		return f[fy]=fx;
	}
}dsu;
void insert(int u,int v,int w)
{
	edge[++p]=(data){v,w,head[u]};head[u]=p;
	edge[++p]=(data){u,w,head[v]};head[v]=p;
}
void getrt(int x,int pre)
{
	sz[x]=1;mx[x]=0;
	for(int i=head[x];i;i=edge[i].nxt)
	  if(!vis[edge[i].v]&&edge[i].v^pre)
	  {
	  	getrt(edge[i].v,x);
	  	sz[x]+=sz[edge[i].v];
	  	getmax(mx[x],sz[edge[i].v]);
	  }
	getmax(mx[x],sn-sz[x]);
	if(mx[x]<mx[rt]) rt=x;
}
void input()
{
	int u,v,w;
	read(n);
	for(int i=1;i<=n;i++) read(a[i]);
	for(int i=1;i<n;i++){read(u);read(v);read(w);insert(u,v,w);}
	dsu.init(n);
	sn=n;mx[rt=0]=INF;getrt(1,1);
}
void getdis(int x,int pre)
{
	stk[++top]=x;sz[x]=1;
	for(int i=head[x];i;i=edge[i].nxt)
	  if(!vis[edge[i].v]&&edge[i].v^pre)
	  {
	  	sum[edge[i].v]=sum[x]+edge[i].w;
	  	getdis(edge[i].v,x);
	  	sz[x]+=sz[edge[i].v];
	  }
}
void dfs(int x)
{
	int id;ll mn=1e18;
	vis[x]=1;top=0;sum[x]=0ll;
	getdis(x,x);
	for(int i=1;i<=top;i++)
	  if(getmin(mn,a[stk[i]]+sum[stk[i]]))
	    id=stk[i];
	for(int i=1;i<=top;i++)
	  G.push_back(Edge(id,stk[i],a[stk[i]]+sum[stk[i]]+a[id]+sum[id]));
	for(int i=head[x];i;i=edge[i].nxt)
	  if(!vis[edge[i].v])
	  {
	  	sn=sz[edge[i].v];rt=0;
	  	getrt(edge[i].v,x);
	  	dfs(rt);
	  }
}
int main()
{
	input();
	dfs(rt);
	sort(G.begin(),G.end());
	for(itr=G.begin();itr!=G.end();++itr)
	  if(dsu.merge(itr->u,itr->v))
	    ans+=itr->w;
	printf("%lld\n",ans);
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    string s;
    cin >> s;

    for (int i = 0; i < s.size(); i += 2) {
        cout << s.at(i);
    }
    cout << endl;
}

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

int main(){
	double v, y, t;
	int n;
	while(cin >> v){
		t = v/9.8;
		y = 4.9*t*t;
		n = 0;
		while(5*n - 5 < y){
			n++;
		}
		cout << n << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    S = list(input())
    S[:4] = "2018"

    print("".join(S))

if __name__ == '__main__':
    main()


Measured memory_bytes: 61800
s = input()
s_num = [ord(s[i]) for i in range(len(s))]
s_num = set(sorted(list(s_num)))

for i in range(ord('a'), ord('z')+2):
  if i == ord('z')+1:
    print('None')
  elif i not in s_num:
    print(chr(i))
    break
  

Measured memory_bytes: 47472
n,*a=`dd`.split.map &:to_i;a.sort!;b=[0]+n.times.map{|j|a[j]*(-1)**j%24};s=24;n.times{|j|(j+1..n).each{|k|s=[s,(b[j]-b[k])%24,(b[k]-b[j])%24].min}};p s

Measured memory_bytes: 2044
#include <iostream>
#include <cstdlib>
#include <cstdio>

using namespace std;

int main(int argc, char const *argv[])
{
	unsigned int menu_time[5];
	unsigned int sum = 0;
	unsigned int shortest = 1000;
	unsigned int added[5];

	for (int i = 0; i < 5; ++i)
	{
		scanf("%d", &menu_time[i]);
	}

	for (int i = 0; i < 5; ++i)
	{
		sum += menu_time[i];

		for (int j = 0; j < 5; ++j)
		{
			if (j == i)
			{
				continue;
			}

			while ((sum + added[j]) % 10 != 0)
			{
				added[j]++;
			}

			sum += menu_time[j] + added[j];

			for (int k = 0; k < 5; ++k)
			{
				if (k == i || k == j)
				{
					continue;
				}

				while ((sum + added[k]) % 10 != 0)
				{
					added[k]++;
				}

				sum += menu_time[k] + added[k];

              	for (int l = 0; l < 5; ++l)
				{
					if (l == i || l == j || l == k)
					{
						continue;
					}

					while ((sum + added[l]) % 10 != 0)
					{
						added[l]++;
					}

					sum += menu_time[l] + added[l];

					for (int m = 0; m < 5; ++m)
					{
						if (m == i || m == j || m == k || m == l)
						{
							continue;
						}

						while ((sum + added[m]) % 10 != 0)
						{
							added[m]++;
						}

						sum += menu_time[m] + added[m];

						if (sum < shortest){
							shortest = sum;
						}

						sum -= menu_time[m] + added[m];
						added[m] = 0;

					}

					sum -= menu_time[l] + added[l];
					added[l] = 0;
				}

				sum -= menu_time[k] + added[k];
				added[k] = 0;
			}

			sum -= menu_time[j] + added[j];
			added[j] = 0;

		}

		sum -= menu_time[i];

	}

	cout << shortest << endl;
	return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    REP(i, n) cin >> h[i];
    const int INF = 1e9;
    vector<int> dp(n, INF);
    dp[0] = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 1; j <= k; j++) {
            if(i + j < n) {
                int cost = abs(h[i] - h[i + j]);
                dp[i + j] = min(dp[i + j], dp[i] + cost);
            }
        }
    }
    cout << dp[n - 1] << endl;
}


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

int bcount[1005][1005];
int wcount[1005][1005];
int bsum[1005][1005];
int wsum[1005][1005];

int main() {
  int n, k;
  cin >> n >> k;
  for (int ni = 0; ni < n; ni++) {
    int x, y;
    char c;
    cin >> x >> y >> c;
    bool black = c == 'B';
    x %= 2 * k;
    y %= 2 * k;
    if (x >= k) {
      x -= k;
      black = !black;
    }
    if (y >= k) {
      y -= k;
      black = !black;
    }
    if (black) {
      bcount[x][y]++;
    } else {
      wcount[x][y]++;
    }
  }
  for (int ki = 1; ki <= k; ki++) {
    for (int kj = 1; kj <= k; kj++) {
      bsum[ki][kj] = bsum[ki][kj - 1] + bsum[ki - 1][kj] - bsum[ki - 1][kj - 1] + bcount[ki - 1][kj - 1];
      wsum[ki][kj] = wsum[ki][kj - 1] + wsum[ki - 1][kj] - wsum[ki - 1][kj - 1] + wcount[ki - 1][kj - 1];
    }
  }
  int answer = 0;
  for (int ki = 0; ki < k; ki++) {
    for (int kj = 0; kj < k; kj++) {
      // (ki, kj) is black
      int ans1 = bsum[ki][kj];
      ans1 += bsum[k][k] - bsum[ki][k] - bsum[k][kj] + bsum[ki][kj];
      ans1 += wsum[ki][k] - wsum[ki][kj];
      ans1 += wsum[k][kj] - wsum[ki][kj];
      if (ans1 > answer) answer = ans1;
      // (ki, kj) is white
      int ans2 = wsum[ki][kj];
      ans2 += wsum[k][k] - wsum[ki][k] - wsum[k][kj] + wsum[ki][kj];
      ans2 += bsum[ki][k] - bsum[ki][kj];
      ans2 += bsum[k][kj] - bsum[ki][kj];
      if (ans2 > answer) answer = ans2;
    }
  }
  cout << answer << endl;
  return 0;
}

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

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int n;
  cin >> n;
  int a[n];
  rep(i, n) cin >> a[i];

  double sum = 0;
  rep(i, n) sum += 1.0 / a[i];
  printf("%.15f\n", 1 / sum);
  return 0;
}


Measured memory_bytes: 256
import sys
from collections import Counter

def main():
    input = sys.stdin.readline
    n = int(input())

    S1 = str(input().strip())
    c = Counter(S1)
    chrs = list(c.keys())

    for _ in range(n-1):
        s = str(input().strip())
        c_tmp = Counter(s)

        for chr_ in chrs:
            c[chr_] = min(c[chr_], c_tmp[chr_])

    ans = ''
    for chr_ in chrs:
        ans += chr_ * c[chr_]

    return ''.join(sorted(ans))


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3316
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (auto& x : a) cin >> x;

    vector<ll> is_prime(pow(*max_element(a.begin(), a.end()), 1.0 / 3.0) + 3,
                        1);
    vector<ll> primes;
    primes.reserve(is_prime.size());
    is_prime[0] = 0;
    is_prime[1] = 0;

    for (int i = 2; i < is_prime.size(); ++i) {
        if (is_prime[i]) {
            primes.push_back(i);
            for (int j = i * i; j < is_prime.size(); j += i) {
                is_prime[j] = 0;
            }
        }
    }

    map<ll, int> cnt;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < primes.size(); ++j) {
            if (primes[j] * primes[j] * primes[j] > a[i]) break;

            while (a[i] % (primes[j] * primes[j] * primes[j]) == 0) {
                a[i] /= primes[j] * primes[j] * primes[j];
            }
        }
        cnt[a[i]]++;
    }

    int ans = 0;
    if (cnt[1] > 0) ans++;

    set<ll> used;

    for (auto& x : cnt) {
        if (x.first == 1) continue;

        if (used.count(x.first)) continue;

        ll y = x.first;
        ll z = 1;
        for (int j = 0; j < primes.size(); ++j) {
            auto divide = primes[j] * primes[j];
            if (y < divide) break;
            if (y % divide == 0) {
                y /= divide;
                z *= primes[j];
            }
        }

        ll w = sqrt(y);
        if (w * w == y) {
            y = 1;
            z *= w;
        }

        z *= y * y;

        if (cnt.count(z)) {
            ans += max(x.second, cnt[z]);
            used.insert(z);
        } else {
            ans += x.second;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 7296
#include<stdio.h>
int main(){
  int unused __attribute__((unused));
  int i, cnt = 0;
  char s[4];
  unused = scanf("%s", s);

  for(i=0; i<3; i++){
    if(s[i]=='1') cnt++;
  }
  printf("%d", cnt);
  return 0;
}

Measured memory_bytes: 128
s = input()
n = len(s)
t = input()
m = len(t)
ans = []
res = []
for start in range(n):
    ok = True
    for i in range(len(t)):
        if i+start > n-1:
            ok = False
            break
        if not(t[i] == s[i+start] or s[i+start] == '?'):
            ok = False
            break
    
    
    if ok:res.append(start)
for st in res:
    string = ""
    for i in range(0,st):
        if s[i] == '?':
            string +='a'
        else:
            string += s[i]
    string += t
    for i in range(st+m,n):
        if s[i] == '?':string += 'a'
        else:string += s[i]
    ans.append(string)
if len(ans) >0:
    ans.sort()
    print(ans[0])
else:
    print('UNRESTORABLE')
        

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

string s,t;
int n,m;

// s[idx,n)
// return : 次の場所
int rec(int idx , int depth){
    int idx_  = idx;
    if(depth == 0) return idx;  // そのまま
    if(idx >= n) return -1;
    idx = rec(idx,depth-1);   // 消費 A_n-1
    if(idx == -1) return -1;
    for(int i=0;i<m;i++){
        while(idx < n and t[i] != s[idx]) idx++;
        if(idx >= n) return -1;
        // t[i] == s[idx]
        idx++;
        // s[idx,n)
        idx = rec(idx,depth-1);
        if(idx == -1) return -1;
    }
    //cout << idx_ << " " << depth << " " << idx << endl;
    return idx;
}

int main(){
    cin >> s >> t;
    n = s.size();
    m = t.size();

    //cout << rec(0,3) << endl;
    //return 0;

    int l,r;
    l = 0;
    r = n+1;
    while(r-l>1){
        int mid = (l+r)/2;
        int ret = rec(0,mid);
        //cout << mid << " " << ret << endl;
        if(ret < 0){    // NG
            r = mid;
        }else{          // OK
            l = mid;
        }
    }
    cout << l << endl;
}



Measured memory_bytes: 6428
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n,k;
  cin >> n >> k;
  vec h(n);
  for(ll i=0;i<n;i++) {
    cin >> h[i];
  }
  sort(h.begin(),h.end());
  ll ans=inf;
  for(ll i=0;i<n-k+1;i++) {
    ans=min(ans,h[i+k-1]-h[i]);
  }
  cout << ans << endl;
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003;
const ll INF=(1LL<<60);
vector<pair<int,ll>> A[MAX],B[MAX];
int stateA[MAX],stateB[MAX],N;
priority_queue<pair<ll,int>> PQ;
ll dA[MAX],dB[MAX];

void dijkstra(int u,int v){
    for(int i=0;i<N;i++){
        dA[i]=INF;
        dB[i]=INF;
        stateA[i]=0;
        stateB[i]=0;
    }
    
    dA[u]=0;
    stateA[u]=1;
    PQ.push(make_pair(0,u));
    
    while(PQ.size()){
        pair<ll,int> f=PQ.top();
        PQ.pop();
        int a=f.second;
        stateA[a]=2;
        
        if(dA[a]<f.first*(-1)) continue;
        
        for(int i=0;i<A[a].size();i++){
            int b=A[a][i].first;
            if(stateA[b]==2) continue;
            if(dA[b]>dA[a]+A[a][i].second){
                dA[b]=dA[a]+A[a][i].second;
                PQ.push(make_pair(-dA[b],b));
                stateA[b]=1;
            }
        }
    }
    
    dB[v]=0;
    stateB[v]=1;
    PQ.push(make_pair(0,v));
    
    while(PQ.size()){
        pair<ll,int> f=PQ.top();
        PQ.pop();
        int a=f.second;
        stateB[a]=2;
        
        if(dB[a]<f.first*(-1)) continue;
        
        for(int i=0;i<B[a].size();i++){
            int b=B[a][i].first;
            if(stateB[b]==2) continue;
            if(dB[b]>dB[a]+B[a][i].second){
                dB[b]=dB[a]+B[a][i].second;
                PQ.push(make_pair(-dB[b],b));
                stateB[b]=1;
            }
        }
    }
}

int main(){
    
    int M,s,t;cin>>N>>M>>s>>t;
    s--;t--;
    for(int i=0;i<M;i++){
        int u,v;
        ll a,b;
        cin>>u>>v>>a>>b;
        u--;v--;
        A[u].push_back(make_pair(v,a));
        A[v].push_back(make_pair(u,a));
        B[u].push_back(make_pair(v,b));
        B[v].push_back(make_pair(u,b));
    }
    
    dijkstra(s,t);
    
    ll D[N];
    
    for(int i=0;i<N;i++){
        D[i]=1000000000000000-dA[i]-dB[i];
    }
    
    for(int i=N-2;i>=0;i--){
        D[i]=max(D[i],D[i+1]);
    }
    
    for(int i=0;i<N;i++){
        cout<<D[i]<<endl;
    }
}


Measured memory_bytes: 20472
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n;
    cin >> n;
    int a[2][n];
    int ans[2][n];
    REP(i, 2)
    {
        REP(j, n)
        {
            cin >> a[i][j];
            ans[i][j] = 0;
        }
    }
    REP(i, 2)
    {
        REP(j, n)
        {
            if (i >= 1 && j >= 1)
            {
                ans[i][j] = max(ans[i][j - 1], ans[i - 1][j]) + a[i][j];
            }
            else if (i == 0 && j == 0)
            {
                ans[i][j] = a[i][j];
            }
            else if (j == 0)
            {
                ans[i][j] = ans[i - 1][j] + a[i][j];
            }
            else if (i == 0)
            {
                ans[i][j] = ans[i][j - 1] + a[i][j];
            }
        }
    }
    cout << ans[1][n - 1] << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	static int GCD(int p, int q){
      	if(p==-1)return q;
		if(p<q)return GCD(q, p);
		if(q==0)return p;
		return GCD(q, p%q);
	}

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int X = sc.nextInt();
		int[] x = new int[n];
		int cgcd = -1;
		for(int i=0; i<n; i++){
			x[i] = sc.nextInt();
			cgcd = GCD(cgcd, Math.abs(x[i]-X));
		}
		System.out.println(cgcd);
	}
}

Measured memory_bytes: 46980
#![allow(unused)]

use proconio::{input, fastout};
use proconio::marker::{Chars, Usize1};

fn partial_sum(xs: &Vec<i64>) -> Vec<i64> {
    return [0].iter().chain(xs.iter()).scan(0, |s, &t| {
        *s += t;
        return Some(*s);
    }).collect();
}

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        k: i64,
        xs: [i64; n],
        ys: [i64; m],
    }

    let xpsum = partial_sum(&xs);
    let ypsum = partial_sum(&ys);

    let nxmax = xpsum.iter().take_while(|&&t| t <= k).count() - 1;
    let mut nsummax = 0;
    let mut ny = 0;

    for nx in (0..=nxmax).rev() {
        while ny + 1 <= m && ypsum[ny + 1] <= k - xpsum[nx] {
            ny += 1;
        }
        nsummax = std::cmp::max(nsummax, nx + ny);
    }

    println!("{}", nsummax);
}



Measured memory_bytes: 12608
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 nn, tmp;
	cin >> nn;
	vector<pair<int64, int64>> aa(nn);
	for(int64 ii = 0;ii < nn;ii++)
	{
		cin >> tmp;
		aa[ii] = make_pair(tmp, ii + 1);
	}
	sort(aa.begin(), aa.end());
	for(int64 ii = 0;ii < nn;ii++)
	{
		cout << aa[ii].second;
		if(ii != nn  - 1)
		{
			cout << ' ';
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 4740
n = int(input())

if n == 0:
	print('0')
	exit()

i = 0
s = ''
while n != 0:
	if n % (2**(i+1)) != 0:
		s += '1'
		n -= (-2)**i
	else:
		s += '0'
	i += 1

print(s[::-1])

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;

class E
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		var map = new int[h[1]].Select(_ => read()).ToLookup(r => r[0], r => r[1]);
		var st = read();

		var u = new bool[h[0] + 1, 3];
		var q = new List<int>();
		u[st[0], 0] = true;
		q.Add(st[0]);

		for (int i = 1; q.Any(); i++)
		{
			var ps = q.ToArray();
			q.Clear();

			var m = i % 3;
			foreach (var p in ps)
				foreach (var np in map[p])
				{
					if (u[np, m]) continue;
					if (np == st[1] && m == 0) { Console.WriteLine(i / 3); return; }
					u[np, m] = true;
					q.Add(np);
				}
		}
		Console.WriteLine(-1);
	}
}


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

int main(){
        int N;
        cin >> N;
        int ans = 0;
        int tmp = 0;
        int pre_no;
        scanf("%d", &pre_no);
        int n;
        for (int i = 1; i < N; i++) {
                scanf("%d", &n);
                if (n <= pre_no) {
                        tmp++;
                } else {
                        if (tmp > ans) {
                                ans = tmp;
                        }
                        tmp = 0;
                }
                pre_no = n;
        }
        if (tmp > ans ) ans = tmp;

        cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;
using namespace std;

int main() {
    long long n = 0;
    cin >> n;
    string s = to_string(n);
    int sum = 0;
    for (char c : s) {
        sum += c - '0';
    }
    if (n%sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if(n==0 && m==0)break;
			int[] p = new int[n];
			
			for(int i=0;i<n;i++){
				p[i] = sc.nextInt();
			}
			Arrays.sort(p);
			
			int sum = 0;
			int count = 0;
			for(int i=n-1;i>=0;i--){
				if(count==m-1){
					count=0;
				}else{
					sum += p[i];
					count++;
				}
			}
			System.out.println(sum);
		}
	}	
}

Measured memory_bytes: 54716
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n; cin >> n;
    ll a[n];
    rep(i, n){
        cin >> a[i];
    }

    ll temp = 0;
    ll ans = 0;
    rep(i, n){
        if(a[i] == 0){
            ans += temp / 2;
            temp = 0;
        }
        else{
            temp += a[i];
        }
    }
    ans += temp / 2;

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    string s; cin >> s;
    ll N = s.size();
    map<char, ll> mp;

    for(auto e:s) ++mp[e];

    ll ans = 1+N*(N-1)/2;
    for(auto itr=mp.begin(); itr!=mp.end(); ++itr){
        ans -= itr->second*(itr->second-1)/2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(){
    long int n, i;
    cin >> n;

    for(i=4;i<=n/16;i+=2){
        if(i%n==0){
            cout << i << endl;
            break;
        }
    }
    if(n%2==0){
        cout << n << endl;
    } else {
        cout << n*2 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define I(i,n)for(int i=0;i<n;i++)
long long M=1e9+7,n,a[2],s[100000],w[2][100001],e[2],l[2][100000],p,v[2];
int main(){
	std::cin>>n>>a[0]>>a[1];
	I(i,n)std::cin>>s[i];
	I(k,2){
		p=0;
		I(i,n){
			while(s[i]-s[p]>=a[k]&&p<i-1)p++;
			l[k][i]=p;
		}
	}
	I(k,2)w[k][0]=1;
	I(i,n){if(i){
		I(k,2)w[k][i]=(e[!k]<=l[k][i]?w[!k][l[k][i]]:0);
		I(k,2)if(s[i]-s[i-1]<a[k])e[k]=i;else(w[k][i]+=w[k][i-1])%=M;
	}
	}
	std::cout<<(w[0][--n]+w[1][n])%M;
	return 0;
}

Measured memory_bytes: 4224
n,k,q=list(map(int,input().split()))
answer = [int(input())-1 for i in range(q)]
score = [ k-q for i in range(n)]

for i in answer:
  score[i] += 1
  
for s in score:
  if s > 0 :
    print('Yes')
  else:
    print('No')




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

int main() {
    int N;
    std::string S;
    std::cin >> N >> S;

    int x = 0, max = 0;
    for (int i = 0; i < N; ++i) {
        if (S[i] == 'I') {
            ++x;
            max = std::max(max, x);
        } else {
            --x;
        }
    }

    std::cout << max << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    ll n;cin>>n;
    string s;cin>>s;
    vector<int> R,G,B;
    For(i,0,n){
        if(s[i]=='R') R.push_back(i);
        if(s[i]=='G') G.push_back(i);
        if(s[i]=='B') B.push_back(i);
    }
    For(i,0,n){
        if(s[i]=='R'){
            ll low1 = lower_bound(ALL(G),i) - G.begin();
            ll high1 = B.end() - lower_bound(ALL(B),i);
            ll low2 = lower_bound(ALL(B),i) - B.begin();
            ll high2 = G.end() - lower_bound(ALL(G),i);
            ans += low1*high1;
            ans += low2*high2;
        }
        if(s[i]=='G'){
            ll low1 = lower_bound(ALL(R),i) - R.begin();
            ll high1 = B.end() - lower_bound(ALL(B),i);
            ll low2 = lower_bound(ALL(B),i) - B.begin();
            ll high2 = R.end() - lower_bound(ALL(R),i);
            ans += low1*high1;
            ans += low2*high2;
        }
        if(s[i]=='B'){
            ll low1 = lower_bound(ALL(R),i) - R.begin();
            ll high1 = G.end() - lower_bound(ALL(G),i);
            ll low2 = lower_bound(ALL(G),i) - G.begin();
            ll high2 = R.end() - lower_bound(ALL(R),i);
            ans += low1*high1;
            ans += low2*high2;
        }
    }
    for(ll d=1;d<n/2+1;d++){
        for(ll i=0;i+d*2<n;i++){
            if(s[i]!=s[i+d]&&s[i]!=s[i+2*d]&&s[i+d]!=s[i+2*d]){
                ans --;
            }
        }
    }
    cout << ans << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

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

int main(){
  int n,l;
  cin>>n>>l;
  
  int ab=INT_MAX,ans;
  for(int i=0;i<n;i++){
    if(ab>abs(l+i)){
      ab=abs(l+i);
      ans=i;
    }
  }
  
  int sum=0;
  for(int i=0;i<n;i++){
    sum+=l+i;
  }
  
  sum-=l+ans;
  cout<<sum<<endl;
}

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

int main() {
    int64_t N;
    cin >> N;
    int64_t T = 0;
    for (int64_t i = 1; i <= N; i++) {
        if (i % 3 != 0) {
            if (i % 5 != 0) {
                T = T + i;
            }
        }
    }
    cout << T << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define pp pair<ll,ll>
#define vi vector<pair<pp,pp> >
#define pq_min priority_queue<ll,vector<ll>,greater<ll>>
#define pq_max priority_queue<ll>
#define forx(i,a,b) for(ll i=0;i<a;i++)
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define ld long double
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef pair<pp,pp> ppll;
const ll mod=1e9+7;
 
 bool check(string s)
 {
 	string h=s;
 	reverse(h.begin(),h.end());
 	if(s==h)
 	{
 		return true;
    }
    return false;
 }
 int main()
 {
 	fast;
 	ll n;
 	cin>>n;
 	ll a[n];
 	map<ll,ll> p;
 	for(ll i=0;i<n;i++)
 	{
 		cin>>a[i];
 		p[a[i]]++;
    }
    map<ll,ll>::iterator it;
    ll x=0;
    for(it=p.begin();it!=p.end();it++)
    {
       ll z=it->ss;
	   x += (z * (z-1))/2;	
	}
	for(ll i=0;i<n;i++)
	{
		ll s=a[i];
		ll d = x - (p[s]*(p[s]-1))/2;
		d += ((p[s]-1)*(p[s]-2))/2;
		cout<<d<<endl;
	}
 }

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const int mod = 1e9+7;
const int N = 1e5+5;
int a[N];

int main()

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

    int n, x, ans = 0;

    cin >> n;

    while (n--) {

        cin >> x;

        ans += x-1;
    }

    cout << ans;

    return 0;
}


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

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

    priority_queue<long long> price_que;
    long price;
    for (int i = 0; i < n; ++i) {
        cin >> price;
        price_que.push(price);
    }

    for (int i = 0; i < m; ++i) {
        long target_price = price_que.top();
        price_que.pop();

        price_que.push(target_price / 2);
    }

    long ans = 0;
    while (!price_que.empty()) {
        ans += price_que.top();
        price_que.pop();
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define reps(i,n) for(int i=1;i<=(int)n;i++)
#define all(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define MOD 1000000007
#define itn int
#define enld endl
using namespace std;
typedef long long ll;
const 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;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    int A,B,C; cin >> A >> B >> C;
    if((A < C && C < B) || (B < C && C < A)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << enld;
    }
    return 0;
}

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

ans = n
count = 0
for i in range(n):
    if s[i] == ".":
        count += 1
ans = min(ans, count)
for i in range(n):
    if s[i] == ".":
        count -= 1
    else:
        count += 1
    ans = min(ans, count)
print(ans)

Measured memory_bytes: 3500
#include <bits/stdc++.h>
 #define f first
 #define s second
 #define endl '\n'
 #define LL long long
 #define pb push_back
 #define sz(a) (int)a.size()
 #define all(a) a.begin(),a.end()
 #define rall(a) a.rbegin(),a.rend()
 #define debug(x) cerr << #x << " is " << x << endl;
 using namespace std;
 int const MAXN = 2e6 + 9;
 int main(){
    ios_base::sync_with_stdio (0),cin.tie(0);
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int x = 1;
    for (int i = 0; i < n; i++)
        if (a[i] == x) x++;
    x--;
    if (x == 0) cout << -1;
    else
    cout << n - x << endl;
 }


Measured memory_bytes: 1024