akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int N = 1e5L + 11;
using ll = long long;

int h[N];

bool check(ll lim, int n, ll a, ll b) {
	ll cnt = 0;
	a -= b;
	for(int i = 1; i <= n; i ++)
		if(h[i] > b * lim)
			cnt += (h[i] - b * lim + a - 1) / a;
	return cnt <= lim;
}

int main() {
	ios :: sync_with_stdio(0);
	int n; cin >> n;
	ll a, b; cin >> a >> b;
	for(int i = 1; i <= n; i ++)
		cin >> h[i];

	ll l = 0, r = 1e9L + 1;
	while(l + 1 < r) {
		ll m = (l + r) / 2;
		if(check(m - 1, n, a, b))
			r = m;
		else
			l = m;
	}
	cout << l << '\n';
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N, M; cin >> N >> M;
  vector<ll> a(N), b(N), c(M), d(M);
  REP(i, N) cin >> a[i] >> b[i];
  REP(i, M) cin >> c[i] >> d[i];
  vector<int> ans(N);
  for(int i = 0; i < N; ++i) {
    ll tmp = pow(10, 17) + 7;
    for(int k = 0; k < M; ++k) {
      if(tmp > abs(a[i] - c[k]) + abs(b[i] - d[k])) {
        ans[i] = k + 1;
        tmp = abs(a[i] - c[k]) + abs(b[i] - d[k]);
      }
    }
  }
  REP(i, N) cout << ans[i] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++) cin>>v[i];
    int cnt=0;
    for(int i=1;i<n-1;i++){
        if((v[i]>v[i-1]&&v[i]<v[i+1])||(v[i]<v[i-1]&&v[i]>v[i+1])){
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


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

int main() {
  int n, x; cin >> n >> x;
  vector<int> m(n);
  for(int i = 0; i < n; ++i) cin >> m[i];
  sort(m.begin(), m.end());
  int ans = 0;
  for(int i = 0; i < n; ++i){
    x -=m[i];
    ans++;
  }
  if(x >= m[0]){
    ans += x / m[0];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string s;
    cin >> s;

    if (s.size() == 2) {
        if (s.at(0) == s.at(1)) {
            cout << 1 << " " << 2 << endl;
            return 0;
        }
        else
        {
            cout << -1 << " " << -1 << endl;
            return 0;
        }
    }
    else {
        for (int i = 0; i < s.size() - 1; i++) {
            if(s.at(i) == s.at(i + 1)) {
                cout << i + 1 << " " << i + 2 << endl;
                return 0;
            }
            else if (i < s.size() - 2 && s.at(i) == s.at(i + 2)) {
                cout << i + 1 << " " << i + 3 << endl;
                return 0;
            }
        }
    }

    cout << -1 << " " << -1 << endl;
    
}


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

int prime[] = { 2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 , 23 , 29 , 31 };

int main() {

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

   int x,y,z;
   cin>>x>>y>>z;

   swap(x,y);
   swap(x,z);

   cout<<x<<" "<<y<<" "<<z;
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
  char ch;
  double bmi,w,h;
  int id;
  while( scanf("%d,%lf,%lf",&id,&w,&h) != EOF)
    {
        bmi = w / (h*h);
      if(bmi >= 25)cout << id << endl;
    }
  return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <cmath>

using namespace std;
using ll = long long;

int main() {
    ll n, t, a, vt = 1, va = 1;
    cin >> n;
    for(ll i = 0; i < n; i++) {
        cin >> t >> a;

        ll r = max( (vt - 1) / t + 1, (va - 1) / a + 1 );
        vt = t * r;
        va = a * r;
    }

    cout << vt + va << endl;

    return 0;
}

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

int main(void){
    int N;
    cin >> N;
    
    vector<int> mountains(N);
    for (int i = 0; i < N; i++) cin >> mountains[i];
    
    int tallest_mountain = mountains[0];
    int total = 1;
    for (int i = 1; i < N; i++){
        if (mountains[i] >= tallest_mountain) {
            total++;
            tallest_mountain = mountains[i];
        }
    }
    
    cout << total << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, c) for(long long i=0; i<(long long)c; i++)
const ll INF=1000000000000001;
int main() {
	int n,t;
	ll ans=0;
	cin >>n;
	for(int i=1;i<=n;i++){
		cin >>t;
		if ((i%2==1) && (t%2==1)) ans++;
	}
	cout <<ans<<endl;
	return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<set>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define INF 1000000100
#define rep(i,n) for (int i=0;i<n;i++)

int main(){
    int N;
    cin >> N;
    map<string, int> mp;
    ll ans=0;
    rep(i,N){
        string s;
        cin >> s;
        sort(s.begin(),s.end());
        ans += mp[s];
        mp[s] +=1;
    }
    /*
    ll ans=0;
    for(auto p :mp){
        ans += p.second*(p.second-1)/2;
    }
    */
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 10868
#include <stdio.h>
#include <math.h>

int main()
{
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);

  printf("%d\n", (int)fmin(fmin(abs(a - b) + abs(c - a), abs(b - c) + abs(a - b)), abs(c - a) + abs(b - c)));
  return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 112345;
const int MAX_Q = 112345;
vector<int> g[MAX_N];

int color[MAX_Q];
int t[MAX_N][11];

int main2() {
  REP(i, MAX_N) g[i].clear();
  CLR(t, -1);

  int N = nextInt();
  int M = nextInt();
  REP(i, M) {
    int a = nextInt() - 1;
    int b = nextInt() - 1;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  int Q = nextInt();
  REP(i, Q) {
    int v = nextInt() - 1;
    int d = nextInt();
    int c = nextInt();
    color[i] = c;
    t[v][d] = i;
  }
  for (int d = 10; d > 0; d--) {
    REP(i, N) {
      chmax(t[i][d-1], t[i][d]);
      for (int j : g[i]) {
        chmax(t[j][d-1], t[i][d]);
      }
    }
  }
  REP(i, N) {
    printf("%d\n", t[i][0] == -1 ? 0 : color[t[i][0]]);
  }
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 12024
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

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

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int N;
	cin >> N;
	LL ans = 1;
	for (LL a = 2; a <= N; ++a) {
		LL ter = a*a;
		LL base = a;
		while (ter <= N) {
			chmax(ans, ter);
			ter *= base;
		}
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))

def gcd(a,b):
  if b>a:
    a,b=b,a
  while a%b!=0:
    a,b=b,a%b
  return b

ans=A[0]
for i in range(1,len(A)):
  ans=gcd(ans,A[i])
  
print(ans)

Measured memory_bytes: 14736
r, c = map(int, input().split())
y = [[0 for j in range(c+1)] for i in range(r+1)]
for i in range(r):
  a = list(map(int, input().split()))
  s= 0
  for j in range(c):
    y[i][j] = a[j]
    s+= a[j]
  y[i][c] = s
for j in range(c+1):
  su= 0
  for i in range(r):
    su+= y[i][j]
  y[r][j] = su
for i in range(r+1):
  for j in range(c+1):
    if j == 0:
      print(y[i][j], end = "")
    else:
      print("", y[i][j], end = "")
  print()


Measured memory_bytes: 6748
S = input()
pre = int(S[:2])
sur = int(S[2:])
if pre <= 12 and pre > 0 and sur <= 12 and sur > 0:
    print('AMBIGUOUS')
elif pre <= 12 and pre > 0:
    print('MMYY')
elif sur <= 12 and sur > 0:
    print('YYMM')
else:
    print('NA')


Measured memory_bytes: 61868
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<string>
#include<stdio.h>
#include<cmath>
#include<map>
#include<bitset>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define repr(i, n) for(int i = n-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define lint long long


int main(){
    int n; cin >> n;
    string s, t; cin >> s >> t;
    string ans = "";
    rep(i, n){
        ans = ans + s[i] + t[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
 
int main(){
    unsigned long long N;
    cin >> N;
    unsigned long long sum=0;
    rep(i, N){
        if((i+1)%3!=0&&(i+1)%5!=0){
            sum += i+1;
        }
    }
    cout << sum << endl;
 
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    int temp1, temp2;
    int ans = (int)1e5 + 1;
    int temp = 0;
    for (int i = 1; i < N / 2 + 1; ++i) {
        temp = 0;
        temp1 = i;
        temp2 = N - i;
        while(temp1){
            temp += temp1 % 10;
            temp1 = temp1 / 10;
        }
        while(temp2){
            temp += temp2 % 10;
            temp2 = temp2 / 10;
        }
        ans = min(ans, temp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

void eratosthenes_max_factor(int n, std::vector<int>& det){
    det.clear();
    det.reserve(n);
    for(int i = 0; i < n; ++i) det.push_back(i + 1);
    int m = std::floor(std::sqrt(n));
    for(int i = 2; i <= m; ++i) if(i == det[i - 1]) for(int j = i + 1; j <= n; ++j) if(0 == j % i) det[j - 1] = i;

    return;
}

int main(void){
    int n;
    std::cin >> n;
    std::vector<int> v;
    eratosthenes_max_factor(n, v);
    int cnt = 0;
    for(int i = 1; i < n; ++i){
        int tmp = 1, tmp2 = n - i;
        std::map<int, int> m;
        while(tmp2 > 1){
            if(m.end() == m.find(v[tmp2 - 1])){
                m.insert(std::make_pair(v[tmp2 - 1], 1));
            }else{
                ++m[v[tmp2 - 1]];
            }
            tmp2 /= v[tmp2 - 1];
        }
        for(auto it = m.begin(); it != m.end(); ++it){
            tmp *= it->second + 1;
        }
        cnt += tmp;
    }
    std::cout << cnt << std::endl;

    return 0;
}

Measured memory_bytes: 7276
def dfs(s, mx):
    if len(s) == N:
        print(s)
        return
    for c in range(ord("a"), mx + 1):
        dfs(s + chr(c), mx + 1 if c == mx else mx)

if __name__ == "__main__":
    N = int(input())
    dfs("", ord("a"))

Measured memory_bytes: 56920
i = input()
j = len(i)
k = int(i)
if j==1:
    print(k)
elif j ==2:
    print(9)
elif j==3:
    print(k-90)
elif j==4:
    print(909)
elif j==5:
    print(k-9999 + 909)
elif j ==6:
    print(90909)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<math.h>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
ll Pow10mod(ll a){
	ll x=10,ans=9;
	while(a){
		if(a%2==1)ans=ans*x%mod;
		a/=2;
		x=x*x%mod;
	}
	return ans;
}
ll L10[10];
int main(){
	L10[0]=1;
	lol(i,9)L10[i+1]=L10[i]*10;
	ll s;cin>>s;
	ll ans=0;
	ll left=1,leftdig=1,right=1,rightdig=1,cnt=1;
	while(leftdig<8){
		while(cnt<s){
			right++;if(right==L10[rightdig])rightdig++;
			cnt+=rightdig;
		}
		if(cnt==s)ans++;
		cnt-=leftdig;
		left++;if(left==L10[leftdig])leftdig++;
	}
	for(ll x=1;s/x>=8;x++){
		if(s%x==0){
			ans+=Pow10mod(s/x-1)-x+1;
			ans%=mod;
		}
		else ans++,ans%=mod;
	}
	if(ans<0)ans+=mod;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    character(100)::s,t
    integer(int32):: i
    integer(int32), allocatable:: si(:),ti(:)

    read*, s
    read*, t
    allocate(si(len_trim(s)), ti(len_trim(t)))
    do i=1, size(si)
        si(i) = ichar(s(i:i))
    end do
    
    do i = 1, size(ti)
        ti(i) = ichar(t(i:i))
    end do

    if (minval(si) < maxval(ti)) then
        print'(a)', 'Yes'
    else if (minval(si) > maxval(ti)) then
        print'(a)', 'No'
    else
        if (maxval(si) > maxval(ti)) then
            print'(a)', 'No'
        else if (size(si) < size(ti)) then
            print'(a)', 'Yes'
        else
            print'(a)', 'No'
        end if
    end if
end program name

Measured memory_bytes: 384
K = int(input())
lunlun = []

def dfs(x):
    lunlun.append(x)
    if len(str(x))==10:
        return
    d = x % 10
    for v in [d-1,d,d+1]:
        if 0<= v <= 9:
            dfs(x*10+v)

for i in range(1, 10):
    dfs(i)

lunlun.sort()
print(lunlun[K-1])

Measured memory_bytes: 12284
N,M = map(int,input().split())
import time
start_t = time.time()
path = [[] for _ in range(N*3+3)]
for _ in range(M):
    u,v = map(int,input().split())
    path[u].append(v)

S,T = map(int,input().split())
import collections

q = collections.deque()
vis = [[-1 for _ in range(3)] for _ in range(N+3)]
def bfs():
    while len(q) > 0:
        now,cnt = q.popleft()
        step = cnt % 3
        if now == T and step  == 0:  
            return cnt
        for x in path[now]:
            if vis[x][(step+1)%3] == -1:
                vis[x][(step+1)%3] = cnt
                q.append((x,cnt+1))
    return -3
vis[S][0] = 1
q.append([S,0])
print(bfs()//3)






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

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

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}

use std::cmp::{max, min};

fn main() {
    let n: usize = read();
    let a: Vec<i64> = read_n(n);

    let mut current = 1;
    for i in a {
        if i == current {
            current += 1;
        }
    }
    if current != 1 {
        println!("{}", n as i64 - current + 1);
    } else {
        println!("{}", -1);
    }
}


Measured memory_bytes: 59516
def get(a, b):
    s = 0
    for i in range(m):
        s += a[i] * b[i]
    return s + c > 0


n, m, c = map(int, input().split())
b = list(map(int, input().split()))
ans = 0
for i in range(n):
    a = list(map(int, input().split()))
    ans += get(a, b)
print(ans)

Measured memory_bytes: 3060
N, M = map(int, input().split())
l = r = None
for _ in range(M):
    L, R = map(int, input().split())
    if l is None:
        l, r = L, R
        continue
    l = max(l, L)
    r = min(r, R)
if l <= r:
    print(r - l + 1)
else:
    print(0)

Measured memory_bytes: 44008
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<algorithm>
#include<map>
#include<functional>
using namespace std;

const int MAX = 20001;
int dp[MAX] = { 0 };


void solve(int n, int v) {
	int temp[MAX] = { 0 };
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < MAX; j++) {
			if (dp[j] == 0 || j + i * v >= MAX)continue;
			temp[j + i * v] += dp[j];
		}
	}
	for (int i = 0; i < MAX; i++) {
		dp[i] += temp[i];
	}
}

int main() {
	int A, B, C, X;
	

	cin >> A >> B >> C >> X;

	dp[0] = 1;
	solve(A, 500);
	solve(B, 100);
	solve(C, 50);

	cout << dp[X] << endl;

	return 0;
}

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

int main(){
  string s;
  int w;
  cin >> s >> w;
  string ans;
  for(int i = 0;(w * i) < s.size(); i++){
    ans += s[w * i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
LP m[200000] = {};
int main() {
	int n; cin >> n;
	rep(i, n) {
		ll x, y; cin >> x >> y;
		if (x > y)swap(x, y);
		m[i] = { x,y };
	}
	if (n == 1) {
		cout << 0 << endl;
		return 0;
	}
	sort(m, m + n);
	ll a = m[0].first;
	ll b;int chk; b = -1;
	rep(i, n) {
		if (b <= m[i].second) {
			b = m[i].second; chk = i;
		}
	}
	if (chk == 0) {
		ll mi = (ll)MOD;
		ll ma = 0;
		rep(i, n) {
			ma = max(ma, m[i].first);
			mi = min(mi, m[i].second);
		}
		cout << (ma - a)*(b - mi) << endl;
	}
	else {
		ll out = INF;
		ll mi = (ll)MOD;
		ll ma = 0;
		rep(i, n) {
			ma = max(ma, m[i].first);
			mi = min(mi, m[i].second);
		}
		out = min(out, (ma - a)*(b - mi));
		ll out2 = INF;
		ll mi3 = min(m[0].second, m[chk].first);
		ll ma3 = max(m[0].second, m[chk].first);
		ll mi2 = m[1].first; ll ma2 = m[n - 1].first;
		out2 = min(out2, max(ma2, ma3) - min(mi2, mi3));
		rep(i, n) {
			if (i == 0 || i == chk)continue;
			mi3 = min(mi3, m[i].second);
			ma3 = max(ma3, m[i].second);
			if (i < n - 1) {
				mi2 = min(mi3, m[i + 1].first);
			}
			else {
				mi2 = mi3;
			}
			ma2 = max(m[n - 1].first, ma3);
			out2 = min(out2, ma2 - mi2);
		}
		out2 *= (b - a);
		cout << min(out, out2) << endl;
	}
	return 0;
}

Measured memory_bytes: 3456
#include <stdio.h>
int main(void){

  char	S[4+1];
  int	x = 0;
  int	y = 0;
  int	z = 0;
  
  scanf("%4s", S);
  
  if(S[0]==S[1]){ x++; }
  if(S[0]==S[2]){ x++; }
  if(S[0]==S[3]){ x++; }
  
  if(S[1]==S[2]){ y++; }
  if(S[1]==S[3]){ y++; }
  
  if(S[2]==S[3]){ z++; }
  
  if( (x+y+z) == 2 ){ printf("Yes"); }
  else				{ printf("No");  }
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>

int main()
{
	std::string S, ans = "Good";

	std::cin >> S;
	for (int i = 1; i < 4; i++){
		if (S[i] == S[i - 1]){
			ans = "Bad";
			break;
		}
	}

	std::cout << ans << std::endl;

	return 0;
}

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

words = []

for i in range(wd_cnt):
    word = input()
    if word in words:
        print('No')
        exit()
    if len(words) > 0 and (word[0] != words[len(words) - 1][-1]):
        print('No')
        exit()
    words.append(word)
print('Yes')


Measured memory_bytes: 2940
#include <iostream>

int main() {
	long long int x;

	std::cin >> x;

	for (long long int i = 0; i <= 1000; ++i)
	{
		for (long long int j = -1000; j <= i-1; ++j) {
			long long int first = i*i*i*i*i;
			long long int second = j*j*j*j*j;

			if (first - second == x) {
				std::cout << i << " " << j;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <list>
#include <vector>
#include <math.h>
#include <fstream>
#include <sstream>
#include <unordered_map>
using namespace std;

const unsigned long long BASE = (unsigned long long)(1e9 + 7);

#define FROM_0(i, n) for(int i = 0; i < (n); i++)
#define FROM_S(i, s, e) for(int i = (s); i < (e); i++)
#define ITER_BEGIN_END(iter, vec) for(auto iter = vec.begin(); iter < vec.end(); iter++)

bool visited[1001][1001];
bool warped[1001][1001];
int state[1001][1001];

struct Pos
{
    Pos(int _x, int _y, int _w) : x(_x), y(_y), warp(_w) {}

    int x;
    int y;
    int warp;
};

int main()
{
    int height, width;
    int startH, startW, endH, endW;
    cin >> height >> width;
    cin >> startH >> startW >> endH >> endW;
    startH--;
    startW--;
    endH--;
    endW--;
    FROM_0(r, height)
    {
        FROM_0(c, width)
        {
            char x;
            cin >> x;
            state[r][c] = x == '.' ? 0 : 1;
            visited[r][c] = false;
            warped[r][c] = false;
        }
    }

    int walk[4][2] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };
    int warp[20][2];
    int idx = 0;
    for (int dy = -2; dy <= 2; dy++)
    {
        for (int dx = -2; dx <= 2; dx++)
        {
            if ((dx == 0 && dy == 0) || (abs(dx) + abs(dy) == 1))
                continue;
            warp[idx][0] = dx;
            warp[idx][1] = dy;
            idx++;
        }
    }
    // search
    std::list<Pos> table;
    table.push_back(Pos(startW, startH, 0));
    while (!table.empty())
    {
        const Pos & next = table.front();
        int x = next.x, y = next.y, w = next.warp;
        table.pop_front();
        if (y == endH && x == endW)
        {
            cout << w << endl;
            return 0;
        }
        if (visited[y][x])
            continue;
        visited[y][x] = true;
        warped[y][x] = true;
        // walk
        FROM_0(i, 4)
        {
            int newX = x + walk[i][0];
            int newY = y + walk[i][1];
            if (newY >= 0 && newX >= 0 && newY < height && newX < width && state[newY][newX] == 0 && !visited[newY][newX])
            {
                table.push_front(Pos(newX, newY, w));
                warped[newY][newX] = true;
            }
        }
        // warp
        FROM_0(i, 20)
        {
            int newX = x + warp[i][0];
            int newY = y + warp[i][1];
            if (newY >= 0 && newX >= 0 && newY < height && newX < width && state[newY][newX] == 0 && !visited[newY][newX] && !warped[newY][newX])
            {
                table.push_back(Pos(newX, newY, w + 1));
                warped[newY][newX] = true;
            }
        }
    }
    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 9804
#include<iostream>
#include<string>

using namespace std;

int main(){
	int nz_s,nh_s,nz_e,nh_e,time;
	cin>>nz_s>>nh_s>>nz_e>>nh_e>>time;
    int aida_z=nz_e-nz_s;
    int aida_h=nh_e-nh_s;
    int aida_sum=aida_z*60+aida_h;
    int ans=aida_sum-time;
    if(ans>=0) cout<<ans<<endl;
    else cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int n;
    cin >> n;

    int r0, r1;
    cin >> r0 >> r1;
    int maxv = r1 - r0;
    int minv = min(r0, r1);

    for (int j = 0; j < n - 2; j++)
    {
        int r;
        cin >> r;
        maxv = max(maxv, r - minv);
        minv = min(minv, r);
    }

    cout << maxv << endl;
}


Measured memory_bytes: 3112
#include<iostream>
using namespace std;
int main(){
	char op;
	int A;
	int B;
	cin>>A;
	cin>>op;
	cin>>B;

	switch(op){
		case '+':
			cout<<A+B<<"\n";
			break;
			case '-':
				cout<<A-B<<"\n";
		
	}
}

Measured memory_bytes: 256
using System;

namespace _051c
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] read = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            int sx = read[0];
            int sy = read[1];
            int tx = read[2];
            int ty = read[3];
            int dx = tx-sx;
            int dy = ty-sy;
            //Pass1
            for(int i = 0;i<dy;i++){
                Console.Write('U');
            }
            for(int i = 0;i<dx;i++){
                Console.Write('R');
            }
            // Pass2
            for(int i = 0;i<dy;i++){
                Console.Write('D');
            }
            for(int i = 0;i<dx;i++){
                Console.Write('L');
            }
            //Pass3
            Console.Write('L');
            for(int i = 0;i<dy+1;i++){
                Console.Write('U');
            }
            for(int i = 0;i<dx+1;i++){
                Console.Write('R');
            }
            Console.Write('D');
            
            //Pass4
            Console.Write('R');
            for(int i = 0;i<dy+1;i++){
                Console.Write('D');
            }
            for(int i = 0;i<dx+1;i++){
                Console.Write('L');
            }
            Console.Write('U');
        }
    }
}

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

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

int main() {
    int K;
    cin >> K;
    long long ans = 0;
    for (int a = 1; a <= K; ++a) {
        for (int b = 1; b <= K; ++b) {
            for (int c = 1; c <= K; ++c)
            ans += gcd(a, gcd(b, c));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3644
def resolve():
    N = int(input())
    A = list(map(int, input().split()))

    P = [0] * (N + 1)
    for i, a in enumerate(A):
        P[a] = i

    l_idx = list(range(-1, N - 1)) + [-1, -1]
    r_idx = list(range(1, N + 1)) + [N, N]  # 番兵

    ans = 0
    for p in range(1, N + 1):
        x = P[p]

        l1 = l_idx[x]
        l2 = l_idx[l1]
        r1 = r_idx[x]
        r2 = r_idx[r1]

        cmb = (x - l1) * (r2 - r1) + (l1 - l2) * (r1 - x)
        ans += p * cmb

        l_idx[r1] = l1
        r_idx[l1] = r1

    print(ans)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 89220
#!/usr/bin/env python3

N = int(input())
A = list(map(int, input().split()))

S = sum(A)

Ret = []
s = 0
for i in range(1, N, 2):
    s += A[i]

Ret.append(S-2*s)

for i in range(N-1):
    Ret.append(2*A[i]-Ret[-1])

print(*Ret)


Measured memory_bytes: 20484
#include <bits/stdc++.h>
#define rep(i,n) for(long long i = 0; i < (long long)(n); ++i)

using namespace std;
using ll = long long;

int main() {
	int d, t, s;
	cin >> d >> t >> s;
	if (t >= (d + s - 1) / s) cout << "Yes";
	else cout << "No";
	return 0;
}


Measured memory_bytes: 3616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    String[] s = new String[n];
    for (int i = 0; i < n; i++) {
      s[i] = sc.next();
    }
    Map<String, Integer> count = new HashMap<>();
    for (String si: s) {
      count.merge(si, 1, Integer::sum);
    }
    System.out.println("AC x " + (count.containsKey("AC") ? count.get("AC") : 0));
    System.out.println("WA x " + (count.containsKey("WA") ? count.get("WA") : 0));
    System.out.println("TLE x " + (count.containsKey("TLE") ? count.get("TLE") : 0));
    System.out.println("RE x " + (count.containsKey("RE") ? count.get("RE") : 0));
  }
}

Measured memory_bytes: 50372
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <unordered_map>

#define mod 1000000007

using namespace std;
using ll = long long;

void solve(){
    string s;
    int res = 0;
    cin >> s;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == '1'){
            res++;
        }
    }
    cout << res << endl;
}

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

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    
    int x,y,w,h,r;
    int a,b;
    
    scanf("%d",&w);
    scanf("%d",&h);
    scanf("%d",&x);
    scanf("%d",&y);
    scanf("%d",&r);
    
   if(x <= 0){
       puts("No");
       return 0;
   }if(y <= 0){
       puts("No");
       return 0;
   }if(h < 2 * r){
       puts("No");
       return 0;
   }if(w < 2 * r){
       puts("No");
       return 0;
   }if(x == h){
       puts("No");
       return 0;
   }if(y == w){
       puts("No");
       return 0;
   }if(h == y){
       puts("No");
       return 0;
   }if(w == x){
       puts("No");
       return 0;
   }if(w < x){
       puts("No");
       return 0;
   }if(h < y){
       puts("No");
       return 0;
   }
   
   puts("Yes");
    
    
    return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int arr[n];
	for(int i = 0; i < n;++i){
		cin >> arr[i];
	}
	int ans = 0;
	for(int i = 0; i < n;++i){
		for(int j = i+1; j < n;++j){
			for(int k = j+1; k < n;++k){
				if(arr[i] == arr[j] || arr[i] == arr[k] || arr[j] == arr[k])
					continue;
				if(arr[i] < arr[j]+arr[k] && arr[j] < arr[i]+arr[k] && arr[k] < arr[i]+arr[j])
					++ans;
			}
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 3652
#include <stdio.h>

#define MAX_N 100

int main(void) {
    int n;
    int bs[MAX_N];
    int score = 0;

    scanf("%d", &n);

    for (int i = 0; i < n - 1; i++) {
        int x;
        scanf("%d", &x);
        bs[i] = x;
    }

    score += bs[0];

    for (int i = 0; i < n-2; i += 1) {
        if (bs[i] < bs[i+1]) {
            score += bs[i];
        } else {
            score += bs[i+1];
        }
    }

    score += bs[n-2];

    printf("%d\n", score);

    return 0;
}


Measured memory_bytes: 128
// author : Kartikey Tewari
// date: 2020-02-16   17:38:55
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl '\n'
using namespace std;

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

    int n;
    cin >> n;
    int flag=0;
    for (int i=0;i<=n-1;i++)
    {
        int a;
        cin >> a;
        if (a%2==0)
        {
            if ((a%3!=0)&&(a%5!=0))
            {
                flag=1;
                break;
            }
        }
    }

    if (flag==1)
    {
        cout << "DENIED" << endl;
    }
    else
    {
        cout << "APPROVED" << endl;
    }

    return 0;    
}

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

using namespace std;

#define all(c) (c).begin(), (c).end()

int main(){
    int N, Q;
    while(cin >> N >> Q, N|Q){
        vector<int> date(100); date[0] = Q - 1;
        while(N--){
            int M;
            cin >> M;
            while(M--){
                int d;
                cin >> d;
                date[d]++;
            }
        }
        cout << max_element(all(date)) - date.begin() << '\n';
    }
    return 0;
}

Measured memory_bytes: 1196
# coding: utf-8
# Your code here!

import numpy as np

n,k = map(int,input().split())

s = input()

now = s[0]
tmp = 0

h = []
if s[0]=="0":
    h.append(0)

for i in s:
    if i != now:
        now = i
        h.append(tmp)
        tmp=0
    tmp+=1
h.append(tmp)

h = np.array(h)

ans = 0

for i in range(0,len(h),2):
    ans = max(ans,np.sum(h[i:i+k*2+1]))
    
print(ans)

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

int main()
{
  int x,y;
  cin>>x>>y;
  int ans=0;
  if(x==1)ans+=300000;
  else if(x==2)ans+=200000;
  else if(x==3)ans+=100000;
  if(y==1)ans+=300000;
  else if(y==2)ans+=200000;
  else if(y==3)ans+=100000;
  if(ans==600000)ans+=400000;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl
#define NL <<"\n"

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
//#undef NUIP
#ifdef NUIP
#include "benri.h"
#else
#define out(args...)
#endif
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif
const ll MOD=1e9+7; //998244353

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout<<fixed<<setprecision(0);
	ll n;
  cin>>n; n;
	reps(i,1,5123456){
		ll m=i*108/100;
		if(m==n){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<":("<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n, a, b;
    cin >> n >> a >> b;
    vector<lint> p(n);
    vector<pair<lint, lint>> pi;
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
        pi.emplace_back(p[i], i);
    }
    sort(pi.begin(), pi.end());
    vector<lint> dp(2 * n + 2);
    vector<lint> dpn(2 * n + 2);
    for (int i = 0; i < 2 * n + 2; ++i) {
        int orig = pi[0].second * 2 + 1;
        if (i < orig)
            dp[i] = b;
        else if (i > orig)
            dp[i] = a;
        else
            dp[i] = 0;
    }

    for (int i = 1; i < n; ++i) {
        int orig  = pi[i].second * 2 + 1;
        lint mini = inf;
        for (int j = 0; j < 2 * n + 2; ++j) {
            mini = min(mini, dp[j]);
            if (j < orig)
                dpn[j] = mini + b;
            else if (j > orig)
                dpn[j] = mini + a;
            else
                dpn[j] = mini;
        }
        swap(dp, dpn);
    }
    cout << *min_element(dp.begin(), dp.end()) << "\n";
    return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Text;

namespace AtCoder
{
  class Program
  {
    static void Main(string[] args)
    {
      string[] ss = Console.ReadLine().Split(' ');
      int H = int.Parse(ss[0]);
      int W = int.Parse(ss[1]);
      char[][] map = new char[H][];
      for(int i = 0; i < H; i++)
      {
        map[i] = Console.ReadLine().ToCharArray();
      }

      for(int i = 0; i < H; i++)
        for(int j = 0; j < W; j++)
        {
          if(map[i][j] == '.')
          {
            map[i][j] = (char)('0' + GetNum(map, i, j));
          }
        }

      foreach(char[] s in map)
      {
        Console.WriteLine(new string(s));
      }
      Console.ReadLine();
    }

    static int GetNum(char[][] map, int i, int j)
    {
      int c = 0;
      if(1 <= i)
      {
        if(1 <= j)
          if(map[i - 1][j - 1] == '#')
            c++;
        if(map[i - 1][j] == '#')
          c++;
        if(j <= map[0].Length - 2)
          if(map[i - 1][j + 1] == '#')
            c++;
      }
      if(1 <= j)
        if(map[i][j - 1] == '#')
          c++;
      if(j <= map[0].Length - 2)
        if(map[i][j + 1] == '#')
          c++;
      if(i <= map.Length - 2)
      {
        if(1 <= j)
          if(map[i + 1][j - 1] == '#')
            c++;
        if(map[i + 1][j] == '#')
          c++;
        if(j <= map[0].Length - 2)
          if(map[i + 1][j + 1] == '#')
            c++;
      }
      return c;
    }
  }
}

Measured memory_bytes: 27484
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

from itertools import product

def cnt(N):
    ret = 0
    for s in product('ACGT', repeat=N):
        s = ''.join(s)
        if 'AGC' in s or 'GAC' in s or 'ACG' in s:
            continue
        if 'AGGC' in s or 'ATGC' in s or 'AGTC' in s:
            continue
        ret += 1
    return ret

def main():
    N = II()
    ans = 0
    dp = {'':1, 'A':0, 'G':0, 'GA':0, 'AC':0, 'AT':0, 'AG':0,
        'ATG':0, 'AGT':0, 'AGG':0}
    for _ in range(N):
        tmp = {}
        tmp[''] = dp[''] * 2 + dp['G'] * 2 + \
            dp['AC'] * 2 + dp['AT'] * 2 + \
            dp['ATG'] * 1 + dp['AGT'] * 1 + dp['AGG'] * 1
        tmp['A'] = dp[''] + dp['A'] + dp['GA'] + dp['AC'] + dp['AT'] + dp['AGT']
        tmp['G'] = dp[''] + dp['G'] + dp['AGG'] + dp['ATG'] + dp['AGT']
        tmp['GA'] = dp['G'] + dp['AG'] + dp['ATG'] + dp['AGG']
        tmp['AC'] = dp['A']
        tmp['AT'] = dp['A'] + dp['GA']
        tmp['AG'] = dp['A'] + dp['GA']
        tmp['ATG'] = dp['AT']
        tmp['AGT'] = dp['AG']
        tmp['AGG'] = dp['AG']
        dp = tmp
    ans = sum(v for v in dp.values())

    return ans % MOD

print(main())

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define rep(i,n)   FOR (i, size_t{}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;
constexpr ll inf = 2e18;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  int a, b;
  cin >> a >> b;
  cout << max (a - b - b, 0) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) (a<<b)
#define Rshift(a,b) (a>>b)
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, r;
    cin >> n >> r;
    if (n >= 10) cout << r << endl;
    else {
        cout << r + (10 - n) * 100 << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1
//#define INFTY 1000000000000000000

int main(){
    LL n;
    LL k;
    cin >> n >> k;
    vector<LL> v(n);
    for(LL i=0; i<n; i++){
        cin >> v[i];
    }

    LL lim=min(n,k);
    LL ans=0;
    LL sum;
    for(LL i=0; i<=lim; i++){
        for(LL j=0; j<=i; j++){
            sum=0;
            multiset<LL> get_val;
            for(LL l=0; l<=j; l++){
                if(l==0){
                    continue;
                }
                sum+=v[l-1];
                get_val.insert(v[l-1]);
                //cout << "left " << v[l-1] << " " << sum << endl;
            }
            for(LL l=0; j+l<=i; l++){
                if(l==0){
                    continue;
                }
                sum+=v[n-l];
                get_val.insert(v[n-l]);
                //cout << "right " << v[n-l] << " " << sum << endl;
            }
            LL tmp=k-i;
            while(tmp>0){
                auto itr=get_val.begin();
                if(*itr>=0){
                    break;
                }
                sum-=*itr;
                //cout << "erase " << *itr << " " << sum << endl;
                get_val.erase(itr);
                tmp--;
            }
            //cout << sum << endl;
            ans=max(ans,sum);
        }
    }

    cout << ans << endl;


    return 0;
}


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

int main()
{
	int n,m;
	int sum1, sum2;

	cin >> n >> m;
	
	if ( n > 1 ) {
		sum1 = n * ( n - 1) / 2;
	} 
	else {
        sum1 = 0;
	}	
	
	if ( m > 1) {
		sum2  = m * ( m - 1 ) / 2;
	}
	else {
		sum2 = 0;
	}
	
	cout << sum1 + sum2 << endl;
	
	return 0;
}

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

int main() {
    long long int n, t, sum = 0, ret = 0;
    std::cin >> n;
    std::vector<long long int> a(n, 0);
    for (long long int i = 0; i < n; i++) {
        std::cin >> t;
        if (t != 0) {
            sum += t;
        } else {
            ret += sum / 2;
            sum = 0;
        }
    }

    ret += sum / 2;

    std::cout << ret << std::endl;
}

Measured memory_bytes: 1024
c = [list(map(int, input().split())) for _ in range(3)]
if c[0][1]-c[0][0]!=c[1][1]-c[1][0]:
    print("No")
    exit()
if c[0][2]-c[0][0]!=c[1][2]-c[1][0]:
    print("No")
    exit()
if c[0][2]-c[0][1]!=c[1][2]-c[1][1]:
    print("No")
    exit()
if c[0][1]-c[0][0]!=c[2][1]-c[2][0]:
    print("No")
    exit()
if c[0][2]-c[0][0]!=c[2][2]-c[2][0]:
    print("No")
    exit()
if c[0][2]-c[0][1]!=c[2][2]-c[2][1]:
    print("No")
    exit()
    
if c[1][0]-c[0][0]!=c[1][1]-c[0][1]:
    print("No")
    exit()
if c[2][0]-c[0][0]!=c[2][1]-c[0][1]:
    print("No")
    exit()
if c[2][0]-c[1][0]!=c[2][1]-c[1][1]:
    print("No")
    exit()
if c[1][0]-c[0][0]!=c[1][2]-c[0][2]:
    print("No")
    exit()
if c[2][0]-c[0][0]!=c[2][2]-c[0][2]:
    print("No")
    exit()
if c[2][0]-c[1][0]!=c[2][2]-c[1][2]:
    print("No")
    exit() 
  
print("Yes")

Measured memory_bytes: 3192
/*
   Author : tarang
*/
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define PI = acos(-1)
using namespace std ;
ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll f(ll x){
	if(x%4 == 0){
		return x ;
	}
	else if(x%4 == 1){
		return 1 ;
	}
	else if(x%4 == 2){
		return (x+1) ;
	}
	else return 0 ;
}
int main(){
	 fastio ; 
	 ll a , b ;
	 cin >> a >> b ;
	 cout << (f(b)^f(a-1)) << endl;
}

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

int main(){
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  int n=5;
  vector<int>time={a,b,c,d,e};
  vector<int>nexttime(n);
  for(int i=0;i<n;i++){
    if(time[i]%10==0)  nexttime[i]=time[i];
    else  nexttime[i]=10-time[i]%10+time[i];
  }
  int bst=1e9;
  for(int i=0;i<n;i++){
    int sum=0;
    for(int j=0;j<n;j++){
      if(i==j){
        sum+=time[j];
      }
      else{
        sum+=nexttime[j];
      }
    }
    bst=min(bst,sum);
  }
  cout<<bst<<endl;
}
      
  
  

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    if(a.equals("SSS")){
      System.out.println(0);
      return;
    }
    if(a.equals("RRR")){
      System.out.println(3);
      return;
    }
    if(a.equals("SRR") | a.equals("RRS") ){
      System.out.println(2);
      return;
    }
    System.out.println(1);
  }
  
}



Measured memory_bytes: 35664
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
vector<vector<pair<ll,int> > > v(100000);
int ans[100000];
void dfs(ll now,int col){
	ans[now]=col;
	for(auto& i:v[now]){
		if(ans[i.first]==-1){
			if(i.second){
				dfs(i.first,col^1);
			}else{
				dfs(i.first,col);
			}
		}
	}
	return;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b,c;
    memset(ans,-1,sizeof(ans));
    cin>>n;
    for(int i=0;i<n-1;i++){
    	cin>>a>>b>>c;
    	a--;b--;
    	v[a].pb(make_pair(b,c&1));
    	v[b].pb(make_pair(a,c&1));
    }
    dfs(0LL,0);
    for(int i=0;i<n;i++){
    	cout << ans[i] <<endl;
    }
    return 0;
}


Measured memory_bytes: 9856
import sys
sys.setrecursionlimit(10000)
def gcd(n1,n2):
    if n1 > n2:
        n1,n2 = n2,n1
    if n2 % n1 == 0:return n1
    else: return gcd(n2%n1,n1)
n = int(input())
if n == 1:
    print(int(input()))
    sys.exit()
t = [int(input()) for i in range(n)]
check = t[0]*t[1]//gcd(t[0],t[1])
for i in range(n-2):
    check = (check*t[i+2])//gcd(check,t[i+2])
print(int(check))

Measured memory_bytes: 3064