akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			final int N = s.nextInt();
			final int M = s.nextInt();

			int lhs = 1;
			int rhs = N;
			for (int i = 0; i < M; i++) {
				int l = s.nextInt();
				if (lhs < l) {
					lhs = l;
				}
				int r = s.nextInt();
				if (rhs > r) {
					rhs = r;
				}
			}
			if (lhs > rhs) {
				System.out.println(0);
			} else {
				System.out.println(rhs - lhs + 1);
			}
		}
	}
}


Measured memory_bytes: 62324
from bisect import bisect_left
def lmi(): return list(map(int, input().split()))

h, w = lmi()
s = [input() for i in range(h)]

cnt = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    j = 0
    while j < w:
        if s[i][j] == '#':
            j += 1
            continue
        l = 0
        while j+l < w:
            if s[i][j+l] == '#':
                break
            l += 1
        for k in range(l):
            cnt[i][j+k] += l
        j += l+1

for i in range(w):
    j = 0
    while j < h:
        if s[j][i] == '#':
            j += 1
            continue
        l = 0
        while j+l < h:
            if s[j+l][i] == '#':
                break
            l += 1
        for k in range(l):
            cnt[j+k][i] += l
        j += l+1


print(max([max([cnt[i][j] for i in range(h)]) for j in range(w)])-1)


Measured memory_bytes: 102232
#include <iostream>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <utility>
using namespace std;
int ky[8] = {-1,1,-2,2,-2,2,-1,1}; 
int kx[8] = {-2,-2,-1,-1,1,1,2,2};
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int ddy[8] = {-1,0,1,-1,1,-1,0,1};
int ddx[8] = {-1,-1,-1,0,0,1,1,1};
typedef long long ll;
#define pi pair
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define rep1(i,a,b) for(int i = a; i < b; i++)
#define rep2(i,a,b) for(int i = a; i <= b; i++) 
#define INF 999999999999
const double PI = acos(-1.0);
int n;
ll a[200000];
ll ans;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> n;
    rep1(i,0,n){
        cin >> a[i];
       //s.insert(a[i]);
    }
    sort(a,a+n);
    reverse(a,a+n);
    
    //ans += a[0];
    rep1(i,1,n) ans += a[i/2];
    cout << ans;
	return 0;
}

Measured memory_bytes: 5212
#include <iostream>
#include <vector>
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define swap(a, b) ((a) += (b), (b) = (a) - (b), (a) -= (b))
using namespace std;

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

int main(){
    int n, i, ans = 1;
    cin >> n;
    vector <int> a(n); rep(i, n) cin >> a[i];
    vector <int> l(n); rep(i, n) l[i] = a[0];
    vector <int> r(n); rep(i, n) r[i] = a[n - 1];

    for(i = 0; i < n - 1; i++){
        l[i + 1] = gcd(a[i], l[i]);
    }

    for(i = n - 1; i > 0; i--){    
        r[i - 1] = gcd(a[i], r[i]);
    }

    ans = r[0];
    for(i = 1; i < n - 1; i++) ans = max(ans, gcd(r[i], l[i]));
    ans = max(l[n - 1], ans);

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


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

struct UF
{
    vi r, p, sz;
    UF(int n) : r(n, 0), p(n, 0), sz(n, 1)
    {
        iota(p.begin(), p.end(), 0);
    }
	
    int f(int x)
    {
        return (p[x] == x ? x : p[x] = f(p[x]));
    }
	
    void u(int i, int j)
    {
        int x = f(i), y = f(j);
        if (x == y)
            return;

        p[y] = x;
        sz[x] += sz[y];
    }

    bool s(int i, int j)
    {
        return f(i) == f(j);
    }
};

int a[50], b[50];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin >> n>> m;
    for (int i = 0; i < m; ++i)
    {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }
    int sol = 0;
    for (int i = 0; i < m; ++i)
    {
        UF uf(n);
        for (int j = 0; j < m; ++j)
            if (j != i)
                uf.u(a[j], b[j]);
        if (uf.sz[uf.f(0)] != n)
            sol++;
    }
    cout << sol;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit = 10000000

def get_gcd(A, B):
    r = A%B
    if r == 0:
        return B
    else:
        return get_gcd(B, r)
           
if __name__ == '__main__':
    N = int(input())
    T = [int(input()) for _ in range(N)]
    
    ans = 1
    for t in T:
        gcd = get_gcd(ans, t)
        ans = t//gcd*ans
        
    print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n; cin>>n;
	string s; cin>>s;
	int t=s.size();
	vi vec(t);
	rep(i,0,t){
		vec[i]=(s[i]-'A'+n)%26;
	}
	rep(i,0,t){
		cout<<char('A'+vec[i]);
	}
	
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#define MAX 100000


int A[MAX], n;

int Partition(int p, int r){
    int x , i , j ,t;
    x = A[r];
    i = p - 1;
    for( j = p ; j < r ; j++){
        if(A[j] <= x){
            i++;
            t = A[j]; A[j] = A[i]; A[i] = t;
        }
    }
    t = A[i+1]; A[i+1] = A[r]; A[r] = t;
    return i+1;
}

int main(){
    int i,q;

    scanf("%d", &n);
    for(int i = 0; i < n; i++)  scanf("%d", &A[i]);

    q = Partition(0,n-1);

    for(i = 0 ; i < n; i++){
        if(i) printf(" ");
        if(i == q) printf("[");
        printf("%d",A[i]);
        if(i == q) printf("]");
    }
    printf("\n");

    return 0;
}



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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

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

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;

  int su = 0;

  FOR(i, 1, n+1) {
    su += i;
    if(su >= n) {
      while(n > 0) {
        if(i <= n) {
          cout << i << endl;
          n -= i;
        }
        i--;
      }

      break;
    }
  }
}


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

int sh, sm, eh, em, K;

int main()
{
	scanf("%d %d %d %d %d", &sh, &sm, &eh, &em, &K);
	int x = eh*60+em - (sh*60+sm) - K;
	x = max(x, 0);
	printf("%d", x);
	return 0;
}

Measured memory_bytes: 3812
/**
  *  Worg
  */
#include <string>
#include <vector>
#include <iostream>

bool check(std::string& s, std::vector<std::pair<char, char>>& ops, int starting_id, int end_id) {
    int q = (int)ops.size();

    for (int i = 0, id = starting_id; i < q; i++) {
        if (ops[i].first == s[id]) {
            if (ops[i].second == 'L') {
                id -= 1;
            } else {
                id += 1;
            }
        }

        if (id == end_id) {
            return true;
        }
    }

    return false;
}


int main() {
    int n, q; std::cin >> n >> q;
    std::string s; std::cin >> s;
    std::vector<std::pair<char, char>> ops(q);
    for (int i = 0; i < q; i++) {
        std::cin >> ops[i].first >> ops[i].second;
    }

    //  Search the left-most character that will end up going out to the right.
    int left, right, left_most = n, right_most = -1;

    left = 0; right = n - 1;
    while (left <= right) {
        int mid = (left + right) / 2;

        if (check(s, ops, mid, n)) {
            left_most = mid; right = mid - 1;
        } else {
            left = mid + 1;
        }
    }

    //  Now the right-most one that ends up going out to the left.
    left = 0; right = n - 1;
    while (left <= right) {
        int mid = (left + right) / 2;

        if (check(s, ops, mid, -1)) {
            right_most = mid; left = mid + 1;
        } else {
            right = mid - 1;
        }
    }

    std::cout << left_most - right_most - 1 << '\n';
    return 0;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

struct SCC {
    int n;
    vector<vector<int>> G, R, T;
    vector<bool> used;
    vector<int> vs, cmp;

    SCC(int n) : n(n), G(n), R(n), used(n), cmp(n) {}

    int operator[](int k) {
        return cmp[k];
    };

    void add_edge(int from, int to) {
        G[from].emplace_back(to);
        R[to].emplace_back(from);
    }

    void dfs(int v) {
        used[v] = true;
        for (int u : G[v]) {
            if (!used[u]) dfs(u);
        }
        vs.emplace_back(v);
    }

    void rdfs(int v, int k) {
        used[v] = true;
        cmp[v] = k;
        for (int u : R[v]) {
            if (!used[u]) rdfs(u, k);
        }
    }

    int build() {
        for (int v = 0; v < n; v++) {
            if (!used[v]) dfs(v);
        }
        fill(used.begin(), used.end(), false);
        int k = 0;
        for (int i = n - 1; i >= 0; i--) {
            if (!used[vs[i]]) {
                rdfs(vs[i], k);
                k++;
            }
        }
        T.resize(k, vector<int>());
        for (int v = 0; v < n; v++) {
            for (int u : G[v]) {
                if (cmp[v] != cmp[u]) T[cmp[v]].emplace_back(cmp[u]);
            }
        }
        for (int i = 0; i < k; i++) {
            sort(T[i].begin(), T[i].end());
            T[i].erase(unique(T[i].begin(), T[i].end()), T[i].end());
        }
        return k;
    }
};

signed main() {
    int n, m;
    cin >> n >> m;
    SCC scc(n);
    int a, b;
    rep(i, m) {
        cin >> a >> b;
        scc.add_edge(a, b);
    }
    int k = scc.build();
    cout << k << endl;
    vector<int> vec[k];
    rep(v, n) {
        vec[scc[v]].emplace_back(v);
    }
    for (auto v : vec) {
        cout << v.size();
        for (int u : v) {
            cout << " " << u;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 101188
#include<iostream>
#include<map>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<vector>
#include<cstring>
#include<sstream>
#include<algorithm>
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;

#define MOD 1000000007

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

    int n;
    cin >> n;

    long long ans = 0;
    for (long long i = 1; i <= n; i++) {
        ans += (i*(i+1))/2;
    }

    long long a, b;
    for (int i = 0; i < n-1; i++) {
        cin >> a >> b;

        if (a > b) swap(a, b);

        ans -= (a*(n-b+1));
    }

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


Measured memory_bytes: 3160
#include<iostream>
#include<queue>
#include<tuple>
using namespace std;
int x[1005][1005], H, W; bool J[1005][1005];
int solve(int r, int s) {
	if (r <= 0 || s <= 0 || r > H || s > W)return 0; int B = 0;
	for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { if (x[r + i][s + j] == 0)B++; } }
	return B;
}
int main() {
	cin >> H >> W; queue<tuple<int, int, int>>Q;
	for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++) { char c; cin >> c; if (c == '.')x[i][j] = 0; else { x[i][j] = c - '0'; } } }
	vector<pair<int, int>>vec1;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (solve(i, j) >= x[i][j] && x[i][j] != 0) { vec1.push_back(make_pair(i, j)); J[i][j] = true; Q.push(make_tuple(i, j, 1)); }
		}
	}
	if (vec1.size() == 0) { cout << "0" << endl; return 0; }int Life = 1;
	for (int i = 0; i < vec1.size(); i++) { x[vec1[i].first][vec1[i].second] = 0; }vec1.clear();
	while (!Q.empty()) {
		int a1 = get<0>(Q.front()), a2 = get<1>(Q.front()), a3 = get<2>(Q.front()); Q.pop();
		if (a3 != Life) {
			for (int i = 0; i < vec1.size(); i++) { x[vec1[i].first][vec1[i].second] = 0; }
			vec1.clear(); Life++;
		}
		for (int i = -1; i <= 1; i++) {
			for (int j = -1; j <= 1; j++) {
				if (solve(a1 + i, a2 + j) >= x[a1 + i][a2 + j] && x[a1 + i][a2 + j] != 0 && J[a1 + i][a2 + j] == false) {
					vec1.push_back(make_pair(a1 + i, a2 + j)); J[a1 + i][a2 + j] = true;
					Q.push(make_tuple(a1 + i, a2 + j, a3 + 1));
				}
			}
		}
	}
	cout << Life << endl;
	return 0;
}

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

using namespace std;

//int cntT[30];
//int cntP[30];

int main() {
  string T, P;
  cin >> T >> P;
  int n = T.size();
  int m = P.size();
  int idx = 0;
  int cntT = 0, cntP = 0;
  bool flag = true;
  for(int i = 0; i < n; i++) {
    if(T[i] == P[idx]) {
      idx++;
    } else if(idx > 0 && T[i] == P[idx-1]) {
      flag = false;
    }
  }
  cout << (flag && idx == m ? "yes" : "no") << endl;
  return 0;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll e = lcm(c, d);
    ll ans = (b - a + 1) - ((b/c-(a-1)/c) + (b/d-(a-1)/d) - (b/e-(a-1)/e));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>

using namespace std;

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

  	int cur = 0;
  	int ans = 0;
  	for (int i = 0; i < (int) s.size() - t.size() + 1; i++) {
  	    int ind = i;
     	 for (int j = 0; j < (int) t.size(); j++) {
			if (s[i] == t[j]) cur++;
			i++;
         }
      
        i = ind;
      	ans = max(cur, ans);
      	cur = 0;
    }
  
  	cout << t.size() - ans << endl;
  	return 0;
}

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

#define MOD 1000000007

int n;

long long memo[1000005][2][2];
long long dp(int i, bool has0, bool has9) {
	if (i >= n) {
		if (has0 && has9) return 1;
		else return 0;
	}
	if (memo[i][has0][has9] != -1) return memo[i][has0][has9];
	long long cur = 0;
	for (int j = 0; j <= 9; j++) {
		if (j == 0) cur += dp(i + 1, true, has9);
		else if (j == 9) cur += dp(i + 1, has0, true);
		else cur += dp(i + 1, has0, has9);
		cur %= MOD;
	}
	return memo[i][has0][has9] = cur;
}

int main() {
	scanf("%d", &n);
	memset(memo, -1, sizeof memo);
	long long ans = dp(0, false, false);
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 128708
#include "vector"
#include "set"
#include "map"
#include "unordered_set"
#include "unordered_map"
#include "string"
#include "iostream"
#include "algorithm"
#include "queue"

using namespace std;

#define ll long long
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define MAX_SIZE 1000000000

typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) { bool first = true; for (const auto& j: v) { if (!first) { os << " "; } first = false; os <<j; } os << "\n"; return os; }
template<typename T>
istream& operator>>(istream& is, vector<T>& v) { for (auto& elem : v) { is >> elem; } return is; }


void solve() {
    string s;
    cin >> s;

    int n = s.size();

    vi pw(n+1);
    pw[0] = 1;
    for (int i=1; i<=n; i++) {
        pw[i] = (10 * pw[i-1]) % 2019;
    }

    vi cnt(2020, 0);
    cnt[0] = 1;

    int cur = 0;
    ll ans = 0;
    for (int i=0; i<n; i++) {
        cur = (cur + pw[n-i-1] * (s[i] - '0')) % 2019;
        ans += cnt[cur];
        cnt[cur]++;
    }

    cout << ans;
}


int main() {
    //ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

    if (0) {
        int tests;
        cin >> tests;
        for (int t = 1; t <= tests; t++) {
            //cout << "Case #" << t << ": ";
            solve();
            cout << "\n";
        }
    } else {
        solve();
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 4452
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define m_p make_pair
#define sz(x) (int)x.size()
#define out(x) cerr<<#x<<" = "<<x<<" "
#define outln(x) cerr<<#x<<" = "<<x<<endl
#define outarr(x,l,r) cerr<<#x"["<<l<<"-"<<r<<"] = "; for (int _i=l;_i<=r;++_i) cerr<<x[_i]<<" ";cerr<<endl;
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
#define gc() getchar()
//char buf[1<<23],*p1=buf,*p2=buf;
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <class T> void read(T &x)
{
    x=0; char c=gc(); int flag=0;
    while (c<'0'||c>'9') flag|=(c=='-'),c=gc();
    while (c>='0'&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=gc();
    if (flag) x=-x;
}
template <class T> T _max(T a,T b){return a>b ? a : b;}
template <class T> T _min(T a,T b){return a<b ? a : b;}
template <class T> bool checkmax(T &a,T b){return b>a ? a=b,1 : 0;}
template <class T> bool checkmin(T &a,T b){return b<a ? a=b,1 : 0;}
const int N=200005;
int n,m,v,p;
int a[N],sum[N];
void init()
{
    read(n); read(m); read(v); read(p);
    for (int i=1;i<=n;++i)
    {
    	read(a[i]);
	}
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	for (int i=1;i<=n;++i)
	{
		sum[i]=sum[i-1]+a[i];
	}
}

bool check(int x)
{
	if (a[x]+m<a[p]) return 0;
	return m*v<=(p-1)*m+(n-x+1)*m-(sum[x-1]-sum[p-1])+(x-p)*(a[x]+m);
}

void solve()
{
	int l=p,r=n,mid,best=p;
	while (l<=r)
	{
		mid=(l+r)>>1;
		if (check(mid))
		{
			best=mid;
			l=mid+1;
		}
		else r=mid-1;
	}
	printf("%lld\n",best);
}

#undef int
int main()
{
	init();
	solve();
    return 0;
}

Measured memory_bytes: 5320
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char[] slist = new char[s.length()];
		for (int i = 0; i < s.length(); i++) {
			slist[i] = s.charAt(i);
		}
		String t = sc.next();
		char[] tlist = new char[t.length()];
		for (int i = 0; i < t.length(); i++) {
			tlist[i] = t.charAt(i);
		}

		int ans = 0;
		for (int i = 0; i < s.length(); i++) {
			if (slist[i] != tlist[i]) {
				ans++;
			}
		}

		System.out.println(ans);
		sc.close();
	}

}

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

using namespace std;

int main(){

  vector<int> arr(80000);

  for(int i=0;i<80000;++i)
	arr[i] = 1;

  for(int i=2;i<sqrt(80000);++i){
	if(arr[i]){
	  for(int j = 0;i*(j+2) < 80000; j++)
		arr[i*(j+2)] = 0;
	}
  }

  int n;
  
  while(cin>>n){
	
	for(int i=n-1;i>=0;--i){
	  if(arr[i]==1){
		cout<<i<<" ";
		break;
	  }
  }

	for(int i=n+1;i<=80000;++i){
	  if(arr[i]==1){
		cout<<i<<endl;
		break;
	  }
	}
	
  }	
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include <vector>
using namespace std;
 
int main() {   
int x;
  cin>>x;
      vector<string>p;
  string q;
      for (int i =0 ; i<x; i++) {
        cin >>q;
        p.emplace_back(q);
      }
    sort(p.begin(), p.end());
    p.erase( unique(p.begin(), p.end()), p.end() );
  cout<<p.size()<<endl;
    }

Measured memory_bytes: 11664
// Link : https://atcoder.jp/contests/dp
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 3010;

string s,t;
int dp[MAXN][MAXN],N,M;
stack<char> resposta;

int solve(int a,int b){

	if(a < 0 || b < 0) return 0;

	if(dp[a][b] != -1) return dp[a][b];

	if(s[a] == t[b]) return dp[a][b] = 1 + solve(a-1,b-1);

	return dp[a][b] = max(solve(a-1,b),solve(a,b-1));

}

void build(int a,int b){

	if(a < 0 || b < 0) return;

	if(s[a] == t[b]){
		resposta.push(s[a]);
		build(a-1,b-1);
		return;
	}

	if(solve(a-1,b) > solve(a,b-1)) build(a-1,b);
	else build(a,b-1);

}

int main(){

	memset(dp,-1,sizeof(dp));

	cin >> s;
	cin >> t;

	N = (int)s.size();
	M = (int)t.size();

	build(N-1,M-1);

	while(!resposta.empty()){
		cout << resposta.top();
		resposta.pop();
	}
	cout << endl;

	return 0;

}

Measured memory_bytes: 35968
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int INF=1e18;
const int MOD=1e9+7;

signed main(){
    int N;cin>>N;
    int lsum=0,rsum=0;
    string S[N];
    REP(i,N)cin>>S[i];
    int ls[N],rs[N];
    REP(i,N)ls[i]=rs[i]=0;
    int sumc=0;
    bool ok=true;
    REP(i,N){
        int D=S[i].size();
      	REP(j,D){
            if(S[i][j]==')'){
            if(rs[i]==0)ls[i]++;
            else rs[i]--;
            }
            else{
                rs[i]++;
            }
        }
        sumc+=ls[i]-rs[i];
    }
    if(sumc!=0)ok=false;
    vector<pair<int,int>>lsc;
    vector<pair<int,int>>rsc;
    REP(i,N){
        if(rs[i]>=ls[i]){
            lsc.pb({ls[i],rs[i]-ls[i]});
        }
        else rsc.pb({rs[i],ls[i]-rs[i]});
    }
    sort(lsc.begin(),lsc.end());
    sort(rsc.begin(),rsc.end());
    int sum=0;
    REP(i,lsc.size()){
        if(lsc[i].first>sum){
            ok=false;
            break;
        }
        sum+=lsc[i].second;
    }
    sum=0;
    REP(i,rsc.size()){
        if(rsc[i].first>sum){
            ok=false;
            break;
        }
        sum+=rsc[i].second;
    }
    cout<<(ok?"Yes":"No")<<endl;
}

Measured memory_bytes: 65788
<?php
for ($i = 0; $i < 20; $i++) {
     $inArray[] = trim(fgets(STDIN));
}
$wCollege = array();
$kCollege = array();
foreach ($inArray as $key => $inVal) {
    if ($key < 10) {
        $wCollege[] = $inVal;
    } else {
        $kCollege[] = $inVal;
    }
}
rsort($wCollege);
rsort($kCollege);
echo ($wCollege[0] + $wCollege[1] + $wCollege[2])." ".($kCollege[0] + $kCollege[1] + $kCollege[2]).PHP_EOL;
?>


Measured memory_bytes: 9260
character(102) S,ans
read*,S
do i=1,len_trim(S)+1
  do j=i,len_trim(S)+1
    if(i==1)then
      ans=trim(S(j+1:))
    else
      ans=S(1:i-1)//S(j+1:)
    end if
    if(trim(ans)=="keyence")then
      print"(A)","YES"
      STOP
    endif
  end do
end do
print"(A)","NO"
end

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

const int dx[4] = { 0, 1, 0, -1 };
const int dy[4] = { 1, 0, -1, 0 };
const char dc[4] = { 'U', 'R', 'D', 'L' };
vector<vector<bool>> chk;
vector<vector<pair<int, string>>> path;

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    string s = "";
    for (auto i = sy; i < ty; i++) s.push_back('U');
    for (auto i = sx; i < tx; i++) s.push_back('R');
    for (auto i = sy; i < ty; i++) s.push_back('D');
    for (auto i = sx; i < tx; i++) s.push_back('L');

    s.push_back('L');
    for (auto i = sy; i <= ty; i++) s.push_back('U');
    for (auto i = sx; i <= tx; i++) s.push_back('R');
    s += "DR";
    for (auto i = sy; i <= ty; i++) s.push_back('D');
    for (auto i = sx; i <= tx; i++) s.push_back('L');
    s.push_back('U');

    cout << s << endl;
    return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  intll a , v , b , w , t  ;
  cin >> a >> v >> b >> w  >> t ;
 
 
  intll x = max(a,b) - min(a,b) ;
  intll y = (v-w) * t ; 
  
  if( y < x){
    cout <<"NO" ;
  }
  else cout <<"YES";
  
}


Measured memory_bytes: 3624
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn gcd(a:u64, b:u64) -> u64 {
    if b==0 {
        a
    } else {
        gcd(b, a%b)
    }
}
// fn lcm(a:u64, b:u64) -> u64 {
//     a / gcd(a, b) * b
// }
fn main() {
    input!{
        n:usize,
        a:[u64;n],
    }
    let mut g = a[0];
    for i in 1..n {
        g = gcd(g, a[i]);
    }
    println!("{}", g);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define mod 1000000007
#define inf 1e18+9
#define fr first
#define sc second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pll pair<ll,ll>
#define vll vector<ll>
#define umap unordered_map<ll,ll>
#define lpq priority_queue<ll,vector<ll>,greater<ll>>
ll globe=0;
ll powe(ll n,ll r){if(!r)return 1;else if(r%2==0)return powe(n*n,r/2);else return n*powe(n*n,(r-1)/2);}

int32_t main(){
 
	ios::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    
	ll t=1;
	//cin>>t;
	while(t--){
	    ll k,n,id=-1;
	    cin>>k>>n;
	    vll a(n);
	    for(ll i=0;i<n;i++){
	        cin>>a[i];
	    }
	    ll mx=a[0];
	    ll ans=0;
	    for(ll i=1;i<n;i++){
	        ll x=a[i]-a[i-1];
	        ans+=x;
	        if(x>mx){
	            mx=x;
	        }
	    }
	    ans+=(k-a[n-1]+a[0]);
	    if(mx<(k-a[n-1]+a[0]))
	        mx=(k-a[n-1]+a[0]);
	    ans-=mx;
	    cout<<ans<<endl;
	    
	}
 
	return 0;
 
}
//BitMasking->setBit: n|(1<<i); unsetBit: n&!(1<<i); checkBit: n&(1<<i);
//ll idx=upper_bound(v.begin(),v.end(),val)-v.begin();
//v.erase(unique(v.begin(),v.end()),v.end());
//ll cnt=count(v.begin(),v.end(),val);
//bool f=find(v.begin(),v.end(),val);

Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>
using namespace std;
int gcd (int a,int b){
    if(!b)return a;
    return gcd(b,a%b);
}
int main()
{
	int n;
	scanf("%d",&n);
	int ans;
	scanf("%d",&ans);
	for(int i=2;i<=n;i++)
	{
		int j;
		scanf("%d",&j);
		ans=gcd(ans,j); 
	}
	printf("%d",ans);
	return 0;
 } 

Measured memory_bytes: 128
N=int(input())
#p=[int(i) for i in input().split()]
#t=[int(i) for i in input().split()]
pa,pb,pc,pd=map(int,input().split())
ta,tb,tc,td=map(int,input().split())
#M=(1+((N-1)//t[0]))*p[0]
M=10**9
ans=M
for a in range(101):
    for b in range(101):
        for c in range(101):
            #t*x>=N
            #d*td=>N-a*ta-b*tb-c*tc
            d=max(0,-((N-a*ta-b*tb-c*tc)//(-td)))
            ans=min(ans,a*pa+b*pb+c*pc+d*pd)
print(ans)

            


Measured memory_bytes: 5600
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
int main(){
int n,a,b;
cin>>n>>a>>b;
int c,d;
if(a>=n)
c=a-n;
else
c=n-a;
if(b>=n)
d=b-n;
else
d=n-b;
if(c>d)
cout<<'B';
else
cout<<'A';
system("pause");
return 0;
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define INF 1e15
#define MOD 1e9+7
string s;
char A = 'A', T = 'T', C = 'C', G = 'G';
int cnt, ans;
signed main() {
	cin >> s;
	rep(i, s.size()) {
		if (s[i] == A || s[i] == T || s[i] == G || s[i] == C)cnt++;
		else cnt = 0;
		ans = max(ans, cnt);

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


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


int main(){


  long long int A;
  scanf("%lld",&A);

  /*
  int A[N];
  int i;
  for(i=0;i<N;i++){
   scanf("%d",&A[i]);
   }
  */



  if(A%10 == 7 || (int)(A/10)%10 == 7 || (int)(A/100)%10 == 7){
    printf("Yes");
  }
  else{
    printf("No");
  }    







 return(0);
 }


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

int main(){
  int N,L;
  cin >> N >> L;
  int sum = 0;
  rep(i,N+1){
    sum += i;
  }
  sum = N*(L-1) + sum;
  int curMin = 1e8;
  int s = 0;
  for(int i = 1;i <= N;i++){
    int n = abs(L+i-1);
    curMin = min(curMin,n);
    if(curMin == n) s = i;
  }
  cout << sum - (L+s-1) << endl;
  return 0;
}

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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V) \
    for (auto v : (V)) cout << v << ' ';
const int MOD = 1000000007;
/* cout << fixed << setprecision(10) << decimal << endl; */
ll rec(ll N) {
    if (N == 1) return 1;
    return rec(N / 2) * 2 + 1;
}
int main() {
    /* code */
    ll H;
    cin >> H;
    cout << rec(H) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fast() ios_base::sync_with_stdio(0),cin.tie(0)
int32_t main()
{int n,i,s;
 cin>>n;
 vector<int> v(n);
 for(i=0;i<n;++i)
 cin>>v[i];
 sort(v.begin(),v.end());
 s=accumulate(v.begin(),v.end(),-v[n-1]);
 if(s>v[n-1])
 cout<<"Yes";
 else
 cout<<"No";
 return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

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

	string ret;
	if(abs(x-a) < abs(x-b))
		ret = "A";
	else
		ret = "B";

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String args[]) throws Exception {
    Scanner sc=new Scanner(System.in);
    
	
		    int n = sc.nextInt();
		    String s = sc.next();
		    char str[] = s.toCharArray();
		    Arrays.sort(str);
		    long count=0;
		    Set<Character> set = new HashSet<>();
		    for(int i=0;i<n;i++){
		        set.add(s.charAt(i));
		    }
		    
		    if(set.size()==1){
		        System.out.println(0);
		    }
		    else{
		    for(int i=0;i<n;i++){
		       if(s.charAt(i)==str[i]){
		           continue;
		       }
		       else{
		           count+=1;
		       }
		      
		    }
		    System.out.println(count/2);
		    }
		
    }
}

Measured memory_bytes: 31848
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next().toInt
  val A = new Array[Int](1 << N)
  for (i <- 0 to (1 << N) - 1)
    A(i) = in.next().toInt


  //
  val dp = Array.fill[(Int, Int)](1 << N)((-1, -1))
  dp(0) = (0, 0)
  dp(1) = (0, 1)
  var ans = A(0) + A(1)
  println(ans)


  import scala.collection.mutable.PriorityQueue

  for (i <- 2 to (1 << N) - 1) {
    val pq = new PriorityQueue[(Int, Int)]
    pq.enqueue(A(i) -> i)

    for (k <- 0 to N) {
      val hoge = i & 1 << k
      if(hoge != 0) {
        val now = i ^ hoge
        val (a, b) = dp(now)
        pq.enqueue(A(a) -> a)
        pq.enqueue(A(b) -> b)
      }
    }

    var lst: List[Int] = Nil
    while(lst.length < 2) {
      val (_, ind) = pq.dequeue
      if(!lst.contains(ind))
        lst = ind :: lst
    }

    dp(i) = (lst(0), lst(1))
    ans = Math.max(ans, lst.map(ind => A(ind)).sum)
    pw.println(ans)
  }
  pw.flush()
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}



Measured memory_bytes: 160632
#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;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  vector<ll> A(n); rep(i, n) cin >> A[i];
  vector<vector<bool>> dpl(n+1, vector<bool>(k+1)), dpr(n+1, vector<bool>(k+1));
  dpl[0][0] = true;
  dpr[n][0] = true;
  rep(i, n) {
    rep(j, k+1) {
      dpl[i+1][j] = dpl[i][j] || dpl[i+1][j];
      dpl[i+1][min(j+A[i], (ll)k)] = dpl[i][j] || dpl[i+1][min(j+A[i], (ll)k)];
    }
  }
  rrep(i, n) {
    rep(j, k+1) {
      dpr[i][j] = dpr[i+1][j] || dpr[i][j];
      dpr[i][min(j+A[i], (ll)k)] = dpr[i+1][j] || dpr[i][min(j+A[i], (ll)k)];
    }
  }
  int ans = n;
  rep(i, n) {
    bool ok = false;
    if(A[i] >= k) {
      ans--;
      continue;
    }
    vector<int> sum(k+2);
    rep(j, k+1) sum[j+1] = sum[j] + dpr[i+1][j];
    rep(j, k) {
      if(dpl[i][j] && sum[k-j]-sum[max(k-A[i]-j, 0LL)]) ok = true;
    }
    if(ok) ans--;
  }
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 10040
#include<stdio.h>

int main(){
	int n,sin[6],i;
	double length;
	
	while(0<=scanf("%d",&n)){
		for(i=0;i<6;i++){
			sin[i]=0;
		}
		
		for(i=0;i<n;i++){
			scanf("%lf",&length);
			if(length<165){
				++sin[0];
			}else if(length<170){
				++sin[1];
			}else if(length<175){
				++sin[2];
			}else if(length<180){
				++sin[3];
			}else if(length<185){
				++sin[4];
			}else{
				++sin[5];
			}
		}
		
		for(i=0;i<6;i++){
			printf("%d:",i+1);
			while(sin[i]>0){
				printf("*");
				--sin[i];
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define N 1000000007
typedef long long ll;
#define all(v) (v).begin(),(v).end()
#define sz(x) int(x.size())
int main(){
	int a,b;
	cin>>a>>b;
	a=a-2*b;
	if(a<0) a=0;
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <queue>
#include <memory>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>

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

using namespace std;
using ll = long long;
const int mod = 1e9+7;
bool flag[300];
int main(){
    int n;
    cin >> n;
    rep(i,25){
        rep(j,14){
            flag[i * 4 + j * 7] = true;
        }
    }
    if(flag[n]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

int main(){

  int A, B; cin >> A >> B;
  cout << max(A + B, max(A - B, A * B)) << endl;
  return 0;
}

Measured memory_bytes: 256
x, n = map(int, input().split())
if not(n==0):
  l = list(map(int, input().split()))
  y = 0
  while True:
      if not(x-y in l):
          print(x-y)
          break
      elif not(x+y in l):
          print(x+y)
          break
      else:
          y +=1
else:
    print(x)




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

using namespace std;
typedef long long ll;
#define MOD 1000000007
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() {
    int n;
    cin >> n;

    int c[10][10];
    for(int i=0; i<10; i++)
        for(int j=0; j<10; j++)
            c[i][j] = 0;

    for(int i=1; i<=n; i++) {
        int degree = log10(i);

        int head = i / (int)pow(10, degree);
        int tail = i % 10;
        c[head][tail]++;
    }

    int cnt = 0;
    for(int i=0; i<10; i++)
        for(int j=0; j<10; j++)
            cnt += c[i][j] * c[j][i];

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 512
N = int(input())
m_nums = [int(i) for i in input().split()]
b_nums = [int(i) for i in input().split()]

cnt = 0
for i in range(len(b_nums)):
    b_num = b_nums[i]
    m_num = m_nums[i]
    cnt += min(b_num, m_num)
    if b_num > m_num:
        tmp = b_num - m_num
        if tmp > m_nums[i+1]:
            cnt += m_nums[i+1]
            m_nums[i+1] = 0
        else:
            cnt += tmp
            m_nums[i+1] -= tmp

print(cnt)


Measured memory_bytes: 19156
#include "bits/stdc++.h"
using namespace std;
int main(){
    int A, B;
    cin >> A >> B;
    if(A == 1)
    A = 14;
    if(B == 1)
    B = 14;
    if(A == B)
    cout << "Draw" << endl;
    if(A > B)
    cout << "Alice" << endl;
    if(A < B)
    cout << "Bob" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stack>
#include<deque>
using namespace std;
struct Reservoir {
  public:
    int amount;
    int right_edge;
    Reservoir(int amount, int right_edge): amount(amount), right_edge(right_edge){}
};
int main() {
  string s; cin >> s;
  int total_amount = 0;
  stack<int> left_slope_xpositions;
  deque<Reservoir> reservoirs;
  for(int i = 0; i < s.size(); ++i) {
    if(s[i] == '\\') {
      left_slope_xpositions.push(i);
    } else if(s[i] == '/') {
      if(left_slope_xpositions.empty()) continue;
      int left = left_slope_xpositions.top(); left_slope_xpositions.pop();
      int amount = i - left;
      total_amount += amount;

      // 自分より左にある貯水湖を結合する
      while(!reservoirs.empty() && reservoirs.back().right_edge > left) {
        amount += reservoirs.back().amount; reservoirs.pop_back();
      }

      // 最も右にある貯水湖としてstackに保存
      reservoirs.push_back(Reservoir(amount, i));
    }
  }

  cout << total_amount << endl;
  if(reservoirs.size()) {
    cout << reservoirs.size() << " ";
  } else {
    cout << reservoirs.size() << endl;
    return 0;
  }
  // stackとして扱ってきた貯水湖を逆順で出力
  while(!reservoirs.empty()) {
    cout << reservoirs.front().amount; reservoirs.pop_front();
    if(reservoirs.empty()) cout << endl;
    else cout << " ";
  }
  return 0;
}


Measured memory_bytes: 3256
import numpy as np

n = int(input())
string = input()

lst_w = []
lst_e = []

count = 0
for i in string:
    if i == 'W':
        lst_w.append(count)
        count += 1
    else:
        lst_w.append(count)
        
count = 0
for i in string[::-1]:
    if i == 'E':
        lst_e.append(count)
        count += 1
    else:
        lst_e.append(count)
lst_e = lst_e[::-1]

print(min(np.array(lst_w) + np.array(lst_e)))

Measured memory_bytes: 35340
def main():
    a, b, c, d = map(int, input().split())
    sum = 0

    while True:
        if (a < d):
            sum = a
            d -= a
        else:
            sum = d
            break

        if (b < d):
            d -= b
        else:
            break
        sum -= d
        break

    print(sum)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9120
import fractions
N = int(input())
A = [int(i) for i in input().split()]
ans = 0

L = [0]*(N+2)
R = [0]*(N+2)
L[0] = 0
L[1] = A[0]
R[N+1] = 0
R[N] = A[N-1]

for i in range(1, N):
  L[i+1] = fractions.gcd(L[i], A[i])
  R[N-i] = fractions.gcd(R[N+1-i],A[N-1-i])
for i in range(N):
  tmp = fractions.gcd(L[i], R[i+2])
  ans = max(tmp, ans)
print(ans)

Measured memory_bytes: 16132
#include<iostream>

int getDigit(int x){
  int digit = 0;

  while(x > 0){
    x /= 10;
    ++digit;
  }
  return digit;
}

int main(){
  const int min = 0;
  const int max = 1000000;
  const int data = 200;
  int a,b,i = 0;
  while(std::cin >> a >> b && i < data){
    if(a >= min && a <= max && b >= min && b <= max)
      std::cout << getDigit(a + b) << std::endl;
  }
}

Measured memory_bytes: 1160
#include<stdio.h>
int main(void)
{
	int n;
	int a;
	int i,j;
	long long int dp[101][105];
	scanf("%d",&n);
	for(j=0;j<=n;j++){
		for(i=0;i<101;i++){
			dp[j][i]=0;
		}
	}
	scanf("%d",&a);
	dp[0][a]=1;
	for(i=0;i<n-1;i++){
		scanf("%d",&a);
		for(j=0;j<=20;j++){
			dp[i+1][j+a]+=dp[i][j];
			dp[i+1][j-a]+=dp[i][j];
		}
	}/*
	for(i=0;i<n-1;i++){
		printf("%d=",i);
		for(j=1;j<=20;j++){
			printf("%d=%lld ",j,dp[i][j]);
		}
		printf("\n");
		printf("\n");
	}*/
	scanf("%d",&a);
	long long int cnt=0;
	cnt=dp[n-2][a];
	printf("%lld\n",cnt);
	return 0;
}

Measured memory_bytes: 1108
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		
		int[] b = new int[n];
		for(int i = 0; i < n; i++) {
			b[a[i] - 1] = i + 1;
		}
		
		for(int i = 0; i < n; i++) {
			System.out.print(b[i] + " ");
		}
		System.out.println();
	}
}

Measured memory_bytes: 61252
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef pair<int,pair<int,int> > P;

int t,p,r;

int main(){
  while(cin>>t>>p>>r,t){
    int an[t+1],wn[t+1][p+1],penalty[t+1];
    for(int i=1; i<=t; i++){
      for(int j=1; j<=p; j++)
	wn[i][j]=0;
      an[i]=penalty[i]=0;
    }
    for(int i=0; i<r; i++){
      int tid,pid,time;
      string mes;
      cin >> tid >> pid >> time >> mes;
      if(wn[tid][pid]==-1){
	;
      }if(mes=="CORRECT"){
	penalty[tid] += wn[tid][pid]*1200+time;
	an[tid]++;
	wn[tid][pid]=-1;
      }else{
	wn[tid][pid]++;
      }
    }
    
    P ps[t];
    for(int i=1; i<=t; i++)
      ps[i-1]=make_pair(-an[i],make_pair(penalty[i],i));
    sort(ps,ps+t);
    
    for(int i=0; i<t; i++)
      cout << ps[i].second.second << " " << -ps[i].first << " " << ps[i].second.first << endl;
  }
}

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


// 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(){
    const long long INF =  130000000;
    long long minimum = INF;
    long long N,M,X;
    cin >> N >> M >> X;
    vector<long long> C(N,0);
    vector<vector<ll>> A(N,vector<ll>(M,0));
    for (ll i=0;i<N;i++){
        cin >> C[i];
        for (ll j=0;j<M;j++){
            cin >> A[i][j];
        }
    }

    for (long long  i = 0;i<(1<<N);i++){
        long long cost = 0;
        vector<ll> score(M,0);
        for (ll j=0;j<12;j++){
            ll mask = 1<<j;
            if (i & mask){
                cost += C[j];
                for (ll k=0;k<M;k++){
                    score[k]+= A[j][k];
                }
            }
        }
        for (ll l = 0;l<M;l++){
            if (score[l] < X) break;
            if (l==M-1) minimum = min(minimum,cost);
        }

    }
    if (minimum == INF) printf("-1\n");
    else printf("%lld\n",minimum);


    return 0;
}


Measured memory_bytes: 3732
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

#define ll long long

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

#define inf std::numeric_limits<int>().max();

int main() {
	int a, b;
	cin >> a >> b;
	int total = 1;
	int ct=0;
	while (total < b) {
		total--;
		total += a;
		ct++;
	}
	cout << ct << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
   ll n,k,x,y,i,j,q;
   vector<ll>v;
   ll sum=0;
   cin>>n;
   map<ll,ll>m;
   for(i=0;i<n;i++)
   {
       cin>>x;
       v.push_back(x);
       sum+=x;
       m[x]++;
   }
   cin>>q;
   for(i=0;i<q;i++)
   {
      cin>>x>>y;
      sum-=m[x]*x;
      sum+=m[x]*y;
      m[y]+=m[x];
      m[x]=0;
      cout<<sum<<endl;


   }
   //cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 9896
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std; 

//しゃくとり方でとく//
int main(void){
 int N,K;

 char S[100050];
 vector<int> A;

 cin>>N>>K;
 cin>>S;

 int cnt=0;
 int now=0;

 for(int i=0; i<strlen(S);i++){
  if(S[i]==(char)('1'-now)){
   cnt++;
  }
  else{
   now=1-now;
   A.push_back(cnt);
   cnt=1;
  }
 }
 A.push_back(cnt);          
 
 if(A.size()%2==0)A.push_back(0);
 
 int sum,left,right,ans,nextleft,nextright;
 sum=0;
 left=0;
 right=0;
 nextleft=0;
 nextright=0;
 ans=0;
 
 for(int i=0; i<A.size();i+=2){
  nextleft=i;
  nextright=min(i+2*K+1,(int)A.size());

  while(nextleft>left){
   sum-=A[left];
   left++;
  }
  while(nextright>right){
   sum+=A[right];
   right++;
  }
  ans=max(sum,ans);
 }

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

Measured memory_bytes: 1020