akhauriyash/Code-Regression huggingface dataset:
//by (111110101)2
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int n,m,ans1,ans2;
string s;
bool vis[101010];
map<int,int>mp;
int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x;
		cin>>x>>s;
		if(s=="WA")
		{
			if(vis[x])
			{
				continue;
			}
			else
			{
				mp[x]++;
			}
		}
		else
		{
			if(!vis[x])
			{
				vis[x]=true;
				ans1++;
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(vis[i])
		{
			ans2+=mp[i];
		}
	}
	cout<<ans1<<' '<<ans2<<endl;
	return 0;
}

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

using namespace std;

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

string s;
int dp[510][510];

bool dfs(int l, int r) {
    int& ret = dp[l][r];
    if(ret >= 0) return ret;
    if(l == r) return ret = 1;
    if(s[l]!='m' || s[r-1]!='w') return ret = 0;
    ret = 0;
    REP(m, l+1, r-1) if(s[m] == 'e' && dfs(l+1, m) && dfs(m+1, r-1)) return ret = 1;
    return ret;
}

int main() {
	cin >> s;
	memset(dp, -1, sizeof(dp));
    cout << (dfs(0, s.size())? "Cat":"Rabbit") << endl; 
}



Measured memory_bytes: 4232
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
int main(){
	string s;
	cin >> s;
	int ans = 0;
	FOR(i,0,3)if(s[i]=='1')ans++;
	cout << ans << endl;
}


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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int c[3][3];
    for (int i = 0;i < 3;++i) for (int j = 0;j < 3;++j) c[i][j] = 0;
    cin >> c[0][0] >> c[0][1] >> c[1][1];
    for (int i = 0;i <= 200;++i) {
        int sum = c[0][0]+c[0][1]+i;
        c[0][2] = i;
        c[2][1] = sum-c[0][1]-c[1][1];
        c[2][0] = sum-c[1][1]-c[0][2];
        c[2][2] = sum-c[0][0]-c[1][1];
        c[1][0] = sum-c[0][0]-c[2][0];
        c[1][2] = sum-c[0][2]-c[2][2];
        bool ok = true;
        for (int k = 0;k < 3;++k) {
            int s = 0;
            for (int j = 0;j < 3;++j) s += c[k][j];
            if (sum != s) {ok = false;break;}
        }
        for (int k = 0;k < 3;++k) {
            int s = 0;
            for (int j = 0;j < 3;++j) s += c[j][k];
            if (sum != s) {ok = false;break;}
        }
        int s = 0;
        for (int j = 0;j < 3;++j) s += c[j][j];
        if (sum != s) ok = false;
        s = 0;
        for (int j = 0;j < 3;++j) s += c[j][2-j];
        if (sum != s) ok = false;
        if (ok) {
            for (int j = 0;j < 3;++j) cout << c[j][0] << " " << c[j][1] << " " << c[j][2] << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N;cin >> N;
    vector<bool> a(8,false);
    int tmp;
    int ct = 0;
    rep(i,N){
        cin >> tmp;
        tmp /= 400;
        if(tmp >= 8)ct++;
        else a[tmp] = true;
    }
    int min = 0;
    int max = 0;
    rep(i,8)if(a[i])min++;
    if(min == 0){
        min = 1;
        max = ct;
    }
    else{
        max = min + ct;
    }
    cout << min << " " << max << endl;
}


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

int main(){
	int n, x;
	int d = 0;
	cin >> n >> x;
	int ans = 1;
	vector<int> l(n);
	for(int i=0; i<n; i++){
    	cin >> l.at(i);
    	d += l.at(i);
    	if(d <= x) ans++;
    }
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val nums = listOfInt().sortedDescending()
    println(nums[0]*10 + nums[1] + nums[2])
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt()= listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 37888
import sys

# -----------------------------------------
# import os
# fdr = os.open('python/abc139/sample.txt', os.O_RDONLY)
# os.dup2(fdr, sys.stdin.fileno())
# -----------------------------------------

str = sys.stdin.readline().split()

A = int(str[0])
B = int(str[1])
c = (B-1) // (A-1)
if (B-1)%(A-1) != 0:
    c+=1

print(c)


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

int main(){
  long l,r,result = 2019;
  cin >> l >> r;
  if(r - l >= 2018){
    result = 0;
  }
  else{
    for(long i = l;i <= r;i++){
      for(long j = i+1;j <= r;j++){
        long x = i*j;
        result = min(result,x%2019);
      }
    }
  }
  cout << result << endl;
}

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

int main(){
	string s;
	cin >> s;
	cout << s.at(0) << s.size()-2 << s.at(s.size()-1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char S[100005];

int main()
{
    cin >> S;
    int n = strlen(S);

    int ans[n] = {0};
    pair<bool, int> arr[n];
    arr[0].first = false; // R
    arr[n-1].first = true; // L
    for(int i = 1; i < n; ++i) { //S[0]はRなので外す
        if(S[i] == 'L') {
            arr[i].first = true;
            if(!arr[i-1].first) arr[i].second = 1;
            else arr[i].second = arr[i-1].second + 1;

            int num = arr[i].second;
            if(num%2 == 0) ++ans[i - num];
            else           ++ans[i - num + 1];
        }
    }

    for(int i = n-2; i >= 0; --i) {
        if(S[i] == 'R') {
            arr[i].first = false;
            if(arr[i+1].first) arr[i].second = 1;
            else arr[i].second = arr[i+1].second + 1;

            int num = arr[i].second;
            if(num%2 == 0) ++ans[i + num];
            else           ++ans[i + num - 1];
        }
    }

    for(int i = 0; i < n; ++i) cout << ans[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 1664
import numpy as np

N, K = map(int, input().split())
A = np.array(tuple(map(int, input().split())), dtype=np.int64)

A = np.sort(A)
pos = A[A > 0]
neg = A[A < 0]
zero = len(A[A == 0])

def cnt(x):
    """return #{a <= x | a in A}"""
    ret = 0

    if x >= 0:
        ret += zero * N

    ret += np.searchsorted(A, x // pos, side='right').sum()
    ret += (N - np.searchsorted(A, (-x - 1) // (-neg), side='right')).sum()
    ret -= ((A * A) <= x).sum()
    return ret // 2

overEq = 10**18 + 100
less = -10**18 - 100

while less + 1 < overEq:
    mid = (overEq + less) // 2
    if cnt(mid) >= K:
        overEq = mid
    else:
        less = mid

print(overEq)


Measured memory_bytes: 32460
n = int(input())
ab=[list(map(int,input().split())) for i in range(n)]

all_min=[]
all_max=[]
for itm in ab:
    a,b=itm
    all_min.append(a)
    all_max.append(b)

import statistics
med_min=statistics.median(all_min)
med_max=statistics.median(all_max)

diff = med_max - med_min

if n%2==0:
    print(int(diff*2+1))
else:
    print(diff+1)

Measured memory_bytes: 129300
import java.util.*

fun main(args:Array<String>){
    val n = readLine()!!.toInt()
    val x = IntArray(n)
    val y = IntArray(n)
    val h = IntArray(n)
    for(i in 0 until n){
        val (X,Y,H) = readLine()!!.split(" ").map{it.toInt()}
        x[i] = X
        y[i] = Y
        h[i] = H
    }
    for(i in 0 .. 100){
        for(j in 0 .. 100){
            var ok = true
            var H = 0
            for(k in 0 until n){
                if(h[k] != 0){
                    H = h[k] + Math.abs(i - x[k]) + Math.abs(j - y[k])
                }
            }
            for(k in 0 until n){
                if(h[k] == 0){
                    if(H - Math.abs(i - x[k]) - Math.abs(j - y[k]) > 0) ok = false
                }
                else{
                    if(H - Math.abs(i - x[k]) - Math.abs(j - y[k]) != h[k]) ok = false
                }
            }
            if(ok){
                println("${i} ${j} ${H}")
                return
            }
        }
    }
}


Measured memory_bytes: 38500
#include <stdio.h>

int n, m, d, p, r[11];

int main()
{
    while(true)
    {
        scanf("%d", &n);
        scanf("%d", &m);
        
        if(n == 0 && m == 0) { break; }
        
        for(int i = 0; i < 11; i++)
        {
            r[i] = 0;
        }
        
        for(int i = 0; i < n; i++)
        {
            scanf("%d", &d);
            scanf("%d", &p);
            
            r[p] += d;
        }
        
        for(int i = 10; i >= 0; i--)
        {
            if(m >= r[i])
            {
                m -= r[i];
                
                r[i] = 0;
            }
            else
            {
                r[i] -= m;
                
                break;
            }
        }
        
        int sum = 0;
        
        for(int i = 0; i <= 10; i++)
        {
            sum += i * r[i];
        }
        
        printf("%d\n", sum);
    }
    
    return 0;
}

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

const int N = 200005;

int n, m;
string s;
vector < pair<int,int> > g[N];
int low[N][2], num[N][2], step;
stack < pair<int,int> > st;

void dfs(int u, int id) {
	low[u][id] = num[u][id] = ++step;
	st.push({u, id});
	for (auto &i : g[u]) {
		int v = i.second, vid = i.first;
		if (vid == id) continue;
		if (num[v][vid]) {
			low[u][id] = min(low[u][id], num[v][vid]);
		} else {
			dfs(v, vid);
			low[u][id] = min(low[u][id], low[v][vid]);
		}
	}

	if (low[u][id] == num[u][id]) {
		int v = 0, vid = 0, cnt = 0;
		do {
			v = st.top().first; vid = st.top().second; 
			st.pop();
			low[v][vid] = num[v][vid] = 1e9;
			++cnt;
		} while(v != u || vid != id);
		
		if (cnt > 1) {
			cout << "Yes\n";
			exit(0);
		}
	}
}

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

	cin >> n >> m;
	cin >> s;
	s = ' ' + s;

	while(m--) {
		int u, v; cin >> u >> v;
		g[u].push_back(make_pair(s[u] != s[v], v));
		g[v].push_back(make_pair(s[u] != s[v], u));
	}

	for (int i = 1; i <= n; ++i) {
		for (auto &j : g[i]) if (!num[i][j.first]) {
			dfs(i, j.first);
		}
	}

	cout << "No\n";
}

Measured memory_bytes: 27868
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using System.IO;

class Solve
{
	const int mod = 1000000007;
	static void Main(string[] args)
	{
		var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
		Console.SetOut(sw);

		var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int N = input[0];
		int M = input[1];

		long ans = 0;
		int dif = Math.Abs(N - M);
		if (dif > 1)
		{
			ans = 0;
		}
        else if (dif == 0)
		{
			ans += 2;
            for(var i = 1; i <= N; i++)
			{
				ans = (ans * i) % mod;
				ans = (ans * i) % mod;
			}
		}
		else
		{
			ans += 1;
			for (var i = 1; i <= Math.Min(N, M); i++) 
			{
				ans = (ans * i) % mod;
				ans = (ans * i) % mod;
			}
			ans = (ans * Math.Max(N, M)) % mod;
		}
		Console.WriteLine(ans);



		Console.Out.Flush();
	}
}


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

/* -------------------------------- Template -------------------------------- */

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

template<typename T> T inf() { assert(false); }
template<> constexpr int inf<int>() { return 1e9; }
template<> constexpr ll inf<ll>() { return 1e18; }
template<> constexpr ld inf<ld>() { return 1e30; }

/* -------------------------------- Library -------------------------------- */

/* ---------------------------------- Main ---------------------------------- */

int main() {
  string s, t;
  cin >> s;
  for (auto c: s) {
    if (c == 'S') t += "S";
    else {
      if (!t.empty() && t.back() == 'S') t.pop_back();
      else t += "T";
    }
  }
  cout << t.size() << endl;
  return 0;
}


Measured memory_bytes: 776
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>

using namespace std;
using Int = long long;

constexpr double EPS = 1e-10;
constexpr long long MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

long long my_mod_pow(long long x, long long n) {
	long long ret = 1;
	for (; n > 0; n >>= 1, x = x * x % MOD) {
		if (n & 1) {
			ret = ret * x % MOD;
		}
	}
	return ret;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    int N, M; cin >> N >> M;
    vector<double> A(N);
    double sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }

    sort(A.begin(), A.end(), greater<int>());

    for (int i = 0; i < M; i++) {
        if (A[i] < sum * (1.0/(4.0*M))) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 888
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    double a;
    double c=0;
    double ans;
    cin>>a;
    for(int i=1; i<=a; i++){
        if(i%2==1){
            c=c+1;
        }
    }
    ans=c/a;
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
int n, m;
int a[maxn];
void no()
{
	puts("0");
	exit(0);
}
int getlcm()
{
	int ret = a[1];
	for(int i = 2; i <= n; ++i)
	{
		ret = 1ll * ret * a[i] / __gcd(ret, a[i]);
		if(ret > m) no();
	}
	for(int i = 1; i <= n; ++i)
		if((ret / a[i]) % 2 == 0)
			no();
	return ret;
}
int main()
{
	scanf("%d%d", &n, &m);
	m *= 2;
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	int lcm = getlcm();
	printf("%d\n", (m / lcm + 1) / 2);
	return 0;
}

Measured memory_bytes: 640
//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
#define int long long
   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 =1002;
const int MOD =1000000007;

signed main(){
  int n;
  cin>>n;
  int d[n];
  for(int i=0;i<n;i++)cin>>d[i];
  sort(d,d+n);
  int ans=1;
  for(int i=1;i<n;i++)if(d[i-1]<d[i])ans++;
  cout<<ans<<endl;

}

Measured memory_bytes: 3592
#include<stdio.h>
int main()
{
    int n,i;
    char s[10001];
    while(1)
    { int sum=0;
        scanf("%s",&s);
        if(s[0]=='0')  break;
        for(i=0;s[i]!='\0';i++)
        {
            sum+=s[i]-'0';
        }
        printf("%d\n",sum);
    }
    return 0;
}



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

int main(){
int a[10];
int b;
int c;
int d;
int e;
c=0;
d=0;
e=0;
b=0;
while(b<10){
cin >> a[b];
if(c<a[b]){e=d;
           d=c;
           c=a[b];}
else if(d<a[b]){e=d;
                d=a[b];}
else if(e<a[b]){e=a[b];}
b=b+1;
}          
cout << c <<endl;
cout << d <<endl;
cout << e <<endl;
    return 0;
}

Measured memory_bytes: 1160
def main():
    N, M = map(int, input().split())
    AB = []
    for _ in range(N + 1):
        AB.append([])
    for _ in range(M):
        a, b = map(int, input().split())
        AB[a].append(b)
        AB[b].append(a)
    result = [0] * (N + 1)
    from collections import deque
    work = deque([])
    append = work.append
    pop = work.popleft
    append(1)
    while len(work) > 0:
        now = pop()
        for to in AB[now]:
            if result[to] == 0:
                result[to] = now
                append(to)
    for i in result[2:]:
        if i == 0:
            print("No")
            return
    print("Yes")
    for i in result[2:]:
        print(i)
main()

Measured memory_bytes: 34732
H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
Q = int(input())
LR = [list(map(int, input().split())) for _ in range(Q)]

numbers = {}
for y in range(H):
	for x in range(W):
		numbers[A[y][x]] = (y, x)

numbers_sum = [0] * (H * W + 1)
for n in range(D + 1, H * W + 1):
	f, t = numbers[n], numbers[n - D]
	cost = abs(f[0] - t[0]) + abs(f[1] - t[1])
	numbers_sum[n] = numbers_sum[n - D] + cost

for l, r in LR:
	print(numbers_sum[r] - numbers_sum[l])


Measured memory_bytes: 47688
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<(n);i++)
#define REP1(i,n) for(long long i=1;i<=(n);i++)
#define REP2D(i,j,h,w) for(long long i=0;i<(h);i++) for(long long j=0;j<(w);j++)
#define REP2D1(i,j,h,w) for(long long i=1;i<=(h);i++) for(long long j=1;j<=(w);j++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();++ite)
#define ALL(a) ((a).begin()),((a).end())
#define RANGE(a) (a),((a)+sizeof(a))
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define ENTER printf("\n")
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<(a)<<endl

#ifdef DEBUG
#define DBPRT(a) cout << "[Debug] - " << #a << " : " << (a) << endl
#define DBSTART if(1){
#define DBEND }
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
#define PRTLST2D(arr2,d1,d2) do{cout<<"L\t";REP(_i,d2) cout<<_i<<"\t"; cout<<endl; REP(_i,d1){cout<<_i<<"\t";REP(_j,d2){cout<<arr2[_i][_j]<<"\t";}cout<<endl;}}while(0);
#else
#define DBPRT(a) if(0){}
#define DBSTART if(0){
#define DBEND }
#define PRTLST(arr,num) if(0){}
#define PRTLST2(arr2,d1,d2) if(0){}
#define PRTLST2D(arr2,d1,d2) if(0){}
#endif

#define TOSUM(arr,sum,n) {sum[0]=arr[0];REP1(i,n-1) sum[i]=sum[i-1]+arr[i];}

#define MIN(target,v1) (target)=min(target,v1)
#define MAX(target,v1) (target)=max(target,v1) 
#define P1 first
#define P2 second
#define PB push_back
#define UB upper_bound
#define LB lower_bound
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,0,1,1,0,0,-1};
const int Move_[8][2] = {-1,0,-1,-1,0,1,1,1,1,0,1,-1,0,-1,-1,-1};
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p) {os<<"( "<<p.P1<<" , "<<p.P2<<" )";return os;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {ITE(v) os << (ite-v.begin()) << " : " << *ite <<endl;return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v) {os<<" { ";ITE(v) {os<<*ite;if(ite!=--v.end()){os<<" , ";}} os<<" } ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& m) {ITE(m) {os<<ite->P1<<"\t\t|->\t\t"<<ite->P2<<endl;} return os;}

//---------------------
#define MAXN 100005
//---------------------

ll A,B,M;
ll a[MAXN],b[MAXN];
ll mina,minb;
int main(){
	cin >> A >> B >> M;
	ll res = mina = minb =10000000;
	REP1(i,A) {cin >> a[i]; MIN(mina,a[i]);}
	REP1(i,B) {cin >> b[i];MIN(minb,b[i]);}
	MIN(res,mina + minb);
	REP1(i,M){
		ll x,y,c;
		cin >> x >> y >> c;
		MIN(res, a[x] + b[y] - c);
	}

	PRT(res);
	return 0;
}









Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 998244353
#define mod2 1000000006
#define inf 1000000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pi 3.141592653589793
using namespace std ;
 
const lli dx4[] = {-1, 0, 1, 0};
const lli dy4[] = {0, 1, 0, -1};
const lli dx8[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const lli dy8[] = {0, 1, 0, -1, -1, 1, -1, 1};
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
 
#define N 1000005

void solve()
{
	lli n,m;
	cin>>n>>m;

	lli cnt[n+1][2];

	memset(cnt,0,sizeof(cnt));

	loopl(i,2,n+1) cnt[i][0] = 1; 
	cnt[1][1] = 1;

	loopl(i,0,m)
	{
		lli x,y;
		cin>>x>>y;

		if(cnt[x][1]>0)
		{
			if(cnt[x][0] > 0)
			{
				cnt[x][0]--;
				cnt[y][1]++;
			}

			else
			{
				cnt[x][1]--;
				cnt[y][1]++;
			}
		}

		else
		{
			cnt[x][0]--;
			cnt[y][0]++;
		}
	}

	lli ans=0;
	loopl(i,1,n+1) 
	{
		if(cnt[i][1] > 0) ans++;
	}
	cout<<ans;


}
 
int main()
{
/////////////////////////////////////
    
    fastio;
 
/////////////////////////////////////  
 	
	lli t;
	t=1;
 
	while(t--)
		solve();
 
}

Measured memory_bytes: 1792
#include<iostream>

using namespace std;

int main(void) {
	double n=0,max=0,min=100;
	while (cin >> n) {
		if (max == 0 && min == 100) {
			max = n;
			min = n;
		}
		else if (max < n) {
			max = n;
		}
		else if (min > n) {
			min = n;
		}
	}
	cout << max - min << endl;
}

Measured memory_bytes: 1276
#include <stdio.h>
#include <string.h>

char O[55];
char E[55];
char ans[110];

int main() {

	scanf("%s", O);
	scanf("%s", E);

	int i;

	int len1 = strlen(O);
	int len2 = strlen(E);
	int cnt1 = 0;
	int cnt2 = 0;

	for (i = 0;; i+=2) {
		if (cnt1 >= len1 && cnt2 >= len2) { break; }
		if (cnt1 < len1) {
			ans[i] = O[cnt1];
			cnt1++;
		}
		if (cnt2 < len2) {
			ans[i + 1] = E[cnt2];
			cnt2++;
		}
	}

	printf("%s\n",ans);

	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;


int dp[2010][2010];
int rev[2010][2010];

int main(void){
	string pa,ra;
	while(cin >> pa){
		if(cin.eof())
			break;

		rep(i,2010)rep(j,2010) dp[i][j]=0;

		ra=pa;
		reverse(ra.begin(),ra.end());
		int n=pa.size();
		rep(i,n)rep(j,n){
			if(pa[i]==ra[j]){
				dp[i+1][j+1]=dp[i][j]+1;
				rev[i+1][j+1]=0;
			}else if(dp[i][j+1] > dp[i+1][j]){
				dp[i+1][j+1]=dp[i][j+1];
				rev[i+1][j+1]=1;
			}else{
				dp[i+1][j+1]=dp[i+1][j];
				rev[i+1][j+1]=-1;
			}
		}
		string ans="";
		
		for(int i=n,j=n;i>0&&j>0;){
			//dump(i) dump(j)
			if(rev[i][j]>0)
				i--;
			else if(rev[i][j]<0)
				j--;
			else {		
				ans+=pa[i-1];
				i--;j--;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 32764
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

constexpr auto mod = 1'000'000'007;

template <large M> static large pow(const large b, const large e) {
    if (e < 0)
        return 0;
    if (e == 0)
        return 1;
    if (e == 1)
        return b;

    auto p = (e % 2 == 0 ? large{1} : b);
    return p * pow<M>(b * b % M, e / 2) % M;
}

template <large M> static large inv(const large k) { return pow<M>(k % M, M - 2); }
template <large M> static large fac(const large x) {
    if (x < 0)
        return 0;
    if (x <= 1)
        return 1;

    auto c = large{1};
    for (auto i = x; i >= 2; --i) {
        c *= i;
        c %= M;
    }
    return c;
}

template <large M = mod> static large choose(const large n, const large k) {
    // n! / (k! * (n-k)!)
    auto fn = fac<M>(n);
    auto fk = inv<M>(fac<M>(k));
    auto fnk = inv<M>(fac<M>(n - k));

    auto c = fn * fk;
    c %= M;
    c *= fnk;
    c %= M;
    return c;
}

static large solve(const large m, const large n) {
    auto sum = 0LL;
    const auto nn = n * n % mod;
    for (auto dx = 1; dx < m; dx++) {
        auto cnt = m - dx;
        auto dxsum = dx * cnt % mod;
        dxsum = (dxsum * nn) % mod;
        sum += dxsum;
        sum %= mod;
    }
    return sum;
}

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

    auto sum = solve(m, n) + solve(n, m);
    sum %= mod;
    sum *= choose(m * n - 2, k - 2);
    sum %= mod;
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3548
#include <cstdio>
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;

vector<tuple<int,int>> table;
int main(void){
	int n,m;
	cin >> n;
	for(int i=0;i<n;++i){
		int a,b;
		cin >> a >> b;
		table.push_back(make_tuple(a,b));
	}
	cin >> m;
	for(int i=0;i<m;++i){
		int a,b;
		cin >> a >> b;
		table.push_back(make_tuple(a,b));
	}
	sort(table.begin(),table.end());
	table.erase(unique(table.begin(),table.end()),table.end());
	for(int i=0;i<table.size();++i){
		int a,b;
		tie(a,b)=table[i];
		if(i) printf(" ");
		printf("%d:%02d",a,b);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 1188
<?php

fscanf(STDIN, "%s", $in_s);

$ans = 0;

for($i = 0; $i < (strlen($in_s) / 2); $i++){
    if((substr($in_s, $i, 1)) != (substr($in_s, -($i + 1), 1))){
        $ans++;
        }
}

echo "$ans\n";

?>

Measured memory_bytes: 4856
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

string s;

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

    cin >> s;

    REP(i, s.size()) {
        if (i + 1 < s.size() && s[i] == s[i + 1]) {
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
        if (i + 2 < s.size() && s[i] == s[i + 2]) {
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;

    return 0;
}


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

int main(){
  int f=0;
  string str;
  cin >> str;
  for(int i=0;i<str.size();i++){
    if(i%2==0){
      if(str.at(i)=='L')
        f=1;
    }
    if(i%2==1){
      if(str.at(i)=='R')
        f=1;
    }
  }
  if(f==0)
    cout << "Yes" <<endl;
  else
    cout << "No" <<endl;
}

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

const int mxn = 100005;
const int inf = 1e7;
int n, k, h[mxn];
int ff[mxn];

int dfs( int pos ) 
{
  if( pos > n ) return 0;
  int& ret = ff[pos];
  if( ~ret ) return ret;
  
  ret = 0;
  if( pos < n )
  {
    ret = abs(h[pos] - h[pos + 1]) + dfs( pos + 1 );
    for(int i = 2; i <= k and pos + i <= n; i++)
    {
      ret = min(ret, abs(h[pos] - h[pos + i]) + dfs( pos + i ));
    }
  }
  return ret;
}

int main()
{
  scanf("%d %d", &n, &k);
  for(int i = 1; i <= n; i++) 
  { 
    scanf("%d", h + i);
  }
  memset(ff, -1, sizeof ff);
  printf("%d\n", dfs( 1 ));
  return 0;
}


Measured memory_bytes: 5760
/*input
8 5
-9 -7 -4 -3 1 2 3 4
*/
#include <bits/stdc++.h>
using namespace std;
#define int int_fast64_t
#define pii pair<int, int>
#define F first
#define S second
const int MX = 1e5 + 100, oo = 1ll << 60;
int v[MX];
main () {
	int ans = oo;
	int n, k; cin >> n >> k;
	for(int i = 0; i < n; i ++) cin >> v[i];
	for(int i = 0; i <= n - k; i ++) {
		int tmp = 0;
		if(v[i] < 0 and v[i + k - 1] < 0) tmp = -v[i];
		else if(v[i] < 0) tmp = -v[i] + v[i + k - 1] + min(-v[i], v[i + k - 1]);
		else tmp = v[i + k - 1];
		ans = min(ans, tmp);
	}
	cout << ans;
}

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

using namespace std;
using lli = int_fast64_t;
using ulli = unsigned long long;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = copy(x);cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

constexpr lli MOD = (lli)1e9 + 7;
constexpr lli LIMIT = 1000000000000000000 * 5;

int main() {
	string s;
	cin >> s;
	cout << s.substr(0, 3) << endl;
	return 0;
}



Measured memory_bytes: 3624
fun main(args: Array<String>) {
    var (N, K) = listOfInt()
    var (R, S, P) = listOfInt()
    var T = next()
    var G = CharArray(N)
    fun g(n: Int) = if (n - K >= 0) G[n - K] else ' '
    var ans = 0
    for (n in 0 until N) {
        G[n] = ' '
        when (T[n]) {
            'r' -> {
                if(g(n) != 'p') {
                    ans += P
                    G[n] = 'p'
                }
            }
            's' -> {
                if(g(n) != 'r') {
                    ans += R
                    G[n] = 'r'
                }
            }
            'p' -> {
                if(g(n) != 's') {
                    ans += S
                    G[n] = 's'
                }
            }
        }
    }
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }


Measured memory_bytes: 41604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
/////////////////////////////////////////////

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

  unordered_map<string, int> dic;
  int left = 0;
  int right = N;
  while (left + 1 < right) {
    int mid = left + (right - left) / 2;
    bool flag = false;
    for (int i = 0; i <= N - mid; i++) {
      string t = S.substr(i,mid);
      if (dic.count(t)){
        if (dic[t] < i) flag = true; 
      }
      else dic.emplace(t,i + mid - 1); 
    }
    if (flag) left = mid;
    else right = mid; 
  }

  cout << left << endl;
}

Measured memory_bytes: 77708
from collections import Counter

n = int(input())
v = list(map(int, input().split()))

c1 = Counter(v[::2]).most_common() + [(0, 0)]
c2 = Counter(v[1::2]).most_common() + [(0, 0)]

if c1[0][0] != c2[0][0]:
    ans = n - c1[0][1] - c2[0][1]
else:
    ans = n - max(c1[0][1] + c2[1][1], c1[1][1] + c2[0][1])

print(ans)

Measured memory_bytes: 20700
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		long x = long.Parse(input[1]);
		long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
		long answer = 1;
    long sum = 0;

    for(int i = 0; i < n; i++)
    {
      sum += nums[i];
      if(sum > x) break;
      answer++;
    }
    

		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 13140
import java.util.Scanner;
import java.util.Set;
import java.util.HashSet;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int n = sc.nextInt();
        Set<Integer> box = new HashSet<>();

        for (int i = 0; i < n; i++) {
            box.add(sc.nextInt());
        }

        int diff = 0;
        int ans = 0;
        while (true) {
            int ansLeft = x - diff;

            if (!box.contains(ansLeft)) {
                ans = ansLeft;
                break;
            }

            int ansRight = x + diff;

            if (!box.contains(ansRight)) {
                ans = ansRight;
                break;
            }

            diff++;
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 27068
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())
 
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18


int main() {
    string S;
    cin>>S;
    int n = (S.size()-1)/2;
    bool flag = true;
    REP(i,n/2+1){
        if(S[i]==S[n-i-1] && S[i] == S[n+1+i] && S[i] == S[S.size()-1-i]){
        }else{
            flag = false;
            break;
        }

    }
    if(flag){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

}


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

def dfs(l):
    return sum([
        # next
        dfs(10 * l + i) if (10 * l + i) <= n else 0
        for i in [3, 5, 7]] +
        # current
        [1 if '3' in str(l) and '5' in str(l) and '7' in str(l) else 0]
        )

print(dfs(0))

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, k, a[2019], dat[2019], pre[2019];

long long quickpow(long long b, int e)
{
	return e ? ((e & 1 ? b : 1)*quickpow((b*b) % MOD, e >> 1)) % MOD : 1;
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	long long inv2 = quickpow(2, MOD - 2);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		dat[a[i]]++;
	}
	pre[1] = dat[1];
	for (int i = 2; i <= 2000; i++) {
		pre[i] = pre[i - 1] + dat[i];
	}
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		long long sum = 0;
		int cnt0 = 0;
		for (int j = i + 1; j < n; j++) {
			if (a[j] < a[i]) cnt0++;
		}
		int d = pre[a[i] - 1];
		sum = cnt0 + cnt0 + d * 1LL * (k - 1);
		sum %= MOD;
		sum *= k;
		sum %= MOD;
		sum *= inv2;
		sum %= MOD;
		ans += sum;
		ans %= MOD;
	}
	cout << ans << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	ll X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;
	vl p(A), q(B), r(C);
	rep(i, A)
		cin >> p[i];
	rep(i, B)
		cin >> q[i];
	rep(i, C)
		cin >> r[i];
	sort(p.begin(), p.end(), greater<ll>());
	sort(q.begin(), q.end(), greater<ll>());
	sort(r.begin(), r.end(), greater<ll>());

	ll ans = 0;
	ll pk = X - 1;
	ll qk = Y - 1;
	ll rk = 0;
	rep(i, X)
		ans += p[i];
	rep(i, Y)
		ans += q[i];
	while (1) {
		ll ptmp = InfLL;
		if (pk >= 0)
			ptmp = p[pk];
		ll qtmp = InfLL;
		if (qk >= 0)
			qtmp = q[qk];
		ll rtmp = -1;
		if (rk < C)
			rtmp = r[rk];

		if (ptmp < qtmp) {
			if (ptmp < rtmp) {
				ans += rtmp - ptmp;
				pk--;
				rk++;
			}
			else
				break;
		}
		else {
			if (qtmp < rtmp) {
				ans += rtmp - qtmp;
				qk--;
				rk++;
			}
			else
				break;
		}
	}

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

Measured memory_bytes: 2560
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

int main() {
    string S;
    cin >> S;
    if(S[2] == S[3] && S[4] == S[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    return 0;
}


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

int main(){
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long tmp, max;
    max = a*c;
    tmp = a*d;
    if (max < tmp) max = tmp;
    tmp = b*c;
    if (max < tmp) max = tmp;
    tmp = b*d;
    if (max < tmp) max = tmp;
    cout << max << endl;
}

Measured memory_bytes: 3632
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

#約数列挙
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

n,m = inpl()
pp = make_divisors(m)
ans = 1
for i in pp:
    if i <= m/n:
        ans = max(ans, i)
print(ans)

    

        

Measured memory_bytes: 39148
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  int a,b,c;
  cin >> a >> b >> c;
  cout << min(a+b,min(a+c,b+c));
  hinata;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 1e4+9;
int a[N];
int main()
{
	
 	int n,m;
 	cin>>n>>m;
 	int sum = 0;
 	for(int i=1;i<=m;i++)
 	{
 		cin>>a[i];
 		sum+=a[i];
	}
	if(n-sum>=0) cout<<n-sum<<endl;
	else cout<<-1<<endl;
	return 0;
}

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

class Cmondai
{
    static void Main()
    {
        var line = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var N = line[0];
        var M = line[1]-1;
        var line1= Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).OrderBy(x=>x).ToArray();
        var list = new List<int>();
        for (int i=0;i<M;++i)
        {
            list.Add(Math.Abs(line1[i] -line1[i+1]));
        }
        var ans=list.OrderBy(x=>x).Take(M-(N-1)).Sum();
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 23904
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

class Point {
 public:
  double x, y;

  Point(double x = 0, double y = 0): x(x), y(y) {}

  Point operator + (Point p) { return Point(x + p.x, y + p.y); }
  Point operator - (Point p) { return Point(x - p.x, y - p.y); }
  Point operator * (double a) { return Point(a * x, a * y); }
  Point operator / (double a) { return Point(x / a, y / a); }

  double abs() { return sqrt(norm()); }
  double norm() {return x * x + y * y; }

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }

};

typedef Point Vector;

double dot(Vector a, Vector b) {
  return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
  return a.x * b.y - a.y * b.x;
}

struct Segment {
  Point p1, p2;
};

typedef Segment Line;

Point getCrossPoint(Segment s1, Segment s2) {
  Vector base = s2.p2 - s2.p1;
  double d1 = abs(cross(base, s1.p1 - s2.p1) / base.abs());
  double d2 = abs(cross(base, s1.p2 - s2.p1) / base.abs());
  return s1.p1 + (s1.p2 - s1.p1) * (d1 / (d1 + d2));
}

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

  cout << fixed;
  for (int i = 0; i < n; i++) {
    Segment s1, s2;
    cin >> s1.p1.x >> s1.p1.y >> s1.p2.x >> s1.p2.y;
    cin >> s2.p1.x >> s2.p1.y >> s2.p2.x >> s2.p2.y;
    Point result = getCrossPoint(s1, s2);
    cout << setprecision(10) << result.x << " " << result.y << endl;
  }
  return 0;
}



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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;

LL isPrime(LL p){
	if(p<=1) return 0;
	if(p==2 || p==3 || p==5 || p==7) return 1;
	if(p==4 || p==6 || p==8 || p==9) return 0;

	LL i;
	int ret = 1;
	for(i=2; i*i<=p; i++){
		if(p%i==0 && i!=p){
			ret = 0;
			break;
		}
	}
	return ret;
}

int ecount(int e){
	if(e == 1 || e == 2) return 1;
	else{
		int ret = 1;
		while(true){
			if( ret*(ret+1) > (2*e)) break;
			ret++;
		}
		ret--;
		return ret;
	}
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	long long N;
	cin >> N;

	if(N == 1){
		cout << "0" << endl;
		return 0;
	}
	if(isPrime(N)){
		cout << "1" << endl;
		return 0;
	}

	map<long long, int> mp;
	long long i = 2;
	long long n = N;
	for(i = 2; n != 1 && i < (N/2) + 1; i++){
		if((n % i)==0){
			if(isPrime(i)){
				int e = 0;
				long long u = n;
				while((u % i)==0){
					e++;
					u = u / i;
					n = u;
				}
				mp[i] = e;
				if(isPrime(n)){
					mp[n] = 1;
					break;
				}
			}
		}
	}

	if(mp.size()==0){
		mp[N] = 1;
		cout << "1" << endl;
		return 0;
	}

	long long ans = 0;
	for(auto itr = mp.begin(); itr != mp.end(); itr++){
		ans += ecount(itr->second);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3672
<?php

fscanf(STDIN, "%d", $n);
$A = array_map('intval', explode(' ', trim(fgets(STDIN))));

$map = [];
$cnt = 0;
for ($j = 0; $j < $n; ++$j) {
    $cnt += $map[$j - $A[$j]];
    ++$map[$j + $A[$j]];
}

echo $cnt;


Measured memory_bytes: 57064
K,A,B = gets.split.map(&:to_i)

count = 1
if A + 2 < B
    k = K

    k -= A - 1
    count += A - 1

    if k.even?
        count += (k/2)*(B-A)
    else
        count += (k/2)*(B-A)+1
    end
else
    count += K
end

puts count


Measured memory_bytes: 1788
a,b,c=map(int,input().split())

count=0
befA=0
befB=0
befC=0

if (a%2==1 or b%2==1 or c%2==1):
    print(0)
    exit()

if a==b==c:
    print(-1)
    exit()

while(a%2==0 and b%2==0 and c%2==0):
    befA=a
    befB=b
    befC=c
    a=befB/2+befC/2
    b=befA/2+befC/2
    c=befA/2+befB/2
    count+=1

print(count)


Measured memory_bytes: 3064