akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){


int a,b;
cin>>a>>b;
for(int i=1;i<=3;i++){
    if(i!=a && i!=b){
        cout<<i<<endl;
        break;
    }
}
return 0;

}
/*


*/


Measured memory_bytes: 256
#include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
int b[10000010]={0};
int main(){
  int n,a,i;
  long long ans;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    b[a]++;
  }
  for(i=ans=0;n;i++){
    ans+=MIN(n,i*4);
    n-=b[i];
  }
  printf("%lld\n",ans+1);
  return 0;
}

Measured memory_bytes: 37456
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  rep(h, 3501) rep(n, 3501) {
    ll a = 1LL*4*h*n - 1LL*N*(n+h);
    ll b = 1LL*N*h*n;
    if(a <= 0) continue;
    if(b % a == 0) {
      ll w = b/a;
      cout << h << ' ' << n << ' ' << w << endk;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3652
def main():
    x, y = map(int, input().split())

    if x in [1, 3, 5, 7, 8, 10, 12] and y in [1, 3, 5, 7, 8, 10, 12]:
        print("Yes")
    elif x in [4, 6, 9, 11] and y in [4, 6, 9, 11]:
        print("Yes")
    elif x in [2] and y in [2]:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


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

#define  SZ(items) (int)items.size()
template <class T> inline T gcd(T a, T b) { while (b) { a = a%b; swap(a, b); } return a; }


int main()
{
	//ios_base::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(10); cout.tie(nullptr); cin.tie(nullptr);
	ios_base::sync_with_stdio(false); cout.tie(nullptr); cin.tie(nullptr);

	
	long long A, B;

	cin >> A >> B;

	if (B%A == 0)
	{
		cout << A + B << endl;
	}
	else
	{
		cout << B - A << endl;
	}


	return 0;
}

Measured memory_bytes: 256
const main = (input) => {
  let [a, b, c, k] = input.trim().split(' ').map(Number)

  let ans = Math.min(a, k)
  k -= a
  k -= b

  if (k > 0) ans -= k

  return console.log(ans)

}

process.env.MYTEST
  ? (process.env.MYTEST === 'test' ? test() : main(require('fs').readFileSync('dev/stdin', 'utf8')))
  : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 29712
#include <iostream>

using namespace std;

int main(){
  string s; cin >> s;
  bool flag = true;
  for (int i =0; i < 3 ; i++){
    if(s[i] == s[i+1]){
      flag = false;
    }
  }
  
  if(flag) cout << "Good" << endl;
  else cout << "Bad" <<endl;
}

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

int main(){
  long long int a,b;
  cin >> a >> b;
  long long int root_a = sqrt(a);
  vector<long long int> primes;
  for(long long int i=2;i*i<=a;i++){
    if(a%i==0){
      primes.push_back(i);
      while(a%i==0){
        a=a/i;
      }
    }
  }
  if(a!=1){
    primes.push_back(a);
  }
  long long int cntr=0;
  for(auto i : primes){
    if(b%i==0){
      cntr++;
    }
  }
  cout << cntr+1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <cmath>
using namespace std;


int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  vector<pair<int, int>> tsk(n);
  int a, b;
  for(int i = 0; i < n; i++){
    cin >> a >> b;
    tsk.at(i).first = b;
    tsk.at(i).second = a;
  }
  sort(tsk.begin(), tsk.end());

  int current = 0;
  for(int i = 0; i < n; i++){
    tie(b,a) = tsk.at(i);
    current += a;
    if(current <= b){
      continue;
    }
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;

}


Measured memory_bytes: 1792
from collections import defaultdict

a = list(map(ord, input()))
N = len(a)
La = ord("a")

data = [0]*(N+1)


d = [[] for i in range(26)]
for i , c in enumerate(a):
    d[c-La].append(i)

odd = 0
for v in d:
    if len(v) % 2:
        odd += 1
if not odd <= N%2:
    print(-1)
    exit(0)

data = [0]*(N+1)
def add(k, x):
    while k <= N:
        data[k] += x
        k += k & -k
def get(k):
    s = 0
    while k:
        s += data[k]
        k -= k & -k
    return s

M = [None]*N
for v in d:
    vl = len(v)
    for i in range(vl):
        if not i <= vl-1-i:
            break
        p = v[i]; q = v[-i-1]
        M[p] = q
        M[q] = p
cnt = 0
B = [0]*N
for i in range(N-1, -1, -1):
    if M[i] <= i:
        B[i] = B[M[i]] = cnt
        cnt += 1

cur = -1
ans = 0
for i in range(N-1, -1, -1):

    if cur < B[i]:
        cur = B[i]
        if M[i] == i:
            ans += N//2 - cur
        else:
            ans += M[i] - get(M[i]+1)
        add(M[i]+1, 1)
print(ans)


Measured memory_bytes: 21372
#include <iostream>
#include <map>

using namespace std;

typedef long long ll;

const int MAX_N = 2e5 + 5;

ll arr [MAX_N];

int main () {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

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

  map<ll, ll> seen;
  seen[0] = 1;
  ll pref = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    pref += arr[i];

    if (!seen.count(pref)) {
      seen[pref] = 0;
    }

    ans += seen[pref];
    seen[pref]++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 14336
N = int(input())
H = list(map(int, input().split()))

cntm = 0
cnt = 0
for i in range(N-1):
	if H[i] >= H[i+1]:
		cnt += 1
	else:
		if cntm < cnt:
			cntm = cnt
		cnt = 0

if cntm < cnt:
	cntm = cnt
print(cntm)


Measured memory_bytes: 14224
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int tmp = 0;
        int res = 0;
        for(int i = 0; i < S.length(); i++) {
            if(S.charAt(i) == 'A' || S.charAt(i) == 'T' || S.charAt(i) == 'G' || S.charAt(i) == 'C') {
                tmp++;
            } else {
                tmp = 0;
            }
            res = Math.max(tmp,res);
        }
        System.out.println(res);
    }
}


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

int main()
{
  int x;
  cin >> x;
  if (x == 1) {
    cout << 1 << endl;
    return 0;
  }
  int ans(0);
  for (int n = 2; n <= x; n++) {
    for (int p = 2; p * p <= n; p++) {
      int m(p);
      while (m < n) {
        m *= p;
      }
      if (m == n) {
        ans = n;
        break;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

using Graph = vector< vector< pair<int, int> > >;
int N, M, Q, u[200010], v[200010], t[200010];
const pair<int, int> INIT(INF, INF);
pair<int, int> dist[100010];

struct Elem {
    int pos, eidx, cost;
    bool operator<(const Elem &e) const {
        if(cost != e.cost) return cost > e.cost;
        return eidx > e.eidx;
    }
};

bool compare_pair(pair<int, int> A, pair<int, int> B) {
    if(A.first != B.first) return A.first < B.first;
    return A.second > B.second;
}

signed main() {
    cin >> N >> M >> Q;
    for(int i=0; i<M; i++) {
        scanf("%lld%lld", &u[i], &v[i]);
        u[i]--; v[i]--;
    }
    fill(t, t+M, Q);
    for(int i=0; i<Q; i++) {
        int e; cin >> e; e--;
        t[e] = i;
    }

    Graph G(N);
    for(int i=0; i<M; i++) {
        G[ u[i] ].emplace_back(v[i], t[i]);
        G[ v[i] ].emplace_back(u[i], t[i]);
    }

    fill(dist, dist + N, INIT);
    dist[0] = make_pair(0, Q);
    priority_queue<Elem> que;
    que.push(Elem{0, Q, 0});
    while(que.size()) {
        Elem cur = que.top(); que.pop();
        if(compare_pair(dist[cur.pos], make_pair(cur.cost, cur.eidx))) continue;
        for(auto e : G[cur.pos]) {
            int to, idx; tie(to, idx) = e;
            int nidx = min(idx, cur.eidx);
            int ncost = cur.cost + 1;

            if(compare_pair(make_pair(ncost, nidx), dist[to])) {
                dist[to] = make_pair(ncost, nidx);
                que.push(Elem{to, nidx, ncost});
            }
        }
    }

    vector<int> cnt(Q+1);
    for(int i=0; i<N; i++) {
        // fprintf(stderr, "v = %lld, query = %lld\n", i+1, dist[i].second + 1);
        cnt[ dist[i].second ]++;
    }
    for(int i=0; i<Q; i++) {
        if(i > 0) cnt[i] += cnt[i-1];
        printf("%lld\n", cnt[i]);
    }
    return 0;
}



Measured memory_bytes: 24888
#include <iostream>
#include <iomanip>
#include <climits>
#include <vector>
#include <queue>
#include <cmath>
 
using namespace std;

void shortestPathSPFA(vector< vector< pair<int, long long int> > > &graph, vector<long long int> &dist, vector<int> &prev, int root) {
	dist[root] = 0;
	queue<int> q; q.push(root);
	vector<bool> in_q(graph.size(), false); in_q[root] = true;
	while(q.size() > 0) {
		int u = q.front(); q.pop(); in_q[u] = false;
		for (int i = 0; i < graph[u].size(); ++i) {
			int v = graph[u][i].first;
			int w = graph[u][i].second;
			if (dist[u] + w < dist[v]) {
				dist[v] = dist[u] + w;
				prev[v] = u;
				if (!in_q[v]) {
					in_q[v] = true;
					q.push(v);
				}
			}
		}
	}
}

void shortestPathDijkstra(vector< vector< pair<int, long long int> > > &graph, vector<long long int> &dist, vector<int> &prev, int root) {
	dist[root] = 0;
	priority_queue< pair<long long int, int>, vector< pair<long long int, int> >, greater< pair<long long int, int> > > pq;
	pq.push(make_pair(0, root));
	while(!pq.empty()) {
		int u = pq.top().second; pq.pop();
		for (int i = 0; i < graph[u].size(); ++i) {
			int v = graph[u][i].first;
			int e = graph[u][i].second;
			if (dist[u] + e < dist[v]) {
				dist[v] = dist[u] + e;
				prev[v] = u;
				pq.push(make_pair(dist[v], v));
			}
		}
	}
}
 
int main(void) {
	int n, m, s, t;
	cin >> n >> m >> s >> t;
	s -= 1; t -= 1;
 
	vector< vector< pair<int, long long int> > > graph_s(n);
	vector< vector< pair<int, long long int> > > graph_t(n);
 
	int u, v, a, b;
	for (int i = 0; i < m; ++i) {
		cin >> u >> v >> a >> b;
		u -= 1; v -= 1;
		graph_s[u].push_back(make_pair(v, a));
		graph_s[v].push_back(make_pair(u, a));
		graph_t[u].push_back(make_pair(v, b));
		graph_t[v].push_back(make_pair(u, b));
	}
	vector<long long int> dist_s(n * 2, LLONG_MAX), dist_t(n * 2, LLONG_MAX);
	vector<int> prev_s(n * 2, -1), prev_t(n * 2, -1);
	shortestPathDijkstra(graph_s, dist_s, prev_s, s);
	shortestPathDijkstra(graph_t, dist_t, prev_t, t);
 
	vector<long long int> res(n, LLONG_MAX);
	res[n - 1] = dist_s[n - 1] + dist_t[n - 1];
	for (int i = n - 2; i >= 0; --i) {
		res[i] = min(res[i + 1], dist_s[i] + dist_t[i]);
	}
 
	long long int init = 1e15;
	for (int i = 0; i < n; ++i) {
		cout << init - res[i] << endl;
	}
 
	return 0;
 
}

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

int main(){
  ll n;cin >> n;
  vector<ll> v(n);
  vector<vector<ll>> dp(n+1,vector<ll>(n+1));
  for(ll i=0;i<n;i++) cin >> v[i];
  for(int i=n-1;i>=0;i--){
    for(int j = i;j<n;j++){
      if(i == j) dp[i][j] = v[i];
      else{
        dp[i][j] = max(v[i]-dp[i+1][j],v[j]-dp[i][j-1]);
      }
    }
  }
  cout << dp[0][n-1] << endl;
  cin.get();cin.get();
}


Measured memory_bytes: 70784
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

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

	string diverse;
	cin >> diverse;

	vector<int> occs(26);
	for (int i = 0; i < (int) diverse.size(); ++i) {
		++occs[diverse[i] - 'a'];
	}

	for (int i = 0; i < 26; ++i) {
		if (!occs[i]) {
			diverse.push_back(i + 'a');
			cout << diverse << "\n";
			return 0;
		}
	}

	if (diverse == "zyxwvutsrqponmlkjihgfedcba") {
		cout << "-1\n";
	} else {
		int i = diverse.size() - 1;
		while (diverse[i] < diverse[i - 1]) {
			--i;
		}

		string suf = diverse.substr(i);
		sort(suf.begin(), suf.end());

		char last;
		for (int j = 0; j < (int) suf.size(); ++j) {
			if (suf[j] > diverse[i - 1]) {
				last = suf[j];
				break;
			}
		}

		cout << diverse.substr(0, i - 1) + last << "\n";
	}

	return 0;

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:1024000000")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;


int main() {
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	string s1, s2;
	cin >> s1 >> s2;
	cout << s2 << s1;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5,M=1e6+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a) memset(a,0,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first 
#define se second
ll a[N];
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++) scanf("%lld",&a[i]);
	sort(a,a+n);
	int l=0,r=n-1,w=1; 
	ll ans=1;
	if(k&1) ans=a[r--],k--,w=(ans<0?-1:1);
	while(k){
		ll x=a[l]*a[l+1],y=a[r]*a[r-1];
		if(x*w>y*w) ans=(ans*(x%mod))%mod,l+=2;
		else ans=(ans*(y%mod))%mod,r-=2;
		k-=2;
	}
	printf("%lld\n",(ans%mod+mod)%mod);
	return 0;
}


Measured memory_bytes: 5388
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import Data.List
import Data.Maybe

main :: IO ()
main = do
  [n] <- readInts
  readInts >>= print . solve n

solve :: Int -> [Int] -> Int
solve n = g . foldl' f (0, [], 0)
  where
    f (m, n, c) x
      | m >= x = (x, n, c+1)
      | otherwise = (x, c:n, 0)
    g (_, n, c) = maximum (c:n)

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

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

const int N = 2e5+7;
int l[N], r[N], a[N];

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

    int n;
    cin>>n;

    for (int i=1; i<=n; i++)    cin>>a[i];

    stack<int> st;
    st.push(0);

    for (int i=1; i<=n; i++) {
        while (a[st.top()] > a[i])  st.pop();
        l[i] = st.top();
        st.push(i);
    }

    st = stack<int>();
    st.push(n+1);

    for (int i=n; i>0; i--) {
        while (a[st.top()] > a[i])  st.pop();
        r[i] = st.top();
        st.push(i);
    }

    long long ans = 0;
    for (int i=1; i<=n; i++) {
        ans += 1LL*a[i]*(r[i]-i)*(i-l[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6284
a = int(input())
b = list(map(int, input().split()))
c = 0
f = True
while f == True:
    lc = 0
    for i in range(a):
        if b[i] % 2 != 0:
            f = False
        else:
            lc += 1
            b[i] = b[i] / 2
            
        if lc == a:
            c += 1
            
        
print(c)

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

int main() {
    int n, ans, p = 0;
    cin >> n;
    if(n == 1)
        cout << 1 << endl;
    else {
        REP(i, n) {
            int a = i, cnt = 0;
            rep(j, 7) {
                if(a % 2 == 0) {
                    a = a / 2;
                    cnt++;
                }
            }
            if(cnt > p) {
                p = cnt;
                ans = i;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
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 <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll,ll> P;
typedef long double ld;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b;
	cin >> a >> b;
	cout << a * (b / gcd(a, b)) << "\n";
	return 0;
}

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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>

int main(){
  int W,H,x,y,r;
  std::scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
  if(x + r > W || x - r < 0 ){
    std::printf("No\n");
  }
  else if(y - r < 0 || y + r > H){
    std::printf("No\n");
  }
  else {
    std::printf("Yes\n");
  }
  return 0;
}


Measured memory_bytes: 2684
#include"bits/stdc++.h"
using namespace std;

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

    //Eの人の数
    int right = 0, left = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'E') {
            right++;
        }
    }

    int ans = N;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'E') {
            right--;
        }

        ans = min(ans, (i - left) + right);

        if (S[i] == 'E') {
            left++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 900
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

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

ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}

double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}

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


/////////////////////////////////////////////////////////////////////////////////////

int main(){
    set<string> item;
    int n;
    cin >> n;
    int cnt = 0;
    for (int i = 0;i < n;i++){
        string s;
        cin >> s;
        item.insert(s);
    }

    cout << item.size() << endl;
}

Measured memory_bytes: 19252
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define REPS(i,n) for(int i=1;i<=(n);i++)
#define RREPS(i,n) for(int i=(n);i>0;i--)
#define mp make_pair
#define pb(a) push_back(a)
typedef long long ll;

int main(){
  int N;
  ll A,B;
  cin >> N >> A >> B;
  vector<ll> h(N);
  REP(i,N) cin >> h[i];
  sort(h.begin(),h.end(),greater<int>());
  ll m = 0;
  ll M = 1e9;
  while(m+1 < M){
    ll T = m + (M-m)/2;
    ll cnt = T;
    REP(i,N){
      if(cnt < 0 || h[i] - B*T <= 0) break;
      cnt -= (h[i] - B*T + (A-B-1))/(A-B);
    }
    if(cnt >= 0) M = T;
    else m = T;
  }
  cout << M << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <map>
#include <queue>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef long double ld;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<pii> vii;
typedef vector<string> vs;
//typedef long long int;
const int mod = 1000000007;

ll mpow(ll x, ll n) {
  ll res = 1;
  while (n) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n /= 2;
  }
  return res;
}

ll inv(ll x) {
  return mpow(x, mod-2);
}

vvi g;
vi sz;
vl fac(10000, 1);
vl invfac(10000, 1);

void dfs(int v, int p) {
  sz[v] = 1;
  for (int nv : g[v]) {
    if (nv == p) continue;
    dfs(nv, v);
    sz[v] += sz[nv];
  }
}

vl mul(const vl & a, const vl & b) {
  vl res(a.size() + b.size() - 1);
  for (int i = 0; i < a.size(); ++i) for (int j = 0; j < b.size(); ++j) {
    res[i+j] = (res[i+j] + a[i] * b[j]) % mod;
  }
  return res;
}

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  for (int i = 2; i < fac.size(); ++i) {
    fac[i] = fac[i-1] * i % mod;
    invfac[i] = inv(fac[i]);
  }
  int n;
  cin >> n;
  g.resize(n);
  for (int i = 0; i < n-1; ++i) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i = 0; i < n; ++i) {
    sz.assign(n, 0);
    dfs(i, -1);
    bool ok = 1, eq = 0;
    for (int v : g[i]) {
      if (sz[v] * 2 > n) {
        ok = 0;
      }
      if (sz[v] * 2 == n) eq = 1;
    }
    if (ok) {
      if (eq) {
        ll res = fac[n/2] * fac[n/2] % mod;
        cout << res << endl;
      } else {
        ll prod = 1;
        for (int v : g[i]) prod = prod * mpow(fac[sz[v]], 2) % mod;
        vl res(1, 1);
        for (int v : g[i]) {
          vl x(sz[v] + 1);
          for (int j = 0; j < x.size(); ++j) {
            x[j] = invfac[j] * mpow(invfac[sz[v] - j], 2) % mod;
          }
          res = mul(res, x);
        }
        ll sum = 0;
        for (int j = 0; j < res.size(); ++j) {
          int zn = j % 2 ? -1 : 1;
          sum = (sum + zn * res[j] * fac[n - j]) % mod;
        }
        sum = sum * prod % mod;
        cout << (sum % mod + mod) % mod << endl;
      }
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 1152
from math import gcd
import numpy as np

def setwise_coprime_check_fun(A_list, N):
    gcd_all = A_list[0]
    for i in range(N - 1):
        gcd_all = gcd(gcd_all, A_list[i + 1])
        if gcd_all == 1:
            break
    return gcd_all

def preprocess_fun(A_max):
    p_flg = [True] * (A_max + 1)
    D = [0] * (A_max + 1)
    p_flg[0] = False
    p_flg[1] = False
    for i in range(2, A_max + 1, 1):
        if p_flg[i]:
            for j in range(i, A_max + 1, i):
                p_flg[j] = False
                D[j] = i
    return D

def pairwise_coprime_check(A_list, D):
    p_count = [0] * (max(A_list) + 1)
    for A in A_list:
        temp = A
        d = 0
        while temp != 1:
            if p_count[D[temp]] == 1 and d != D[temp]:
                return 0
            p_count[D[temp]] = 1
            d = D[temp]
            temp = temp // D[temp]
    return 1

## 標準入力
N = int(input())
A_list = list(map(int, input().split(" ")))

# 整数の最大値を取得
A_max = max(A_list)

# 本体
if(setwise_coprime_check_fun(A_list, N) != 1):
    print("not coprime")
else:
    D = preprocess_fun(A_max)
    if pairwise_coprime_check(A_list, D) == 1:
        print("pairwise coprime")
    else:
        print("setwise coprime")

Measured memory_bytes: 150464
# coding: utf-8
S = input()
T = input()
for i in range(len(S)-len(T), -1, -1):
    for cs, ct in zip(S[i:i+len(T)], T):
        if not (cs == "?" or cs == ct):
            break
    else:
        S = S[:i] + T + S[i+len(T):]
        S = S.replace("?", "a")
        print(S)
        break
else:
    print("UNRESTORABLE")


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
//debug() << imie(x) imie(y);
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main()
{

int a,b;
cin>>a>>b;
if(a==1)
a=16;
if(b==1)
b=16;
if(a>b)
cout<<"Alice";
else if(a<b)
cout<<"Bob";
else
cout<<"Draw";
return 0;
}


Measured memory_bytes: 256
n = int(input())
A = list(sorted(map(int, input().split())))
q = int(input())
M = list(map(int, input().split()))

R = [[None for j in range(2000)] for i in range(n + 1)]

def solve(i, m):
    if R[i][m] != None:
        return R[i][m]
    if m == 0:
        R[i][m] = True
        return True
    elif i > n - 1:
        R[i][m] = False
        return False
    else:
        ans = solve(i + 1, m) or solve(i + 1, m - A[i])
        R[i][m] = ans
        return ans

sum_A = sum(A)
for i in M:
    if sum_A < i:
        print('no')
    elif solve(0, i):
        print('yes')
    else:
        print('no')

Measured memory_bytes: 8028
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        List<Pair> list = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            list.add(new Pair(scan.nextInt(), scan.nextInt()));
        }
        if (N % 2  == 1) {
            list.sort(new PairAComparator());
            long left = list.get(N / 2).A;
            list.sort(new PairBComparator());
            long right = list.get(N / 2).B;
            System.out.println(right - left + 1);
            return;
        }
        list.sort(new PairAComparator());
        long left = list.get(N / 2 - 1).A + list.get(N / 2).A;
        list.sort(new PairBComparator());
        long right = list.get(N / 2 - 1).B + list.get(N / 2).B;
        System.out.println(right - left + 1);
        return;
    }
    class Pair {
        long A;
        long B;
        Pair(long A, long B) {
            this.A = A;
            this.B = B;
        }
    }
    class PairAComparator implements Comparator<Pair> {
        @Override
        public int compare(Pair o1, Pair o2) {
            if (o1.A != o2.A) {
                return Long.compare(o1.A, o2.A);
            }
            return Long.compare(o1.B, o2.B);
        }
    }
    class PairBComparator implements Comparator<Pair> {
        @Override
        public int compare(Pair o1, Pair o2) {
            if (o1.B != o2.B) {
                return Long.compare(o1.B, o2.B);
            }
            return Long.compare(o1.A, o2.A);
        }
    }
}


Measured memory_bytes: 68368
l = list(map(int,input().split()))

l = sorted(l,reverse = True)

a,b,c=l[0],l[1],l[2]

if (b-c)%2 == 0:
    print((b-c)//2+a-b)
else:
    print((b-c)//2+1+a+1-b)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

using ipair = pair<int,int>;

int INF = 1e9+7;

using ipair = pair<int,int>;
bool operator>(const ipair a,const ipair b){return a.first > b.first;}


ll solve(ll N){
  if(N%2==1) return 0;

  ll res = 0;

  N /= 2;
  while(N){
    res += N/5;
    N /= 5;
  }

  return res;
}


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

  cout << solve(N) << endl;

}


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

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int n; cin >> n;
	vector<int> p(n), dp(n, 0);
	REPU(i, 0, n) {
		cin >> p[i];
		--p[i];
	}
	dp[p[0]] = 1;
	REPU(i, 1, n) {
		if (p[i]) amax(dp[p[i]], dp[p[i] - 1] + 1);
		else dp[p[i]] = 1;
	}
	int ans = *max_element(ALL(dp));
	ans = n - ans;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
open System

// 2000 2100
// 2000 91 -> 0

// 2020 2040
// 1 21 -> 1 * 2 


let [|L; R|] = stdin.ReadLine().Split() |> Array.map int

let i, j = L%2019, R%2019
if R - L >= 2019 || i >= j then 0
else List.min [ for l in i..j-1 ->
                  List.min [ for r in l+1..j -> l * r % 2019 ]
              ]
|> stdout.WriteLine

Measured memory_bytes: 16664
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class CCookieBreedingMachine {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int q; cin >> q;
      while(q--) {
        int n, d; cin >> n >> d;
        if (n%2==0) {
          d ^= 127;
        }
        cout << d + 127*(n-1) << endl;
      }
    }
};

signed main() {
  CCookieBreedingMachine solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		for(i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		sc.close();
		sc = null;
		int cnt = 0;
		while(true) {
			for(j = 0; j < n; j++) {
				if(a[j] % 2 == 0) {
					a[j] >>= 1;
				} else {
					break;
				}
			}
			if(j == n) {
				cnt++;
			} else {
				break;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 21716
fun main(args: Array<String>) {

    val n = readLine()!!.toInt()

    when {
        n < 10 -> println(n)
        n < 100 -> println(9)
        n < 1000 -> println(n - 90)
        n < 10000 -> println(909)
        n < 100000 -> println(n - 9090)
        else -> println(90909)
    }
}

Measured memory_bytes: 31740
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,j,k;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  
  j = vec.at(0);
  
  for (int i = 0; i < n; i++){
    if(j == 2){
      cout << i+1 << endl;
      break;
    }
    else if (i == n-1){
      cout << -1 << endl;
      break;
    }
    k = vec.at(j-1);
    j = k;
  }

 
  
  
  
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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; }



int a,b,c;
void solve(){
	cin >> a >> b >> c;
	
	cout << a*b/2 << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    ll ans = 0;
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        ans += mp[i - a];
        mp[a + i]++;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 20584
n,y=map(int,input().split())
for i in range(n+1):
    for j in range(n-i+1):
        if (n-i-j)*1000==(y-(i*10000+j*5000)):
            print("{} {} {}".format(i,j,n-i-j))
            exit()
print("{} {} {}".format(-1,-1,-1))
    

Measured memory_bytes: 8888
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 2005
#define INF 1000000005
#define INFLL (long long)1e18
#define PI 3.1415926535897
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000005;
const int MOD = 1000000007;
int main(){
    int n;
    cin>>n;
    ll ans=1;
    ll m=INFLL;
    REP(i,n){
        ll a;
        cin>>a;
        if(a==0){
            ans=0;
            break;
        }
        if(a<=m){
            ans*=a;
            m/=a;
        }else{
            ans=-1;
        }
    }
    OUT(ans);
    return 0;
}


Measured memory_bytes: 3612
import java.util.Scanner;
 

public class Main {
	
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        double x = Math.ceil(n / 1.08);
        if (Math.floor(x*1.08) == n) {
        	System.out.println((int)x);
        } else {
        	System.out.println(":(");
        }

        sc.close();
	}
	
}


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

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

    vector<int> coor_w;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='W'){
            coor_w.push_back(i);
        }
    }

    long long count=0;
    for(int i=0; i<coor_w.size(); i++){
        count+=abs(coor_w[i]-i);
    }

    cout<<count<<endl;
}

Measured memory_bytes: 1532
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
int a[505][505];
void solve(){
  int h,w;
  cin>>h>>w;
  vector<vector<int> > ans;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
        cin>>a[i][j];
    }
  }
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
        if(j!=w and a[i][j]%2){
            a[i][j]--;
            a[i][j+1]++;
            ans.pb({i,j,i,j+1});
        }
    }
  }
  for(int i=1;i<=h;i++){
    if(i!=h){
        if(a[i][w]%2){
            a[i][w]--;
            a[i+1][w]++;
            ans.pb({i,w,i+1,w});
        }
    }
  }
    int z = ans.size();
  cout<<z<<endl;
  for(int i=0;i<z;i++){
       for(int j=0;j<=2;j++)cout<<ans[i][j]<<" ";
        cout<<ans[i][3]<<endl;
  }
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1;
//	cin>> t;
	while(t--)solve();
	return 0;
}


Measured memory_bytes: 10032
from numba import njit
 
# @njit(cache=True)
@njit()
def convolve(a, b):
    def poww(aa, bb, mm):
        ss = 1
        tt = aa
        while bb:
            if bb % 2:
                ss = ss * tt % mm
                bb -= 1
            tt = tt * tt % mm
            bb //= 2
        return ss
    def fft(n, p, g, w, invw, f):
        d = n // 2
        v = w
        while d >= 1:
            u = 1
            for i in range(d):
                for j in range(i, n, 2*d):
                    f[j], f[j+d] = (f[j] + f[j+d]) % p, u * (f[j] - f[j+d]) % p
                u = u * v % p
            v = v * v % p
            d //= 2
 
    def ifft(n, p, g, w, invw, f):
        d = 1
        while d < n:
            v = poww(invw, n // (2 * d), p)
            u = 1
            for i in range(d):
                for j in range(i, n, 2*d):
                    f[j+d] *= u
                    f[j], f[j+d] = (f[j] + f[j+d]) % p, (f[j] - f[j+d]) % p
                u = u * v % p
            d *= 2
 
    p = 1107296257
    g = 5
    n0, n1 = len(a), len(b)
    n = 1
    while n < max(n0, n1) * 2:
        n *= 2
    a = a + [0] * (n-n0)
    b = b + [0] * (n-n1)

    w = poww(g, (p - 1) // n, p)
    invw = poww(w, p-2, p)
    fft(n, p, g, w, invw, a), fft(n, p, g, w, invw, b)
    for i in range(n):
        a[i] = a[i] * b[i] % p
    ifft(n, p, g, w, invw, a)
    invn = poww(n, p - 2, p)
    for i in range(n0 + n1 - 1):
        a[i] = a[i] * invn % p
    return a[:n0 + n1 - 1]

N = 100000
A = []
B = []
s = 0
for i in range(N):
    s = (s * 3 + i * 7) % 100
    a = s
    b = (s * 3 + a * 11) % 100
    A.append(a)
    B.append(b)

AB = convolve(A, B)


#####
A, B, C, K = map(int, input().split())
if K <= A + B:
    print(min(A, K))
else:
    print(A - (K - A - B))

Measured memory_bytes: 134000
import           Data.Char
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed   as U

main :: IO ()
main = do
  n <- readLn
  ps <- U.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
  print $ solve ps

solve :: U.Vector Int -> Int
solve = U.length . U.filter id . (U.zipWith3 monotone <$> id <*> U.tail <*> U.drop 2)
  where
    monotone x y z
      | x < y     = y <= z
      | otherwise = y >= z

Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <map>
#include <cstdlib>
#include <algorithm>
#include <string>	

using namespace std;

int main(){
	string s, inter, s2;
	int q, a, b;
	cin >> s >> q;
	for (int i = 0; i < q; i++){
		cin >> inter >> a >> b;
		if (inter == "replace"){
			cin >> s2;
			s = s.substr(0, a) + s2 + s.substr(b + 1, s.size() - b - 1);
		}
		else if (inter == "print") cout << s.substr(a, b - a + 1) << endl;
		else  reverse(s.begin() + a, s.begin() + b + 1);
	}
}

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

int main(void) {
    long long n, a, b ;
    cin >> n ;

    for (int i = 1; i <= (int)sqrt(n); i++) {
        if (n%i == 0) {
            b = n/i ;
            a = i ;
        }
    }

    cout << a + b - 2 << endl ;


    return 0 ;
}

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

bool isPrime(long long num) {
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    // 素数である
    return true;
}

void solve(long long X){
    while(!isPrime(X)) X++;
    cout << X << endl;
}

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include <math.h>

#define LL long long
#define MOD 1000000007
#define rep(i,n) for(int i = 0;i < (n);i++)

using namespace std;

int gcd(int a, int b){
    if(a<b) gcd(b,a);

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

int main(){

    int K = 0;
    cin >> K;

    LL ans = 0;
    rep(i,K) rep(j,K) rep(k,K) ans += gcd(i+1,gcd(j+1,k+1));
    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 3644
#include "bits/stdc++.h"
#include<vector>
#include<iostream>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<iomanip>
#include<assert.h>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<stack>
#include<complex>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;
	
#define WHATS(var)//cout<<__LINE__<<' '<<#var<<"="<<var<<endl;
	
template<class S, class T> ostream& operator <<(ostream &os, const pair<S, T> v){
	os << "( " << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<T> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<vector<T>> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<set<T>> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const set<T> &v){
	int i=0;
	for(auto it:v){
		if(i > 0){os << ' ';}
		os << it;
		i++;
	} 
	return os;
}

using ll =long long ;
ll mod;

void solve(vector<vector<int>>&cango){
	int tt=cango.size();
	for(int i=0;i<tt;++i){
		for(int j=0;j<tt;++j){
			for(int k=0;k<tt;++k){
				cango[j][k]|=cango[j][i]&cango[i][k];
			}
		}
	}
}
int main() {
	ios::sync_with_stdio(false);
	int H,W;cin>>H>>W;
	int A,B;cin>>A>>B;
	int y=H%A,x=W%B;
	cout<<y*W+x*H-y*x<<endl;
	return 0;	
}


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

int main()
{
	char b;
	cin >> b;
	switch (b)
	{
	case 'A':
		cout << 'T' << endl;
		break;
	case 'T':
		cout << 'A' << endl;
		break;
	case 'C':
		cout << 'G' << endl;
		break;
	case 'G':
		cout << 'C' << endl;
		break;
	default:
		break;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a=0,b,d=-1;
  cin>>n;
  int c[n];
  for(int i=0;i<n;i++){
    cin>>c[i];
    a=max(a,c[i]);
  }
  for(int i=0;i<n;i++){
    if(c[i]!=a){
      if(d<min(c[i],a-c[i])){
        b=c[i];
        d=min(c[i],a-c[i]);
      }
    }
  }
  cout<<a<<" "<<b;
}


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

using namespace std;

const int N = 3e5 +1 , mod = 1e9 +7 ;
int n;
int main()
{
    cin>>n;
    bool ok = 1;
    for(int i = 0;i<n;i++)
    {
        int t ; cin>> t;
        if(t%2==0)
        {
            if(t%3&&t%5)
            {
                ok = 0;
            }
        }
    }
    if(ok)
        cout<<"APPROVED";
    else cout<<"DENIED";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1e9+7
#define MOD 1e9+7
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;

string s;
int n;
int y, x, M[9][9];
int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };

void solve(int y, int x){
	M[y][x] = 0;

	for (int i = 0; i < 4; i++){
		for (int j = 1; j <= 3; j++){
			int ny = y + dy[i] * j, nx = x + dx[i] * j;
			if (ny >= 0 && ny < 8 && nx >= 0 && nx < 8){
				if (M[ny][nx] == 1)solve(ny, nx);
			}
		}
	}
}

int main(){
	cin >> n;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < 8; j++){
			cin >> s;
			for (int k = 0; k < 8; k++){
				M[j][k] = s[k] - '0';
			}
		}
		cin >> x >> y;
		solve(y - 1, x - 1);
		cout << "Data " << i + 1 << ":" << endl;
		for (int j = 0; j < 8; j++){
			for (int k = 0; k < 8; k++){
				cout << M[j][k];
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 3052