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

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Map<String,Long> map = new HashMap<>();
        long ans = 0;
        for(int i = 0;i<n;i++){
            char[] tmp = sc.next().toCharArray();
            Arrays.sort(tmp);
            String key = String.valueOf(tmp);
            if(map.get(key) != null){
                ans += map.get(key);
                map.put(key,map.get(key) + 1);
            }else{
                map.put(key,1L);
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 55256
#include<bits/stdc++.h>
#define int long long 
using namespace std;
signed main(){
  string a,b,c;
  int z,x,n=0,m=0;
  cin>>a>>b;
  z=a.size();
  x=b.size();
  for(int i=0;i<z+x;i++){
    if(i%2==0){
      c[i]=a[n];
      n++;
    }else{
      c[i]=b[m];
      m++;
    }
  }
  for (int i=0;i<z+x;i++){
    cout<<c[i];
  }
  cout<<"\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100005
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
using namespace std;
int k,cnt;
int main(){
   // freopen("A.inp","r",stdin);
  //  freopen("A.out","w",stdout);
    string s="1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51";
    cin>>k;
    int cnt=0;
    if (k==16) {cout<<14; exit(0);}
    if (k==24) {cout<<15; exit(0);}
    if (k==32) {cout<<51; exit(0);}
    FOR(i,0,s.size()){
        if (s[i]==',') ++cnt;
        if (cnt==k) {cout<<s[i-1];
        exit(0);}
    }
}


Measured memory_bytes: 256
X, N = map(int, input().split())
listp = list(set(map(int, input().split())))


def f(X, N, listp):
    if N == 0:
        return X
    if X not in listp:
        return X

    index = listp.index(X)
    
    downres = 1000
    for i,p in enumerate(listp):
        if index - i >= 0:
            if listp[index-i] != X-i:
                downres = X-i
                break
    if downres == 1000:
        downres = X - index -1

    upres = 1000
    l = len(listp)
    for i,p in enumerate(listp):

        if index + i < l:
            if listp[index+i] != X+i:
                upres = X+i
                break
    if upres == 1000:
        upres = X + l - index

    if abs(upres - X) < abs(downres - X):
        return upres
    else:
        return downres


print(f(X, N, listp))

Measured memory_bytes: 9248
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

const int MAX_N = 100010;
using edge = struct {int to; ll cost;};
vector<edge> tree[MAX_N];
ll dist[MAX_N];

void dfs(int v, int p, ll d) {
    dist[v] = d;
    for (edge e: tree[v]) {
        if(e.to==p) continue;
        dfs(e.to, v, d + e.cost);
    }    
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
	int n;
	cin >> n;
    rep(i,n-1) {
        int a, b, c;
        cin >> a >> b >> c;
        --a, --b;
        tree[a].push_back({b, c});
        tree[b].push_back({a, c});
    }
    int q, k;
    cin >> q >> k;
    --k;
    dfs(k,-1,0);
    rep(i,q) {
        int x, y;
        cin >> x >> y;
        --x, --y;
    	cout << dist[x] + dist[y] << "\n";
    }
	return 0;
}


Measured memory_bytes: 16028
lst = input().split()
N = int(lst[0])
A = int(lst[1])
B = int(lst[2])

def sum(n):
   result = 0
   s = str(n)
   for i in range(len(s)):
      result += int(s[i])
   return result

count = 0

for i in range(1, N+1):
   if A <= sum(i) <= B:
      count += i

print(count)

Measured memory_bytes: 9068
a,b,c,d,e,f = map(int,(input().split()))

possible_water = []
for i in range(31):
    for j in range(31):
        water = 100*a*i + 100*b*j
        if 0 < water <= f:
            possible_water.append(water)
pw = list(set(possible_water))

possible_sugar = []
for i in range(3001):
    for j in range(3001):
        sugar = c*i + d*j
        if sugar <= f:
            possible_sugar.append(sugar)
ps = list(set(possible_sugar))

ans = []
for i in pw:
    for j in ps:
        if i + j <= f and j <= (i//100)*e:
            c = 100*j/(i+j)
            ans.append([c,i+j,j])

ans.sort(reverse=True)
print(ans[0][1],ans[0][2])

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

using namespace std;

int main()
{
    int k, a, b;
    cin >> k;
    cin >> a >> b;
    bool c = false;
    for( int i = a; i <= b; i++ )
        if( i % k == 0 )
        {
            c = true;
            break;
        }
    
    if( c )
        cout << "OK" << endl;
    else
        cout << "NG" << endl;

    return 0;
}

Measured memory_bytes: 3612
#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int a,b,c,k;cin >> a >> b >> c >> k;
    if (a >= k) {
        cout << k << endl;
    }
    else if (a + b >= k) {
        cout << a << endl;
    }
    else {
        cout << a - (k - a - b) << endl;
    }
    return 0;
}



Measured memory_bytes: 3532
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int a[3],b=0,c=0;
	for(int i=0;i<=2;i++)
		scanf("%d",&a[i]);
	for(int i=0;i<=1;i++)
		for(int j=1;j<=2;j++)
			if(a[i]>a[j])
			{
				b=a[i];
				a[i]=a[j];
				a[j]=b;
			}
	c=a[0]+a[1];
	printf("%d",c);
	return 0;
}

Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)


bool isprime(LL x) {
	if (x == 2)return true;
	if (x % 2 == 0)return false;
	for (LL i = 3; i <= sqrt(x); i += 2) {
		if (x%i == 0)return false;
	}
	return true;
}

int n;

int main() {
	cin >> n;
	LL num;
	int ret = 0;
	REP(i, n) {
		cin >> num;
		ret += isprime(num);
	}
	cout << ret << endl;
}


Measured memory_bytes: 3088
#include<iostream>
#include<cmath>
int main(){
  int antenna[5];
  int dist,dist_antenna{};
  for (int idx{};idx<5;++idx)
    std::cin>>antenna[idx];
  std::cin>>dist;
  for (int left{};left<4;++left){
    for (int right{4};0<right;--right){
      if (dist<std::abs(antenna[left]-antenna[right])){
	std::cout<<":(";
	return 0;
      }
    }
  }
  std::cout<<"Yay!";
  return 0;
}


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

#define fto(i, a, b) for(int i = a; i <= b; ++i)
#define fdto(i, a, b) for(int i = a; i >= b; --i)
#define ff first
#define ss second
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mp make_pair
#define pb push_back
#define oo 1000000007
#define OO 1000000000000000007

using namespace std;

int n;
int a[100005];
bool used[100005];

bool bs(int x, int left, int right) {
    int l = left;
    while (left < right-1) {
        int mid = (left+right)/2;
        if (a[mid] == x) {
            if (!used[mid]) {
                used[mid] = 1;
                return 1;
            }
            int i = mid;
            while (a[i+1] == x && i < n) {
                if (!used[i+1]) {
                    used[i+1] = 1;
                    return 1;
                }
                ++i;
            }
            i = mid;
            while (a[i-1] == x && i > 2 && i-1 > l) {
                if (!used[i-1]) {
                    used[i-1] = 1;
                    return 1;
                }
                --i;
            }
            return 0;
        }
        if (x > a[mid]) right = mid;
        if (x < a[mid]) left = mid;
    }
    return 0;
}

int main() {
    scanf("%d", &n);
    fto(i, 1, n) scanf("%d", &a[i]);
    sort(a+1, a+1+n, greater<int>());
    int cnt = 0;
    ll x = 1;
    fto(i, 1, n) {
        if (cnt == 2) break;
        if (used[i]) continue;
        if (bs(a[i], i, n+1)) {
            x = x*a[i];
            ++cnt;
        }
    }
    if (cnt == 2) cout << x;
    else puts("0");
    return 0;
}
/// 362


Measured memory_bytes: 640
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

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

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N := sc.nextInt()
	S := sc.nextStr()
	S += S[0:2]
	// [before][now], SSS, SWW, WSW, WWS
	okMap := [][]int{[]int{0, 1}, []int{1, 0}}
	// [before][now], SSW, SWS, WSS, WWW
	ngMap := [][]int{[]int{1, 0}, []int{0, 1}}
	for i := 0; i < 2; i++ {
		for j := 0; j < 2; j++ {
			arr := make([]int, N+2)
			arr[0] = i
			arr[1] = j
			for k := 1; k < N+1; k++ {
				if S[k] == 'o' {
					arr[k+1] = okMap[arr[k-1]][arr[k]]
				} else {
					arr[k+1] = ngMap[arr[k-1]][arr[k]]
				}
			}
			if arr[N] == i && arr[N+1] == j {
				for i := 0; i < N; i++ {
					if arr[i] == 0 {
						fmt.Fprint(wtr, "S")
					} else {
						fmt.Fprint(wtr, "W")
					}
				}
				fmt.Fprintln(wtr)
				return
			}
		}
	}
	fmt.Fprintln(wtr, "-1")
}


Measured memory_bytes: 5504
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  re0 x=0,f=1;rec c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline void read(rel &x){
  x=0;re0 f=1;rec c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  x=f?x:-x;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  re0 bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  rec c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=1e5;
typedef int fuko[yuzu|10];
int n=read(),k=read(),ans;
fuko x,y,c,mp;
int main(){
re0 i,j;
for (i=1;i<=n;++i){
  x[i]=read()%(k<<1),y[i]=read()%(k<<1),c[i]=fuhao()=='W';
  }
for (i=0;i<=k;++i){
  int cnt=0;
  memset(mp,0,sizeof mp);
  for (j=1;j<=n;++j){
    int now=(i<=x[j]&&x[j]<i+k)^(0<=y[j]&&y[j]<k);
    now==c[j]?++cnt,mp[y[j]]++:mp[y[j]]--;
    }
  for (j=0;j<=k;++j){
    ans=max(ans,max(cnt,n-cnt));
    j!=k?cnt-=mp[j]+mp[k+j]:0;
    }
  }
write(ans);
}

Measured memory_bytes: 1792
//ll _(){
//    ll n,m;
//    cin >> n >> m;
//    n = min(n,m/2);
//    ll ans = n;
//    m -= 2*n;
//    ans += m/4;
//    return ans;
//}
//
//
//
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define all(v) (v).begin(), (v).end()
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
ll _(){
    ll n,m;
    cin >> n >> m;
    n = min(n,m/2);
    ll ans = n;
    m -= 2*n;
    ans += m/4;
    return ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        cout << _() << '\n';
}


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

int main() {
  int n,d; cin >> n >> d;
  //1人が見れる最大本数：2d+1
  //(x-1)(2d+1) < n <= x(2d+1)を満たすxが答え
  int ans;
  for (int i=1; i<100; i++) {
    if ((i-1) * (2*d+1) < n && n <= i * (2*d+1)) {
      ans = i;
      cout << ans << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, vector<ll>> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll a, b;
    cin >> a >> b;
    a -= b;
    vector<ll> h(n);
    rep(i,n) cin >> h[i];
    ll ok = 1e9 + 1, ng = 0;
    while(ok - ng > 1){
        ll mid = (ok + ng) / 2;
        ll cost = 0;
        rep(i,n){
            ll c = (h[i] - b*mid + a - 1) / a;
            chmax(c, 0LL);
            cost += c;
        }
        if(cost <= mid) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
    return 0;
}


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

using namespace std;

#ifndef ONLINE_JUDGE
#define pr_debug(...) do { printf("DEBUG: line %d: %s: ", __LINE__, __PRETTY_FUNCTION__); printf(__VA_ARGS__); } while(0)
#define pr_vars(...) do { pr_debug(" "); pr_var(split(#__VA_ARGS__, ',').begin(), __VA_ARGS__); } while(0)
#else
__attribute__ ((constructor)) static void fast_cin() { ios_base::sync_with_stdio(false); cin.tie(0); }
#define pr_debug(...) do { } while(0)
#define pr_vars(...) do { } while(0)
#endif /* ONLINE_JUDGE */

using ll = int64_t;
using ull = uint64_t;
#define X first
#define Y second
#define pb push_back

template<typename T> ostream &operator<< (ostream &fout, const vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fout << vec[i] << ' '; return fout; }

template<typename T> istream &operator>> (istream &fin, vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fin >> vec[i]; return fin; }

vector<string> split(const string &s, char c) { vector<string> v; ull st = 0, fn = 0, lvl = 0;
                                                for ( ; fn < s.size(); fn++ ) { if (s[fn] == c && lvl == 0) { v.push_back(s.substr(st, fn - st)); st = fn + 1; }
                                                    if (s[fn] == '(') { lvl++; } if (s[fn] == ')') { lvl--; } } v.push_back(s.substr(st, fn - st)); return v; }

void pr_var(vector<string>::iterator it) { (void) it; cout << endl; }
template<typename T, typename... Args> void pr_var(vector<string>::iterator it, T a, Args... args)
{ cout << *it << "=" << a << "  "; pr_var(++it, args...); }

ll div_ceil(ll n, ll d) { ll res = n / d; if (res >= 0) res += n % d ? 1 : 0; return res; }
ll gcd(ll a, ll b) { a = llabs(a); b = llabs(b); while (a && b) a > b ? a %= b : b %= a; return a + b; }
ll lcm(ll a, ll b) { ll c = gcd(a, b); return c == 0 ? 0 : llabs(a / c * b); }

#define setp(a) fixed << setprecision(a)
const double PI = acos(-1.0);
constexpr double EPS = 1e-9;
constexpr double INF = 2e18;
constexpr ll MOD = 1e9 + 7;

using mp = pair<ll, ll>;
using mt = tuple<ll, ll, ll>;    // unpack: tie(ll, ll, ll) = mt;

constexpr ll MAX = 1e5 + 5;

int main()
{
    ll res = 0;
    ll n; cin >> n;
    vector<string> vn(n); cin >> vn;
    ll m; cin >> m;
    vector<string> vm(m); cin >> vm;

    for (ll i = 0; i < n; i++) {
        string s = vn[i];
        ll r = 0;
        for (ll j = 0; j < n; j++)
            if (s == vn[j]) r++;
        for (ll j = 0; j < m; j++)
            if (s == vm[j]) r--;
        res = max(res, r);
    }

    cout << res << endl;
    return 0;
}


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

using namespace std;

int main(){
  int N, Q;
  long long K;
  cin >> N >> K >> Q;
  long long A[N];
  for (int i = 0; i < N; i++){
    A[i] = 0;
  }

  for (int i = 0; i < Q; i++){
    int q;
    cin >> q;
    A[q-1]++;
  }


  for (int i = 0; i < N; i++){
    A[i] = K - ((long long)Q - A[i]);
  }
  
  for (int i = 0; i < N; i++){
    if (A[i] > 0){
      printf("Yes\n");
    }else{
      printf("No\n");
    }
  }
  

}


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

int main()
{
	int a,b,c,x;
	while(cin >> a >> b >> c)
	{
		x=0;
		for(int i=1; i<=10; i++)
		{
			if(i==a || i==b || i==c) continue;
			if(a+b+i<=20) x++;
		}
		cout << (x>3?"YES":"NO") << endl; 
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int K; scanf("%d", &K);
  priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> Q;
  vector<bool> vis(K+1);
  Q.emplace(0, 1);
  while(!Q.empty())
  {
    int dist, node; tie(dist, node) = Q.top(); Q.pop();
    if(vis[node]) continue; vis[node] = true;
    if(node == 0)
    {
        printf("%d\n", dist+1);
        return 0;
    }
    Q.emplace(dist, node*10%K);
    Q.emplace(dist+1, (node+1)%K);
  }
}

Measured memory_bytes: 1404
n, m, k = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
aa = [0]
bb = [0]
 
for s in range(n):
    aa.append(aa[s] + a[s])
for s in range(m):
    bb.append(bb[s] + b[s])      
ans = 0
j = m
 
for i in range(n+1):
    if aa[i] > k:
        break
    while bb[j] > k - aa[i]:
        j -= 1
    ans = max(ans, i+j)
        
print(ans)

Measured memory_bytes: 47360
#pragma region Include
#include <bits/stdc++.h>
// #include <algorithm>
// #include <bitset>
// #include <climits>
// #include <cmath>
// #include <iostream>
// #include <iterator>
// #include <map>
// #include <queue>
// #include <sstream>
// #include <stack>
// #include <string>
// #include <unordered_map>
// #include <unordered_set>
// #include <vector>
#pragma endregion

using namespace std;

#pragma region Macros
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define all(c) (c).begin(), (c).end()
#define newl "\n"
#define out(x) cout << (x) << newl
#define dump(x) \
  cout << "Line " << __LINE__ << " : " << #x << " = " << (x) << newl
template <class T>
using VV = vector<vector<T>>;
#define Uni(v) (v).erase(unique((v).begin(), (v).end()), (v).end());

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  os << "[";
  rep(i, vec.size()) os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  os << "]";
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, vector<vector<T>>& mat) {
  os << "[";
  rep(i, mat.size()) os << mat[i] << (i + 1 == mat.size() ? "" : ",\n ");
  os << "]";
  return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}

template <typename V, typename H>
void resize(vector<V>& vec, const H head) {
  vec.resize(head);
}

template <typename V, typename H, typename... T>
void resize(vector<V>& vec, const H& head, const T... tail) {
  vec.resize(head);
  for (auto& v : vec) resize(v, tail...);
}
constexpr double EPS = 1e-10;
const int INF = 0x3f3f3f3f;

string tostring(int i, int digit) {
  auto cur = cout.flags();
  stringstream ss;
  ss << setw(4) << setfill('0') << i;
  string ret = ss.str();
  cout.flags(cur);
  return ret;
}

template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
bool chmin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

#pragma endregion

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S;
  cin >> S;
  int len = S.length();
  int ans = 0;
  rep(i, len / 2) {
    if (S[i] != S[len - 1 - i]) ++ans;
  }

  out(ans);

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <stack>
#include <cctype>

using namespace std;

/* typedef */

typedef long long ll;

/* constant */

const int INF = 1 << 30;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */

/* function */

/* main */
int main() {

    string S, T; cin >> S;

    int cnt = 0;
    while (cin >> T && T != "END_OF_TEXT") {

        for (int i = 0; i < T.size(); i++) 
            T[i] = tolower(T[i]);

        if (T == S) cnt++;
    }
    cout << cnt << '\n';

}



Measured memory_bytes: 3228
import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class Main {
	
	public static void printlnYN(boolean b){
		if(b) System.out.println("Yes");
		else System.out.println("No");
	}

	public static void main(String[] args) throws IOException {
		
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
    	int h = sc.nextInt();
    	int w = sc.nextInt();
    	String[][] c = new String[h][w];
    	for(int i = 0; i < h; i++){
    		String s = sc.next();
    		
    		for(int j = 0; j < w; j++){
    			c[i][j] = String.valueOf(s.charAt(j));
    		}
    		
    	}
    	
    	boolean flag = true;
    	
    	for(int i = 0; i < h; i++){
    		for(int j = 0; j < w; j++){
    			if(c[i][j].equals("#")){
    				boolean f = false;
    				if(i != 0 && c[i-1][j].equals("#")) f = true;
    				if(i != h-1 && c[i+1][j].equals("#")) f = true;
    				if(j != 0 && c[i][j-1].equals("#")) f = true;
    				if(j != w-1 && c[i][j+1].equals("#")) f = true;
    				
    				if(!f){
    					flag = false;
    					break;
    				}
    			}
    			if(!flag) break;
    		}
    	}
    	
    	printlnYN(flag);
	}

}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

lli n, k;
string s;

int main(void){
    cin >> n >> k >> s;
    vector<lli> p;
    rep(i, n){
        if(i == 0) p.push_back(i);
        else{
            if(s[i] != s[i-1]) p.push_back(i);
        }
    }
    p.push_back(n);
    lli m = p.size();
    lli ans = 0;
    rep(i, m-1){
        if(s[p[i]] == '0'){
            ans=max(ans, p[min(i+2*k, m-1)]-p[i]);
        }else{
            ans=max(ans, p[min(i+2*k+1, m-1)]-p[i]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4476
#[int(i) for i in input().split()]
n = int(input())
s = input()
ls_r = []
ls_g = []
ls_b = []
len_r = 0
len_g = 0
len_b = 0

if n <=3:
    print(0)
else:
    ans = 0
    for i in range(n):
        if s[i] == "R":
            ls_r.append(i)
            len_r += 1
        elif s[i] == "G":
            ls_g.append(i)
            len_g += 1
        else:
            ls_b.append(i)
            len_b += 1
    for b in ls_b:
        for g in ls_g:
            tmp = 0
            if b < g:
                if 2 * b - g >= 0:
                    if s[2*b-g] == "R":
                        tmp -= 1
                if 2 * g - b <= n-1:
                    if s[2*g-b] == "R":
                        tmp -= 1
                if (g - b) % 2 == 0:
                    if s[(g+b)//2] == "R":
                        tmp -= 1
                ans += tmp+len_r
            else:
                if 2 * g - b >= 0:
                    if s[2*g-b] == "R":
                        tmp -= 1
                if 2 * b - g <= n-1:
                    if s[2*b-g] == "R":
                        tmp -= 1
                if (b - g) % 2 == 0:
                    if s[(g+b)//2] == "R":
                        tmp -= 1
                ans += tmp+len_r
    print(ans)


Measured memory_bytes: 9280
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize,
    }

    let mut m = 0;
    for i in 1.. {
        if i * (i+1) > 2*n {
            println!("No");
            return;
        }
        if i * (i+1) == 2*n {
            m = i;
            break;
        }
    }

    let mut ans = vec![vec![0; m]; m+1];
    let mut num = 1;
    for i in 0..m {
        let r = m - i;
        for j in 0..r {
            ans[i][i+j] = num + j;
            ans[i+1+j][i] = num + j;
        }
        num += r
    }

    println!("Yes");
    println!("{}", ans.len());
    for row in ans {
        print!("{} ", m);
        for v in row {
            print!("{} ", v);
        }
        println!();
    }

}


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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> in(n), out(n), s(n);
    for(int i = 0; i < n; i++){
        cin >> in[i] >> out[i];
    }
    s[0] = m + (in[0] - out[0]);
    for(int i = 1; i < n; i++){
        s[i] = s[i - 1] + (in[i] - out[i]);
        if(s[i] < 0){
            cout << 0 << endl;
            return 0;
        }
    }


    sort(s.begin(), s.end());

    cout << s[n - 1] << endl;

    return 0;
}


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

int main()
{
    int X; cin >> X;
    int lim = 150;
    for (int a = -1*lim; a < lim; a++) {
        for (int b = -1*lim; b < lim; b++) {
            if (pow(a, 5) - pow(b, 5) == X) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
}

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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )

const int INF = 1e9;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;


int main() {

    string s;
    cin >> s;
    char op1, op2, op3;

    for ( op1 = '+'; ; op1 = '-' ) {
        for ( op2 = '+'; ; op2 = '-' ) {
            for ( op3 = '+'; ; op3 = '-' ) {
                int soma = 0;
                if ( op1 == '+' ) soma += s[0] - '0' + s[1] - '0';
                else soma += (s[0] - '0') - (s[1] - '0');

                if ( op2 == '+' ) soma += s[2] - '0';
                else soma -= (s[2] - '0');

                if ( op3 == '+' ) soma += s[3] - '0';
                else soma -= (s[3] - '0');

                if ( soma == 7 ) {
                    cout << s[0] << op1 << s[1] << op2 << s[2] << op3 << s[3] << "=7\n";
                    return 0;
                }

                if ( op3 == '-' ) break;
            }
            if ( op2 == '-' ) break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++) cin >> a.at(i);
    vector<int> ans(100011);
    for(int i = 0; i < N; i++){
        ans.at(a.at(i))++;
    }
    vector<int> answer(100010);
    for(int i = 0; i < 100010; i++){
        if(i >= 1){
            answer.at(i) = ans.at(i-1) + ans.at(i) + ans.at(i+1);
        }
        else{
            answer.at(i) = ans.at(i) + ans.at(i+1);
        }
    }
    sort(answer.begin(),answer.end());
    reverse(answer.begin(),answer.end());
    cout << answer.at(0) << endl;
}


Measured memory_bytes: 1408
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;
    cin>>n;
    vector<vector<int>> a(n,vector<int>(n-1,0));
    rep(i,n)rep(j,n-1) {cin>>a[i][j];a[i][j]--;}
    vector<int> now(n,0);
    vector<int> bat(n,false);
    int ans=-1;
    int cnt=1;
    while(cnt){
        cnt=0;
        rep(i,n){
            if(now[i]==n-1) continue;
            int op=a[i][now[i]];
            if(op<i) continue;
            if(bat[op] || bat[i]) continue;
            if(a[ op ][ now[op] ] != i) continue;
            cnt ++;
            now[i] ++;
            now[op] ++;
            bat[i] =true;
            bat[op]=true;
        }
        ans ++;
        rep(i,n) bat[i]=false;
    }
    rep(i,n){
        if(now[i]<n-1){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
}/*
./problem.exe
*/


Measured memory_bytes: 7092
n=int(input())
l=list(map(int,input().split()))

from itertools import combinations
count = 0
for seq in combinations(range(0, n), 3):
  if l[seq[0]] + l[seq[1]] <= l[seq[2]]:
    continue
  if l[seq[0]] + l[seq[2]] <= l[seq[1]]:
    continue
  if l[seq[2]] + l[seq[1]] <= l[seq[0]]:
    continue
  if l[seq[0]] == l[seq[1]]:
    continue
  if l[seq[2]] == l[seq[1]]:
    continue
  if l[seq[2]] == l[seq[0]]:
    continue
  
  count += 1
print(count)


Measured memory_bytes: 9212
a=[[0,0,0]]*3
for i in range(3):
    a[i]=list(map(int,input().split()))
if a[0][0]+a[1][1]==a[0][1]+a[1][0] and a[1][1]+a[2][2]==a[1][2]+a[2][1] and a[0][1]+a[1][2]==a[1][1]+a[0][2] and a[1][0]+a[2][1]==a[2][0]+a[1][1]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
# https://atcoder.jp/contests/abc054/tasks/abc054_c
# なんか水パフォだけど全探索するだけ

import sys
read = sys.stdin.readline


from itertools import permutations


def read_ints():
    return list(map(int, read().split()))


def main():
    N, M = read_ints()

    from collections import defaultdict
    graph = defaultdict(lambda: [])
    for m in range(M):
        a, b = read_ints()
        graph[a].append(b)
        graph[b].append(a)

    def is_ok(p):  # 順序pにしたがってグラフがつながっているか
        for now, nx in zip(p, p[1:]):
            if nx not in graph[now]:
                return 0
        return 1

    ans = 0
    for perm in permutations(range(2, N + 1)):
        perm = [1] + list(perm)
        ans += is_ok(perm)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
n, m = map(int, input().split())
cakes = []
for i in range(n):
    x, y, z = map(int, input().split())
    cakes.append([x, y, z])

ans = []
for sign in range(8):
    check = [0, 0, 0]
    for i in range(3):
        if (sign >> i) & 1:
            check[i] = 1
        else:
            check[i] = -1

    cakes.sort(reverse=True, key=lambda x: x[0]*check[0] + x[1]*check[1] + x[2]*check[2])
    value = [0, 0, 0]
    for i in range(m):
        a, b, c = cakes[i]
        value[0] += a
        value[1] += b
        value[2] += c
        
    candidate = 0
    for i in range(3):
        candidate += abs(value[i])

    ans.append(candidate)

print(max(ans))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vll p(A), q(B), r(C);
    rep(i, A)
    {
        cin >> p[i];
    }
    rep(i, B)
    {
        cin >> q[i];
    }
    rep(i, C)
    {
        cin >> r[i];
    }
    vll ans;
    sort(all(p), greater<ll>());
    sort(all(q), greater<ll>());
    sort(all(r), greater<ll>());
    rep(i, X)
    {
        ans.push_back(p[i]);
    }
    rep(i, Y)
    {
        ans.push_back(q[i]);
    }
    rep(i, C)
    {
        ans.push_back(r[i]);
    }
    sort(all(ans), greater<ll>());
    ll Ans = 0;
    rep(i, X + Y)
    {
        Ans += ans[i];
    }
    cout << Ans;
    return 0;
}

Measured memory_bytes: 8688
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long ans;
        if (k % 2 == 0) {
            long a = n / k;
            long b = n / (k / 2);
            long c = b - a;
            ans = c * c * c + a * a * a;
        } else {
            long a = n / k;
            ans = a * a * a;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 25172
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;


int main() {
    int N;
    scanf("%d", &N);
    map<int, int> difficulties;
    for (int i = 0; i < N; ++i) {
        int di;
        scanf("%d", &di);
        if (difficulties.find(di) == difficulties.end()) {
            difficulties[di] = 1;
        } else {
            difficulties[di] = difficulties[di] + 1;
        }
    }

    int M;
    scanf("%d", &M);
    bool ans = true;
    for (int i = 0; i < M; ++i) {
        int ti;
        scanf("%d", &ti);
        if(difficulties.find(ti) == difficulties.end()){
            ans = false;
            break;
        }else{
            difficulties[ti] = difficulties[ti]-1;
            if(difficulties[ti] < 0){
                ans = false;
                break;
            }
        }
    }

    if(ans){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define LIMIT 1000000007 //10^9+7
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define all(v) (v).begin(), (v).end()

namespace /* debug */{
  #define DEBUG(...) do{cout<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数
  #define ldebug(...) do{cout<<"["<<setw(3)<<__LINE__<<"] ";debug(__VA_ARGS__);}while(0) //行数
  #define lDEBUG(...) do{cout<<"["<<setw(3)<<__LINE__<<"] "<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数, 行数
  template<class T>void show(T&x){cout<<x<<" ";} //出力
  template<class T>void showendl(T&x){cout<<x<<endl;} //出力改行
  template<class P,class Q>void show(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<") ";} //pair出力
  template<class P,class Q>void showendl(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<")"<<endl;} //pair出力改行
  template<class H>void debug(H&&h){showendl(h);} //引数1つ
  template<class H,class...Ts>void debug(H&&h,Ts&&...ts){show(h);debug(forward<Ts>(ts)...);} //可変引数
  template<class T>void debug(vector<T>&vt){int i=0;for(auto x:vt)++i!=vt.size()?show(x):showendl(x);} //vector出力
  template<class T>void debug(initializer_list<T>init){int i=0;for(auto x:init)++i!=init.size()?show(x):showendl(x);} //初期化子リスト出力
}

int main(){
	char b;cin>>b;
  switch(b){
    case 'A': b='T';break;
    case 'T': b='A';break;
    case 'C': b='G';break;
    case 'G': b='C';break;
  }
  cout<<b<<endl;
}

Measured memory_bytes: 3596
import io
import sys

lines = sys.stdin.read().splitlines()[::-1]


def readline():
    return lines.pop()


N, M = map(int, readline().split())
A = []
B = []
for _ in range(M):
    a, b = map(int, readline().split())
    A.append(a - 1)
    B.append(b - 1)

uf = [-1] * N
values = []
for i in range(M - 1, -1, -1):
    a = A[i]
    b = B[i]

    cur = a
    while 0 <= uf[cur]:
        cur = uf[cur]
    num_a = -uf[cur]
    root_a = cur
    cur = a
    while 0 <= uf[cur]:
        nxt = uf[cur]
        uf[cur] = root_a
        cur = nxt

    cur = b
    while 0 <= uf[cur]:
        cur = uf[cur]
    num_b = -uf[cur]
    root_b = cur
    cur = b
    while 0 <= uf[cur]:
        nxt = uf[cur]
        uf[cur] = root_b
        cur = nxt

    if root_a != root_b:
        values.append(num_a * num_b)

        if num_a < num_b:
            uf[root_b] += uf[root_a]
            cur = uf[root_a]
            uf[root_a] = root_b
            while 0 <= cur and 0 <= uf[cur]:
                nxt = uf[cur]
                uf[cur] = root_b
                cur = nxt
        else:
            uf[root_a] += uf[root_b]
            cur = uf[root_b]
            uf[root_b] = root_a
            while 0 <= cur and 0 <= uf[cur]:
                nxt = uf[cur]
                uf[cur] = root_a
                cur = nxt
    else:
        values.append(0)

total = 0
out = io.StringIO()
for v in reversed(values):
    total += v
    print(total, file=out)
print(out.getvalue())


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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V)                                                           \
    for (auto v : (V))                                                         \
        cout << v << ' ';
const int MOD = 1000000007;
/* cout << fixed << setprecision(10) << decimal << endl; */

int main() {
    /* code */
    ll N, K;
    cin >> N >> K;
    cout << min(N % K, K - N % K) << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
enemy = list(map(int, input().split()))
hero = list(map(int, input().split()))
count = 0
for i in range(N):
    if hero[i] <= enemy[i]:
        count += hero[i]
    else:
        count += enemy[i]
        hero[i] -= enemy[i]
        if enemy[i+1] >= hero[i]:
            count += hero[i]
            enemy[i+1] -= hero[i]
        else:
            count += enemy[i+1]
            enemy[i+1] = 0
print(count)


Measured memory_bytes: 18624
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
#include<bits/stdc++.h>

#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pi 3.1415926535897932
#define eps 0.000001

//#define int ll

using namespace std;

int main()
{
    int n = 111, k;
    cin >> k;
    for(int i = 1;i <= 9;i++)
    {
        if (n * i >= k)
        {
            cout << n * i;
            return 0;
        }
    }

    return 0;
}






Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
        new Main().run();
    }
	public void run(){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			for(int i = 0;i < n;i++){
				String[] time = scan.next().split(":");
				double tH = Double.parseDouble(time[0]) * 30 + Double.parseDouble(time[1])*0.5;
				double tM = Double.parseDouble(time[1]) * 6;
				double dif = Math.abs(tH - tM);
				dif = Math.min(dif,360 - dif);
				if(dif < 30){
					System.out.println("alert");
				}else if(dif >= 90 && dif <= 180){
					System.out.println("safe");
				}else{
					System.out.println("warning");
				}
			}
		}
	}
}

Measured memory_bytes: 23420
#include <iostream>
#include<algorithm>
#include<vector>
using namespace std;
main(){
	int n,m,p,q,r,x,y;
	vector<int>::iterator v,w,z;
	for(;cin>>n>>m>>p>>q>>r;cout<<x<<endl){
	vector<int>t(1),u;

	for(t.push_back(r);m--;u.clear()){
		cin>>x>>y;
		v=upper_bound(t.begin(),t.end(),x);
		w=upper_bound(t.begin(),t.end(),y);

//		if(w-t.begin()+1&1)u.push_back(0);u.push_back(0);
		u.insert(u.end(),w-t.begin()&1?1:2,0);
		for(z=w;z<t.end();++z)
			u.push_back(*z-y);
			
			if(t.end()-v&1)u.push_back(n-y);
			for(z=v;z<w;++z)
				u.push_back(*z-x+n-y);
			
			z=t.begin();
			if(w-t.begin()&1)++z;
			if(!z[1])z+=2;
			if(*z+n-x==u.back())++z,u.pop_back();
			for(;z<v;++z)
				u.push_back(*z+n-x);
			
			t.swap(u);
		}
		t.insert(upper_bound(t.begin(),t.end(),p-1),2,p-1);
		t.insert(lower_bound(t.begin(),t.end(),q),q);
		t.push_back(n);
		z=upper_bound(t.begin(),t.end(),p-1);
		if(z-t.begin()&1)--z;
		for(x=0;*z<q;
			x+=*z++-m)
			m=*z++;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

//ifstream f("/home/mihai/Documents/c++/A/A.in");
//ofstream g("/home/mihai/Documents/c++/A/A.out");

//ifstream f("triunghi2.in");
//ofstream g("triunghi2.out");

#define int long long

int sum;

const int NMAX = 2e5 + 7;
int a[NMAX];

main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
		{
			cin >> a[i];
			a[i] -= i;
		}
	sort(a + 1, a + 1 + n);
	int b = a[n / 2 + 1];
	for(int i = 1; i <= n; i++)
		sum += abs(a[i] - b);
	cout << sum;
}

Measured memory_bytes: 1792
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,b,a) for(int i=b;i>=a;i--)
#define efo(i,v,u) for(int i=last[v],u=to[last[v]];i;i=nxt[i],u=to[i])
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define mset(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
void read(int &n)
{
	int t=0,p=1;char ch;
	for(ch=getchar();!('0'<=ch && ch<='9');ch=getchar())
		if(ch=='-') p=-1;
	for(;'0'<=ch && ch<='9';ch=getchar()) t=t*10+ch-'0';
	n=t*p;
}
const int N=4e5+5,M=7000005;
int n,nn,rtn,tot,ext,b[N][2];
struct node
{
	int x,id;
}a[N];
bool cmp(node a,node b){return a.x<b.x;}
int m,co[N],to[M],nxt[M],last[N],list[N],L[N],R[N];
void link(int u,int v)
{
	to[++m]=v,nxt[m]=last[u],last[u]=m;
}
bool dfs(int v)
{
	if(v<=tot && co[v^1]) return 0;
	if(v<=tot && co[v]) return 1;
	co[v]=1;
	list[++list[0]]=v;
	efo(i,v,u) if(!co[u])
		if(!dfs(u)) return 0;
	return 1;
}
bool check(int lim)
{
	m=0;mset(last,0);
	fo(i,1,n)
	{
		link(b[i+i-1][0],b[i+i][1]),link(b[i+i][1],b[i+i-1][0]);
		link(b[i+i-1][1],b[i+i][0]),link(b[i+i][0],b[i+i-1][1]);
	}
	fo(i,1,rtn)
		fo(j,L[i],R[i]) link(tot+i,b[a[j].id][0]);
	int l=1,r=1;
	fo(i,1,nn)
	{
		while(l<nn && a[i].x-a[l].x>=lim) ++l;
		while(r<nn && a[r+1].x-a[i].x<lim) ++r;
		int ql=min(rtn,(l-1)/rtn+1),qr=min(rtn,(r-1)/rtn+1),qi=min(rtn,(i-1)/rtn+1);
		if(ql==qr)
		{
			fo(j,l,r)
				if(j!=i) link(b[a[i].id][1],b[a[j].id][0]);
		}
		else
		{
			if(ql==qi)
				fo(j,l,i-1) link(b[a[i].id][1],b[a[j].id][0]);
			else
			{
				fo(j,l,R[ql]) link(b[a[i].id][1],b[a[j].id][0]);
				fo(j,ql+1,qi-1) link(b[a[i].id][1],tot+j);
				fo(j,L[qi],i-1) link(b[a[i].id][1],b[a[j].id][0]);
			}
			if(qi==qr)
				fo(j,i+1,r) link(b[a[i].id][1],b[a[j].id][0]);
			else
			{
				fo(j,i+1,R[qi]) link(b[a[i].id][1],b[a[j].id][0]);
				fo(j,qi+1,qr-1) link(b[a[i].id][1],tot+j);
				fo(j,L[qr],r) link(b[a[i].id][1],b[a[j].id][0]);
			}
		}
	}
	mset(co,0);
	fo(i,1,tot)
	{
		int x=i+i-1;
		if(!co[b[x][0]] && !co[b[x][1]])
		{
			list[0]=0;
			if(!dfs(b[x][0]))
			{
				fo(j,1,list[0]) co[list[j]]=0;
				list[0]=0;
				if(!dfs(b[x][1])) return 0;
			}
		}
	}
	return 1;
}
namespace Prog2{
	const int N = 10010;
	int m=0,n;
	int v[N<<1],f[N<<1];
	inline bool ok(int x){
		v[0]=-1e9;
		memset(f,0,sizeof f); f[0]=0;
		int j=1;
		for(int i=1;i<=m;++i){
		//	j=lower_bound(v,v+1+m,v[i]-x)-v;
			while(v[j]<=v[i]-x) ++j;
			if (v[j]>v[i]-x) --j;
			f[i]=max(f[i-1],f[j]+1);
		}
		return f[m]>=n;
	}
}
int main()
{
	int x,y;
	read(n);nn=n+n; Prog2::n=n;
	fo(i,1,n) read(a[i+i-1].x),read(a[i+i].x),Prog2::m+=2;
	tot=1;
	fo(i,1,nn) a[i].id=i,b[i][0]=++tot,b[i][1]=++tot;
	rtn=sqrt(nn);
	fo(i,1,rtn-1) L[i]=1+rtn*(i-1),R[i]=rtn*i;
	L[rtn]=1+rtn*(rtn-1),R[rtn]=nn;
	sort(a+1,a+nn+1,cmp);
	fo(i,1,n+n) Prog2::v[i]=a[i].x;
	int l=0,r=a[nn].x;
	while (l<r-1){
		int M=(l+r)>>1;
		if(Prog2::ok(M)) l=M;
		else r=M;
	}
	l=0;
	while(l<r-1)
	{
		int mid=(l+r)>>1;
		if(check(mid)) l=mid;
		else r=mid;
	}
	printf("%d\n",l);
	return 0;
}

Measured memory_bytes: 41344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi = 3.141592654;
int dp[1000001];
int main()
{

    //freopen("Input.txt","r",stdin);
    //ios_base :: sync_with_stdio(false);
    int n;
    cin>>n;
    int h[n];
    for(int i=1;i<=n;i++)
        cin>>h[i];
    dp[1]=0;
    dp[2]=abs(h[1]-h[2]);
    for(int i=3;i<=n;i++)
    {
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n]<<endl;



}


Measured memory_bytes: 1024
a, b, x = map(int, input().split())
rect = a**2 * b

import math

if x <= rect / 2:
    s = x / (a**2) * a
    angle = 90 - math.atan((2 * s) / (b**2)) * (180 / math.pi)
else:
    s = (a**2 * b-x)/(a**2) * a
    angle = math.atan((2 * s) / (a**2)) * (180 / math.pi)

print(angle)

Measured memory_bytes: 3060