akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <bitset>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
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; }
const long long INF = 1LL <<60;
typedef long long ll;
using namespace std;

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

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

ll choose2(ll n){
    return n*(n-1)/2;
}

int main(){
    int x,n;
    cin>>x>>n;
    if(n == 0) {
        cout<<x<<endl;
        return 0;
    }
    vector<int> p(n);
    rep(i,0,n-1){
        cin>>p[i];
    }

    int high = 0;
    int low = 0;
    int tmp = x;
    while(1){
        bool flag = true;
        rep(i,0,n-1){
            if(tmp == p[i]){
                flag = false;
                break;
            }
        }

        if(flag){
            high = tmp;
            break;
        }
        tmp++;
    }

    tmp = x;
    while(1){
        bool flag = true;
        rep(i,0,n-1){
            if(tmp == p[i]){
                flag = false;
                break;
            }
        }

        if(flag){
            low = tmp;
            break;
        }
        tmp--;
    }

    if(high - x < x - low){
        cout<<high<<endl;
    }
    else cout<<low<<endl;
    return 0;
}

Measured memory_bytes: 3636
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# Factoring by trial split
def getPrimeList(n):
  l=[]
  t=int(math.sqrt(n))+1
  
  for a in range(2,t):
    while n%a==0:
      n//=a
      l.append(a)
  
  if n!=1:
    l.append(n)
  
  return l

# Summarize count of factor within list
def summarize_list(l):
  sl=sorted(l)

  a=l[0]
  c=1
  res=[]

  for x in sl[1:]:
    if x==a:
      c+=1
    else:
      res.append([a,c])
      a=x
      c=1
  res.append([a,c])

  return res

def main():
  n=I()
  l1=LI()

  l2=[]
  for x in l1:
    _l=getPrimeList(x)
    l2+=summarize_list(_l)

  l2.sort(reverse=True)

  k=1
  a=l2[0]
  for x in l2[1:]:
    # print(x)

    if a[0]!=x[0]:
      k*=a[0]**a[1]
      a=x
      # print(k)

  k*=a[0]**a[1]
  k-=1

  # print(k)

  b=0
  for x in l1:
    b+=k%x

  return b

# main()
print(main())


Measured memory_bytes: 8264
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
using namespace std;
using ll = long long;

int main()
{
    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    int nxt = a[0] - 1;
    vector<int> route(0);
    route.emplace_back(0);
    route.emplace_back(nxt);
    vector<bool> visited(n);
    visited[0] = true;
    while(visited[nxt] == false){
        visited[nxt] = true;
        nxt = a[nxt] - 1;
        route.emplace_back(nxt);
    }
    int begin;
    rep(i,route.size()){
        if(route[i] == nxt) {begin = i; break;}
    }
    ll p;
    if(k<=begin) p=k;
    else{
        p = (ll)begin + (k-begin)%(route.size()-1-begin);
    }
    cout << route[p] + 1 << endl;

    return 0;
}

Measured memory_bytes: 5040
#include <bits/stdc++.h>
using namespace std;
constexpr int MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    int dp[101][4][4][4] = {};
    string s = "AGCT";
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            for (int k = 0; k < 4; k++) {
                string t = ""s + s[i] + s[j] + s[k];
                if (t == "AGC" || t == "ACG" || t == "GAC") continue;
                dp[3][i][j][k] = 1;
            }
        }
    }
    for (int d = 4; d <= n; d++) {
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                for (int k = 0; k < 4; k++) {
                    for (int l = 0; l < 4; l++) {
                        string t = ""s + s[j] + s[k] + s[l];
                        if (t == "AGC" || t == "ACG" || t == "GAC") continue;
                        if (s[i] == 'A' && s[l] == 'C' && (s[j] == 'G' || s[k] == 'G')) continue;
                        dp[d][j][k][l] = ((long long) dp[d][j][k][l] + dp[d - 1][i][j][k]) % MOD;
                    }
                }
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            for (int k = 0; k < 4; k++) {
                ans = ((long long) ans + dp[n][i][j][k]) % MOD;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def mp(): return map(int, input().split())
def lmp(): return list(map(int, input().split()))


n = int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

u = factorization(n)
ans = 0
if n == 1:
    print(0)
    exit()
for i in range(len(u)):
    tar = u[i][1]
    c = 0
    t = 0
    while True:
        if c+t+1 > tar:
            break
        t += 1
        c += t
    ans += t
print(ans)




Measured memory_bytes: 63372
#include<iostream>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
using namespace std;
void is(map<int,int> &mp,int n,int *a){
	for(int len=1;len<=n;len++)rep(i,n-len+1){
			int sum=0;
			rep(j,len)sum+=a[i+j];
			mp[sum]++;
		}
}
int main(){
	int m,n;
	while(cin>>n>>m,n){
		map<int,int> hm,wm;
		int h[1500],w[1500],ans=0;
		rep(i,n)cin>>h[i]; rep(i,m)cin>>w[i];
		is(hm,n,h); is(wm,m,w);
		foreach(i,hm)ans+=i->second*wm[i->first];
		cout<<ans<<endl;
	}
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        if(i%3==0 || i%5==0) continue;
        else ans+= i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3564
mod = 1000000007
MOD = 998244353
ii = lambda :  int(input())
si = lambda :  input()
dgl = lambda : list(map(int, input()))
f = lambda :   map(int, input().split())
il = lambda :  list(map(int, input().split()))
it = lambda :  tuple(map(int, input().split()))
ls = lambda :  list(input())
n,k=f()
l=il()
print(sum(i>=k for i in l))


Measured memory_bytes: 11884
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  string s;
  cin >>n>> s;
  
  for(int i=0; i<s.size(); i++){
    s[i]=char(s[i]+n);
    if(s[i]-'A'>=26) s[i]=char(s[i]-26);
  }
  
  
  cout << s << endl;
  
}

Measured memory_bytes: 256
gameCount = int(input())
output = []

for lp in range(gameCount):

    hitCount = 0
    outCount = 0
    score = 0

    while outCount < 3:

        content = input()

        if content == "HIT":
            if hitCount < 3:
                hitCount += 1
            else:
                score += 1
        elif content == "HOMERUN":
            score += hitCount
            score += 1
            hitCount = 0
        else:
            outCount += 1

    output.append(str(score))

print("\n".join(output))



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

using namespace std;

int n, k, y;
string s;
vector <pair <char, int> > v;
vector <pair<int, int> > l, r;

int main () {
  cin >> n >> k >> s;
  int h = 0;
  s = 'x'+s;
  for (int i = 1; i <= n; i++) {
    h++;
    if (s[i] != s[i-1]) {
      v.push_back({s[i], h});
      if (i-1 && s[i] == 'R') r.push_back({h, v.size()-1});
      if (i-1 && s[i] == 'L') l.push_back({h, v.size()-1});
      h=0;
      continue;
    }
    if(i-1)y++;
  }
  int a = l.size();
  int b = r.size();
  int inter = min(a, b);
  a -= inter; 
  b -= inter;
  int res = n-1;
  if(k <= inter) res = y + 2*k;
  else if(k <= inter + max(a, b))res = y + 2*inter + k - inter;
  cout << res << endl;
}

Measured memory_bytes: 2292
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
#define opt ios_base::sync_with_stdio(false); cin.tie(NULL);

void freak__()
{
    int n;
    cin >> n;
    cout << n*(n+1)/2 << "\n";
}

int main()
{
    opt;
    freak__();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	int top=b-a+1;
	for(int i=0;i<2*a-1;i++)
	{   if(i==0)
		cout<<top;
		else
		cout<<" "<<top;
		top++;
	}
}

Measured memory_bytes: 256
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

my ($n, $a, $b) = split / /, <STDIN>;

if ($a%2 == $b%2) {
  say abs($b-$a) / 2;
} elsif ($b+$a-1 < 2*$n-$a-$b+1) {
  say int(($b+$a-1)/2);
} else {
  say int((2*$n-$a-$b+1)/2);
}

Measured memory_bytes: 768
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

bool IsAcgt(const char ch) {
  return (ch == 'A' || ch == 'C' || ch == 'G' || ch == 'T');
}

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

  string S;
  cin >> S;
  const int32_t length = static_cast<int32_t>(S.length());
  int32_t max_length = 0;
  int32_t temp_length = 0;
  for (int32_t i = 0; i < length; ++i) {
    if (IsAcgt(S.c_str()[i])) {
      ++temp_length;
    } else {
      temp_length = 0;
    }
    if (temp_length > max_length) {
      max_length = temp_length;
    }
  }
  cout << max_length << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(n,v) cout<<#v<<":";for(int i=0;i<n;i++)cout<<v[i]<<" ";cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }
const int MAX=1000010;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        //???
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main(){
    COMinit();
    ll h,w,a,b;
    cin>>h>>w>>a>>b;
    ll ans=0;
    for(int i=0;i<h-a;i++){
        ll p=COM(i+b-1,i);
        ll f=COM(w-1-b+h-1-i,h-1-i);
        ans=(ans+(p*f)%mod)%mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 23808
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int dy[] = {-1, -1, 0, 0, 1, 1};
int dx[2][6] = {{-1, 0, -1, 1, -1, 0}, {0, 1, -1, 1, 0, 1}};
bool visited[128][128], wall[128][128];
long long h, w, ret;

void dfs(int y, int x)
{
   
    if (visited[y][x]) return;
 
    visited[y][x] = true;
    for (int i = 0; i < 6; i++){
        int ny = y + dy[i];
        int nx = x + dx[y % 2][i];
    	 if (ny < 0 || nx < 0 || ny > h+1 || nx > w+1) continue;
        if (wall[ny][nx]) {
            ret++;
            continue;
        }
        dfs(ny, nx);
    }
    return;
}
 
int main(void)
{
    int a;
    cin >> w >> h;
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            cin >> a;
            if (a) wall[i+1][j+1] = true;
        }
    }
 
    ret = 0;
    dfs(0, 0);
 
    cout << ret << endl;
 
    return 0;
}

Measured memory_bytes: 1504
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(void)
{
	int x, y;
	vector<string> v;
	while (1)
	{
		cin >> x >> y;
		if (x == 0&&y==0)break;
		else if (x > y)v.push_back(to_string(y) + " " + to_string(x));
		else v.push_back(to_string(x) + " " + to_string(y));
	}
	for (string s : v)
	{
		cout << s << endl;
	}
}


Measured memory_bytes: 3276
#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);
	int n;
	cin >> n;
	vector<int> a(n);
	rep (i, n) cin >> a[i];
	int now = 1, ans = 0;
	rep (i, n) {
		if (a[i] == now) {
			now++;
			ans++;
		}
	}
	if (ans == 0) cout << "-1\n";
	else cout << n - ans << "\n";
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
//#include<cmath>
using namespace std;

typedef long long llong;
const int MAX = 2000001;
int C[10010], A[MAX], B[MAX];

int main(void)
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		C[A[i]]++;
	}
	for (int i = 1; i < 10001; i++)
		C[i] = C[i] + C[i - 1];
	for (int i = n - 1; i >= 0; i--) {
		B[C[A[i]]] = A[i];
		C[A[i]]--;
	}
	for (int i = 1; i <= n; i++) {
		if (i - 1)
			cout << " ";
		cout << B[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 18744
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
    int n;
    int i=0;
    cin >> n;
    while(i<n){
        i++;
        int x = i;
        if(x%3==0){
            cout << " " << i << flush;
            continue;
        }
        while(x){
            if(x%10==3){
                cout << " " << i << flush;
                break;
            }
            x /= 10;
        }     
    }
    cout << endl;
}


Measured memory_bytes: 3116
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
 
int main()
{
	ll n, k, a, b, i, m = 0;
	pair<ll, ll> p[100001];

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

	sort(p, p + n);

	for(i = 0; i < n; i++){
		m += p[i].second;
		if(m >= k){
			break;
		}
	}

	cout << p[i].first << endl;
}

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

int nth_bit(int64_t num, int n){
    return (num >> n) & 1;
}

void chmin(int64_t& a, int64_t b){
    a = min(a, b);
}

int main(){
    int N;
    cin >> N;
    vector<int64_t> X(N), Y(N), P(N);
    for(int i=0; i<N; i++) cin >> X[i] >> Y[i] >> P[i];

    vector<int64_t> pre(1<<N, 1e18), pre0(1<<N);
    for(int b=0; b<(1<<N); b++){
        vector<pair<int64_t, int64_t>> xp, yp;
        for(int i=0; i<N; i++) if(nth_bit(b, i)){
            xp.emplace_back(X[i], P[i]);
            yp.emplace_back(Y[i], P[i]);
            pre0[b] += min(abs(X[i]), abs(Y[i])) * P[i];
        }
        sort(xp.begin(), xp.end());
        sort(yp.begin(), yp.end());
        for(int i=0; i<N; i++){
            int64_t xs = 0, ys = 0;
            for(auto& p : xp) xs += abs((p.first-X[i])*p.second);
            for(auto& p : yp) ys += abs((p.first-Y[i])*p.second);
            chmin(pre[b], min(xs, ys));
        }
    }

    vector<vector<int64_t>> dp(1<<N, vector<int64_t>(N+1, 1e18));
    for(int b=0; b<(1<<N); b++) for(int k=0; k<=N; k++) dp[b][k] = pre0[b];
    for(int b=0; b<(1<<N); b++) for(int b1=b; b1>0; b1=(b1-1)&b) for(int k=0; k<N; k++) chmin(dp[b][k+1], dp[b-b1][k] + pre[b1]);
    for(int k=0; k<=N; k++) cout << dp[(1<<N)-1][k] << endl;
    return 0;
}


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

int main()
{
    long long n, k; cin >> n >> k;
    long long tmp = n%k;
    long long ans = min(tmp, k - tmp);
    cout << ans << endl;
    
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final int n = Integer.parseInt(sc.next());
        final int r = Integer.parseInt(sc.next());
        int answer = 0;
        if (n >= 10) {
            answer = r;
        } else {
            answer = r + (100 * (10 - n));
        }
        System.out.println(answer);
        sc.close();
    }
}


Measured memory_bytes: 35636
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define vv vector
#define pp pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define fastio                    \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);
typedef pair<ll, ll> pll;
typedef vv<ll> vll;
typedef vv<pll> vpll;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//adds two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set]
//(2)set.order_of_key(k)[count of elements strictly less than k]
#define LG(args...)                               \
	{                                             \
		string _s = #args;                        \
		replace(_s.begin(), _s.end(), ',', ' ');  \
		stringstream _ss(_s);                     \
		err(istream_iterator<string>(_ss), args); \
		cerr << endl;                             \
	}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "(" << *it << ":" << a << ") ";
	err(++it, args...);
}
//:::::::::::::::::::::::::::::::::::::::::::::
const ll INF = 9e18;
const ll MOD = 1e9 + 7;
// #define dbg

int main(){
	fastio;
	ll n;
	cin>>n;
	ll a[n][3];
	for(ll i=0; i<n; i++){
		cin>>a[i][0]>>a[i][1]>>a[i][2];
	}
	vv<vll> dp(n, vll(3, 0));
	dp[0] = {a[0][0], a[0][1], a[0][2]};
	for(ll i=1; i<n; i++){
		for(ll j=0; j<3; j++){
			dp[i][j] = max(dp[i-1][(j+1)%3] , dp[i-1][(j+2)%3]) + a[i][j];
		}
	}
	cout<<*max_element(all(dp[n-1]));
}

Measured memory_bytes: 10984
use std::io::*;
use std::str::FromStr;

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

fn main(){
    let n: usize = read();
    let mut v: Vec<i64> = Vec::with_capacity(n);
    let mut c: Vec<i64> = Vec::with_capacity(n);
    for _ in 0..n {
        v.push(read());
    }
    
    for _ in 0..n {
        c.push(read());
    }
    let ret = (0..n)
        .map(|i| v[i] - c[i])
        .filter(|e| e > &0)
        .fold(0, |a, b| a + b);
    println!("{}", ret);
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;

struct data{
  ll d,v;
  void c(){
    ll x = __gcd(d,v);
    d/=x;
    v/=x;
  }
};

int n;
data t[10];
ll u[10],size;

ll lcm(ll a,ll b){
  return a/ __gcd(a,b) * b;
}

ll gcd(ll a,ll b){
  return __gcd(a,b);
}

void change(){
  ll x = t[0].d;
  for(int j=1;j<n;j++)x=gcd(x,t[j].d);
  for(int j=0;j<n;j++)t[j].d/=x;
}
void de();

int main(){
  while(cin>>n&&n){
    for(int i=0;i<n;i++){
      cin>>t[i].d>>t[i].v;
      t[i].c();
    }
    change();
    for(int i=1;i<n;i++){
      for(int j=0;j<n;j++)t[j].d*=t[(j+i)%n].v;
      change();
    }//i

    
    for(int i=0;i<n;i++){
      //cout<<t[i].d<<endl;
      
      size=0;

      for(int j=1;j<n;j++){
	ll y = t[(j+i)%n].d;
	y = y / gcd(y,t[i].d);
	for(int k=0;k<size;k++)y=y/gcd(y,u[k]);
	if(y>1)u[size++]=y;
      }


      ll ans=1;
      for(int j=0;j<size;j++)ans*=u[j];
      cout<<ans<<endl;
    }
    
  }
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
const long long INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main()
{   
    int H,W; cin >> H >> W;
    vector<vector<char> > s(H+2,vector<char>(W+2));
    ll wal_num = 0;
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            char c; cin >> c;
            s[i][j] = c;
            if(c == '#')wal_num++;
        }
    }
   
    int dy[4] = {1,0,-1,0};
    int dx[4] = {0,1,0,-1};
    vector<vector<ll> > dist(H+2,vector<ll>(W+2,MOD));
    dist[1][1] = 1;
    queue<pair<int,int>> Q;
    Q.push(make_pair(1,1));

    while(!Q.empty()){
        int cx = Q.front().first,cy = Q.front().second;
        Q.pop();
        for(int i=0;i<4;i++){
            int ex = cx + dx[i],ey = cy + dy[i];
            //行先が壁、探索済ならやめる
            if(s[ex][ey] != '.' || dist[ex][ey] != MOD)continue;
            dist[ex][ey] = dist[cx][cy] + 1;
            Q.push(make_pair(ex, ey));
        }
    }
    if(dist[H][W] == MOD)cout << -1 << endl;
    else cout << (H*W - wal_num - dist[H][W]) << endl;
}
    

Measured memory_bytes: 256
using System;

public class Program
{ 
  private static void Main()
  {
    string[] input = Console.ReadLine().Split(' ');
    
    int a = int.Parse(input[0]);
    int b = int.Parse(input[1]);
    
    Console.WriteLine(a < 10 & b < 10 ? a * b : -1);
  }
}


Measured memory_bytes: 13140
pairs = (
    ("SUN", 7),
    ("MON", 6),
    ("TUE", 5),
    ("WED", 4),
    ("THU", 3),
    ("FRI", 2),
    ("SAT", 1)
)

date = input()
for pair in pairs:
    if pair[0] == date:
        print(pair[1])


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

void Z_algo(string &S, vector<int> &v) {
    int N = S.size();
    v = vector<int>(N, 0);
    v[0] = N;
    int i = 1, j = 0;
    while (i < N) {
        while (i+j < N && S[j] == S[i+j]) {
            j++;
        }
        v[i] = j;
        int k = 1;
        while (i+k < N && k+v[k] < v[i]) {
            v[i+k] = v[k];
            k++;
        }
        i += k;
        j = max(j-k, 0);
    }
    
    return;
}


int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans = 0;
    vector<int> table(N, 0);
    for (int i = 0; i < N; i++) {
        string T = S.substr(i, N-i);
        Z_algo(T, table);
        for (int j = 1; j < N-i; j++) {
            ans = max(ans, min(table[j], j));
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(void)
{
	char test[10], test2[10], test3[10];
	cin >> test >> test2 >> test3;
	if (test[0] >= 97 && test[0] <= 122) {
		test[0] = test[0] - 32;
	}
	if (test2[0] >= 97 && test2[0] <= 122) {
		test2[0] -= 32;
	}
	if (test3[0] >= 97 && test3[0] <= 122) {
		test3[0] -= 32;
	}
	cout << test[0] << test2[0] << test3[0] << endl;
	
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int a=0, b=0;
	scanf("%d %d", &a, &b);
	if (a < b) {
printf("a < b\n");
}
	if (a > b) {
printf("a > b\n");
}
	if (a == b) {
printf("a == b\n");
}
}

Measured memory_bytes: 2592
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int answer=2147483647;
    for (int i=1;i<=n;i++)
    {
     int x;
     int temp=0;
          cin>>x;
     while (!(x&1))
     {
      x=x>>1;
      temp++;
     }
     if (temp<answer) answer=temp;
    }
    cout<<answer<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
	string s;
	cin>>s;
	if((s[0]==s[1]&&s[1]==s[2])||(s[1]==s[2]&&s[2]==s[3])) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    int s[13] = {}, d[13] = {}, h[13] = {}, c[13] = {};
    for (int i = 0; i < n; ++i)
    {
        char mark;
        int num;
        cin >> mark >> num;
        num--;
        if (mark == 'S')
            s[num]++;
        else if (mark == 'D')
            d[num]++;
        else if (mark == 'H')
            h[num]++;
        else
            c[num]++;
    }
    for (int i = 0; i < 13; ++i)
    {
        if(!s[i])
            cout << "S " << i + 1 << endl;
    }
    for (int i = 0; i < 13; ++i)
    {
        if (!h[i])
            cout << "H " << i + 1 << endl;
    }
    
    for (int i = 0; i < 13; ++i)
    {
        if (!c[i])
            cout << "C " << i + 1 << endl;
    }
    for (int i = 0; i < 13; ++i)
    {
        if (!d[i])
            cout << "D " << i + 1 << endl;
    }
}



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

int main(){
  string s; int q;
  cin >>s >>q;
  deque<char> ds(s.size()); 
  rep(i,s.size()) ds[i]=s[i];
  int F = 0;
  rep(i,q){
    int t; cin >>t;
    if(t==1) F = 1-F;
    else {
      int f; char c;
      cin >>f >>c; f--;
      if(F) f = 1-f;
      if(f==0) ds.push_front(c);
      else ds.push_back(c);
    }
  }
  if(F) reverse(ds.begin(), ds.end());
  for(auto c:ds) cout << c;
  cout << endl;
  return 0;
}

Measured memory_bytes: 4008
#include <iostream>
#include <unordered_map>
#include <vector>
#include <stack>
#include <algorithm>
#include <list>
#include <set>
#include <climits>
#include <cmath>
#define lli long long int
using namespace std ;

int eval(vector<int> &height, vector<int> &dp, int i)
{
	if(i == 0) return 0 ;
	if(dp[i] != -1) return dp[i] ;

	dp[i] = INT_MAX ;

	dp[i] = min(dp[i],eval(height,dp,i-1) + abs(height[i] - height[i-1])) ;
	if(i-2 >= 0) 
		dp[i] = min(dp[i], eval(height,dp,i-2) + abs(height[i] - height[i-2])) ;

	return dp[i] ;
}

int main(int argc, char const *argv[])
{
	int n ;
	cin>>n ;

	vector<int> height(n) ;
	vector<int> dp(n,-1) ;
	for(int i = 0 ; i < n ; i++) cin>>height[i] ;

	cout<<eval(height,dp,n-1)<<endl ;
	return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
//#include "optimization.h"

using namespace std;

#define vec vector
#define ALL(x) begin(x), end(x)

typedef unsigned int ui;
typedef long long ll;
typedef long double ld;
typedef pair< int, int > pii;
typedef pair< long long, long long > pll;

const int inf = 1000 * 1000 * 1000;
const ll inf64 = 1e18;

int main() {

#ifdef debug
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(0);

    int n, m;
    string s, t;

    cin >> n >> m;
    cin >> s >> t;

    ll l = 1ll * n * m / __gcd(n, m);

    unordered_map< ll, char > mp;

    for(int i = 0;i < n;i++) {
        mp[(l/n) * i] = s[i];
    }

    for(int i = 0;i < m;i++) {
        ll ps = (l/m) * i;
        if(mp.count(ps) && mp[ps] != t[i]) {
            cout << "-1\n";
            return 0;
        }
    }

    cout << l << "\n";

    return 0;
}



Measured memory_bytes: 4260
#include <stdio.h>
int main(void){
	int k,j,a;
	char flag[1000000]={1,1};//0,1は除外する
	for(k=2;k<1000;k++){
		if(flag[k]==0){
			for(j=k*k;j<1000000;j+=k)
				flag[j]=1;
		}
	}
	while(~scanf("%d",&a)){
		k=0;
		for(j=2;j<=a;j++) if(flag[j]==0) k++;
		printf("%d\n",k);
	}
}

Measured memory_bytes: 0
import java.util.*;
//import java.lang.Math;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(true){
            int H=sc.nextInt();
            int W=sc.nextInt();
            if(H+W==0) break;
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++) System.out.print((i+j)%2==1?'.':'#');
                System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 37128
W,H,N = map(int,input().split())
L,R,D,U = 0,W,0,H

for i in range(N):
  x,y,a = map(int,input().split())
  if a==1:
    L=max(L,x)
  elif a==2:
    R=min(R,x)
  elif a==3:
    D=max(D,y)
  else:
    U=min(U,y)

print(max(0,R-L)*max(0,U-D))

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
int a[maxn],b[maxn],c[maxn],dp[maxn][3];
int main()
{
	int n,k;
	while(~scanf("%d",&n))
	{
		for(int i=1;i<=n;i++)
		  scanf("%d%d%d",&a[i],&b[i],&c[i]);
		dp[1][0]=a[1],dp[1][1]=b[1],dp[1][2]=c[1];
		for(int i=2;i<=n;i++)
		{
			dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
			dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
			dp[i][2]=max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]);
		}
		int ans=0;
		for(int i=0;i<3;i++)
		  if(dp[n][i]>ans)
		    ans=dp[n][i];
		cout<<ans<<endl;
	}
}

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

char s[4];
int ans;

int main(){
	cin >> s[1] >> s[2] >> s[3];
	if (s[1] == 'R'){
		if (s[2] == 'R'){
			if (s[3] == 'R') puts("3");
			else puts("2");
		} else puts("1");
	} else {
		if (s[2] == 'R'){
			if (s[3] == 'R') puts("2");
			else puts("1");
		} else {
			if (s[3] == 'R') puts("1");
			else puts("0");
		}
	}
	return 0;
}

Measured memory_bytes: 3580
S=input()
N=len(S)
S_r=S[::-1]
S2=S[:int((N-1)/2)]
S2_r=S2[::-1]
S3=S[int((N+3)/2)-1:]
S3_r=S3[::-1]
x=0
a=0
b=0
c=0
for i in range(int((N-1)/2)):
    if S[i]==S_r[i]:
        a+=1
if a==int((N-1)/2):
    x+=1
    for i in range(len(S2)):
        if S2[i]==S2_r[i]:
            b+=1
if b==len(S2):
    x+=1
    for i in range(len(S3)):
        if S3[i]==S3_r[i]:
            c+=1
if c==len(S3):
    x+=1

if x==3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define LL long long
using namespace std;
struct good
{
    int w,v;
}g[110];
 
bool cmp(good a,good b)
{
    return a.v > b.v;
}
good A[110],B[110],C[110],D[110];
 
LL swa[110],swb[110],swc[110],swd[110];//重量的前缀和
LL sva[110],svb[110],svc[110],svd[110];//价值的前缀和
 
int main(void)
{
    int n,w,i,j,k,l;
    int a,b,c,d;
    while(scanf("%d%d",&n,&w)==2)
    {
        a = b = c = d = 0;
        for(i=1;i<=n;i++)
        {
            scanf("%d%d",&g[i].w,&g[i].v);
            if(g[i].w == g[1].w)
                A[++a] = g[i];
            if(g[i].w == g[1].w + 1)
                B[++b] = g[i];
            if(g[i].w == g[1].w + 2)
                C[++c] = g[i];
            if(g[i].w == g[1].w + 3)
                D[++d] = g[i];
        }
        sort(A+1,A+a+1,cmp);
        sort(B+1,B+b+1,cmp);
        sort(C+1,C+c+1,cmp);
        sort(D+1,D+d+1,cmp);
        swa[0] = swb[0] = swc[0] = swd[0] = 0;
        sva[0] = svb[0] = svc[0] = svd[0] = 0;
        for(i=1;i<=a;i++)
        {
            swa[i] = swa[i-1] + A[i].w;
            sva[i] = sva[i-1] + A[i].v;
        }
        for(i=1;i<=b;i++)
        {
            swb[i] = swb[i-1] + B[i].w;
            svb[i] = svb[i-1] + B[i].v;
        }
        for(i=1;i<=c;i++)
        {
            swc[i] = swc[i-1] + C[i].w;
            svc[i] = svc[i-1] + C[i].v;
        }
        for(i=1;i<=d;i++)
        {
            swd[i] = swd[i-1] + D[i].w;
            svd[i] = svd[i-1] + D[i].v;
        }
        int sumv = 0;
        int ans = 0;
        for(i=0;i<=a;i++)
        {
            for(j=0;j<=b;j++)
            {
                for(k=0;k<=c;k++)
                {
                    for(l=0;l<=d;l++)
                    {
                        LL sum = swa[i] + swb[j] + swc[k] + swd[l];
                        if(sum <= (LL)w)
                        {
                            ans = max((LL)ans,sva[i]+svb[j]+svc[k]+svd[l]);
                        }
                    }
                }
            }
        }
        cout << ans << endl;
    }
 
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int i,n,a,b,ac,bc[101],s[101];
	scanf("%d",&n);
	scanf("%d %d",&a,&b);
	scanf("%d",&ac);
	s[1]=ac;
	for(i=1;i<=n;i++){
		scanf("%d",&bc[i]);
	}
	sort(bc+1,bc+n+1,greater<int>());
	for(i=1;i<=n;i++){
		s[i+1]=s[i]+bc[i];
	}
	s[1]=s[1]/a;
	for(i=2;i<=n+1;i++){
		s[i]=s[i]/(a+(b*(i-1)));
	}
	sort(s+1,s+n+2,greater<int>());
	printf("%d\n",s[1]);
	return 0;
}
	

Measured memory_bytes: 1040
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<long long,long long>& a,
         pair<long long,long long>& b)
{
    return a.second < b.second;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,c[4]={0};
    string s;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        if(s=="AC")
        {
            c[0]++;
        }
        else if(s=="WA")
            c[1]++;
        else if(s=="TLE")
            c[2]++;
        else
            c[3]++;
    }
    cout<<"AC x "<<c[0]<<endl;
    cout<<"WA x "<<c[1]<<endl;
    cout<<"TLE x "<<c[2]<<endl;
    cout<<"RE x "<<c[3]<<endl;
}


Measured memory_bytes: 3652
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[]) {
  ll N, M;
  cin >> N >> M;
  vector<pair<ll, ll>> ab(M);
  map<ll, ll> B;
  for (size_t i = 0; i < ab.size(); i++) {
    cin >> ab[i].first >> ab[i].second;
    if (ab[i].first == 1 || ab[i].second == 1) {
      cerr << "18" << endl;
      B[ab[i].second * ab[i].first]++;
    } else if (ab[i].first == N || ab[i].second == N) {
      cerr << "21" << endl;
      B[ab[i].second * ab[i].first / N]++;
    }
  }
  for (auto iter = B.begin(); iter != B.end(); iter++) {
    cerr << "iter.second" << iter->second << endl;
    if (iter->second >= 2) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }

  cout << "IMPOSSIBLE" << endl;

  return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  int tmp = n;
  int ans = 0;  
  while(1){
    if(tmp <= 3){
      ans++;
      break;
    }
    else if(tmp%3 == 0){
      tmp = tmp/3;
    }else if(tmp%3 == 1){
      tmp = tmp/3+1;
    }else if(tmp%3 == 2){
      tmp = tmp/3+1;
    }
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1164
# 2019/07/26
# かんにんぐ

n=int(input())
s=list(input())
bk=0
wh=s.count('.')
cnt=wh
for i in range(n):
	if s[i]=='#':bk+=1
	else:wh-=1
	cnt=min(cnt,bk+wh)

print(cnt)

Measured memory_bytes: 4840
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Robot> li = new ArrayList<Robot>();
        for(int i = 0; i < n; i++){
            int x = sc.nextInt();
            int a = sc.nextInt();
            li.add(new Robot(x-a,x+a));
        }
        Collections.sort(li);
        int ans = 0;
        int left = Integer.MAX_VALUE;
        for(Robot r : li){
            if(left >= r.r){
                ans++;
                left = r.l;
            }else{
                left = Math.max(left,r.l);
            }
        }
        System.out.println(ans);
    }
}

class Robot implements Comparable<Robot>{
    int l,r;
    public Robot(int l, int r){
        this.l = l;
        this.r = r;
    }
    
    public int compareTo(Robot r){
        if(this.r > r.r){
            return -1;
        }else if(this.r < r.r){
            return 1;
        }else{
            return 0;
        }
    }
}

Measured memory_bytes: 65108
# ABC82 C - Good Sequence
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
counter = Counter(A)
ans = 0
for c in counter.items():
    d = c[1]-c[0]
    if  d > 0:
        ans += d
    elif d < 0:
        ans += c[1]
print(ans)

Measured memory_bytes: 18672
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;

#define repi(i,a,b) for(ll i = (a); i < (b); i++)
#define rep(i, n) for(ll i = 0; i < (n); ++i)


int main() {
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    ll res = 1e18;
    for (uint b = 0; ((b >> (N-1)) & 1) != 1; ++b) {
        vector<int> buf = a;
        ll mx = buf[0];
        ll sum = 0;
        repi(i, 1, N) if (((b >> (i - 1)) & 1) == 1) {
            sum += max(0ll, mx + 1 - buf[i]);
            buf[i] = max(mx + 1, (ll)buf[i]);
            mx = max(mx + 1, (ll)buf[i]);
        }
        int c = 1;
        mx = buf[0];
        repi(i,1, N) {
            if (buf[i] > mx) {
                c++;
                mx = buf[i];
            }
        }
        if(c >= K) res = min(res, sum);
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner cin = new Scanner(System.in);
        String S = cin.nextLine();

        if(S.equals("AAA" )|| S.equals("BBB"))
            System.out.println("No");
        else
            System.out.println("Yes");


        cin.close();
    }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
int ans;
char S[10000];
int main()
{
    scanf("%s",S);
    for(register int i=0;i<strlen(S);++i)
    	if(S[i]=='1')ans++;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
def solve():
    A, B, C = list(map(int, input().split()))
    ans = 0
    if A%2 == B%2 and A%2 != C%2:
        A += 1
        B += 1
        ans += 1
    elif A%2 == C%2 and A%2 != B%2:
        A += 1
        C += 1
        ans += 1
    elif B%2 == C%2 and A%2 != B%2:
        B += 1
        C += 1
        ans += 1
    max_val = max(A, B, C)
    ans += abs(max_val-A)//2 + abs(max_val-B)//2 + abs(max_val-C)//2
    print(ans)
    
    
solve()


Measured memory_bytes: 3064
#include <stdio.h>

int main(){

	long long int a = 0, b = 0, x;
	
	scanf("%lld", &x);
	b = x;
	while(b != 0){
		a += b%10;
		b /= 10;
	}
	if (x%a == 0)
		printf("Yes\n");
	else
		printf("No\n");
		
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

struct RollingHash {
    int n;
    long long base1, base2, mod1, mod2;
    vector<long long> hash1, hash2, pow1, pow2;
    RollingHash(const string &s) : base1(1009), base2(1007), mod1(1000000007), mod2(1000000009) {
        n = s.size();
        hash1.assign(n + 1, 0);
        hash2.assign(n + 1, 0);
        pow1.assign(n + 1, 1);
        pow2.assign(n + 1, 1);
        for(int i = 0; i < n; i++) {
            hash1[i + 1] = (hash1[i] + s[i]) * base1 % mod1;
            hash2[i + 1] = (hash2[i] + s[i]) * base2 % mod2;
            pow1[i + 1] = pow1[i] * base1 % mod1;
            pow2[i + 1] = pow2[i] * base2 % mod2;
        }
    }
    pair<long long, long long> get(int l, int r) {
        long long t1 = ((hash1[r] - hash1[l] * pow1[r - l]) % mod1 + mod1) % mod1;
        long long t2 = ((hash2[r] - hash2[l] * pow2[r - l]) % mod2 + mod2) % mod2;
        return {t1, t2};
    }
    int lce(int l, int r){
        int len = n - r;
        int low = -1, high = len + 1;
        while(high - low > 1){
            int mid = (low + high) / 2;
            if(get(l, l + mid) == get(r, r + mid)) low = mid;
            else high = mid;
        }
        return low;
    }
};

int n;
RollingHash rh("");

bool f(int len){
    map<P, P> mp;
    rep(i, 0, n - len + 1){
        P tmp = rh.get(i, i + len);
        if(!mp.count(tmp)){
            mp[tmp] = {i, i};
        }else{
            mp[tmp].first = min(mp[tmp].first, i);
            mp[tmp].second = max(mp[tmp].first, i);
        }
    }
    for(auto i : mp){
        if(i.second.second - i.second.first >= len){
            return true;
        }
    }
    return false;
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // int n;
    string s;
    cin >> n >> s;
    int d[26] = {};
    rep(i, 0, n) d[s[i] - 'a']++;
    bool g = true;
    rep(i, 0, 26) if(d[i] > 1) g = false;
    if(g){
        cout << 0 << endl;
        return 0;
    }
    RollingHash rh2(s);
    rh = rh2;
    int ok = 0, ng = n;
    while(ng - ok > 1){
        int mid = (ok + ng) / 2;
        if(f(mid)) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}

Measured memory_bytes: 1024
function main(input) {
  var lines = input.split("\n")
  var n = lines[0]*1
  var str = lines[1].split(" ")

  var result = ""
  for (var i = 0; i < n; i++) {
    result = result + str[0][i] + str[1][i]
  }

  console.log(result)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

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

using namespace std;

struct Point{
	int x;
	int y;
	void display(){
		cout << x << " " << y << endl;
	}
};

int cross_product(Point O, Point A, Point B){
	return (A.x - O.x) * (B.y - O.y) - (A.y - O.y) * (B.x - O.x);
}

vector<Point> find_convex_hull(vector<Point> points){
	int n = points.size();
	if(n <= 2) return points;

	vector<Point> convex_hull(2 * n);
	sort(points.begin(), points.end(), [](Point p, Point q){ return p.y < q.y || (p.y == q.y && p.x < q.x);} );

	int hull_idx = 0;
	// build the lower hull
	for(auto i = 0; i < n; ++i){
		// suppose we have built a lower hull with >= 3 points
		while(hull_idx >= 2 && cross_product(convex_hull[hull_idx - 2], convex_hull[hull_idx - 1], points[i]) < 0){
			// if the candidate point violate the hull, reduce the hull
			--hull_idx;
		}
		convex_hull[hull_idx++] = points[i];
	}

	// save the last point of the lower hull
	int last_point = hull_idx - 1;
	// build the upper hull
	// start from the point before the last point
	for(auto i = n - 2; i >= 0; --i){
		// same, suppose we have built an upper hull with >= 3 points
		while(hull_idx >= last_point + 2 && cross_product(convex_hull[hull_idx - 2], convex_hull[hull_idx - 1], points[i]) < 0){
			--hull_idx;
		}
		convex_hull[hull_idx++] = points[i];
	}
	convex_hull.resize(hull_idx - 1);
	return convex_hull;
}

int main(){
	int n;
	cin >> n;
	vector<Point> points;
	for(auto i = 0; i < n; ++i){
		int x, y;
		cin >> x >> y;
		points.push_back({x, y});
	}

	vector<Point> convex_hull = find_convex_hull(points);
	
	cout << convex_hull.size() << endl;
	for(auto p: convex_hull){
		p.display();
	}
}


Measured memory_bytes: 5944
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    int n,q;
    cin >> n >> q;
    queue<pair<string,int>> que;
    REP(_,n) {
        string a;
        int b;
        cin >> a >> b;
        que.push(make_pair(a,b));
    }

    ll t = 0;
    while (!que.empty()) {
        auto p = que.front();
        que.pop();
        if (p.second > q) {
            p.second -= q;
            t+=q;
            que.push(p);
            continue;
        }
        t+=p.second;
        cout << p.first << " " << t << endl;
    }
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 6316
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = 1 << 29;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const int MAX_V = 500;
const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



struct UnionFind {
    vector<ll> par;
        
    UnionFind(ll n) : par(n, -1) { }
    void init(ll n) { par.assign(n, -1); }
    
    ll find(ll x) {
        if (par[x] < 0) return x;
        else return par[x] = find(par[x]);
    }
    
    bool same(ll x, ll y) {
        return find(x) == find(y);
    }
    
    bool unite(ll x, ll y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    ll size(ll x) {
        return -par[find(x)];
    }

    void print(ll x){
        rep(i,x){
            cout<<par[i]<<endl;
        }
        return ;
    }
};



void solve() {

    ll n,m;
    cin>>n>>m;
    UnionFind uf(n);
    rep(i,m){
        ll a,b;
        cin>>a>>b;
        uf.unite(a,b);
    }
    set<ll> st;
    rep(i,n){
        st.insert(uf.find(i));
    }
    cout<<st.size()-1<<endl;


}



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);


    ll t=1;
    
    // cin>>t;

    rep(i,t){
        solve(); 
    }

    return 0;
}


Measured memory_bytes: 7772
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main(){
ll N;cin >> N;
vector<ll> V(N);
vector<double> A;

rep(i, 0, N)cin >> V[i];

sort(ALL(V));

ll M = V[N - 1];

for(auto v : V ){

    A.push_back(abs(M/2.0 - v));

}

auto Iter = min_element(ALL(A)) - A.begin();

cout << M << " " << V[Iter];

}

Measured memory_bytes: 5032