akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e6+6;


int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	int n,l,r;
	
	cin>>n>>l>>r;
	
	for(int i=l;i<=r;++i) if(i%n==0){
		cout<<"OK";
		return 0;
	}
	
	cout<<"NG";
	
	
	return 0;
}


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

using namespace std;

using int64 = long long;
const int64 INF = 1LL << 60;

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename G >
struct StronglyConnectedComponents {
  const G &g;
  UnWeightedGraph gg, rg;
  vector< int > comp, order, used;

  StronglyConnectedComponents(G &g) : g(g), gg(g.size()), rg(g.size()), comp(g.size(), -1), used(g.size()) {
    for(int i = 0; i < g.size(); i++) {
      for(auto e : g[i]) {
        gg[i].emplace_back((int) e);
        rg[(int) e].emplace_back(i);
      }
    }
  }

  int operator[](int k) {
    return (comp[k]);
  }

  void dfs(int idx) {
    if(used[idx]) return;
    used[idx] = true;
    for(int to : gg[idx]) dfs(to);
    order.push_back(idx);
  }

  void rdfs(int idx, int cnt) {
    if(comp[idx] != -1) return;
    comp[idx] = cnt;
    for(int to : rg[idx]) rdfs(to, cnt);
  }

  bool build(UnWeightedGraph &t) {
    for(int i = 0; i < gg.size(); i++) dfs(i);
    reverse(begin(order), end(order));
    int ptr = 0;
    for(int i : order) if(comp[i] == -1) rdfs(i, ptr), ptr++;

    t.resize(ptr);
    for(int i = 0; i < g.size(); i++) {
      for(auto &to : g[i]) {
        int x = comp[i], y = comp[to];
        if(x == y) return true;
        t[x].push_back(y);
      }
    }
    return false;
  }
};

int main() {
  int N, M;
  string S;

  cin >> N >> M;
  cin >> S;
  UnWeightedGraph g(4 * N);
  for(int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    for(int j = 0; j < 2; j++) {
      if(S[x] == S[y]) {
        if(S[x] == 'A') g[x].emplace_back(y + N);
        else g[x + N + N].emplace_back(y + N + N + N);
      } else {
        if(S[x] == 'A') g[x + N].emplace_back(y + N + N);
        else g[x + N + N + N].emplace_back(y);
      }
      swap(x, y);
    }
  }
  StronglyConnectedComponents< UnWeightedGraph > scc(g);
  UnWeightedGraph t;
  if(scc.build(t))cout << "Yes\n";
  else cout << "No\n";
}


Measured memory_bytes: 105332
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

ll groupingRec(vector<vector<ll>> &arr, int n, int mask, vector<ll> &dp,
               vector<ll> &scores){

    if(dp[mask] != -1)
        return dp[mask];
    // Pick a non-empty subset of not chosen rabbits among 2^n possible subsets
    // and take that as one group
    ll ans = 0;
    // We only go to all the valid subsets
    // (the subsets having only not chosen elements)
    for(int group = mask; group>0; group=(group-1)&mask){
            ll currGroupScore = scores[group];
            // Mark the bits of current group as 0 in the mask
            // indicating that we have picked these elements
            ll currRecAns = groupingRec(arr, n, mask^group, dp, scores) +
                            currGroupScore;
            if(currRecAns > ans)
                ans = currRecAns;

    }
    dp[mask] = ans;
    return ans;
}

void precalculateScores(vector<vector<ll>> &arr, int n, vector<ll> &scores){

    // Store the score for every group combinations

    for(int group=0; group<(1<<n); group++){
        ll score = 0;
        for(int i=0; i<n; i++)
            if((group&(1<<i)))
                for(int j=i+1; j<n; j++)
                    if((group&(1<<j)))
                        score += arr[i][j];
        scores[group] = score;
    }
}


ll grouping(vector<vector<ll>> &arr, int n){

    // O(3^n)
    // Earlier, In the recursive function,
    // we were going to all the 2^n subsets
    // regardless of whether the elements in those subsets are available
    // to use or not
    // We denote the unused elements as '1' in the bit (instead of 0)
    // For eg: if we have mask = 00001011  (total 8 elements)
    // Here the bits at position 0, 1, 3 are set meaning we can currently
    // pick these elements and make groups (or subsets) using these elements
    // Earlier we would go to all the 2^8 subsets and check
    // if all the elements in those subsets are unused or not
    // But instead of going to all the 2^n subsets,
    // we can also directly go to all the 2^k subsets
    // (where k is the no. of set bits)
    // So in the above case, we can go to all the 2^3 subsets (instead of 2^8)
    // and that is beneficial for us because out of 2^8 subsets
    // only 2^3 subsets will be valid and we directly go to all the valid subsets

    // Consider following segment of code:

    // for(int mask=0; mask<(1<<n); mask++)
    //      for(int group=mask; group>0; group = (group-1)&mask)
    //          // Do something

    // The time complexity of this segment of code will be O(3^n)
    // Refer to: https://codeforces.com/blog/entry/45223 --> Suboptimal solution


    vector<ll> dp(1<<n, -1);
    vector<ll> scores(1<<n);
    precalculateScores(arr, n, scores);
    // Initially set all the bits (those will be unused elements)
    ll ans = groupingRec(arr, n, (1<<n)-1, dp, scores);
    return ans;
}

int main()
{
 int n;
 cin>>n;
 vector<vector<ll>> arr(n, vector<ll>(n));
 for(int i=0; i<n; i++)
    for(int j=0; j<n; j++)
        cin>>arr[i][j];
 ll ans = grouping(arr, n);
 cout<<ans;
 return 0;
}



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


int main(){
    #ifdef LOCAL_MACHINE
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif
    
    int n,m;
    scanf("%d %d",&n,&m);

    for(int i=0;i<m;i++){
        int x;
        scanf("%d",&x);

        n-=x;
    }    

    if(n<0)n=-1;
    printf("%d\n",n);
      
    
    return 0;
}


Measured memory_bytes: 3828
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
const int mod= 1e+9+7;

int main() {
    int N,M; cin>>N>>M;
    int ans = N*(N-1)/2+M*(M-1)/2;
    cout<<ans<<endl;
}



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

	string s[n];

	for(int  i = 0;i<n;i++)
		cin>>s[i];

	for(int  i = 0;i<n;i++)
	{
		 for(int j = 0;j<m;j++)
		 {
		 	if(s[i][j]=='#')
		 		continue;

		 	s[i][j] = '0';
            
            if(i+1 < n && j+1 < m && s[i+1][j+1]=='#')
            	s[i][j]++;

            if(i+1 < n && j < m && s[i+1][j]=='#')
            	s[i][j]++;

            if(i+1 < n && j-1 >=0 && s[i+1][j-1]=='#')
            	s[i][j]++;

            if(i < n && j-1 >=0 && s[i][j-1]=='#')
            	s[i][j]++;

            if(i-1 >= 0  && j-1 >= 0 && s[i-1][j-1]=='#')
            	s[i][j]++;

            if(i-1 >= 0 && j < m && s[i-1][j]=='#')
            	s[i][j]++;

            if(i-1 >= 0 && j+1 < m && s[i-1][j+1]=='#')
            	s[i][j]++;

            if(i < n && j+1 < m && s[i][j+1]=='#')
            	s[i][j]++;

		 }
	}



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

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=15;
const int a[11]={0,1,2,4,7,12,20,29,38,52,73};

int read()
{
	int s=0;
	char c=getchar(),lc='+';
	while (c<'0'||'9'<c) lc=c,c=getchar();
	while ('0'<=c&&c<='9') s=s*10+c-'0',c=getchar();
	return lc=='-'?-s:s;
}
void write(int x)
{
	if (x<0)
	{
		putchar('-');
		x=-x;
	}
	if (x<10) putchar(x+'0');
	else
	{
		write(x/10);
		putchar(x%10+'0');
	}
}
void print(int x,char c='\n')
{
	write(x);
	putchar(c);
}
int e[N][N],p[N];

signed main()
{
	memset(e,0,sizeof(e));
	int n=read(),Max=0;
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<i;j++) e[i][j]=e[j][i]=a[j]*(Max+1);
		for (int j=1;j<=i;j++) p[j]=j;
		do
		{
			int sum=0;
			for (int j=1;j<i;j++) sum+=e[p[j]][p[j+1]];
			Max=max(Max,sum);
		}while (next_permutation(p+1,p+i+1));
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=n;j++) print(e[i][j],' ');
		putchar('\n');
	}

	return 0;
}

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

int main() {
    ios_base::sync_with_stdio(0);
	cin.tie(nullptr);
    ll n,k;
    cin >> n >> k;
    ll ans = 0;
    ans = k;
    ans *= pow(k-1,n-1);
    cout << ans;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC141E
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            int ans = 0;
            for (int k = 1; k <= N / 2; k++)
            {
                string n = s.Substring(N - k) + s.Substring(0, N - k);

                int[] count = new int[N + 1];
                for (int i = 0; i < N; i++)
                {
                    if (s[i] == n[i]) count[i + 1] = count[i] + 1;
                    if (i == k && count[i + 1] > 0) count[i + 1] = 1;
                }

                int cand = Math.Min(count.Max(), k);
                ans = Math.Max(ans, cand);
            }

            Console.WriteLine(ans);
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


Measured memory_bytes: 34932
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
	int n,ans =0;
	cin >> n;
	vector<string> color(n);
	for (int i = 0; i < n; i++) {
		cin >> color.at(i);
	}
	for (int i = 0; i < n; i++) {
		if (color.at(i) == "Y") {
			ans = 1;
		}
	}
	if (ans == 0) cout << "Three" << endl;
	else if (ans == 1) cout << "Four" << endl;
	else cout << "" << endl;

	return 0;
}

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

using namespace std;

int main() {
    int a, b, q;
    cin >> a >> b >> q;

    using ll = long long;

    const ll inf = 1LL << 60;

    vector<ll> s(a + 2), t(b + 2);

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

    s[0] = -inf;
    s[a + 1] = inf;

    for (int i = 1; i <= b; i++) {
        cin >> t[i];
    }

    t[0] = -inf;
    t[b + 1] = inf;

    for (int i = 0; i < q; i++) {
        ll x;
        cin >> x;

        auto it1 = lower_bound(s.begin(), s.end(), x);

        ll ss[2] = {*(it1 - 1), *it1};

        auto it2 = lower_bound(t.begin(), t.end(), x);

        ll tt[2] = {*(it2 - 1), *it2};

        ll ans = inf;

        for (int j = 0; j < 2; j++) {
            for (int k = 0; k < 2; k++) {
                ans = min(ans, abs(x - ss[j]) + abs(ss[j] - tt[k]));
                ans = min(ans, abs(x - tt[k]) + abs(tt[k] - ss[j]));
            }
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 2944
import sys
input = sys.stdin.buffer.readline
N,K= map(int,input().split())
x= list(map(int,input().split()))

cand = []
for i in range(N-K+1):
    l = i
    r = i+K-1
    if x[r]<0:
        cand.append(abs(x[l]))
    elif x[l] > 0:
        cand.append(abs(x[r]))
    else:
        cand.append(2*abs(x[l]) + abs(x[r]))
        cand.append(abs(x[l]) + 2*abs(x[r]))
print(min(cand))






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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 500

int H, W;
vector<string> S;

int pos_to_id[MAX_N][MAX_N];
pair<int, int> id_to_pos[MAX_N];

int Dist[MAX_N][MAX_N];
int V;

void connect(int i, int j) {
    if(i > 0) {
        int next_i = i - 1;
        int next_j = j;
        if(S[next_i][next_j] == '.') {
            Dist[pos_to_id[i][j]][pos_to_id[next_i][next_j]] = 1;
            Dist[pos_to_id[next_i][next_j]][pos_to_id[i][j]] = 1;
        }
    }
    if(i < H - 1) {
        int next_i = i + 1;
        int next_j = j;
        if(S[next_i][next_j] == '.') {
            Dist[pos_to_id[i][j]][pos_to_id[next_i][next_j]] = 1;
            Dist[pos_to_id[next_i][next_j]][pos_to_id[i][j]] = 1;
        }
    }
    if(j > 0) {
        int next_i = i;
        int next_j = j - 1;
        if(S[next_i][next_j] == '.') {
            Dist[pos_to_id[i][j]][pos_to_id[next_i][next_j]] = 1;
            Dist[pos_to_id[next_i][next_j]][pos_to_id[i][j]] = 1;
        }
    }
    if(j < W - 1) {
        int next_i = i;
        int next_j = j + 1;
        if(S[next_i][next_j] == '.') {
            Dist[pos_to_id[i][j]][pos_to_id[next_i][next_j]] = 1;
            Dist[pos_to_id[next_i][next_j]][pos_to_id[i][j]] = 1;
        }
    }
}

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

    cin >> H >> W;
    S.resize(H);
    REP(i, H) {
        cin >> S[i];
    }

    MINUS(pos_to_id);
    int node_size = 0;
    int root = -1;
    REP(i, H) {
        REP(j, W) {
            if(S[i][j] == '.') {
                pos_to_id[i][j] = node_size;
                id_to_pos[node_size] = make_pair(i, j);
                node_size++;
            }
        }
    }

    V = node_size;
    REP(i, V) {
        REP(j, V) {
            Dist[i][j] = (i==j) ? 0 : LLINF;
        }
    }
    REP(i, H) {
        REP(j, W) {
            if(S[i][j] == '.') {
                connect(i, j);
            }
        }
    }
    REP(k, V) {
        REP(i, V) {
            REP(j, V) {
                Dist[i][j] = min(Dist[i][j], Dist[i][k] + Dist[k][j]);
            }
        }
    }

    int ans = 0;
    REP(i, V) {
        REP(j, V) {
            ans = max(ans, Dist[i][j]);
        }
    }

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 3840
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
#include <assert.h>

using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef  unsigned long long  ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;

ll inf=(ll)2e18;
const int mod=1000000007;
//const int mod=998244353;

int n,m;
const int N=2e5+10;




int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    int q,t,k,u,v;
    ll x,a,b,c,d,y,p,z;
    cin >> a >> b >> c;
    cin >> k;
    while(k&&b<=a){
        b*=2;
        k--;
    }
    while(k&&c<=b){
        c*=2;
        k--;
    }
    if(a<b&&b<c){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
    return 0;
}






Measured memory_bytes: 3636
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define inf INT_MAX/3
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 3.141592653589793
#define in scanf
#define out printf
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define FOR(i,a,b) for( int i=(a),_b=(b);i<=_b;i++)
#define DOW(i,b,a) for( int i=(b),_a=(a);i>=_a;i--)
#define sz size()
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
#define N 20000009
bool prime[N];
vector<ll> prm;
void seive ()
{

    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {
        if (prime[i] == true)
        {
            prm.pb(i);
            for (ll j=i*i; j<=N; j += i)
                prime[j] = false;
        }
    }
}
void pr (int f)
{
    if(f==1)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}
map<int,int>mp;
set<int> s;

int main()
{
    fast;

    int n, t;
    cin >> n >> t;

    vector <int> c(n);
    vector <int> tt(n);

    for(int i = 0; i < n; i++)
    {
        cin >> c[i] >> tt[i];
    }

    int min = *max_element(c.begin(), c.end()) + 1;
    int mn = min;
    for(int i = 0; i < n; i++)
    {
        if (tt[i] <= t)
        {
            if (min >= c[i])
            {
                min = c[i];
            }
        }
    }
    if (min != mn)
    {
        cout << min << endl;
    }
    else
    {
        cout << "TLE" << endl;
    }
    return 0;
}



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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int n;

int fib(int x, int y, int i){
	if(i == n) return x+y;
	i++;
	fib(y, x+y, i);
}

int main(){
	cin >> n;
	if(n == 1 || n == 0){
		cout << 1 << endl;
		return 0;
	}
	cout << fib(1, 1, 2) << endl;
}



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

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

using namespace std;


int main()
{
	int A,B,X;
	cin>>A>>B>>X;
	
	if((A<=X) and (A+B>=X)){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	
	
	
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
//#define uint __int128_t
 
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))-(a).begin()
#define upp(a,b) upper_bound(all(a),(b))-(a).begin()
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;


int L,N;
int a[200020];
int b[200020];
int suma[200020];
int sumb[200020];
int ans=0;

signed main() {
    IOS();
    //(1ll<<N)シフト演算のオーバーフローに気をつける
    cin>>L>>N;
    rep(i,1,N+1){
        cin>>a[i];
    }
    rep(i,1,N+1){
        b[i]=L-a[N-i+1];
        a[N-i+1]*=2;
        b[i]*=2;
    }
    rep(i,0,N){
        suma[i+1]=suma[i]+a[i+1];
        sumb[i+1]=sumb[i]+b[i+1];
    }
    
    int ma=suma[N/2]+sumb[N-N/2],sum=0;
    if(N%2)ma-=b[N-N/2]/2;
    else ma-=a[N/2]/2;
    rep(i,0,N){
        sum=a[i+1];
        int nokori=N-i-1;
        int tmp=sum+suma[i+1+nokori/2]-suma[i+1]+sumb[nokori-nokori/2];
        //cout<<sum<<" "<<suma[i+1+nokori/2]<<" "<<suma[i+1]<<" "<<sumb[nokori-nokori/2]<<endl;
        if(nokori%2)tmp-=b[nokori-nokori/2]/2;
        else tmp-=a[i+1+nokori/2]/2;
        chmax(ma,tmp);
        //cout<<ma<<endl;
    }
    ans=ma;
    
    swap(a,b);
    swap(suma,sumb);
    ma=suma[N/2]+sumb[N-N/2]-b[N-N/2+1]/2;
    if(N%2)ma-=b[N-N/2]/2;
    else ma-=a[N/2]/2;
    rep(i,0,N){
        sum=a[i+1];
        int nokori=N-(i+1);
        int tmp=sum+suma[i+1+nokori/2]-suma[i+1]+sumb[nokori-nokori/2];
        //cout<<sum<<" "<<suma[i+1+nokori/2]<<" "<<suma[i+1]<<" "<<sumb[nokori-nokori/2]<<endl;
        if(nokori%2)tmp-=b[nokori-nokori/2]/2;
        else tmp-=a[i+1+nokori/2]/2;
        chmax(ma,tmp);
        //cout<<ma<<endl;
    }
    cout<<max(ans,ma)<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
char a[500];
int main()
{
	cin>>a;
	int ls=strlen(a);
	for(int i=0;i<ls-1;i++)
	{
		for(int j=i+1;j<ls;j++)
		{
			if(a[i]=='C' && a[j]=='F')
			{
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
	return 0;
} 

Measured memory_bytes: 256
#include <cstdio>
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main(void){
//////////////////////////////////////////////////////

int N;
scanf("%d",&N);
int A[N],B[N];
rep(i,N){
	scanf("%d",&A[i]);
}
rep(i,N){
	B[A[i]-1]=i+1;
}
rep(i,N){
	printf("%d ",B[i]);
}

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 1536
N = int(input())
S = input()

e = [0] * (N+1)
w = [0] * (N+1)

for i in range(1,N+1):
    if S[i-1] == 'W':
        w[i] = w[i-1]+1
    else:
        w[i] = w[i-1]
for i in reversed(range(N)):
    if S[i] == 'E':
        e[i] = e[i+1]+1
    else:
        e[i] = e[i+1]

ans = N+1
for i in range(N):
   if e[i+1] + w[i] < ans:
       ans = e[i+1] + w[i]

print(ans)


Measured memory_bytes: 17640
program ec12;
var 
	n,m,i,j,sum:longint;
	t:array[0..101] of longint;
	a:array[1..101] of longint;
begin 
	fillchar(t,sizeof(t),0);
	readln(n);
	sum:=0;
	for i:=1 to n do
	begin 
		readln(a[i]);
		inc(t[a[i]]);
		sum:=sum+a[i];
	end;
	if sum mod 10>0 then 
	begin 
		writeln(sum);
		halt;
	end;
	for i:=1 to 100 do 
	begin 
		if (t[i]>0) and (i mod 10>0) then 
		begin 
			writeln(sum-i);
			halt;
		end;
	end;
	writeln(0);
end. 

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int D = sc.nextInt();
    int X = sc.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
    }
    int[] num = new int[D + 1];
    for (int i = 0; i < N; i++) {
      for (int j = 0; j * A[i] + 1 <= D; j++) {
        num[j * A[i] + 1]++;
      }
    }
    int count = X;
    for (int i = 1; i <= D; i++) {
      count += num[i];
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 21972
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""

from collections import defaultdict
import sys
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def round_up(a, b):
    """ a/b の切り上げ """
    c = (a + b - 1) / b
    return c


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def floor(a, b):
    """floor(a/b) 整数値を返す"""
    c = (a - a % b)/b
    return int(c)


def main():
    n = int(input())
    a = wi()
    L = defaultdict(int)
    R = defaultdict(int)
    for i in range(n):
        L[i + a[i]] += 1
        R[i - a[i]] += 1
    ans = 0
    for i in L:
        ans += L[i] * R[i]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 164740
// https://atcoder.jp/contests/abc071/tasks/abc071_b
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    set<char> st;
    for (auto &x : s) {
        st.insert(x);
    }
    char c = 'a';
    while (c <= 'z') {
        if (st.count(c) == 0) {
            cout << c << endl;
            return 0;
        }
        c++;
    }
    cout << "None\n";
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
}
const ll M=1e9+7;
int n;
ll a[202020],s=0,ans=0; 
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	cin>>n;
	fo(i,0,n)cin>>a[i],s+=a[i];
	fo(i,0,n)ans=(ans+(s-a[i])%M*a[i]%M)%M;
	if(ans%2==0)cout<<ans/2<<endl;
	else cout<<(ans+M)/2<<endl;
	return 0;
}


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

int main() {
  vector<int> A(3);
  cin >> A[0] >> A[1] >> A[2];
  sort(A.begin(), A.end());
  
  cout << A[2]*10 + A[1] + A[0] << endl;
  
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <iomanip>


using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define dump(x)  cout << #x << " = " << (x) << endl;

#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
//             0123456789 - digits. check the limits, int vs long
const int MX = 100001;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(6);
    cout << std::fixed;
    // freopen("ex.in","r",stdin);
    // freopen("ex.out","w",stdout);
    int n;
    cin >> n;
    vpi a;
    int x;
    for (int i=0; i< n; i++) {
        cin >> x;
        a.push_back({x, i + 1});
    }
    sort(a.begin(), a.end());
    for (auto u : a) {
        cout << u.second << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1780
// Last Change: 08/18/2019 21:25:06.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll N;
  cin >> N;
  vector<double> v(N);
  for (auto &&e : v) {
    cin >> e;
  }
  sort(v.begin(), v.end());
  double ans = v[0];
  for (ll i = 1; i < N; ++i) {
    ans = (ans + v[i]) / 2;
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
n = int(input())
b = int(n / 3)
c = int(n / 5)
d = int(n / 15)
a = (n * (n + 1) / 2) - (b * (b + 1) / 2) * 3 - (c * (c + 1) / 2) * 5 + (d * (d + 1)/ 2) * 15
print(int(a))

Measured memory_bytes: 9112
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;



int main() {
	int i, n;
	cin >> n;
	vector<int> a(n);
	for (i = 0; i < n; i++)cin >> a[i];

	int mod04 = 0, even = 0, odd = 0;
	for (i = 0; i < n; i++) {
		if (a[i] % 2 == 1)odd++;
		if (a[i] % 4 == 0)mod04++;
		else {
			if (a[i] % 2 == 0)even++;
		}
	}
	bool flag = false;

	if (even == 0) {
		if (mod04 + 1 >= odd) flag = true;
		else flag = false;
	}
	else {
		if (mod04 >= odd) flag = true;
		else flag = false;
	}

	cout << ((flag) ? "Yes" : "No") << endl;
	
	return 0;
}

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

vector<vector<long long> >dp;
vector<int>v,w;
void solve(){
	int n,wt;cin>>n>>wt;
	v.resize(n);
	w.resize(n);
	dp.resize(n,vector<long long>(wt+1,-1));
	for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
	}
	for(int i=0;i<w[0];i++){
        dp[0][i]=0;
	}
	for(int i=w[0];i<=wt;i++){
        dp[0][i]=v[0];
	}
	for(int i=1;i<n;i++){
        for(int j=0;j<=wt;j++){
            long long mx = dp[i-1][j];
            if(j>=w[i]){
                mx =  max(mx,dp[i-1][j-w[i]]+v[i]);
            }
            dp[i][j]=mx;
        }
	}
	cout <<dp[n-1][wt]<<"\n";
}
int main(){
	int t=1;//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 79488
import sys
input = sys.stdin.readline


def dfs(V, start):
    q = [(start, 0)]
    used = [False] * (n+1)
    farthest = 0
    pos = 0

    while q:
        s, cost = q.pop()
        if farthest < cost:
            pos = s
            farthest = cost
        used[s] = True
        for t, c in V[s].items():
            if used[t]:
                continue
            q.append((t, cost + c))
    
    return farthest, pos


if __name__ == "__main__":
    n = int(input())
    V = {i:dict() for i in range(1, n+1)}

    for _ in range(n - 1):
        s, t = map(int, input().split())
        V[s][t] = 1
        V[t][s] = 1

    if n==1:
        print("First")
    else:
        d = dfs(V, dfs(V, 1)[1])[0]
        if d==1:
            print("Second")
        elif d==2:
            print("First")
        elif (d-1)%3==0:
            print("Second")
        else:
            print("First")


Measured memory_bytes: 122020
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  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);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main() {
  string s;
  cin >> s;
  int n = s.size();
  vector<int> ans(n);
  REP(ri, 2) {
    int count = 0;
    REP(i, n) {
      if (s[i] == 'R')
        count++;
      else {
        ans[i] += count / 2;
        ans[i - 1] += (count + 1) / 2;
        count = 0;
      }
    }
    reverse(ALL(ans));
    reverse(ALL(s));
    REP(i, n) {
      if (s[i] == 'L')
        s[i] = 'R';
      else
        s[i] = 'L';
    }
  }
  REP(i, n) { cout << ans[i] << endl; }
  return 0;
}

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

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

const int MOD = 1e9 + 7;
const int INFi = 2e9 + 1;
const lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(i, vec) for(auto &(i) : (vec))


template <class T> inline int argmin(vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


int main(void){
  lli x, q, p; cin >> x;
  p = x / 11; q = x % 11;
  if(q == 0) cout << 2 * p << "\n";
  else cout << (2 * p + 1) + (q > 6) << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	string a,b;
	int i;
	cin>>a>>b;
	for(i=0;i<a.size();i++){
		cout<<a[i];
		if(a.size()==b.size()||i+1<a.size()){
			cout<<b[i];
		}
	}
	return 0;
}

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

#define ALL(a) (a).begin(), (a).end()
#define FOR(i, a ,b) for(int i = int(a); i < int(b); ++i)
#define REP(i, a) FOR(i, 0, a)
#define RFOR(i, a, b) for(int i = int(b)-1; i >= int(a); --i)
#define RREP(i,a) RFOR(i, 0, a)
#define IN(a, x , b) (a <= x && x <= b)
template<class T> inline void CHMIN(T& a, T& b){if(a<b)a=b;}
template<class T> inline void CHMAX(T& a, T& b){if(a>b)a=b;}

using ll = long long;

template<class T> using V = std::vector<T>;



int main(){
  string s,t;
  cin>>s>>t;
  vector<vector<int>>ssum(s.size()+1,vector<int>(26,0)),tsum(t.size()+1,vector<int>(26,0));
  REP(i,s.size()){
    REP(j,26){
      ssum[i+1][j]+=ssum[i][j]+(s[i]-'a'==j);
    }
  }
  REP(i,t.size()){
    REP(j,26){
      tsum[i+1][j]+=tsum[i][j]+(t[i]-'a'==j);
    }
  }
  int lim = min(s.size(),t.size());
  RFOR(i,1,lim+1){
    set<vector<int>>st;
    REP(j,(int)s.size()-i+1){
      std::vector<int> tmp(26,0);
      REP(k,26){
        tmp[k]=ssum[j+i][k]-ssum[j][k];
      }
      st.insert(tmp);
    }
    REP(j,(int)t.size()-i+1){
      std::vector<int> tmp(26,0);
      REP(k,26){
        tmp[k]=tsum[j+i][k]-tsum[j][k];
      }
      if(st.count(tmp)){
        cout<<i<<endl;
        return 0;
      }
    }
  }
  cout<<0<<endl;
}



Measured memory_bytes: 4796
n,m=map(int,input().split())
X=sorted(list(map(int,input().split())))

A=[]
for i in range(m-1):
    A.append(abs(X[i]-X[i+1]))

A.sort()
ans=0
for i in range(m-n):
    ans +=A[i]
print(ans)

Measured memory_bytes: 13968
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
  #define pb push_back
#define f first
#define s second
  #define MAXN 100005
using namespace std;
int n;
int arr[MAXN],dp[MAXN];
/*
   int solve(int i){
        if(i>=n) {
                return 1e9;
        }
        if(i==n-1) {
                return 0;
        }
        int cost1=abs(arr[i+1]-arr[i]);

        int cost2=abs(arr[i+2]-arr[i]);
        if(dp[i]!=-1) return dp[i];
        return dp[i]=min(cost1+solve(i+1),cost2+solve(i+2));
   }
 */
int main()
{
	std::ios::sync_with_stdio(false);

	cin>>n;
	int k;
	cin>>k;

	for(int i=0; i<n; i++) cin>>arr[i];
	for(int i=0; i<n; i++) dp[i]=(int)1e9;
	dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);
	for(int i=2; i<n; i++) {
		for(int j=1; j<=k; j++) {
			if(i-j>=0)
				dp[i]=min(dp[i],dp[i-j]+abs(arr[i-j]-arr[i]));
		}

	}
	cout<<dp[n-1]<<endl;
	return 0;
}


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

int main() {
	int n;
	cin >> n;
	int arr[n];
	
	for(int i=0;i<n;i++)
	cin >> arr[i];
	
	int dp[n];
	memset(dp,0,sizeof dp);
	
	for(int i=1;i<n;i++)
	{
		dp[i]=abs(arr[i]-arr[i-1])+dp[i-1];
		if(i>1)
		{
			dp[i]=min(dp[i],abs(arr[i]-arr[i-2])+dp[i-2]);
		}
	}
	
	cout << dp[n-1] << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define mm(a,b) memset(a,b,sizeof(a))
#define ACCELERATE (ios::sync_with_stdio(false),cin.tie(0))
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<long long,long long>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#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 rush() int T;scanf("%d",&T);while(T--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define pf(x) printf("%d\n",x)
#define pf2(x,y) printf("%d %d\n",x,y)
#define pf3(x,y,z) printf("%d %d %d\n",x,y,z)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
#define E exp(1.0)
#define db double
#define ll long long
#define ld long double
#define ull unsigned long long
//#define io
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
//#define gc getchar
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
//inline int read()
//{
//    int ret=0,f=0;char c=gc();
//    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
//    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
//    if(f)return -ret;return ret;
//}
int a,b,c;
int main()
{
    #ifdef io
    freopen("in.txt","r",stdin);
    #endif
    cin>>a>>b>>c;
    if(b+c<=a)puts("0");
    else{
        int t=c-(a-b);
        cout<<t<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    #define int long long
    int n,m,s;
    cin>>n>>m>>s;
    int u[m],v[m],a[m],b[m];
    int ma=0;
    vector<vector<tuple<int,int,int>>>pas(n);//{vertex,cost,time}
    for(int i=0;i<m;i++){
        cin>>u[i]>>v[i]>>a[i]>>b[i];
        ma=max(ma,a[i]);
        pas[u[i]-1].emplace_back(v[i]-1,a[i],b[i]);
        pas[v[i]-1].emplace_back(u[i]-1,a[i],b[i]);
    }
    int lim=ma*n;
    int c[n],d[n];
    for(int i=0;i<n;i++)cin>>c[i]>>d[i];//{rate,time}
        int used[n][lim]={};
        vector<vector<int>>t(n,vector<int>(lim,1000000000000000000));
        t[0][min(s,lim-1)]=0;
        priority_queue<tuple<int,int,int>,vector<tuple<int,int,int>>,greater<tuple<int,int,int>>>q;//{time,vertex,money}
        q.push(make_tuple(0,0,min(s,lim-1)));
        while(q.size()){
            int time=get<0>(q.top());
            int x=get<1>(q.top());
            int money=get<2>(q.top());
            q.pop();
            if(used[x][money])continue;
            used[x][money]=1;
            q.push(make_tuple(time+d[x],x,min(money+c[x],lim-1)));
            for(int j=0;j<pas[x].size();j++){
                int y=get<0>(pas[x][j]);
                int cost=get<1>(pas[x][j]);
                int move_time=get<2>(pas[x][j]);
                if(money>=cost && time+move_time<t[y][money-cost] && used[y][money-cost]==0){
                    t[y][money-cost]=time+move_time;
                    q.push(make_tuple(time+move_time,y,money-cost));
                }
            }
        }
    for(int i=1;i<n;i++)cout<<*min_element(t[i].begin(),t[i].end())<<endl;
    return 0;
}


Measured memory_bytes: 8312
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
#include <cstdlib>
#include <bitset>
using namespace std;
int main(){
    string s;
    cin >> s;
    int l = s.length();
    int count = 0;
    for(int i = 0; i < l-1; i++){
        if(s[i] != s[i+1]) count++;
    }
    if(count != 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
}

ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
// Union Find
 
template<typename T>
struct UnionFind
{
	vector<T> par;
	vector<T> rank;
	vector<T> sizes;
	UnionFind(T n):par(n),rank(n,0),sizes(n,1){
	   for(T i=0;i<n;i++){
	     par[i]=i;
	   }
	}
	T root(T x){
	  return par[x]==x?x:par[x]=root(par[x]);
	}
 
	bool unite(T x,T y){
	  if(x==y) return false;
	  x=root(x); y=root(y);
	  if(x==y) return false;
	  if(rank[x]<rank[y]) swap(x,y);
	  if(rank[x]==rank[y]) rank[x]++;
	  par[y]=x;
	  sizes[x]=sizes[x]+sizes[y];
	  return true;
	}
	bool same(T x,T y){
	  return root(x)==root(y);
	}
	T size(T x){
	  return sizes[root(x)];
	}
};
struct edge{ ll u,v,cost;};
bool comp(const edge &e1, const edge &e2){
   return e1.cost<e2.cost;
}
int main(){
  ll n;
  cin>>n;
  vector<pll> x(n),y(n);
  rep(i,n){
    cin>>x[i].F>>y[i].F;
    x[i].S=i;
    y[i].S=i;
  }
  sort(all(x));
  sort(all(y));
  vector<edge> es(0);
  rep(i,n-1){
    edge k;
    k.u=x[i].S;
    k.v=x[i+1].S;
    k.cost=x[i+1].F-x[i].F;
    es.pb(k);
    k.u=y[i].S;
    k.v=y[i+1].S;
    k.cost=y[i+1].F-y[i].F;
    es.pb(k);
  }
  sort(all(es),comp);
  UnionFind<ll> uf(n);
  ll ans=0;
  rep(i,sz(es)){
    edge ee=es[i];
    if(!uf.same(ee.v,ee.u)){
      uf.unite(ee.u,ee.v);
      ans+=ee.cost;
    }
  }
  COUT(ans);
}

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

int main() {
  int a, b, c, k, ct=0;
  cin >> a >> b >> c >> k;
  while(a>=b){
    ct++;
    b*=2;
  }
  while(b>=c){
    ct++;
    c*=2;
  }
  if(ct<=k)cout << "Yes";
  else cout << "No";
  return 0;
}

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

int main() {
	int N, M, Q;
	std::cin >> N >> M >> Q;

	// 添え字は1から
	std::vector<std::vector<int>> answer(N + 2, std::vector<int>(N + 2, 0));

	std::vector<std::vector<int>> count(N + 2, std::vector<int>(N + 2, 0));
	for(int i = 0; i < M; i++) {
		int L, R;
		std::cin >> L >> R;
		count[L][R]++;
	}

	for(int dis = 0; dis < N; dis++) {
		for(int i = 1; i + dis <= N; i++) {
			const int l = i;
			const int r = i + dis;
			int ans = 0;
			// XXX: answer[1][0]とかは0によって処理
			ans += answer[l][r - 1];
			ans += answer[l + 1][r];
			ans -= answer[l + 1][r - 1];
			ans += count[l][r];
			//ans += std::count(LR.begin(), LR.end(), std::make_pair(l, r));
			answer[l][r] = ans;
		}
	}

	std::vector<int> p(Q);
	std::vector<int> q(Q);
	for(int i = 0; i < Q; i++) {
		std::cin >> p[i] >> q[i];
	}
	for(int i = 0; i < Q; i++) {
		std::cout << answer[p[i]][q[i]] << std::endl;
	}

	return 0;
}

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

int main() {
  int N, A;
  cin >> N;
  vector<int> boss(N);
  for (int i = 0; i < N - 1; i++){
    cin >> A;
    boss.at(A - 1)++;
  }
  for (int i = 0; i < N; i++){
    cout << boss.at(i) <<endl;
  }
  return 0;
}

Measured memory_bytes: 4048
n = int(input())
A = [int(input()) for _ in range(n)]
a = sorted(A)
i = 0
ans = 0
while i < n:
    if i == 0:
        if a[0] == a[1]:
            cnt = 2
            i = 2
            while i < n and a[i-1] == a[i]:
                cnt += 1
                i += 1
            ans += cnt%2
        else:
            ans += 1
            cnt = 1
            i = 2
            while i < n and a[i-1] == a[i]:
                cnt += 1
                i += 1
            ans += cnt%2
    else:
        cnt = 1
        i += 1
        while i < n and a[i-1] == a[i]:
            cnt += 1
            i += 1
        ans += cnt%2
print(ans)

Measured memory_bytes: 13896
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a<=b&&b<=c)cout<<a+b<<endl;
	else if(a<b&&c<b)cout<<a+c;
	else if(b<a&&c<a)cout<<c+b;
	else if(a<c&&b<c)cout<<a+b<<endl;
	else if(c<b&&a<b)cout<<c+b;
	return 0;
}

Measured memory_bytes: 256