akhauriyash/Code-Regression huggingface dataset:
#define _DEBUG 1
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

map<ll, ll> cc;
map<ll, ll> dd;

void solve(ll N, std::vector<ll> A) {
  map<ll, ll> mp;
  rep(i, N) {
    if (mp.count(A[i])) {
      mp.at(A[i])++;
    } else {
      mp[A[i]] = 1;
    }
  }

  ll cnt = 0;
  for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
    auto key = itr->first;
    auto value = itr->second;
    cnt += (value * (value - 1)) / 2;
  }

  rep(k, N) {
    auto key = A[k];
    auto v0 = mp[key];
    auto v1 = v0 - 1;
    auto c = cnt;

    c -= (v0 * (v0 - 1)) / 2;
    c += (v1 * (v1 - 1)) / 2;

    cout << c << endl;
  }
}

int main() {
  ll N;
  scanf("%lld", &N);
  std::vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); ++i)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;
// get<K>(tuple型の変数)

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

    int n; cin >> n;
    vector<int> pos(n+1, 0);
    for(int i=1; i<=n; ++i){
        int p; cin >> p;
        pos[p] = i;
    }

    ll ans = 0;
    multiset<int> se{0, 0, n+1, n+1};
    for(int i=n; i>=1; --i){
        auto itr = se.lower_bound(pos[i]);
        int r1 = *itr;
        ++itr;
        int r2 = *itr;
        --itr;
        --itr;
        int l1 = *itr;
        --itr;
        int l2 = *itr;
        ans += (ll)i*(l1-l2)*(r1-pos[i]);
        ans += (ll)i*(r2-r1)*(pos[i]-l1);
        se.insert(pos[i]);
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 5376
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

bool flag=false;

void dfs(vector<int>&cs, const vector<vector<int>>&es, int now,int c) {
	cs[now]=c;
	for (auto e : es[now]) {
		if(cs[e]==c)flag=true;
		else if(cs[e]!=-1)continue;
		else {

			dfs(cs, es, e, !c);
		}
	}
	return ;
}

int main() {

	long long int N,M;cin>>N>>M;
	vector<int>cs(N,-1);
	vector<vector<int>>es(N);
	for (int i = 0; i < M; ++i) {
		int a,b;cin>>a>>b;
		a--;b--;
		es[a].push_back(b);
		es[b].push_back(a);
	}
	dfs(cs,es,0,0);
	long long int a=count(cs.begin(),cs.end(),1);
	if (flag) {
		cout<<N*(N-1)/2-M<<endl;
	}
	else {

		cout << a*(N - a) - M << endl;
	}
	return 0;
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;

int main(){
    ll N, K; cin >> N >> K;
    vector<ll> V(N); for(int i = 0; i < N; i++) cin >> V[i];
    sort(V.begin(), V.end());
    ll ans = 0;
    for(int i = 0; i < K; i++) ans += V[i];
    cout << ans << endl;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
template<class T> 
inline void read(T& x)
{
	char c = getchar(); T p = 1, n = 0;
	while(c < '0' || c > '9'){if(c == '-') p = -1; c = getchar();}
	while(c >= '0' && c <= '9'){n = n * 10 + c - '0'; c = getchar();}
	x = p * n;
}
template<class T, class U>
inline void read(T& x, U& y){read(x), read(y);}
template<class T, class U, class V>
inline void read(T& x, U& y, V& z){read(x), read(y), read(z);}
const double eps = 1e-10;
const int maxn = 1e3;
struct Point
{
	double x, y;
	Point(int a, int b){x = a, y = b;}
	Point(double a = .0, double b = .0){x = a, y = b;}
	Point operator+(const Point& r){return Point(x + r.x, y + r.y);}
	Point operator-(const Point& r){return Point(x - r.x, y - r.y);}
	Point operator*(double r){return Point(r * x, r * y);}
	double operator*(const Point& r){return x * r.y - y * r.x;}
} g[maxn];
int n; 
typedef Point Vector;
inline double dot(Vector l, Vector r){return l.x * r.x + l.y * r.y;}
int contains(Point p)
{
	bool x = false;
	for(int i = 0; i < n; ++i)
	{
		Vector a = g[i] - p, b = g[(i + 1) % n] - p;
		double cross = a * b;
		if(abs(cross) < eps && dot(a, b) < eps) return 1;
		if(a.y > b.y) swap(a, b), cross = a * b;
		if(a.y < eps && eps < b.y && cross > eps) x = !x;
	}
	return x ? 2 : 0;
}
int main()
{
	read(n);
	for(int i = 0, x, y; i < n; ++i) read(x, y), g[i] = Point(x, y);
	int q; read(q);
	while(q--)
	{
		int x, y; read(x, y);
		printf("%d\n", contains(Point(x, y)));
	}
	return 0;
}

Measured memory_bytes: 2716
n, k = list(map(int, input().split()))


def check(p):
    i = 0
    for j in range(k):
        s = 0
        while s + T[i] <= p:
            s += T[i]
            i += 1
            if i == n:
                return n
    return i


def solve():
    left = 0
    right = 100000 * 10000
    while right - left > 1:
        mid = (left + right) // 2
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid
    return right


T = []
for _ in range(n):
    T.append(int(input()))
ans = solve()
print(ans)



Measured memory_bytes: 9556
#include <iostream>
#include <cstdio>
using namespace std;
int a[100005];
int main() {
    int k;
    scanf("%d",&k);
    for (int i=1; i<=k; i++) {
        scanf("%d",&a[i]);
    }
    long long mmax=2,mmin=2;
    for(int i=k;i>=1&&mmax>=mmin;i--)
    {
        if(mmin%a[i]!=0)
            mmin=mmin/a[i]*a[i]+a[i];
        mmax=(mmax/a[i]+1)*a[i]-1;
    }
    if(mmax>=mmin)
        printf("%lld %lld\n",mmin,mmax);
    else
        printf("-1\n");
    // insert code here...
    //std::cout << "Hello, World!\n";
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<cstdio>
#include<math.h>
#include<algorithm>
using namespace std;

int main() {
  int A1, A2, A3;
  scanf("%d%d%d", &A1, &A2, &A3);
  int res12 = abs(A1-A2);
  int res23 = abs(A2-A3);
  int res13 = abs(A1-A3);
  if (res12 <= res23 && res23 <= res13) {
    printf("%d\n", res12+res23);
  } else if (res12 <= res13 && res13 <= res23) {
    printf("%d\n", res12+res13);
  } else if (res23 <= res12 && res12 <= res13) {
    printf("%d\n", res23+res12);
  } else if (res23 <= res13 && res13 <= res12) {
    printf("%d\n", res23+res13);
  } else if (res13 <= res23 && res23 <= res12) {
    printf("%d\n", res13+res23);
  } else if (res13 <= res12 && res12 <= res23) {
    printf("%d\n", res13+res12);
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = a; i <= b; ++i)
#define PER(i, a, b) for (int i = a; i >= b; --i)
#define RVC(i, S) for (int i = 0; i < S.size(); ++i)
#define mp make_pair
#define pb push_back
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
using namespace std;
 
typedef unsigned long long LL;
typedef pair<int, int> pii;
typedef vector<int> VI;

int n, cnt[26];
char str[200005];

int main(){
	scanf("%s", str + 1);
	n = strlen(str + 1);
	LL ans = 1;
	REP(i, 1, n){
		REP(j, 0, 25) if (j != str[i] - 'a') ans += cnt[j];
		++cnt[str[i] - 'a'];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
object Main extends App {
  def judge(n: Int) = for {
    a <- 0 to 9
    b <- 0 to 9
    c <- 0 to 9
    d <- 0 to 9
  } yield if (a + b + c + d == n) true else false

  Stream.continually(readLine).takeWhile(_ != null).map(_.toInt).map(n => judge(n).count(b => b)).foreach(println)
}


Measured memory_bytes: 80064
#include <string>
#include <iostream>
#include <vector>
#include <iomanip>
#define range(i, r) for(int i=0;i<r;i++)
using namespace std;
int main(int argc, char const *argv[]) {
  double T, X;
  std::cin >> T >> X;
  std::cout << fixed << '\n';
  std::cout << setprecision(10) <<(double)T/X << '\n';
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> h(n);
    ll max_hp = 0;
    for(int i = 0; i < n; i++){
        cin >> h[i];
        max_hp = max(max_hp, h[i]);
    }
    stack<ll> st;
    ll t_min = 1, t_max = 1000000000;
    ll t;
    while(t_min != t_max){
        t = (t_min + t_max)/2;
        ll additional = 0;
        for(int i = 0; i < n; i++){
            ll res = max(0LL,h[i]-b*t);
            additional += res/(a-b);
            if(res%(a-b)>0){additional++;}
        }
        if(additional>t){
            if(t_min==t){t_min++;}
            else{t_min = t;}
        }else if(additional<t){
            st.push(t);
            if(t_max==t){t_max--;}
            else{t_max = t;}
        }else{
            st.push(t);
            break;
        }
    }

    cout << st.top() << endl;
    return 0;
}


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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

#define PQ(T) priority_queue<T>
#define RPQ(T) priority_queue<T,vector<T>,greater<T>>

template<class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template<class T> inline void amax(T & a, T const & b) { a = max(a, b); }

inline ll square(ll x) { return x * x; }
inline ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
template <typename T>
inline T mod(T a, T b) { return ((a % b) + b) % b; }


int solve(int R,int G,int B,int N){
    int ans=0;
    for (int r=0; r<=N; r+=R){
        for (int g=0; g<=N; g+=G) {
            int b=N-r-g;
            if (IN(b,0,N) && b%B == 0) {
                ans++;
            }
        }
    }
    return ans;
}

int main() {
    int R,G,B,N; cin>>R>>G>>B>>N;
    cout << solve(R,G,B,N) << endl;
    return 0;
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))
ZIP = lambda: zip(*(MAP() for _ in range(n)))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N, K = MAP()

    r = N%K
    if r == 0:
        print(0)
    else:
        if 2*r > K:
            print(abs(r - K))
        else:
            print(r)


if __name__ == '__main__':
    main()


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

int main(){
  int N;
  cin >> N;
  vector<char> v(N);
  for (int i=0;i<N;i++){
    cin >> v[i];
  }
  char x;
  int count=0;
  for (int i=0;i<N;i++){
    if (v[i]==x)
      continue;
    x=v[i];
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 384
a_list = list(input())[::-1]
b_list = list(input())[::-1]
c_list = list(input())[::-1]

pop_str = a_list.pop()
winner = ''

while True:
  if pop_str == 'a':
    if len(a_list) == 0:
      winner = 'A'
      break
    else:
      pop_str = a_list.pop()
      
  elif pop_str == 'b':
    if len(b_list) == 0:
      winner = 'B'
      break
    else:
      pop_str = b_list.pop()
      
  elif pop_str == 'c':
    if len(c_list) == 0:
      winner = 'C'
      break
    else:
      pop_str = c_list.pop()

print(winner)

Measured memory_bytes: 3064
import math
a,b,h,m = map(int,input().split())
N = 360*m/60
M = 30*h + 30*m/60
siita = abs(N - M)
if siita >= 180:
  siita = 360 - siita
ans = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians((siita))))
print(ans)

Measured memory_bytes: 9512
exec("def nWord(): nWord.cache = raw_input() if not hasattr(nWord, 'cache') or nWord.cache=='' else nWord.cache ; pos = nWord.cache.find(nWord.sep) ; ret, nWord.cache = (nWord.cache, '') if pos==-1 else (nWord.cache[:pos], nWord.cache[pos+1:].lstrip(nWord.sep)) ; return ret") ; exec("nWord.sep = ' '") ; exec("def ___nLine2(): ret, nWord.cache = (raw_input(), nWord.cache if hasattr(nWord, 'cache') else '') if not hasattr(nWord, 'cache') or nWord.cache=='' else (nWord.cache, '') ; return ret") ; exec('def nInt(): return int(nWord())') ; exec('def nFloat(): return float(nWord())') ; exec("def ___nAuto2():\n ret = nWord()\n try: return int(ret)\n except: pass\n try: return float(ret)\n except: return ret") ; exec("def nAuto(n=None): return ___nAuto2() if n is None else [___nAuto2() for i in range(n)]") ; exec("def nLine(n=None): return ___nLine2() if n is None else [___nLine2() for i in range(n)]")

import itertools

P = nAuto(nAuto())

P2 = [-1]*len(P)
for i, p in enumerate(P):
    P2[p-1] = i

n = 0
mn = 0
bp = len(P)+100
for p in P2:
    assert 0<=p
    if p<bp:
        n = 0
    bp = p
    n += 1
    mn = max(mn, n)

print(len(P) - mn)


Measured memory_bytes: 36892
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

a, b, c, d = nl()

if abs(a - c) <= d or (abs(a - b) <= d and abs(b - c) <= d):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int N, M;
int main() {
    cin >> N;
    vector<int> T(N, 0);
    for(int i = 0; i < N; ++i) {
        cin >> T.at(i);
    }
    cin >> M;
    for(int i = 0; i < M; ++i) {
        int p = 0, x = 0;
        cin >> p >> x;
        p--;
        int sum = 0;
        for(int j = 0; j < N; ++j) {
            if(j == p) {
                sum += x;
            }else {
                sum += T.at(j);
            }
        }
        cout << sum << endl;
    }
}

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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> A(M);
  for(int i=0;i<M;i++) cin >> A.at(i);
  int total = 0;
  for(int i=0;i<M;i++) total += A.at(i);

  int rest = N-total;
  if(rest < 0) cout << -1 << endl;
  else
    cout << rest << endl;
  return 0;
}


Measured memory_bytes: 3644
N;b;c;z;char s;x;y;main(a){for(;scanf("%d",&N),N;printf("%d\n",z))for(a=z=1,b=2,c=3;N--;z+=a){scanf("%s",&s);x=a;y=b;s==78?a=b,b=7-x:s==69?a=7-c,c=x:s==87?a=c,c=7-x:s==83?a=7-b,b=x:s==82?b=c,c=7-y:s==76?b=7-c,c=y:0;}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll N, T, ans = 0;
    cin >> N >> T;
    vector<ll> t(N);
    rep(i, N) cin >> t[i];

    ans = T;
    repd(i, 1, N) {
        if (t[i - 1] + T < t[i]) ans += T;
        else ans += t[i] - t[i - 1];
    }

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

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

vector<ll> A;
ll N;

void crt(ll x) {
  if(x > N) {
    return;
  } else {
    A.push_back(x);

    crt(x * 10 + 3);
    crt(x * 10 + 5);
    crt(x * 10 + 7);
  }
}

bool good(string s) {
  if(s.find("3") == string::npos || s.find("5") == string::npos ||s.find("7") == string::npos) {
    return false;
  } else {
    return true;
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  ll ans = 0;
  crt(0);
  for(auto x : A) {
    if(good(to_string(x))) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<queue>

using namespace std;
static const int N=100;
static const int INFTY=(1<<21);
int n,M[N][N];
int d[N];

void bfs(int s){
  queue<int> q;
  q.push(s);
  for(int i=0;i<n;i++){
    d[i]=INFTY;
  }
  d[s]=0;
  int u;
  while(!q.empty()){
    u=q.front(); q.pop();
    for(int v=0;v<n;v++){
      if(M[u][v]==0)continue;
      if(d[v]!=INFTY)continue;
      d[v]=d[u]+1;
      q.push(v);
    }
  }
  for(int i=0;i<n;i++){
    cout<<i+1<<" "<<((d[i]==INFTY)?(-1):d[i])<<endl;
  }
}

int main(){
  int u,k,v;
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++)
      M[i][j]=0;
  }
  for(int i=0;i<n;i++){
    cin>>u>>k;
    u--;
    for(int j=0;j<k;j++){
      cin>>v;
      v--;
      M[u][v]=1;
    }
  }
  bfs(0);
  return 0;
}

Measured memory_bytes: 3108
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String line = reader.readLine();
		String[] str = line.split(" ");
		int W = Integer.parseInt(str[0]);
		int H = Integer.parseInt(str[1]);
		int x = Integer.parseInt(str[2]);
		int y = Integer.parseInt(str[3]);
		boolean flag = (W / 2.0 == x && H / 2.0 == y);
		double ans = W / 2.0 * H;

		System.out.print(ans + " ");
		if (flag) {
			System.out.println(1);
		}
		else {
			System.out.println(0);
		}

//		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
//		String line = reader.readLine();
//		String[] str = line.split(" ");
//		int N = Integer.parseInt(str[0]);
//		long K = Long.parseLong(str[1]);
//		int[] a = new int[N];
//		String[] a_str = reader.readLine().split(" ");
//		for (int i = 0; i < N; i++) {
//			a[i] = Integer.parseInt(a_str[i]);
//		}
//		long ans = 0;
//		
//		for (int i = 0; i < N; i++) {
//			long sum = 0;
//			for (int k = i; k < N; k++) {
//				sum += a[i];
//				if (sum >= K) {
//					ans += N - k;
//					break;
//				}
//			}
//			System.out.println(ans);
//		}
//		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
<?php
$push_array = explode(" ",trim(fgets(STDIN)));
if ($push_array[0] <= $push_array[2] && $push_array[2] <= $push_array[1] && $push_array[0] <= $push_array[3] && $push_array[3] <= $push_array[1]) {
    echo $push_array[3] - $push_array[2];
} else if ($push_array[2] <= $push_array[0] && $push_array[0] <= $push_array[3] && $push_array[2] <= $push_array[1] && $push_array[1] <= $push_array[3]) {
    echo $push_array[1] - $push_array[0];
}else if ($push_array[0] <= $push_array[2] && $push_array[2] <= $push_array[1]) {
    echo $push_array[1] - $push_array[2];
} else if ($push_array[0] <= $push_array[3] && $push_array[3] <= $push_array[1]) {
    echo $push_array[3] - $push_array[0];
} else {
    echo "0";
}

Measured memory_bytes: 4604
/********************************
*** ******** ********** *********
*** * ****** ********* * ********
*** ** ***** ******** *** *******
*** *** **** ******* ***** ******
*** **** *** ****** ******* *****
*** ***** ** ***** +++++++++ ****
*** ****** * **** *********** ***
*** *******  *** ************* **
*** ******** ** *************** *
**********_**********************
* |   /  / \  \     /    /\     *
* |  /  |   |  \   /    /  \    *
* | /   |   |   \ /    /    \   *
* |+\   |   |    |    /______\  *
* |  \  |   |    |   |        | *
* |   \  \_/     |   |        | *
********************************/
#include<bits/stdc++.h>
#define lli long long int
#define ld long double
#define MOD 1000000007
#define KING 1000000002
#define queen 1000002
#define fi first
#define se second
#define se second
#define lsb(i) (i & -i)
#define Pi 3.141592653589793238
#define nl cout<<'\n'
#define TEST cout<<"TEST",nl
#define all(a) a.begin(), a.end()
#define remax(a, b) (a = ((a<b) ? b : a))
#define remin(a, b) (a = ((a<b) ? a : b))
#define pr pair<lli,lli>
#define pb push_back
#define eb emplace_back
#define precise(a) cout<<fixed<<setprecision(a)
#define mp make_pair
#define vi vector<lli>
#define vpi vector<pr> 
#define P pair<lli,pr>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define NA(i,s,n) for(lli i=s;i<n;i++)
using namespace std;

lli power(lli x,lli y,lli p = MOD) { 
	lli res = 1;	 
	x = x % p; 
	while (y > 0) 
	{ 
		if (y & 1) 
			res = (res*x) % p; 
		y = y>>1; 
		x = (x*x) % p; 
	} 
	return res; 
} 

const lli N = 2e5 + 4;
lli n, a[N], sm = 0, x = 0, k, b, c, q;

void solve(){
	cin >> n;
	NA(i,0,n) cin >> a[i], x ^= a[i];
	NA(i,0,n) a[i] = a[i] ^ x, cout << a[i] << ' ';
    return;
}
        
int main(){
    fastIO;
    lli t = 1;
    // cin>>t;
    NA(i,0,t){
        solve();
    }
    return 0;
}


Measured memory_bytes: 5140
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,sum=0;
    cin>>n;
    vector<long long>a(n+1),b(n);
    for(int i=0; i<=n; i++)
        cin>>a[i];
    for(int i=0; i<n; i++)
        cin>>b[i];
    for(int i=0; i<n; i++)
    {
        if(a[i]>=b[i])
            sum+=b[i];
        else if((a[i]+a[i+1])>=b[i])
        {
           sum+=b[i];
           a[i+1]-=b[i]-a[i];
        }
        else
        {
            sum+=(a[i]+a[i+1]);
            a[i+1]=0;
        }
    }
    cout<<sum<<endl;
}



Measured memory_bytes: 4816
from collections import defaultdict


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

dish = []

for _ in range(n):
    time, point = map(int, input().split())
    dish.append([time, point])

dish.sort()
DP = [[0]*t for i in range(n+1)]
ans = defaultdict(int)

for i in range(1, n+1):
    time, point = dish[i-1]

    for j in range(t):
        DP[i][j] = max(DP[i-1][j], DP[i][j])
        if j + time >= t:
            ans[i] = max(DP[i-1][j]+point, ans[i])
            continue
        DP[i][j+time] = max((DP[i-1][j] + point), DP[i-1][j+time])

res = max(ans.values())
print(res)

Measured memory_bytes: 117592
public class Main {
	public static void main(String[] args) {
		for (int i = 0; i < 9; i++) {
			for (int j = 0; j < 9; j++) {
				System.out.println((i + 1) + "x" + (j + 1) + "="
						+ ((i + 1) * (j + 1)));
			}
		}
	}
}

Measured memory_bytes: 9372
N=int(input())
from collections import defaultdict
dic=defaultdict(int)
import math
mod=1000000007
for _ in range(N):
    A,B=map(int,input().split())
    if A<0:
        A,B=-A,-B
    if A==0:
        if B==0:
            dic[(0,0)]+=1
        else:
            dic[(0,-1)]+=1
    elif B==0:
        dic[(1,0)]+=1
    else:
        gcd=math.gcd(A,B)
        A,B=A//gcd,B//gcd
        dic[(A,B)]+=1

ans=1
N-=dic[(0,0)]
for k,v in dic.items():
    if k==(0,0):
        continue
    a,b=k
    if not (b,-a) in dic:
        continue
    v_dash=dic[(b,-a)]
    ans*=((pow(2,v,mod)-1)+(pow(2,v_dash,mod)-1)+1)
    ans%=mod
    N-=v+v_dash
ans*=pow(2,N,mod)
ans+=dic[(0,0)]-1
ans%=mod
print(ans)


Measured memory_bytes: 46756
#include <bits/stdc++.h>
const int N = 1e3 + 5;
int n, a;
long long x[N], y[N], bin[33];
inline void shu(long long x, long long y) {
	for (int i = a - 1; i >= 0; i--) {
		if (std::labs(x) > std::labs(y)) {
			putchar(x < 0 ? 'L' : 'R');
			x < 0 ? x += bin[i] : x -= bin[i];
		} else {
			putchar(y < 0 ? 'D' : 'U');
			y < 0 ? y += bin[i] : y -= bin[i];
		}
	}
	puts("");
}
int main() {
	scanf("%d", &n);
	bool tf = false, tf1 = false;
	for (int i = 1; i <= n; i++) {
		scanf("%lld %lld", &x[i], &y[i]);
		((x[i] + y[i]) & 1 ? tf : tf1) = true;
	}
	if (tf && tf1) return puts("-1"), 0;
	if (tf) {
		printf("%d\n", a = 33);
		for (int i = a - 1; i >= 0; i--) 
			printf("%lld%c", bin[i] = 1LL << i, " \n"[i == 0]);
	} else {
		printf("%d\n", a = 34);
		for (int i = a - 1; i >= 1; i--) 
			printf("%lld ", bin[i] = 1LL << (i - 1));
		printf("%lld\n", bin[0] = 1);
	}
	for (int i = 1; i <= n; i++) shu(x[i], y[i]);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

void swap(int *a,int *b){
	int temp=*a;
	*a=*b;
	*b=temp;
}

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

	for(i=0;i<10;i++) scanf("%d", &hight[i]);
	
	/*３つだけソート*/
	for(j=0;j<3;j++){
	for(i=10;i>j;i--)
		if(hight[i-1]<hight[i]) swap(&hight[i-1],&hight[i]);
	}

	printf("%d\n%d\n%d\n",hight[0],hight[1],hight[2]);

	return (0);
}

Measured memory_bytes: 600
/*  ***  In The Name of God ... ***  */ 
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int long long
#define all(v) v.begin() , v.end()
#define endl '\n'

template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

int a , b ; 

void res ( int t ) {
	if ( !t )
		cout << "Zero\n" ;
	else if ( t == 1 )
		cout << "Positive\n" ;
	else
		cout << "Negative\n" ;
	exit ( 0 ) ; 
}

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> a >> b ;
	int t = b - a + 1 ; 
	if ( a < 0 ) {
		if ( b < 0 ) {
			if ( t % 2 == 0 )
				res ( 1 ) ;
			else
				res ( -1 ) ; 
		}
		else
			res ( 0 ) ; 
	}
	if ( a >= 0 ) {
		if ( !a )
			res ( 0 ) ;
		res ( 1 ) ; 
	}
}


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

using namespace std;

bool IntegerCheck(double X) {
	if (ceil(X) != floor(X)) return false;
	else return true;
}


int main(void) {
	int N, D, ans=0;
	double add;
	cin >> N >> D ;

	vector<vector<int>> Data(N, vector<int>(D));

	for (int i=0;i<N ;i++)
	{
		for (int j = 0; j < D; j++)
		{
		cin >> Data[i][j];
		}
	}

	for (int k = 0; k < N; k++)
	//比べられるデータ
	{
		for (int l = k+1; l < N; l++)
		//比べるデータ
		{
			add = 0;
			for (int m = 0; m < D; m++)
			//二乗を足す
			{
				add += pow(Data[k][m] - Data[l][m], 2);
			}

			//整数かどうか
			if (IntegerCheck(sqrt(add)))
			{
				ans++;
			}

		}
	}

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



Measured memory_bytes: 256
#include<stdio.h>

void show(int a[], int n){
  int i;
  for(i=0; i<n-1; i++){
    printf("%d ", a[i]);
  }
  printf("%d", a[n-1]);
  printf("\n");
  return ;
}

void selection(int a[], int n){
  int i, j, temp;
  int minj=-1;
  int cnt = 0;
  for(i=0; i<n; i++){
    minj = i;
    for(j=i; j<n; j++){
      if(a[j] < a[minj]){
        minj = j;
      }
    }
    if(i != minj){
      temp = a[i];
      a[i] = a[minj];
      a[minj] = temp;
      cnt++;
    }
  }
  show(a, n);
  printf("%d\n", cnt);
}

int main(){
  int n, i;
  int a[101];
  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &a[i]);
  }
  selection(a, n);
  return 0;
}

Measured memory_bytes: 1852
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
int main() {
  ll N;
  cin >> N;
  vector<P> Ans(0);
  int id = 0;
  if (N % 2 == 1) {
    for (int i = 1; i < N; i++) {
      id++;
      Ans.push_back(P(i, N));
    }
    for (int i = 1; i < N; i++) {
      for (int j = i + 1; j < N; j++) {
        if (i == j || i + j == N) continue;
        id++;
        Ans.push_back(P(i, j));
      }
    }
  } else {
    for (int i = 1; i <= N; i++) {
      for (int j = i + 1; j <= N; j++) {
        if (i == j || i + j == N + 1) continue;
        id++;
        Ans.push_back(P(i, j));
      }
    }
  }
  cout << id << endl;
  REP(i, Ans.size()) { cout << Ans[i].first << " " << Ans[i].second << endl; }
}

Measured memory_bytes: 3688
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		final int MOD = 1000000007;
		
		int m = sc.nextInt();
		int n = sc.nextInt();

		long ret = 1;
		while (n > 0) {
			if (n % 2 == 1) {
				ret = ret * m % MOD;
			}
			m = (int)((long)m * m % MOD);
			n /= 2;
		}

		System.out.println(ret);

		sc.close();
	}
}

Measured memory_bytes: 17364
// in case of multiple test cases and N=1e5 don't intialize arrays as global except for graph vector-array
// always check whether or not you are doing mod of a negative number
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
using namespace __gnu_pbds;
using namespace std;

#define double      	long double
#define int         	long long
#define pb          	push_back
#define pii         	pair<int,int>
#define vi          	vector<int>
#define vii         	vector<pii>
#define mi          	map<int,int>
#define mii         	map<pii,int>
#define all(a)      	(a).begin(),(a).end()
#define sz(x)       	(int)x.size()
#define endl        	"\n"
#define repp(i,a,b) 	for(int i=a;i<b;i++)
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define brep(i,a,b)     for(int i=a;i>=b;i--)
#define deb1(x)      	cout << #x << "=" << x << endl
#define deb2(x, y)  	cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x, y, z)  	cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define trace(v) 		for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define tracearr(a,l,r) for(int iii=l;iii<=r;iii++)cout << a[iii] << " ";cout << endl;
#define PI          	3.1415926535897932384626
#define F 				first
#define S 				second
#define clr(x,y) 		memset(x, y, sizeof(x))
#define IOS         	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// *s.find_by_order(1) - gives the 2nd samllest element in set
// s.order_of_key(x)   - gives the number of elements in the set which are strictly smaller than x


const int N=1e5 + 5;
const int MOD=1e9 + 7;

int func(int x,int y,int z)
{
	mi mp;
	mp[x]++;
	mp[y]++;
	mp[z]++;
	if(mp.size()==3)
		return 1;
	return 0;
}

int32_t main()
{
	IOS;
	int T=1;
	//cin >> T;
	// int numOfSetBits = __builtin_popcountll(n);
	std::cout << std::fixed << std::setprecision(12);
	while(T--)
	{
		int n;
		cin >> n;
		int a[n+5];
		rep(i,1,n)
			cin >> a[i];
		int ans = 0;
		rep(i,1,n)
		{
			rep(j,i+1,n)
			{
				rep(k,j+1,n)
				{
					if( (a[i]+ a[j]>a[k]) && (a[i]+ a[k]>a[j]) && (a[k]+ a[j]>a[i]) && func(a[i],a[j],a[k])==1)
					{
						ans ++ ;
						//deb3(a[i],a[j],a[k]);
						//deb3(i,j,k);
					}
						
				}
			}
		}
		cout << ans;
	}
}

Measured memory_bytes: 3648
import sys
from collections import deque
def input(): return sys.stdin.readline().strip()


def main():
    n = int(input())
    ans = deque([])
    while n > 0:
        rem = n % 26
        if rem != 0:
            ans.appendleft(chr(96 + n % 26))
            n = (n - rem) // 26
        else:
            ans.appendleft("z")
            n = (n - 26) // 26

    print("".join(ans))



if __name__ == "__main__":
    main()


Measured memory_bytes: 82512
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.stream.IntStream;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static IntStream INS(int n){return REPS(n).map(i->getInt());}
	static int getInt(){return Integer.parseInt(s.next());}
	public static void main(String[]$){
		int n=getInt(),m=getInt();
		TreeMap<Integer,Integer>t=new TreeMap<>();//<cost,no>
		HashMap<Integer,Integer>r=new HashMap<>();//<  no,vote>
		REPS(n).forEach(i->t.merge(getInt()-1,i+1,Math::min));
		INS(m)
		.mapToObj(t::headMap)
		.map(o->o.values().stream()
				.min(Comparator.naturalOrder())
				.get())
		.forEach(i->r.merge(i,1,Integer::sum));
		System.out.println(
				r.entrySet().stream()
				.max(Entry.comparingByValue())
				.get()
				.getKey());
	}
}

Measured memory_bytes: 37808
fun main(args: Array<String>) {
    val l = readLine()!!.split(' ').map { it.toInt() }
    val a = readLine()!!.split(' ').map { it.toInt() }
    var cost0 = 0
    var costX = 0
    for (i in a) {
        if (i < l[2]) {
            cost0++
        } else {
            costX++
        }
    }
    println(Math.min(cost0, costX))
}


Measured memory_bytes: 38216
/** 
 *  Author : Parth Prajapati aka (PARTH_4399, hungry_chef)
 *  Institute : Pandit Deendayal Petroleum University
 **/
#include<bits/stdc++.h>

using namespace std; 

#define start_cooking int main()
#define food_is_ready return 0;
#define main_ingredient_added ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void cook()
{
    // start with your recipe
    long long i, j, n, cnt = 0, ans = 0;
    cin>>n;
    while(n%2 == 0)
    {
        n /= 2;
        ++cnt;
    }
    for(i=1;;++i)
    {
        if(cnt >= i)
        {
            cnt -= i;
            ++ans;
        }
        else
            break;
    }
    for(j=3;j<=sqrt(n);j+=2)
    {
        cnt = 0;
        while(n%j == 0)
        {
            n /= j;
            ++cnt;
        }
        for(i=1;;++i)
        {
            if(cnt >= i)
            {
                cnt -= i;
                ++ans;
            }
            else
                break;
        }
    }
    if(n != 1)
        ++ans;
    cout<<ans;
}

start_cooking
{
    main_ingredient_added
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    //cin>>t;
    while(t--)
        cook();
    food_is_ready
}

Measured memory_bytes: 3668
import java.util.*;
 public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);

      int N = sc.nextInt();
      String S = sc.next();
      int count = 0;

      for(int i = 0;i < N - 2;i++){
       if(S.charAt(i) == 'A' && S.charAt(i + 1) == 'B' && S.charAt(i + 2) == 'C'){
        count++;
        } 
      }
       System.out.print(count);
   }
 }

Measured memory_bytes: 35804
#include <stdio.h>

int main()
{
  int n;
  int debt = 100000;
  int i;

  scanf("%d", &n);
  for (i = 0; i < n; i++){
    debt = debt * 105 / 100;
    if (debt % 1000 != 0){
      debt = (debt / 1000 + 1) * 1000;
    }
  }
  printf("%d\n", debt);

  return (0);
}

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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(s) s.begin(),s.end()
#define vll vector<ll>
#define vi vector<int>
#define vpii vector<pii>
#define vpll vector<pll>
#define vd vector<double>
#define vull vector<ull>
#define vc vector<char>
#define vs vector<string>
#define fi first
#define se second
#define sz(x) x.size()
#define cinarr(n,a) for(int i = 0; i < n; i++) cin >> a[i];
#define coutarr(n,a) for(int i = 0; i < n; i++) cout << a[i] << (i+1==n?'\n':' ');
#define fori(i,a,b,x) for(int i = a; i <= b; i+=x)
#define ford(i,a,b,x) for(int i = a; i >= b; i-=x)
#define tc int t; cin >> t; for(int cs = 1; cs <= t; cs++)
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define ld long double
#define reset(x,y) memset(x,y,sizeof x);
#define sqr(x) 1LL*(x)*(x)
#define cube(x) 1LL*(x)*(x)*(x)
#define ub(v, a) upper_bound(all(v), a)
#define lb(v, a) lower_bound(all(v), a)
#define EPS 1e-10
#define INF 2000000000
#define mod 1000000007
#define minof(a) min_element(all(a))
#define maxof(a) max_element(all(a))
#define debug(val) cerr << "The value of " << #val << " is = " << val << endl;
#define testing cerr << "--------------------------\n";

//input space ---> scanf("%[^\n]%*c",s);

ll n,k,ans;
vll a(200005),b(200005);

bool can(ll x) {
	ll K = k;
	fori(i,0,n-1,1) {
		K -= max(0LL,a[i]-x/b[i]);
	}
	return K >= 0;
}

int main() {
	IOS
	cin >> n >> k;
	fori(i,0,n-1,1) {
		cin >> a[i];
	}
	fori(i,0,n-1,1) {
		cin >> b[i];
	}
	sort(a.begin(),a.begin()+n,greater<ll>());
	sort(b.begin(),b.begin()+n);
	ll l = 0,r = 1LL*INF*INF;
	while(l <= r) {
		ll m = (l+r)/2;
		if(can(m)) {
			if(!can(m-1)) {
				ans = m;
				break;
			}
			r = m-1;
		} else {
			l = m+1;
		}
	}
	cout << max(0LL,ans) << endl;
}


Measured memory_bytes: 3456
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <cmath>
#include <cstdarg>
#include <cstdlib>
#include <string>

#include <tuple>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

typedef pair<int, int> P;

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;

    int x, l;
    vector<P> v(n);

    for(int i = 0; i < n; i ++) {
        cin >> x >> l;
        v[i] = make_pair(x+l, x-l);
    }
    sort(v.begin(), v.end());

    int count = 1;
    int now = 0;
    for (int i = 1; i < n; i ++) {
        if (v[now].first <= v[i].second) {
            count ++;
            now = i;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1152
N = int(input())

s = [input() for i in range(N)]

c = [s.count('AC'),s.count('WA'),s.count('TLE'),s.count('RE')]
d = ['AC','WA','TLE','RE']

for i in range(4):
    print(d[i]+' '+'x'+' '+str(c[i]) )

Measured memory_bytes: 16284
import math
if __name__ == "__main__":
    A, B, H, M = map(int, input().split())
    angle = 0
    small = (H * 60 + M) * 0.5
    big = M * 6
    if small > big:
        angle = small - big
    else:
        angle = big - small
    cos_c = math.cos(math.radians(angle))
    print(math.sqrt(A**2 + B**2 -(2*A*B*cos_c)))

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

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

using namespace std;
typedef long double ld;
const ld eps = 1e-8, INF = 1e+8;

int main() {
  int h,w;
  cin>>h>>w;
  vector<string> t(h+2,string(w+2,'.'));
  REP(i,h) {
    string str;
    cin>>str;
    t[i+1] = '.'+str+'.';
  }
  reverse(begin(t),end(t));
  map<ld,int> s;
  REP(i,h+1)REP(j,w+1) {
    if (t[i][j] == t[i+1][j+1] && t[i+1][j] != t[i][j+1]) {
      if (t[i][j] == t[i][j+1]) ++s[((ld)i)/j];
      else --s[((ld)i)/j];
    }
  }
  int sum = 0;
  int mxsum = 0;
  for (auto p : s) {
    int addv;
    tie(ignore, addv) = p;
    sum += addv;
    mxsum = max(mxsum, sum);
  }
  cout << mxsum+1 << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 100000000000

ll d[101][101][101];
ll H[101][101];

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

	ll N;

	cin >> N;

	vector<ll> x(N), y(N), h(N);
	rep(i, N) {
		cin >> x[i] >> y[i] >> h[i];
	}

	ll cx, cy;
	rep(i, 101) {
		rep(j, 101) {
			rep(n, N) {
				d[n][i][j] = abs(x[n] - i) + abs(y[n] - j);
				if (h[n] != 0) {
					H[i][j] = h[n] + d[n][i][j];
				}
			}
		}
	}

	bool is_correct;
	rep(i, 101) {
		rep(j, 101) {
			is_correct = true;
			rep(n, N) {
				if (h[n] != max(H[i][j] - d[n][i][j], 0LL)) {
					is_correct = false;
				}
			}
			if (is_correct) {
				cout << i << " " << j << " " << H[i][j] << "\n";
				return 0;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 8320
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    X = input()
    ans = 0
    now = 0
    for x in X:
        if x == 'S':
            now -= 1
        else:
            now += 1
        ans = max(ans,now)
    print(ans*2)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9384
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    s=input()
    N=len(s)
    dp=[[0]*13 for i in range(N+1)]
    dp[0][0]=1
    cur=1
    for i in range(1,N+1):
        si=s[-i]
        if si.isnumeric():
            si=int(si)
            for j in range(13):
                nj=(j+cur*si)%13
                dp[i][nj]+=dp[i-1][j]
                
        else:
            tsum=0
            for j in range(13):
                for k in range(10):
                    nj=(j+k*cur)%13
                    dp[i][nj]+=dp[i-1][j]
                    dp[i][nj]%=mod

        cur*=10
        cur%=13
    print(dp[-1][5])






if __name__ == "__main__":
    main()

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

bool kaibun(string &S, int i, int j){
  if(i==j){
    return true;
  }
  bool hey = true;
  for(int k=0;k<(j-i)/2+1;k++){//0,1,2,3
    if(S.at(i+k-1)!=S.at(j-k-1))//
      hey = false;
  }
  return hey;
}

int main() {
  string S;
  cin >> S;
  int N = S.size();
  if(kaibun(S,1,N)&&kaibun(S,1,(N-1)/2)&&kaibun(S,(N+3)/2,N)){//1,7 1,3 5,7
    cout << "Yes" << endl;
  }
  else
    cout << "No" << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  
  for(int i = 0; i < d.size(); i++){
    cin >> d.at(i);
  }
  
  vector<int> m;
  
  for(int i = 0; i < d.size(); i++){
    int flag = 0;
    
    for(int j = 0; j < m.size(); j++){
      if(d.at(i) == m.at(j)){
        flag = 1;
        break;
      }
    }
    
    if(flag != 1){
    	m.push_back(d.at(i));
    }
  }
  
  cout << m.size() << endl;
}


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

int main(){
    string S;
    cin>>S;
    vector<int> data;

    long long ans=0;
    int N=S.size();
    for(int i=0;i<N;i++) data.push_back(S.at(i)-'0');

    for(int bit=0;bit<(1<<N-1);bit++){
        long int kari=0;
        long int num=data.at(0);
        for(int i=1;i<=N-1;i++){
            if (bit & (1<<i-1)) {
                kari+=num;
                num=data.at(i);
            }
            else num=num*10+data.at(i);
        }
        kari+=num;
        //cout<<kari<<endl;
        ans+=kari;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
 
class Program {
    static List<long> rep;
    static void Main(string[] args){
        //入力を受け取る
        var N = long.Parse(Console.ReadLine());
        var A  = Console.ReadLine().Split().Select(a => long.Parse(a)).ToArray();
        var B = new long[N];
      　Array.Copy(A, B, A.Length);
        long ans = 0;
        long sum = A[0];
        if(A[0] == 0){
          ans = 1;
          sum = -1;
        }
        for(int i =1 ;i <N; i++){
            if(sum > 0){
                if(sum+A[i] >= 0){
                    var aim = sum*(-1)-1;
                    ans += (long) Math.Abs(A[i]-aim);
                    A[i] = aim;
                }
            }else{
                if(sum+A[i] <= 0){
                    var aim = sum*(-1)+1;
                    ans += (long) Math.Abs(A[i]-aim);
                    A[i] = aim;
                }
            }
            sum += A[i];
        }
        
        long ans2 = (long)Math.Abs(B[0])+1;
        long sum2 = 0;
        if(B[0] > 0){
          sum2 = -1;
        }else{
          sum2 = 1;
        }
        for(int i =1 ;i <N; i++){
            if(sum2 > 0){
                if(sum2+B[i] >= 0){
                    var aim = sum2*(-1)-1;
                    ans2 += (long) Math.Abs(B[i]-aim);
                    B[i] = aim;
                }
            }else{
             // Console.WriteLine(B[i]);
                if(sum2+B[i] <= 0){
                    var aim = sum2*(-1)+1;
                    ans2 += (long) Math.Abs(B[i]-aim);
                    B[i] = aim;
                }
            }
            sum2 += B[i];
          
        }
      
        if(ans2 < ans){
          Console.WriteLine(ans2);
        }else{
          Console.WriteLine(ans);
        }
       　
        
        
    }
    
 
}


Measured memory_bytes: 32092