akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using tiii = tuple<int,int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const ll DIV =1e9+7;
//const double PI = M_PI;
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
#define chmax(a,b) a=max(a,b)

/*Coding Space*/
vi G[100001];
int memo[100001];
int tmemo[100001];
int n,u,v;
bool usedw[100001] = {};
void aoki(int u, int depth = 0){
  if(usedw[u])  return;
  usedw[u] = 1;
  memo[u] = depth;
  rep(i,G[u].size())  aoki(G[u][i], depth + 1);
}
bool used[100001] = {};
void takahashi(int u, int depth = 0){
  if(depth >= memo[u]){return;}
  if(used[u])  return;
  used[u] = 1;
  tmemo[u] = depth;
  rep(i,G[u].size())  takahashi(G[u][i], depth + 1);
}

int main(){
  cin >> n >> u >> v;
  rep(i,n-1){
    int a,b; cin >> a >> b;
    G[a].pb(b);
    G[b].pb(a);
  }
  rep(i,100001) tmemo[i] = INF;
  aoki(v);
  takahashi(u);
  int ans = 0;
  rep(i,n){
    cerr << memo[i+1] << ' ' << tmemo[i+1] << endl;
    if(memo[i+1] == tmemo[i+1])  ans = max(ans, memo[i+1]);
    if(memo[i+1] > tmemo[i+1])   ans = max(ans, memo[i+1] - 1);
  }
  cout << ans << endl;
}


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

#define ll long long
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define MAX 1e9
#define MIN -1e9
#define MOD 1000000007
#define println(x) cout << "[" << #x << ":" << x << "]\n"; 
#define print(x) cout << "[" << #x << ":" << x << "] "; 

int main(){
	ios::sync_with_stdio(0); 
    cin.tie(0); 
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	int n, W; cin >> n >> W;
	ll dp[W+1];

	for(int i=0; i<=W; i++)
		dp[i] = 0;

	for(int i=0; i<n; i++){
		int w, v; cin >> w >> v;
		// print(w) println(v)
		for(int j= W-w; j>=0; j--){
			// print(j) print(j+w) print(dp[j+w])
			dp[j+w] = max(dp[j+w], dp[j]+v);
			// println(dp[j+w])
		}
	}

	ll ans = 0;
	for(int i=0; i<=W; i++)
		ans = max(ans, (ll)dp[i]);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 4360
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<iomanip>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(1001,1);
	
	int x,j;
	for(int i=2;i<=n;i++){
			x=i;
			j=2;
			while(1){
				if(x%j==0){
					x/=j;
					a[j]++;
					if(x<=1)break;
				}else{
					j++;
				}
			}
	}	
	
	long long sum=1;
	for(int i=0;i<=1000;i++){
			sum*=a[i];
			sum=sum%1000000007;
	}
	cout << sum << endl;	
	return 0;
}


Measured memory_bytes: 256
import fractions

integral_count = int(input())
blackboard_integers = list(map(int, input().split()))

gcd_integers = list(set(blackboard_integers))

gcd = 0
result = 1
for i in range(len(gcd_integers)):
    gcd = 0
    if blackboard_integers.count(gcd_integers[i]) >= 2:
        for n in gcd_integers:
            gcd = fractions.gcd(gcd, n)
    else:
        for n in gcd_integers[:i]:
            gcd = fractions.gcd(gcd, n)
        for n in gcd_integers[i+1:]:
            gcd = fractions.gcd(gcd, n)
    if gcd > result:
        result = gcd

print(result)

Measured memory_bytes: 16136
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n,m,x,y;
    cin >> n >> m;
    VI d(n), in(n);
    deque<int> q;
    VVI es(n);
    REP(i,0,m) {
        cin >> x >> y;
        --x; --y;
        ++in[x];
        es[y].push_back(x);
    }
    REP(i,0,n) if (in[i] == 0) q.push_back(i);
    while (!q.empty()) {
        int src = q.front();
        q.pop_front();
        for (auto &&dst: es[src]) {
            d[dst] = max(d[dst], d[src] + 1);
            --in[dst];
            if (in[dst] == 0) q.push_back(dst);
        }
    }
    cout << *max_element(all(d)) << endl;
}

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

Measured memory_bytes: 6528
#include<iostream>

int main(){

  int h, w;
  while(1){
    std::cin >> h >> w;
    if(h == 0 && w == 0) break;

    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
	std::cout << '#';
      }
      std::cout << std::endl;
    }
    std::cout << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3028
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N){
    cin >> A.at(i);
  }
  int Max = A.at(0);
  int Min = A.at(0);
  rep(i, N){
    if(A.at(i) > Max){
      chmax(Max, A.at(i));
    }
    else if(A.at(i) < Min){
      chmin(Min, A.at(i));
    }
  }
  cout << Max - Min << endl;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
w=[1]
x=set([1])
for i in range(k):
    t=a[w[-1]-1]
    if t in x: break
    x.add(t)
    w.append(t)
p=w.index(t)
if p==0:
    print(w[k%len(w)])
else:#l 2,5,3
    p=w.index(t)
    k-=p
    loop=len(w)-p
    print(w[p+k%loop])


Measured memory_bytes: 121720
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<ll> enum_div(ll n) {
    std::vector<ll> ret;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll A, B;
    cin >> A >> B;
    A--;

    auto func = [](ll n) {
        ll tmp = (n / 4) * 4;
        ll res = tmp;
        for (ll i = res + 1; i <= n; i++) { res ^= i; }
        return res;
    };

    cout << (func(A) ^ func(B)) << endl;

    return 0;
}

Measured memory_bytes: 256
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.root = [-1]*(n+1)
    self.rnk = [0]*(n+1)
  def find(self, x):
    if(self.root[x] < 0):
      return x
    else:
      self.root[x] = self.find(self.root[x])
      return self.root[x]
  def unite(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if(x == y):
      return 
    elif(self.rnk[x] > self.rnk[y]):
      self.root[x] += self.root[y]
      self.root[y] = x
    else:
      self.root[y] += self.root[x]
      self.root[x] = y
      if(self.rnk[x] == self.rnk[y]):
        self.rnk[y] += 1
  def same(self, x, y):
    return self.find(x) == self.find(y)
  def count(self, x):
    return -self.root[self.find(x)]
n,m=map(int,input().split())
e=[[]for _ in range(m)]
uf=UnionFind(n)
for i in range(n):
  k,*lk,=map(int,input().split())
  for j in lk:
    e[j-1]+=[i]
for i in e:
  if not i:continue
  k=i[0]
  for j in i[1:]:
    uf.unite(k,j)
print(['NO','YES'][uf.count(0)==n])

Measured memory_bytes: 89456
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int K = scan.nextInt();
		int A = scan.nextInt();
		int B = scan.nextInt();

		if (A % K == 0) {

			System.out.println("OK");

		} else if ((K - A % K) + A <= B) {

			System.out.println("OK");

		} else {

			System.out.println("NG");

		}

		scan.close();
	}
}


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

typedef long long ll;
const int maxn=2e5+10;
char s[maxn];
ll ans;

int main(){
	cin>>s;
	for(int i=0,j=0;s[i];++i)
		if(s[i]=='B')
			++j;
		else
			ans+=j;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
const int ININF = 1000000;
using pint = pair<int, int>;
using Edge = pair<long long, pint>; //<cost,<u,v>>の形
vector<Edge> edges;

int N, M, s;

vector<long long> d; //最短距離

//どこかに負の閉路が存在する場合はtrue
bool find_negative_loop() {
    rep(i, 0, N) {
        rep(j, 0, M) {
            Edge e = edges[j];
            long long cost = e.first;
            int to = e.second.second;
            int fr = e.second.first;
            if(d[to] > d[fr] + cost) {
                d[to] = d[fr] + cost;
                if(i == N - 1) {
                    return true;
                }
            }
        }
    }
    return false;
}
//ベルマンフォード法で最短経路を求める（負の辺がある場合）
//到達可能な負の閉路がある場合はfalseを返す
bool shortest_path(int start) {
    rep(i, 0, N) { d[i] = INF; }
    d[start] = 0LL;
    rep(i, 0, N) {
        bool update = false;
        rep(j, 0, M) {
            Edge e = edges[j];
            long long cost = e.first;
            int to = e.second.second;
            int fr = e.second.first;
            if(d[fr] != INF && d[to] > d[fr] + cost) {
                d[to] = d[fr] + cost;
                update = true;
            }
        }
        if(!update) {
            break;
        }
        if(i == N - 1) {
            return false;
        }
    }
    return true;
    ;
}
int main() {
    cin >> N >> M >> s;
    d.assign(N, 0);
    rep(i, 0, M) {
        int a, b, c;
        cin >> a >> b >> c;
        // b--;
        // c--;
        edges.push_back(make_pair(c, make_pair(a, b)));
    }
    if(!shortest_path(s)) {
        cout << "NEGATIVE CYCLE" << endl;
    } else {

        rep(i, 0, N) {
            if(d[i] != INF) {
                cout << d[i] << endl;
            } else {
                cout << "INF" << endl;
            }
        }
    }
}



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

int main( void )
{
  int N, X;
  cin >> N >> X;
  vector<int> m( N );
  int count = 0;
  int min = INT_MAX;
  
  for( int i = 0; i < N; i++ ) {
    cin >> m.at( i );
    X -= m.at( i );
    count++;
    if( min > m.at( i ) )
      min = m.at( i );
  }

  while( X >= min ) {
    count++;
    X -= min;
  }

  cout << count << endl;
 
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> a(M);
    vector<int> broken(N + 1, false);
    REP(i, M) {
        cin >> a[i];
        broken[a[i]] = true;
    }
    vector<int> dp(N + 1);
    dp[N] = 1;
    RREP(i, N) {
        if (broken[i]) {
            dp[i] = 0;
        } else {
            if (i + 2 <= N) {
                dp[i] = (dp[i + 1] + dp[i + 2]) % MOD;
            } else {
                dp[i] = dp[i + 1];
            }
        }
    }
    cout << dp[0] << endl;
    return 0;
}



Measured memory_bytes: 1408
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

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

int n;
ll k;
ll a[200005], f[200005];

bool check(ll lw){
	ll k1 = k;
	rep(i, n){
		//use the minimum to get it <= lw
		ll l = 0, r = k1;
		while(l < r){
			ll mid = (l + r) / 2;
			if(((a[i] - mid) * (f[i])) <= lw) r = mid;
			else l = mid + 1;
		}
		if(((a[i] - l) * (f[i])) > lw) return 0;
		k1 -= l;
	}
	return 1;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	cin >> n >> k;
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> f[i];
	sort(a, a + n);
	sort(f, f + n);
	reverse(f, f + n);
	ll l = 0, r = 1e13;
	while(l < r){
		ll mid = (l + r) / 2;
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	cout << l << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 3328
import heapq
n, m = map(int, input().split())
aas = sorted(list(map(int, input().split())))
hq = []
for i in range(m):
    b, c = map(int, input().split())
    heapq.heappush(hq,(-c,b))
i = 0
while hq:
    c, b = heapq.heappop(hq)
    c = -c
    for j in range(i,min(n,i+b)):
        if aas[j] < c:
            aas[j] = c
        else:
            print(sum(aas))
            exit()
    i = j + 1
print(sum(aas))

Measured memory_bytes: 26732
#include<iostream>
#include<algorithm>
using namespace std;
class back {
	public:
		int weight, value;
};
back b[100];
/*
	用递归数据较大时会超时。应该用数组储存方法。
*/
//void solve(int k, int weight,int value) {
//	if (weight > m) return;
//	if (value > all) all = value;
//	if (k == n) return;
//	solve(k + 1, weight + b[k].weight, value + b[k].value);
//	solve(k + 1, weight, value);
//}
int a[101][10001];
int main(void) {
	int n, w;
	cin >> n >> w;
	for (int i = 0; i < n; i++) {
		cin >> b[i].value >> b[i].weight;
	}
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= w; j++) {
			a[i][j] = 0;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= w; j++) {			//j+b[i].weight 不行 因为前面的也要更新.
			if (j - b[i].weight < 0) a[i + 1][j] = a[i][j];
			else {
			a[i + 1][j] = max(a[i][j], a[i][j - b[i].weight] + b[i].value);
			}
		}
	}
	cout << a[n][w]<<endl;
}


Measured memory_bytes: 7032
n = int(input())
s = []
found = False
for i in range(n):
    s.append(list(map(int, input().split())))
for i in range(n-2):
    if s[i][0] == s[i][1] and s[i+1][0] == s[i+1][1] and s[i+2][0] == s[i+2][1]:
        print("Yes")
        found = True
        break
    else:
        pass
if found == False:
    print("No")

Measured memory_bytes: 9196
package main

import (
	"fmt"
	"math"
)

func main() {
	var x int
	fmt.Scan(&x)

	m := 100
	for i := 0; ; i++ {
		if m >= x {
			fmt.Println(i)
			return
		}
		m = int(math.Floor(float64(m) * 1.01))
	}
}


Measured memory_bytes: 1756
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	int K;
	cin >> K;
	cout << (K / 2) * ((K + 1) / 2);
	return 0;
}


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

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

    int L; cin >> L;
    int N = 2, p = 2;
    while (p * 2 <= L) {
        N++;
        p *= 2;
    }
    int M = (N - 1) * 2 - 1;
    int l = L;
    while (l) {
        M += l % 2;
        l /= 2;
    }
    cout << N << " " << M << "\n";

    p = L - p;
    l = L;
    for (int i = 1; i < N; i++) {
        cout << i << " " << i+1 << " " << 0 << "\n";
        cout << i << " " << i+1 << " "<< (1 << i-1) << "\n";
        if (1 << i - 1 & p) {
            l -= 1 << i-1;
            cout << i << " " << N << " " << l << "\n";
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,i,x;
	cin>>n;
	int ans[n]={0};
	for(i=1;i<n;++i){ 
		cin>>x;
		++ans[x-1];
	}
	for(i=0;i<n;++i)
	cout<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 4372
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c;
    cin>>a>>b>>c;
    if(a>1&&c>=b||a==1&&b==c)
    { 
        cout<<(a-2)*(c-b)+1;
		cout<<endl;
    } 
    else
        cout<<0<<endl; 
 } 

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

int main()
{
    int A_h[2];
    int A_m[2];
    int A_s[2];
    int A_sum;
    int A_sum1 = 0;
    int A_sum2 = 0;

    int B_h[2];
    int B_m[2];
    int B_s[2];
    int B_sum;
    int B_sum1 = 0;
    int B_sum2 = 0;

    int C_h[2];
    int C_m[2];
    int C_s[2];
    int C_sum;
    int C_sum1 = 0;
    int C_sum2 = 0;

    int Ah = 0;
    int Am = 0;
    int As = 0;
    int Bh = 0;
    int Bm = 0;
    int Bs = 0;
    int Ch = 0;
    int Cm = 0;
    int Cs = 0;

    cin >> A_h[0];
    cin >> A_m[0];
    cin >> A_s[0];
    cin >> A_h[1];
    cin >> A_m[1];
    cin >> A_s[1];

    cin >> B_h[0];
    cin >> B_m[0];
    cin >> B_s[0];
    cin >> B_h[1];
    cin >> B_m[1];
    cin >> B_s[1];

    cin >> C_h[0];
    cin >> C_m[0];
    cin >> C_s[0];
    cin >> C_h[1];
    cin >> C_m[1];
    cin >> C_s[1];

    if (A_s[0] > A_s[1]){
        A_m[1]--;
        A_s[1] += 60;
        As = A_s[1] - A_s[0];
    }
    else {
        As = A_s[1] - A_s[0];
    }

    if (A_m[0] > A_m[1]){
        A_h[1]--;
        A_m[1] += 60;
        Am = A_m[1] - A_m[0];
    }
    else {
        Am = A_m[1] - A_m[0];
    }

        Ah = A_h[1] - A_h[0];

    if (B_s[0] > B_s[1]){
        B_m[1]--;
        B_s[1] += 60;
        Bs = B_s[1] - B_s[0];
    }
    else {
        Bs = B_s[1] - B_s[0];
    }

    if (B_m[0] > B_m[1]){
        B_h[1]--;
        B_m[1] += 60;
        Bm = B_m[1] - B_m[0];
    }
    else {
        Bm = B_m[1] - B_m[0];
    }

        Bh = B_h[1] - B_h[0];

    if (C_s[0] > C_s[1]){
        C_m[1]--;
        C_s[1] += 60;
        Cs = C_s[1] - C_s[0];
    }
    else {
        Cs = C_s[1] - C_s[0];
    }

    if (C_m[0] > C_m[1]){
        C_h[1]--;
        C_m[1] += 60;
        Cm = C_m[1] - C_m[0];
    }
    else {
        Cm = C_m[1] - C_m[0];
    }

   Ch = C_h[1] - C_h[0];

   cout << Ah << " " << Am << " " << As << endl;
   cout << Bh << " " << Bm << " " << Bs << endl;
   cout << Ch << " " << Cm << " " << Cs << endl;
    
   return (0);
}



Measured memory_bytes: 3112
n = int(input())
v = list(map(int, input().split()))
odd = {}
even = {}
change = 0
for i in range(n):
    if i % 2 == 0:
        if v[i] in even:
            even[v[i]] += 1
        else:
            even[v[i]] = 1
    else:
        if v[i] in odd:
            odd[v[i]] += 1
        else:
            odd[v[i]] = 1

if len(odd) == 1 and len(even) == 1:
    if odd == even:
        change = int(n / 2)
else:
    max_e = max(even, key=even.get)
    max_o = max(odd, key=odd.get)
    if max_e != max_o:
        change = n - even[max_e] - odd[max_o]
    else:
        if even[max_e] > even[max_o]:
            max_o2 = min(odd, key=odd.get)
            for o in odd:
                if o != max_o and odd[o] > odd[max_o2]:
                    max_o2 = o
            change = n - even[max_e] - odd[max_o2]
        elif even[max_e] == even[max_o]:
            max_o2 = min(odd, key=odd.get)
            for o in odd:
                if o != max_o and odd[o] > odd[max_o2]:
                    max_o2 = o
            max_e2 = min(even, key=even.get)
            for e in even:
                if e != max_e and even[e] > even[max_e2]:
                    max_e2 = e
            change = min(n - even[max_e] - odd[max_o2], n - odd[max_o] - even[max_e2])
        else:
            max_e2 = min(even, key=even.get)
            for e in even:
                if e != max_e and even[e] > even[max_e2]:
                    max_e2 = e
            change = n - odd[max_o] - even[max_e2]
print(change)

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




int main(){
int N,sum;
sum=0;
cin>>N;
int a[N],b[N];

for(int i=0;i<N;i++){
int s;
cin>>s;
sum+=s;
a[i]=s;
}


b[0]=sum;
for(int j=1;j<=(N-2);j+=2){
b[0]-=a[j%N]*2;
}
for(int i=1;i<N;i++) b[i]=2*a[i-1]-b[i-1];

for(int i=0;i<N;i++) cout<<b[i]<<' ';

 return 0;
}

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

using namespace std;

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

const ll INF = 1e15;
const ll MOD = 1e9 + 7; 

int main(){
    int h,w,ch,cw,dh,dw;
    cin >> h >> w >> ch >> cw >> dh >> dw;
    ch--; cw--;
    dh--; dw--;
    vector<string> m(h);
    for(int i = 0; i < h; i++) cin >> m[i];
    priority_queue<pipii,vector<pipii>,greater<>> p;
    bool used[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            used[i][j] = false;
        }
    }
    p.push({0,{ch,cw}});
    vector<pair<int,int>> dis = {{1,0},{0,1},{-1,0},{0,-1}};
    while(!p.empty()){
        pipii tar = p.top();
        p.pop();
        int cost = tar.first;
        int x = tar.second.first;
        int y = tar.second.second;
        if(used[x][y]) continue;
        used[x][y] = true;
        if(x == dh && y == dw){
            cout << cost << endl;
            return 0;
        }
        for(auto d : dis){
            int xx = x + d.first;
            int yy = y + d.second;
            if(0 <= xx && xx < h && 0<= yy && yy < w && m[xx][yy] == '.'){
                p.push({cost,{xx,yy}});
            }
        }
        for(int i = -2; i <= 2; i++){
            for(int j = -2; j <= 2; j++){
                int xx = x + i;
                int yy = y + j;
                if(0 <= xx && xx < h && 0<= yy && yy < w && m[xx][yy] == '.'){
                    p.push({cost+1,{xx,yy}});
                }
            }
        }
    }
    cout << -1 << endl;
    return 0;
}


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

int main(){
    int n,l;
    cin >> n >> l;
    vector<string> s(n);
    for(int i=0; i<n; i++){
        cin >> s[i];
    }
    sort(s.begin(),s.end());
    for(int i=0; i<n; i++){
        cout << s[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
L=[list(map(int,input().split()))[1:] for _ in range(m)]
P=list(map(int,input().split()))
cnt=0
for i in range(2**n):
    on=bin(i)[2:].zfill(n)
    for l,p in zip(L,P):
        if sum(int(on[s-1]) for s in l)%2!=p:
            break
    else:cnt+=1
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
typedef int ll;
 
//typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
 
 
const ll N = 500002;
const ll mod = 1000000007;
const long long int inf = INT64_MAX;
#define pp pair<ll,ll>

typedef long double ld;
typedef vector<pp> vpl;
#define MP make_pair
#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++) 
#define trace(i,a) for(auto i=a.begin();i!=a.end();i++) 
#define mtrace(i,a) for(auto i=a.begin();i!=a.end();i++)  cout<<i->first<<" "<<i->second<<endl;   
 
const ld pi = 3.14159265359;
 
 
void fastIO(void);
void decimal(int);
ll modmulti(ll, ll);
ll modadd(ll, ll);
ll modpower(ll, ll);
ll gcd(ll, ll );
ll modinv(ll);

ll tree[26][4*N];
ll a[26][N];
void build(ll node, ll l, ll r, ll id)
{
	if(l==r){
		tree[id][node] = a[id][l];
		return;
	}
	ll m = (l+r)/2;
	build(2*node+1,l,m,id);
	build(2*node+2,m+1,r,id);
	tree[id][node] = tree[id][2*node+1]+tree[id][2*node+2];
	return;
}
void update(ll node, ll l, ll r, ll pos,ll val, ll id)
{
	if(l==r){
		tree[id][node] = val;
		return;
	}
	ll m = (l+r)/2;
	if(pos<=m) update(2*node+1,l,m,pos,val,id);
	else update(2*node+2,m+1,r,pos,val,id);
	tree[id][node] = tree[id][2*node+1]+tree[id][2*node+2];
	return;


}
ll query(ll node, ll l, ll r, ll st, ll ed, ll id)
{
	if(l==st && r==ed){
		return tree[id][node];
	}
	if(l>st) return 0;
	if(r<ed) return 0;
	if(ed<st) return 0;
	ll m = (l+r)/2;
	if(ed<=m) return query(2*node+1,l,m,st,ed,id);
	if(st>m) return query(2*node+2,m+1,r,st,ed,id);
	ll t1,t2;
	t1 = query(2*node+1,l,m,st,m,id);
	t2 = query(2*node+2,m+1,r,m+1,ed,id);
	return t1+t2;
}
int main()
{
	fastIO();
	ll n;
	cin>>n;
	string s;
	cin>>s;
	rep(i,n){
		a[s[i]-'a'][i]=1;
	}
	rep(i,26) build(0,0,n-1,i);
	ll q;
	cin>>q;
	ll tp,l,r,id;
	char c;
	while(q--){
		cin>>tp;
		if(tp==1){
			cin>>id>>c;
			id--;
			//cout<<"c = "<<c<<endl;
			a[s[id]-'a'][id] = 0;
			a[c-'a'][id] = 1;
			update(0,0,n-1,id,0,s[id]-'a');
			update(0,0,n-1,id,1,c-'a');
			s[id] = c;
		}
		else{
			cin>>l>>r;
			ll cnt = 0;
			l--;
			r--;
			rep(i,26){
				if(query(0,0,n-1,l,r,i)>0) cnt++;
			}
			cout<<cnt<<endl;
		}
	}

}


	


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}
 
void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a){
   return modpower(a,mod-2);
}

Measured memory_bytes: 209820
#include <stdio.h>
#include <limits.h>
int cnt = 0;

#define INFTY 1000000000

void merge(int S[], int left, int mid, int right){
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1 + 1], R[n2 + 1];
  for (i = 0; i < n1; i++){
    L[i] = S[left + i];
  }
  for (i = 0; i < n2; i++){
    R[i] = S[mid + i];
  }
  L[n1] = INT_MAX; // intの最大値
  R[n2] = INT_MAX;
  i = 0;
  j = 0;
  for (k = left; k < right; k++){
    cnt++;
    if (L[i] <= R[j]){
      S[k] = L[i++];
    } else {
      S[k] = R[j++];
    }
  }
  return;
}

void mergeSort(int S[], int left, int right){
  if (left + 1 < right){
    int mid = (left + right) / 2;
    mergeSort(S, left, mid);
    mergeSort(S, mid, right);
    merge(S, left, mid, right);
  }
  return;
}

int main(){
  int i, n, S[500000];
  scanf("%d", &n);
  for (i = 0; i < n; i++){
    scanf("%d", &S[i]);
  }
  mergeSort(S, 0, n);
  printf("%d", S[0]);
  for (i = 1; i < n; i++) {
    printf(" %d", S[i]);
  }
  printf("\n");
  printf("%d\n", cnt);
  return 0;
}



Measured memory_bytes: 5604
#include<stdio.h>
int card[200]={0};
int yama[200]={0};
int yamaa[200]={0};
int yamab[100]={0};
int n;
void seisu(int k);
void rihuru();
int main(){
  scanf("%d",&n);
  int m;
  scanf("%d",&m);
  int k;
  int ma;
  for(ma=1;ma<=2*n;ma++){
    card[ma-1]=ma;
  }
  for(ma=0;ma<m;ma++){
    scanf("%d",&k);
    if(k==0){
      rihuru();
    }
    else if(k>=1&&k<=2*n-1){
      seisu(k);
    }
  }
  for(ma=0;ma<2*n;ma++){
    printf("%d\n",card[ma]);
  }
  return 0;
}
void seisu(int k){
  int ma;
  int maa=0;
  for(ma=0;ma<2*n;ma++){
    if(ma<k){
      yama[ma+(2*n-k)]=card[ma];
    }
    else{
      yama[ma-k]=card[ma];
    }
  }
  for(ma=0;ma<2*n;ma++){
    card[ma]=yama[ma];
  }
  for(ma=0;ma<2*n;ma++){
    yama[ma]=0;
  }
  return;
}
void rihuru(){
  int ma;
  for(ma=0;ma<2*n;ma++){
    if(ma+1<=n){
      yamaa[ma]=card[ma];
    }
    else{
      yamab[ma-n]=card[ma];
    }
  }
  for(ma=0;ma<2*n;ma++){
    if(ma%2==0){
      card[ma]=yamaa[ma/2];
    }
    else{
      card[ma]=yamab[ma/2];
    }
  }
  for(ma=0;ma<2*n;ma++){
    yamaa[ma]=0;
    yamab[ma]=0;
  }
  return;
}

Measured memory_bytes: 600
//in the name of allah
#include<bits/stdc++.h>
using namespace std;

int main(){
	long long n , a , b;

	scanf("%lld%lld%lld" , &n , &a , &b);
	if(b<a){
		puts("0");
		return 0;
	}
	if(b != a && n == 1){
		puts("0");
		return 0;
	}
	printf("%lld\n" , (n-1)*b + a - (n-1)*a - b + 1);
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a;
  scanf("%d",&a);
  char b[101];
  scanf("%s",b);
  int c;
  int d=0;
  for(c=0;c<a;c++){
    if(b[c]=='R') d++;
    else d--;
  }
  if(d>0) printf("Yes");
  else printf("No");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1000000000
#define  pow(x) pow(10,(x)) 
typedef long long int LL;
const int MOD = 1000000007;
//sort(all(x))とするとソートできるよ

int main(){
    int N,D;cin >> N >> D;
    if(N%(2*D+1) == 0){
        cout << N / (2*D+1) << endl;
    }
    else{
        cout << (N / (2*D+1)) + 1 << endl; 
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	string s;
	cin >> s;
	
	ll ans = 0, cnt = 0;
	for(auto x : s) {
		if( x == 'B' ) cnt++;
		else ans += cnt;
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3664
//Created by Kira

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

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS
   int k; cin>>k;

   int N = 1e7;
    ll cur = 0, rem;
    int i = 1;
   for(; i <= N; i++){
       cur *= 10;
       cur += 7;
       rem = cur % k;
       if(rem == 0){
           cout<<i<<'\n';
           return 0;
       }
       cur = rem;
   }

   cout<<-1<<'\n';

    







}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1) res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



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

int main(){
  int N;
  string S;
  cin>>N>>S;
  int ans=0,tmp=0;
  for(int i=0;i<N;i++){
    if(S[i]=='I'){
      tmp++;
      ans=max(tmp,ans);
    }else if(S[i]=='D'){
      tmp--;
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 256
/* When Talent doesn't work, Hard work beats Talent*/
#include"bits/stdc++.h"
using namespace std;

#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define llu long long unsigned int
#define nl "\n"
const long long x = 1000000000000000000 ;
int main()
{
	int n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]==0)
		{
			cout<<"0";
			return 0;
		}
	}
	ll ans=1;
	for(int i=0;i<n;i++)
	{
		if(a[i]>x/ans)
		{
			cout<<"-1";
			return 0;
		}
		ans*=a[i];
	}
	cout<<ans;
    return 0 ;
}


Measured memory_bytes: 4412
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int Levenstein(string a,string b){
  int dp[a.size()+1][b.size()+1];

  for(int i=0;i<=a.size();i++)dp[i][0]=i;
  for(int i=0;i<=b.size();i++)dp[0][i]=i;

  for(int i=1;i<=a.size();i++){
    for(int j=1;j<=b.size();j++){
      int cost=(a[i-1]==b[j-1])?0:1;
      dp[i][j]=min(dp[i-1][j]+1,min(dp[i][j-1]+1,dp[i-1][j-1]+cost));
    }
  }
  return dp[a.size()][b.size()];
}

int main(void){

  string a,b;
  cin >> a >> b;
  cout << Levenstein(a,b) << endl;

  return 0;
}

Measured memory_bytes: 5104
N,Q = map(int,input().split())
ans = [0]*N
ab = []
for i in range(1,N):
    ab.append(list(map(int,input().split())))
for j in range(Q):
    pj,xj = map(int,input().split())
    ans[pj-1] += xj
ab.sort()
for i in range(N-1):
    ans[ab[i][1]-1]+=ans[ab[i][0]-1]
print(' '.join(map(str,ans)))

Measured memory_bytes: 78396
<?php
$s = trim(fgets(STDIN));
$t = trim(fgets(STDIN));

for($i = 0; $i < strlen($s); $i++){
    $sArray[] = $s[$i];
}
for($i = 0; $i < strlen($t); $i++){
    $tArray[] = $t[$i];
}
sort($sArray);
rsort($tArray);
echo implode("", $sArray) < implode("", $tArray) ? "Yes" : "No";



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

using namespace std;
const long long P = 1000000007;

int main() {
  string s;
  cin >> s;
  if(s[s.size()-1] == 's') s += "es";
  else s += 's';
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <string>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;

int main() {
 int a,b,c,d;
  cin >> a >> b >> c >>d;
  cout << a*b-b*c-a*d+c*d << endl;
}

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

const int MAXN = 21;
const int MAXX = 10001;
const double eps = 1e-6;
const double inf = 1e10;

int n;
double r, th;
P ps[MAXN];
double G[MAXN][MAXN][MAXN];
double dp[MAXX][MAXN][MAXN];

double dot(P a, P b) {
  return a.real()*b.real() + a.imag()*b.imag();
}

double cross(P a, P b) {
  return a.real()*b.imag() - a.imag()*b.real();
}

double getAngle(P a, P b) {
  double v = dot(a, b) / (abs(a) * abs(b));
  if(v > 1.0) return 0;
  if(v < -1.0) return M_PI;
  return acos(v);
}

int main() {
  while(cin >> n) {
    cin >> r >> th;
    th = th * M_PI / 180.0;
    for(int i = 0; i < n; ++i)
      cin >> ps[i].real() >> ps[i].imag();

    for(int j = 0; j < n; ++j) {
      for(int k = 0; k < n; ++k) {
        for(int l = 0; l < n; ++l) {
          P a = ps[k] - ps[j], b = ps[l] - ps[k];
          if(k == l) G[j][k][l] = inf;
          else if(j == k) G[j][k][l] = abs(b);
          else if(getAngle(a, b) < th + eps) G[j][k][l] = abs(b);
          else G[j][k][l] = inf;
        }
      }
    }

    fill(dp[0][0], dp[MAXX][0], inf);
    dp[0][0][0] = 0;
    int res = 0;
    for(int i = 0; i+1 < MAXX; ++i) {
      if(i != res) break;
      for(int j = 0; j < n; ++j) {
        for(int k = 0; k < n; ++k) {
          for(int l = 0; l < n; ++l) {
            dp[i+1][k][l] = min(dp[i+1][k][l], dp[i][j][k] + G[j][k][l]);
            if(dp[i+1][k][l] < r + eps) {
              res = i + 1;
            }
          }
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 35836
#include<bits/stdc++.h>
#define For(i,j,k) for(int i=j;i<=k;++i)
#define Forr(i,j,k) for(int i=j;i>=k;--i)
#define ll long long 
using namespace std;
const int N=200010,M=200010,INF=0x3f3f3f3f;
template<class T>void read(T &x){
	x=0;char c=getchar();
	while(!isdigit(c))c=getchar();
	while( isdigit(c))x=x*10+c-48,c=getchar();
}
inline void file(){
#ifndef ONLINE_JUDGE
	freopen("test.in","r",stdin);
	freopen("test.out","w",stdout);
#endif 
}
struct Segment_tree{
	#define lc h<<1
	#define rc h<<1|1
	#define Mid ((l+r)>>1)
	#define Lc lc,l,Mid
	#define Rc rc,Mid+1,r
	ll Sum[N<<2],Add[N<<2],Max[N<<2],Sum1[N<<2],Max1[N<<2];
	inline void Pushup(int h){
		Sum[h]=Sum[lc]+Sum[rc];
		Max[h]=max(Max[lc],Max[rc]);
		Sum1[h]=Sum1[lc]+Sum1[rc];
		Max1[h]=max(Max1[lc],Max1[rc]);
	}
	inline void Pushdown(int h,int l,int r){
		if(Add[h]){
			Sum[lc]+=Add[h]*(Mid-l+1),Sum[rc]+=Add[h]*(r-Mid);
			Sum1[lc]+=Add[h]*(Mid-l+1),Sum1[rc]+=Add[h]*(r-Mid);
			
			Add[lc]+=Add[h],Add[rc]+=Add[h];
			Max[lc]+=Add[h],Max[rc]+=Add[h];
			Max1[lc]+=Add[h],Max1[rc]+=Add[h];
			Add[h]=0;
		}
	}	
	void Build(int h,int l,int r,int n){
		if(l==r)return void (Max[h]=Sum[h]=-(n-l+1));
		Build(Lc,n),Build(Rc,n);
		Pushup(h);
	}
	void Modify(int h,int l,int r,int L,int R){
		if(L<=l&&r<=R){
			Add[h]+=1,Sum[h]+=r-l+1,Max[h]+=1;
			Max1[h]+=1,Sum1[h]+=r-l+1;
			return ;
		}
		Pushdown(h,l,r);
		if(L<=Mid)Modify(Lc,L,R);
		if(R>Mid)Modify(Rc,L,R);
		Pushup(h);
	}
	ll Query(int h,int l,int r,int L,int R){
		if(L<=l&&r<=R)return Max[h];
		Pushdown(h,l,r);
		ll ans=0;
		if(L<=Mid)ans=max(ans,Query(Lc,L,R));
		if(R>Mid)ans=max(ans,Query(Rc,L,R));
		return ans;
	}
}t;
struct node{
	int x,y;
	bool operator <(const node &r)const {
		return x<r.x;
	}
}P[N];
int n,m;
void init(){
	read(n),read(m);
	For(i,1,n)
		read(P[i].x),read(P[i].y);
	sort(P+1,P+n+1);
}
void solve(){
	ll ans=0;
	t.Build(1,1,m+1,m);
	For(i,1,n){
		t.Modify(1,1,m+1,1,P[i].y);
		ans=max(ans,t.Query(1,1,m+1,P[i].x+1,m+1)-P[i].x);
		ans=max(ans,t.Max1[1]-m);
		//printf("%d\n",t.Max1[1]);
	}
	printf("%lld\n",ans);
}
int main(){
	init();
	solve();
	return 0;
}


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

using namespace std;
string res[] = {
	"Close",
	"Open",
	"Close",
	"faaa",
	"Close",
	"faaaa",
	"Open"
};

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int x = a * 4 + b * 2 + c;
	cout << res[x] << endl;
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
#define bitcnt(v) __builtin_popcount(v)
#define all(v) v.begin(), v.end()

int mod = 1e9 + 7;

void solution(){

	int x; cin >> x;
	cout << (x+1)%2 << endl;





}	


int main(){ 
	fio;
	int t;
	t = 1;
	// cin >> t;
	for(int i = 1; i <= t; i++){
		// cout << "Case #" << i << ": ";
		solution();
	} 
	return 0;
}

Measured memory_bytes: 3648
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long ans = 0;
            for (int i = 1; i <= n; i++)
                if (i % 3 != 0 && i % 5 != 0)
                    ans += i;
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



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

Measured memory_bytes: 256
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
N, X = map(int, input().split())
xlist =[X]
xlist.extend(list(map(int, input().split())))
dlist =[]
for i in range(N):
    dlist.append(abs(xlist[i+1]-xlist[i]))
g = max(dlist)
for d in dlist:
    g = gcd(g, d)
print(g)


Measured memory_bytes: 14480
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int n, k; scan(n, k);
    string s = read!string;

    auto a = s.array;
    a[k-1] = a[k-1].toLower();
    writeln(a);
}


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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (n); i < (a); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  string a,b,c;cin>>a>>b>>c;
  cout<<(char)(a[0]-32);
  cout<<(char)(b[0]-32);
  cout<<(char)(c[0]-32);
  cout<<endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	N := nextInt()
	L := map[int]int{}
	R := map[int]int{}

	for i := 0; i < N; i++ {
		a := nextInt()

		n, ok := L[i-a]
		if !ok {
			n = 0
		}
		n++
		L[i-a] = n

		n, ok = R[i+a]
		if !ok {
			n = 0
		}
		n++
		R[i+a] = n
	}

	c := 0
	for n1, v1 := range L {
		v2, ok := R[n1]

		if ok {
			c += v1 * v2
		}
	}

	fmt.Println(c)
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 23780