akhauriyash/Code-Regression huggingface dataset:
import java.awt.Point;
import java.util.ArrayDeque;
import java.util.Scanner;
import java.util.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.util.Collection;


 
public class Main{
	
        static final Scanner sc=new Scanner(System.in);
        
        
        
        
        
        
        public static void main(String[]args){
                 int N=sc.nextInt();
                 if(N%2==0){
                         System.out.println(N);
                 }else{
                         System.out.println(N*2);
                 }
                
                

        }
        
        
        

		
	
}


Measured memory_bytes: 21844
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  int n; cin >>n;
  vector<int> a(n);
  set<int> A;
  rep(i,n){
    cin >>a[i];
    A.insert(a[i]);
  }
  vector<ll> v;
  for(auto x:A)v.push_back(x);
  sort(all(v));
  map<int,int> mp;
  rep(i,n) mp[a[i]]++;
  int sum=0;
  rep(i,v.size()){
    if(mp[v[i]]<v[i])sum+=mp[v[i]];
    if(mp[v[i]]>v[i])sum+=mp[v[i]]-v[i];
  }
  cout <<sum<<endl;
}



Measured memory_bytes: 13300
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <inttypes.h>

//int compare_int(const void *a, const void *b){//qsort 整数比較<
//	return *(int*)a - *(int*)b;
//}
//int compare_int2(const void *a, const void *b){//qsort 整数比較>
//	return *(int*)b - *(int*)a;
//}
//

//long long int combination(int n, int r)
//{
//	if (r == 0 || r == n)
//		return (1);
//	else if (r == 1)
//		return (n);
//	return (combination(n - 1, r - 1) + combination(n - 1, r));
//}

int main(void){
	char s[1020]={'\0'};
	int len;

	scanf("%s",s);
	len=strlen(s);
	if(s[len-1]=='s'){
		strcat(s,"es");
	}else{
		strcat(s,"s");
	}
	printf("%s",s);

	return 0;
}


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

int main(){
  int a[10],i,j;

  for(i=0;i<10;i++){
    cin >> a[i];
  }

  sort(a,a+10);

  for(i=9;i>=7;i--){
    cout << a[i] << endl;
  }
}

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

int main()
{
    int N, x; cin >> N >> x;

    auto moves = 0LL;

    auto previous = 0;
    for (auto i = 0; i < N; i++)
    {
        int a; cin >> a;
        const auto goal = previous + a > x ? x - previous : a;
        moves += a-goal;
        previous = goal;
    }

    cout << moves << endl;
}


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

using namespace std;

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

	int n, k;
	cin >> k >> n;
	if (n == 1) {
		cout << 0 << '\n';
	} else {
		cout << (k - (n - 1)) - 1 << '\n';
	}
}

Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

ll dp[2][60];

int main() {
	int N, P;
	cin >> N >> P;
	dp[0][0] = 1;
	for(int i = 0; i < N; i++) {
		int A;
		cin >> A;
		if(A % 2) {
			dp[0][i+1] = dp[0][i] + dp[1][i];
			dp[1][i+1] = dp[1][i] + dp[0][i];
		}
		else {
			dp[0][i+1] = dp[0][i]*2;
			dp[1][i+1] = dp[1][i]*2;
		}
	}
	cout << dp[P][N] << endl;

	return 0;
}


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

#define Fi first
#define Se second
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<(n);i++)
typedef tuple<int, int, int> t3;

int N;
int color[3][100010];
vector <int> E[3][100010];
const int mod = 998244353;

ll pw(ll x, ll y = mod - 2) {
	ll res = 1;
	while(y) {
		if(y & 1) res = res * x % mod;
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}

const int L = 1<<17;
void FFT_XOR(ll A[], int rev) {
	for(int len=1;len<L;len<<=1) {
		for(int i=0;i<L;i+=len*2) {
			for(int j=0;j<len;j++) {
				ll x = A[i+j];
				ll y = A[i+j+len];
				A[i+j] = (x + y) % mod;
				A[i+j+len] = (x - y + mod) % mod;
			}
		}
	}
	if(rev) rep(i, L) A[i] = A[i] * pw(L) % mod;
}

ll V[3][L];
ll rp[300010];

int main() {
	ll r = 1;
	rep(i, 18) r = r * 10 % mod;
	rp[0] = 1;
	for(int i=1;i<300010;i++) rp[i] = rp[i-1] * r % mod;
	scanf("%d", &N);
	rep(v, 3) {
		int m; scanf("%d", &m);
		while(m--) {
			int x, y;
			scanf("%d%d", &x, &y);
			E[v][x].pb(y);
			E[v][y].pb(x);
		}
		for(int i=N;i;i--) {
			set <int> x;
			for(int e : E[v][i]) if(e > i) x.insert(color[v][e]);
			for(int j=0;;j++) if(x.find(j) == x.end()) {
				color[v][i] = j;
				break;
			}
		}
		for(int i=1;i<=N;i++) {
			int c = color[v][i];
			V[v][c] = (V[v][c] + rp[i]) % mod;
		}
		FFT_XOR(V[v], 0);
	}
	rep(i, L) {
		V[0][i] = V[0][i] * V[1][i] % mod * V[2][i] % mod;
	}
	FFT_XOR(V[0], 1);

	printf("%lld\n", V[0][0]);
	return 0;
}

Measured memory_bytes: 22272
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <time.h>
#include <complex>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;
using std::complex;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::min;
using std::max;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;
typedef complex<double> cd;

namespace MySpace{
    struct Small_Segment_Tree{
        vector<int> a;
        int l, r;

        private:
        int __summ(int L, int R, int l, int r, int v)
        {
            if (L <= l && r <= R)
                return a[v];
            if (R <= l || r <= L)
                return 0;
            int m = (l + r) / 2;
            return __summ(L, R, l, m, 2 * v + 1) + __summ(L, R, m, r, 2 * v + 2);
        }

        void __set(int P, int l, int r, int v, int V)
        {
            if (l + 1 == r)
            {
                a[v] = V;
                return;
            }
            int m = (l + r) / 2;
            if (P < m)
            {
                __set(P, l, m, 2 * v + 1, V);
                a[v] = a[2 * v + 1] + a[2 * v + 2];
            }
            else
            {
                __set(P, m, r, 2 * v + 2, V);
                a[v] = a[2 * v + 1] + a[2 * v + 2];
            }
        }

        public:
        int Summ(int L, int R)
        {
            if (R < L)
                return 0;
            return __summ(L, R + 1, l, r, 0);
        }

        void Set(int P, int V)
        {
            __set(P, l, r, 0, V);
        }

        Small_Segment_Tree(int _n)
        {
            a.resize(4 * _n);
            l = 0, r = _n;
        }
    };
    long long inq(long long x, long long q, long long MOD)
    {
        if (q == 0)
            return 1;
        long long l = inq(x, q / 2, MOD);
        if (q % 2)
            return l * l % MOD * x % MOD;
        return l * l % MOD;
    }
};


using namespace MySpace;

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

const ll MOD = 1e9 + 7;
ll a[500000];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    cout << a[n / 2] - a[n / 2 - 1];
}


Measured memory_bytes: 1024
n = int(input())
ans = []

if n < 105:
    print(0)
    exit(0)

for i in range(105, n + 1, 2):
    divisors = []
    for j in range(1, i + 1):
        if i % j == 0:
            divisors.append(j)

    if len(divisors) == 8:
        ans.append(i)

print(len(ans))

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

typedef long long ll;
typedef std::pair <ll, ll> pr;
typedef std::map <ll, ll> map;
const int N = 100054;
const ll INF = 0x3f3f3f3f3f3f3f3fll;

int n;
int pn = 0, c[2254], p[354];
map M;

inline ll min(const ll x, const ll y) {return x < y ? x : y;}
inline int max(const int x, const int y) {return x < y ? y : x;}

void sieve(int n) {
	int i, j, v;
	memset(c, -1, sizeof c);
	for (i = 2; i <= n; ++i) {
		if (!~c[i]) p[pn] = i, c[i] = pn++;
		for (j = 0; (v = i * p[j]) <= n && j <= c[i]; ++j) c[v] = j;
	}
}

ll cubic_characteristic(ll x) {
	int i; ll C;
	for (i = 0; i < pn && (C = (ll)p[i] * p[i] * p[i]) <= x; ++i)
		for (; !(x % C); x /= C);
	return x;
}

ll Compl(ll x) {
	int i; ll t, y = 1;
	for (i = 0; i < pn && p[i] <= x; ++i)
		x % (p[i] * p[i]) ? (x % p[i] ? 0 : (y *= p[i] * p[i], x /= p[i])) : (y *= p[i], x /= p[i] * p[i]);
	return t = sqrt(x), y * min(INF / y, t * t == x ? t : x * x);
}

int main() {
	int i, ans = 0; ll x;
	map::iterator it;
	scanf("%d", &n), sieve(2253);
	for (i = 0; i < n; ++i) scanf("%lld", &x), ++M[cubic_characteristic(x)];
	for (const pr &e : M)
		if (e.first == 1) ++ans;
		else if ((it = M.find(x = Compl(e.first))) == M.end()) ans += e.second;
		else if (e.first < x) ans += max(e.second, it->second);
	printf("%d\n", ans);
	return 0;
}

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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if (a + b > c + d){
    cout << "Left" << endl;
  }
  
  else if (a + b == c + d){
    cout << "Balanced" << endl;
  }

  else{
    cout << "Right" << endl;
  }
  
}

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


/*  
    
*/

void test_case(){
    int n; cin >> n;
    
    int res = 0;
    
    for(int i = 1; i*i < n; i++){
        for( int j = i ; j * i < n; j++){
            res += 2;
            if( i == j )
                res--;
        }
    }
    
    
    cout << res;
}

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

    int t; t = 1;
    //cin >> t;
    while(t--)
        test_case();
    return 0;
}


Measured memory_bytes: 3648
import bisect
n = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)
h = a[0] / 2
m = a[1] - h
ans = 1
for i in range(2, n):
    if (abs(a[i] - h) < m):
        m = abs(a[i] - h)
        ans = i


print(a[0], a[ans])


Measured memory_bytes: 14420
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <functional>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
//#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, m;
vector<int> et[100000];
int inV[100000];
int pa[100000];
queue<int> que;

signed main() {
	int i;
	
	cin >> n >> m;
	rep(i, n - 1 + m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		et[a].push_back(b);
		inV[b]++;
	}
	
	int rt;
	rep(i, n) {
		if (inV[i] == 0) {
			rt = i;
			que.push(i);
			break;
		}
	}
	
	while (!que.empty()) {
		int v = que.front();
		que.pop();
		rep(i, et[v].size()) {
			int nv = et[v][i];
			inV[nv]--;
			if (inV[nv] == 0) {
				pa[nv] = v;
				que.push(nv);
			}
		}
	}
	
	for (i = 0; i < n; i++) {
		if (i == rt) { cout << 0 << endl; }
		else { cout << pa[i] + 1 << endl; }
	}
	return 0;
}

Measured memory_bytes: 7040
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;


int main(void) {
	ll n, x;
	cin >> n >> x;
	ll ans = 0;
	vl l(n);
	rep(i, n) cin >> l[i];
	ll now = 0;
	rep(i, n) {
		now = now + l[i];
		if (now <= x) ans++;
	}
	cout << ans + 1 << endl;
	return 0;
}


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

typedef long long ll;

int main() {
    ll N;
    cin >> N;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    ll hi = 1e18, lo = -1;
    while (lo + 1 < hi) {
        ll mi = (lo + hi) / 2, s = 0;
        //cout << mi << "\n";
        rep(i, N) {
            s += (a[i] + mi + 1) / (N + 1);
        }
        if (s <= mi) hi = mi;
        else lo = mi;
    }
    for (ll i = max(0LL, hi - 100000); i <= hi; i++) {
        //cout << i << "\n";
        ll s = 0;
        rep(j, N) {
            s += (a[j] + i + 1) / (N + 1);
        }
        if (s <= i) {
            cout << i << "\n";
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
using ll = long long;
using namespace std;

int main() {
    int N, A; cin >> N >> A;
    vector<int> x(N), y(N);
    for (int& xi : x) cin >> xi;
    for (int i = 0; i < N; i++) y[i] = x[i] - A;
    map<int, ll> dp;
    dp[0] = 1;
    for (int yi : y) {
        if (yi >= 0) {
            for (int k = 50 * N; k >= -A * N; k--) {
                dp[k] = dp[k] + dp[k - yi];
            }
        }
        if (yi < 0) {
            for (int k = -A * N; k <= 50 * N; k++) {
                dp[k] = dp[k] + dp[k - yi];
            }
        }
    }
    cout << dp[0] - 1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int a,b,c,count=0;
    cin >>a>>b>>c;
    for (int i=a; i<=b; i++) {
        if (c%i==0) {
            count++;
        }
    }
    cout << count <<endl;
    return 0;
}


Measured memory_bytes: 3116
def main():
    n, k = map(int, input().split())
    MOD = 10**9 + 7
    a = [0]*(k+1)
    for i in range(1, k+1):
        a[i] = pow(k//i, n, MOD)
    for i in reversed(range(1, k+1)):
        for j in range(2*i, k+1, i):
            a[i] -= a[j]
            a[i] %= MOD
    ans = 0
    for i in range(1, k+1):
        ans += a[i]*i
        ans %= MOD
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 11120
def main():
  from math import sqrt
  N, D = map(int, input().split())
  P = [list(map(int, input().split())) for i in range(N)]
  ans = 0
  for i in range(N):
    if sqrt(P[i][0]**2 + P[i][1]**2) <= D:
      ans += 1
  print(ans)
main()

Measured memory_bytes: 107200
#include<bits/stdc++.h>
using namespace std;
#define     bolt     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     F        first
#define     S        second
#define     pb       push_back
#define     ll       long long
#define     inf      3e5
#define     pi       3.141592
int main()
{
   ll n;
   cin>>n;
   cout<<fixed<<setprecision(12)<<2*pi*n;
}


Measured memory_bytes: 3784
import sys
import heapq


def main():
    input = sys.stdin.buffer.readline
    n, m = map(int, input().split())
    a = list(map(lambda x: -int(x), input().split()))
    heapq.heapify(a)
    for _ in range(m):
        price = heapq.heappop(a)
        heapq.heappush(a, -((-price) // 2))
    print(-sum(a))


if __name__ == "__main__":
    main()


Measured memory_bytes: 18380
import itertools
n,m = map(int,input().split())
info = [list(map(int,input().split())) for i in range(m)]

tree= [[] for i in range(n)]
for i in range(m):
  tree[info[i][0]-1].append(info[i][1]-1)
  tree[info[i][1]-1].append(info[i][0]-1)

num = []  
for i in range(n):
  num.append(i)
  
ans = 0
for li in itertools.permutations(num, n):
  flag =True
  if li[0]==0:
    for i in range(n-1):
      if li[i+1] not in tree[li[i]]:
        flag =False
    if flag:
      ans = ans +1
    
  else:
    print(ans)
    exit()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) os << "[" << el.first << " " << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) os << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }
inline void chmax(ll &a, ll b){if(a<b) a=b;};


int N;
struct block{
    ll w,s,v;
    block(ll w,ll s,ll v):w(w),s(s),v(v){}
};
ll MAX_S;
vector<block> blocks;
void input(){
  fast_io();
  #ifdef __LOCAL
      fs::path p = __FILE__;
      fs::path input,output;
      input = output = p.parent_path();
      input += string("/input/") + string(p.stem()) + string(".txt");
      output += string("/output/") + string(p.stem()) + string(".txt");
      freopen(input.c_str(), "r", stdin);
      freopen(output.c_str(), "w", stdout);
  #endif
  cin >> N;
  MAX_S = 0;
  for (int i = 0; i < N; i++)
  {
      ll w,s,v; cin >> w >> s >> v;
      blocks.emplace_back(w,s,v);
      chmax(MAX_S,s);
  }
  sort(blocks.begin(),blocks.end(),[](block a,block b){return (a.s+a.w)<(b.s+b.w);});
}


int solve(){
    vector<unordered_map<int,ll>> dp(N+1);
    dp[0][0] = 0;
    for (int i = 0; i < N; i++)
    {
        for (auto p:dp[i])
        {
            int w = p.first;
            chmax(dp[i+1][w], dp[i][w]);
            if(w<=blocks[i].s) chmax(dp[i+1][w+blocks[i].w], dp[i][w]+blocks[i].v);
        }
        dp[i].clear();
    }
    ll ans=0;
    for (auto p:dp[N])
    {
        chmax(ans,p.second);
    }
    cout << ans << endl;
    
    
    return 0;
}

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


Measured memory_bytes: 114136
N = int(input())
A = [int(_) for _ in input().split()]
B = [int(_) for _ in input().split()]
C = [int(_) for _ in input().split()]

res = sum(B)

for i in range(N-1):
    if A[i+1] -A[i] == 1:
        res += C[A[i]-1]

print(res)


Measured memory_bytes: 3060
import java.io.IOException;
import java.util.NoSuchElementException;

 
public class Main{
	
	public static void main(String args[])throws Exception{
		FastScanner sc = new FastScanner();
		
		int S = sc.nextInt();
		int s = S%60;
		S /= 60;
		int m = S%60;
		int h = S/60;
		System.out.println(h+":"+m+":"+s);
		
	}
}









class FastScanner {
    private final java.io.InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return (minus ? -n : n);
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return (int) (minus ? -n : n);
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}





Measured memory_bytes: 24344
import java.util.*;
import java.util.Scanner;
import java.util.*;
import java.io.IOException;
import java.io.InputStream;

public class Main {


    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];

        private int curChar;

        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new RuntimeException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String readString() {
            final StringBuilder stringBuilder = new StringBuilder();
            int c = read();
            while (isSpaceChar(c))
                c = read();
            do {
                stringBuilder.append(c);
                c = read();
            } while (!isSpaceChar(c));
            return stringBuilder.toString();
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long readLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    }


    public static void main(String[] args) throws IOException {

        Scanner scan = new Scanner(System.in);
        String s = scan.next();

        int max = 0;
        int count = 0;
        for(int i = 0; i < s.length();i++ ){
            char c = s.charAt(i);

            if(c == 'R'){
                count++;
            }else{
                count = 0;
            }
            max = Math.max(max, count);
        }
        System.out.println(max);
    }

}



Measured memory_bytes: 35636
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
#include <functional>
using namespace std;
typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA cerr << "AAAAA" << endl
#define debug_ cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    cout << #v << endl;                \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    cout << #v << endl;                       \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

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

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

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const ll LINF = 1001002003004005006ll;
const ll INF = 1001001001;
const double pi = acos(-1);

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(100010, 0);
    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        ans += x;
        a[x]++;
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        ll b, c;
        ll cnt = 0;
        cin >> b >> c;
        cnt = a[b];
        a[b] = 0;
        a[c] += cnt;
        ans -= b * cnt;
        ans += c * cnt;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 4048
// Repsept　　#15711069　by Kayanochann
#include <bits/stdc++.h>
using namespace std;

int main(){
    int k;
    cin >> k;
    int rest=7%k;
    for(int i=1; i<=k; i++){
        if(rest==0){
            cout << i << endl;
            return 0;
        }
        rest=(rest*10+7)%k;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<b;i++)
int main(){
   string s;
   cin>>s;
   int b=999;
   rep(i,0,s.size()-2){
      if (stoi(s.substr(i,3))==753) {
         cout<<0;
         return 0;
      }
      else if(stoi(s.substr(i,2))==75){
         int n=stoi(s.substr (i+2,1)) ;
         if(abs(n-3)<b) b=abs(n-3);         
      }
      else if(stoi(s.substr(i,1))==7) {
         int m=stoi(s.substr (i+1,2));
         if(abs(m-53)<b) b=abs(m-53);
      } else {
         int m=stoi(s.substr (i,3));
         if(abs(m-753)<b) b=abs(m-753);         
      }
   }
   cout<<b;
}

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

using namespace std;
int main()
{
	int A, B, C;
	int E[3];
  
	cin >> A >> B >> C;

	E[0] = abs(A - B);
	E[1] = abs(B - C);
	E[2] = abs(A - C);

	sort(E, E + 3);

	cout << E[0]+E[1];

	return 0;
}

Measured memory_bytes: 256
import java.util.*;


public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = a * 10 + b;
			if(a == 10){
				if(b < 10){
					System.out.println(9);
				}
				else{
					System.out.println(10);
				}
			}
			else if(a == 11){
				if(b < 11){
					System.out.println(10);
				}
				else{
					System.out.println(11);
				}
			}
			else if(a == 12){
				if(b < 12){
					System.out.println(11);
				}
				else{
					System.out.println(12);
				}
			}
			else {
				System.out.println(c / 11);
			}
			
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


Measured memory_bytes: 20820
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repr(i,a,b) for(int i=a,i > b;--i)
#define mm(lamb, tttt) memset(lamb, tttt, sizeof lamb)

#define null NULL
#define eps 0.000000001
#define mod 1000000007
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define sz(V) (ll)V.size()
#define _ <<" "<<

#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <iterator>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <limits.h>
#include <iomanip>
#include <cctype>
#include <numeric>
#include <complex>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<int> vii;

int main(){
	int n;cin>>n;
	vector<int> pos;pos.pb(0);
	ll tot=0;
	rep(i,0,n){
		int x;cin>>x;
		tot+=abs(x-pos.back());
		pos.pb(x);
	}
	tot+=abs(pos[n]);
	//cout<<tot<<endl;
	vector<ll> ans(n+1,0);
	rep(i,1,n+1){
		int j=(i+1)%(n+1);
		ans[i]=tot-(abs(pos[i]-pos[i-1])+abs(pos[j]-pos[i]))+abs(pos[j]-pos[i-1]);
		cout<<ans[i]<<endl;
	}

}









Measured memory_bytes: 2552
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int n,a,b;
	cin>>n>>a>>b;
	if(a*n<=b){
		cout<<a*n<<endl;
	}
	
	else if(a*n>=b){
		cout<<b<<endl;
	}
}

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

using namespace std;
int main(){
  long long a, b, c, k;
  cin >> a >> b >> c >> k;
  if(k <= a) cout << k;
  else if(k <= b) cout << a;
  else cout << a - (k - b - a);
  return 0;
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    int max = 0;
    int x = 0;

    for (int i = 0; i < n; i++) {
      if (s.charAt(i) == 'I') {
        x++;
      } else {
        x--;
      }
      max = Math.max(max, x);
    }

    System.out.println(max);

  }
}

Measured memory_bytes: 35640
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

int main()
{
    long long n, k;
    std::cin >> n >> k;

    std::vector<std::pair<int, int>> num_and_amount;

    for (int i = 0; i < n; i++) {
        int a, b;
        std::cin >> a >> b;

        num_and_amount.push_back(std::make_pair(a, b));
    }

    std::sort(num_and_amount.begin(), num_and_amount.end());

    long long pos = 1;
    for (int i = 0; i < n; i++) {
        if (pos + num_and_amount[i].second > k) {
            std::cout << num_and_amount[i].first << std::endl;
            return 0;
        }
        pos += num_and_amount[i].second;
    }
    std::cout << num_and_amount.back().second << std::endl;
}


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

int main() {
	ll x;
	cin >> x;
	ll ans = x / 11 * 2;
	if (x%11 == 0) ;
	else if(x%11 <= 6) ans++;
	else ans += 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stack>
#include <array>
#include <queue>
#include <string>
#include <vector>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <new>
#include <map>
#define ESP (1e-13)
#define INF 2000000000
#define ll long long

using namespace std;

int main() {
	int H, W,N;
	cin >> H >> W >> N;
	int a[10001];
	for (int i = 1;i <= N;i++) {
		cin >> a[i];
	}
	int it = 1;
	string s[100] = { "" };
	for (int i = 0;i < H;i++) {
		for (int j = 0;j < W;j++) {
			stringstream ss;
			ss << it;
			if (i % 2 == 0) {
				s[i] += ss.str();
				if (j < W - 1) s[i] += " ";
			}
			else {
				s[i] = ss.str() + s[i];
				if (j < W - 1) s[i] = " "+s[i];
			}
			a[it]--;
			if (a[it] == 0) it++;
		}
	}

	for (int i = 0;i < H;i++) {
		cout << s[i] << endl;
	}

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,P>
using namespace std;

int main(){
  	int n,m,x; cin >> n >> m >> x;
    int san[n][m+1];
    rep(i,n){
        int c; cin >> c;
        san[i][0]=c;
        rep(j,m){
            int a; cin >> a;
            san[i][j+1]=a;
        }
    }

    int ans=INF;

    int l=pow(2,n);
    for(int i=0; i<l; i++){
        vector<int> us(m,0);
        int cost=0;
        int now=i;
        rep(k,n){
            if(now%2==1){
                cost+=san[k][0];
                rep(j,m) us[j]+=san[k][j+1];
            }
            now/=2;
        }
        bool can2=false;
        rep(j,m){
            if(us[j]<x){
                can2=true;
                break;
            }
        }
        if(can2) continue;
        ans=min(ans,cost);
    }

    if(ans==INF) cout << -1 << endl;
    else cout << ans << endl;
return 0;
}




Measured memory_bytes: 4068
#include <iostream>

using namespace std;

int path[102];

void init()
{
    for (int i = 1; i < 102; i++)
        path[i] = 0;
}


int main()
{
    int a, b;
    bool flag = true;

    while (cin >> a >> b) {
        if (a == 0 && b == 0) {
            if (path[1] % 2 && path[2] % 2) {
                for (int i = 3; i <= 100; i++) {
                    if (path[i] == 0)
                        continue;
                    if (path[i] % 2) {
                        flag = false;
                    }
                }
            }
            else
                flag = false;

            if (flag)
                cout << "OK" << endl;
            else
                cout << "NG" << endl;
            init();
            flag = true;
            continue;
        }

        path[a]++;
        path[b]++;
    }

    return 0;
}

Measured memory_bytes: 1156
#!/usr/bin/env python3
import bisect
import numpy as np

N, M = list(map(int, input().split()))
a_list = list(map(int, input().split()))
bc_list = []

for i in range(M):
    try:
        b, c = list(map(int, input().split()))
        bc_list.append((b, c))
    except:
        M = i

bc_list = sorted(bc_list, key=lambda x: x[1], reverse=True)
a_list = sorted(a_list)

fix_list = []
s = 0
b, c = bc_list[0]
bc_index = 0
now_b, now_c = 0, c

for i, a in enumerate(a_list):
    # a = a_list[i]
    if now_b >= b:
        bc_index += 1
        if bc_index >= len(bc_list):
            # TODO: 残りを足す
            fix_list.append(a)
            s += a
            continue
        now_b = 0
        b, c = bc_list[bc_index]

    if a < c:
        fix_list.append(c)
        s += c
    else:
        fix_list.append(a)
        s += a
    now_b += 1

ans = s
print(ans)


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

pair<int, long long> merge(pair<int, long long> u, pair<int, long long> v)
{
  pair<int, long long> res(u.first + v.first, u.second + v.second + 1);
  if (res.first >= 10)
  {
    res.first -= 9;
    res.second++;
  }
  return res;
}

pair<int, long long> calc(int digit, long long cnt)
{
  if (cnt == 1)
    return {digit, 0};
  auto res = calc(digit, cnt / 2);
  res = merge(res, res);
  if (cnt % 2)
    res = merge(res, {digit, 0});
  return res;
}

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

  int m;
  pair<int, long long> ans(0, 0);
  cin >> m;
  for (int i = 0; i < m; i++)
  {
    int d;
    long long c;
    cin >> d >> c;
    if (!i) ans = calc(d, c);
    else ans = merge(ans, calc(d, c));
  }

  cout << ans.second << endl;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let abc = get!(usize, usize, usize; n-1);
    let (q,k) = get!(usize, usize);
    let xy = get!(usize,usize; q);

    let mut nodes = vec![Vec::new(); n+1];
    for (a,b,c) in abc {
        nodes[a].push((b,c));
        nodes[b].push((a,c));
    }
    let mut costs = vec![0; n+1];
    let mut queue = VecDeque::new();
    let mut visited = BTreeSet::new();

    queue.push_back((k, 0));
    visited.insert(k);
    costs[k] = 0;
    while let Some((node, cost)) = queue.pop_front() {
        costs[node] = cost;
        for &(next, ncost) in &nodes[node] {
            if visited.contains(&next) {
                continue;
            }
            queue.push_back((next, cost + ncost));
            visited.insert(next);
        }
    }

    for (x,y) in xy {
        println!("{}", costs[x]+costs[y]);
    }
}


Measured memory_bytes: 28028
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

use std::cmp;

fn main() {
    let (a, b, c, d) = get!(i32, i32, i32, i32);
    println!("{}", cmp::max(0, cmp::min(d, b) - cmp::max(a, c)));
}

Measured memory_bytes: 4352
# -*- coding: utf-8 -*-
import sys

def main():
    N,K = list(map(int, sys.stdin.readline().split()))
    A_list = list(map(int, sys.stdin.readline().split()))


    A_list.sort(key=lambda x: -abs(x))
    mod = 10**9 + 7

    L_plus  = R_plus  = -1 # the Index of plus value
    L_minus = R_minus = -1 # the Index of minus value
    # L : between index 0 to (K-1)
    # R : between index K to end


    for i in range(K-1, -1, -1):
        if (L_plus == -1) and (A_list[i] >= 0):
            L_plus = i
        if (L_minus == -1) and (A_list[i] < 0):
            L_minus = i
        if (L_plus != -1) and (L_minus != -1):
            break
    
    for i in range(K,N):
        if (R_plus == -1) and (A_list[i] >= 0):
            R_plus = i
        if (R_minus == -1) and (A_list[i] < 0):
            R_minus = i
        if (R_plus != -1) and (R_minus != -1):
            break


    cnt_minus = 0

    for i in range(K):
        if A_list[i] < 0:
            cnt_minus += 1


    if cnt_minus % 2 == 0:
        target_idx = [0, K-1]
    
    else: # cnt_minus % 2 != 0
        if (R_plus == -1) and \
           ( (L_plus == -1) or (R_minus == -1) ) :
        
            calc1 = calc2 = 0
        
        elif (R_plus != -1) and \
           ( (L_plus == -1) or (R_minus == -1) ) :
        
            calc1 = 1
            calc2 = 0
        
        elif (R_plus == -1) and \
           ( (L_plus != -1) and (R_minus != -1) ) :
        
            calc1 = 0
            calc2 = 1
        
        elif (R_plus != -1) and \
           ( (L_plus != -1) and (R_minus != -1) ) :
            
            calc1 = A_list[L_plus] * A_list[R_plus]
            calc2 = A_list[L_minus] * A_list[R_minus]


        if calc1 == calc2:
            target_idx = [N-K, N-1]
        
        elif calc1 > calc2:
            A_list[L_minus], A_list[R_plus] = A_list[R_plus], A_list[L_minus]
            target_idx = [0, K-1]

        elif calc1 < calc2:
            A_list[L_plus], A_list[R_minus] = A_list[R_minus], A_list[L_plus]
            target_idx = [0, K-1]


    ans = 1

    for i in range( target_idx[0], (target_idx[1] + 1) ):
        ans *= A_list[i]
        ans %= mod
    
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 31700
y, m, d = map(int, input().split("/"))

if y < 2019:
    print("Heisei")
elif y == 2019:
    if m < 4:
        print("Heisei")
    elif m == 4:
        if d <= 30:
            print("Heisei")
        else:
            print("TBD")
    else:
        print("TBD")
else:
    print("TBD")

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static boolean debug = true;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int x = sc.nextInt();

        int start = x- k + 1;
        int end = x + k - 1;

        if(start < -1000000){
            start = -1000000;
        }
        if(end > 1000000){
            end = 1000000;
        }

        for (int i=start; i<end+1;i++){
            System.out.print(i + " ");
        }

    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,e) for(int i = a;i < e;++i)
using LL = long long;

const LL LINF = 1e18;

struct Edge {
	int to; LL cost;
	Edge(int t, LL c = 0) : to(t), cost(c) {}

	bool operator>(const Edge& rhs) const {
		return cost > rhs.cost;
	}
	bool operator<(const Edge& rhs) const {
		return cost < rhs.cost;
	}

};
using Graph = vector< vector<Edge> >;
bool BellmanFord(const Graph& G, vector<LL>& d, int s) {
	const int V = G.size();
	for (int i = 0; i < V; ++i)
		d[i] = LINF;
	d[s] = 0;

	for (int lp = 0; lp < 2 * V; ++lp) {
		for (int i = 0; i < V; ++i) {
			for (const auto& e : G[i]) {
				if (d[i] != LINF && d[e.to] > d[i] + e.cost) {
					d[e.to] = d[i] + e.cost;
					if (lp >= V && e.to == V - 1)return true;/// inf!
				}
			}
		}
	}
	return false;
}

int main() {
	LL N, M, P;
	cin >> N >> M >> P;
	Graph G(N);
	vector<vector<LL>>lis(N, vector<LL>(N, 0));

	FOR(i, 0, M) {
		LL a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		G[a].emplace_back(b, -c + P);
	}
	vector<LL>d(N);
	bool infmax = BellmanFord(G, d, 0);

	if (infmax) {
		cout << -1 << endl;
	}
	else {
		cout << max(0LL, -d.back()) << endl; // こっち～
	}


}






Measured memory_bytes: 51072
A[1<<17];i;b;y;k;long s;main(j){for(;i<=*A;)scanf("%d",A+i++);for(;~scanf("%d",&b);i<0?s+=i,++y:(A[k++]=i))i=A[j++]-b;for(qsort(A,k,4,"׋+Ð");k--&&s<0;++y)s+=A[k];printf("%d",s<0?-1:y);}

Measured memory_bytes: 2264