akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#define _GLIBCXX_DEBUG
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    ll N, K;
    cin >> N >> K;
    ll ans;
    if(N==0){
        ans = 0;
    }
    else if(N > 0){
        if(N%K==0){
            ans = 0;
        }
        else{
            while(N >= K){
                ll nN1,nN2,nN;
                nN1 = abs(N - K);
                nN2 = N % K;
                if(nN1 < nN2){
                    nN = nN1;
                }
                else{
                    nN = nN2;
                }
                N = nN;
            }
            ll N1;
            N1 = abs(N-K);
            if(N1 < N){
                N =N1;
            }
            ans = N;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    for( int i = 0 ; i < s.length() ; i += 2 ) cout << s[i];
}




Measured memory_bytes: 592
#include<stdio.h>
#include<math.h>

typedef struct Node{
  double x;
  double y;
} Point;


void kock(int, Point ,Point);

int main(){
  int n;
  Point p1;
  Point p2;

  p1.x = 0;
  p1.y = 0;
  p2.x = 100;
  p2.y = 0;

  scanf("%d",&n);
  printf("%f %f\n",p1.x,p1.y);

  kock(n,p1,p2);
  printf("%f %f\n",p2.x,p2.y);
  return 0;
}
void kock(int n,Point p1,Point p2){
  Point s;
  Point t;
  Point u;

  if(n == 0) return;

  s.x = (2*p1.x + p2.x)/3;
  s.y = (2*p1.y + p2.y)/3;
  t.x = (p1.x + 2*p2.x)/3;
  t.y = (p1.y + 2*p2.y)/3;
  u.x = (t.x - s.x) * cos(M_PI/3) - (t.y - s.y) * sin(M_PI/3) + s.x;
  u.y = (t.x - s.x) * sin(M_PI/3) + (t.y - s.y) * cos(M_PI/3) + s.y;

  kock(n-1,p1,s);
  printf("%f %f\n",s.x,s.y);

  kock(n-1,s,u);
  printf("%f %f\n",u.x,u.y);

  kock(n-1,u,t);
  printf("%f %f\n",t.x,t.y);
  
  kock(n-1,t,p2);
}



Measured memory_bytes: 2060
#include <iostream>
#include <utility>
#include <string>
#include <deque>

using namespace std;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    deque<int> s;
    deque<pair<int, int> > l;
    string g;
    cin>>g;
    int sum=0;
    for(int i=0; i<g.length(); i++) {
        if(g[i]=='\\') s.push_back(i);
        else if(g[i]=='/' && !s.empty()) {
            int area = i-s.back();
            sum+=area;
            while(!l.empty() && s.back()<l.back().first) {
                area+=l.back().second;
                l.pop_back();
            }
            l.push_back(make_pair(s.back(), area));
            s.pop_back();
        }
    }
    cout<<sum<<'\n';
    cout<<l.size();
    for(int i=0; i<l.size(); i++) {
        cout<<' '<<l[i].second;
    }
    cout<<'\n';
    return 0;
}

Measured memory_bytes: 1328
#include<stdio.h>
int main(void){
    int month[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
    char week[7][10]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
    int x,y,i,day,WeekNum;
    while(1){
        day=0;
       scanf("%d %d",&x,&y);
       if(x==0)break;
        for(i=1;i<x;i++){
            day=day+month[i];
        }
        day=day+y;
        WeekNum=day%7;
        printf("%s\n",week[WeekNum]);
    }
    return 0;
}

Measured memory_bytes: 584
#include<stdio.h>
int main (void){
    int a,b,n,x,y,i,j,road[17][17];
    for(;;){
        scanf("%d%d",&a,&b);
        if(a==0&&b==0)break;
        for(i=0;i<17;i++){
            for(j=0;j<17;j++){
                road[i][j]=0;
                if(i>a)road[i][j]=2;
                if(j>b)road[i][j]=2;
            }
        }
        road[1][1]=1;
        scanf("%d",&n);
        for(i=0;i<n;i++){
            scanf("%d%d",&x,&y);
            road[x][y]=2;
        }
        for(i=1;i<=a;i++){
            for(j=1;j<=b;j++){
                if(road[i][j]!=2){
                    road[i][j]=road[i][j]+road[i][j-1]+road[i-1][j];
                }
                else road[i][j]=0;
            }
        }
        printf("%d\n",road[a][b]);
    }
return 0;
}

Measured memory_bytes: 600
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int M = scan.nextInt();
        UnionFind uf = new UnionFind(N);
        for (int i = 0; i < M; i++) {
            int A = scan.nextInt()-1;
            int B = scan.nextInt()-1;
            uf.unite(A, B);
        }
        int ans = 0;
        for (int i = 0; i < N; i++) {
            int size = uf.size(i);
            ans = Math.max(ans, size);
        }
        System.out.println(ans);
    }
    class UnionFind {
        int[] parent;
        int[] size;
        UnionFind(int N) {
            int[] parent = new int[N];
            for (int i = 0; i < N; i++) {
                parent[i] = i;
            }
            this.parent = parent;
            int[] size = new int[N];
            Arrays.fill(size, 1);
            this.size = size;
        }
        int parent(int x) {
            if (this.parent[x] == x) {
                return x;
            }
            return this.parent[x] = this.parent(this.parent[x]);
        }
        int size(int x) {
            int p_x = this.parent(x);
            return this.size[p_x];
        }
        void unite(int x, int y) {
            int p_x = this.parent(x);
            int p_y = this.parent(y);
            if (p_x == p_y) {
                return;
            }
            if (this.size[p_x] < this.size[p_y]) {
                this.size[p_y] += this.size[p_x];
                this.size[p_x] = -1;
                this.parent[p_x] = p_y;
                return;
            }
            this.size[p_x] += this.size[p_y];
            this.size[p_y] = -1;
            this.parent[p_y] = p_x;
        }
    }
}


Measured memory_bytes: 61140
def main10():
    buf = int(input(""));
    strbuf = input("");
    strbufs = strbuf.split();
    buf2 = [];
    for i in range(buf):
        buf2.append(int(strbufs[i]));
    if len(buf2) == 1:
        return("YES");
    else:
        ki = 0;
        for i in range(buf):
            if buf2[i] % 2 == 1:
                ki += 1;
        if ki % 2 == 0:
            print("YES");
        else:
            print("NO");



if __name__ == '__main__':
    main10()

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

using namespace std;

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const double PI = 3.14159265358979323846;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed

int N;
int W[110];

signed main() {
    cin >> N;
    for (int i = 1; i <= N; i++)cin >> W[i];
    int a = 0, b = 0;
    for (int i = 1; i <= N; i++)b += W[i];
    int ans = 1145141919;
    for (int i = 1; i < N; i++) {
        a += W[i], b -= W[i];
        ans = min(ans, abs(a - b));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

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

    def count_bigger(seq):
        cnt = 0
        for i in seq:
            for j in seq:
                if i < j:
                    cnt += 1
        return cnt

    # Python3 program to count inversions using
    # Binary Indexed Tree

    # Returns sum of arr[0..index]. This function
    # assumes that the array is preprocessed and
    # partial sums of array elements are stored
    # in BITree[].
    def getSum(BITree, index):
        sum = 0  # Initialize result

        # Traverse ancestors of BITree[index]
        while (index > 0):

            # Add current element of BITree to sum
            sum += BITree[index]

            # Move index to parent node in getSum View
            index -= index & (-index)

        return sum

    # Updates a node in Binary Index Tree (BITree)
    # at given index in BITree. The given value
    # 'val' is added to BITree[i] and all of its
    # ancestors in tree.
    def updateBIT(BITree, n, index, val):

        # Traverse all ancestors and add 'val'
        while (index <= n):

            # Add 'val' to current node of BI Tree
            BITree[index] += val

            # Update index to that of parent
            # in update View
            index += index & (-index)

    # Returns count of inversions of size three
    def getInvCount(arr, n):

        invcount = 0  # Initialize result

        # Find maximum element in arrays
        maxElement = max(arr)

        # Create a BIT with size equal to
        # maxElement+1 (Extra one is used
        # so that elements can be directly
        # be used as index)
        BIT = [0] * (maxElement + 1)
        for i in range(1, maxElement + 1):
            BIT[i] = 0
        for i in range(n - 1, -1, -1):

            invcount += getSum(BIT, arr[i] - 1)
            updateBIT(BIT, maxElement, arr[i], 1)
        return invcount

    # Driver code
    A = list(map(int, input().split()))
    tot1 = getInvCount(A, n)

    tot2 = count_bigger(A)
    mod = 10**9+7
    print((tot1*k + tot2*(k*(k-1)//2)) % mod)

resolve()

Measured memory_bytes: 40560
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
using vc = vector<char>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
  int n,k;
  cin >> n >> k;
  vl h(n,0);
  rep(i,n) cin >> h.at(i);
  vvl dp(400,vl(400,1000000000000000));
  rep(i,n) dp[i][1] = h.at(i);
  int m = n-k;
  if(m <= 0){
    cout << 0 << endl;
    return 0;
  }
  REP(i,1,n){
    REP(j,1,m+1){
      rep(l,i){
        if(dp[l][j-1] == 1000000000000000) continue;
        dp[i][j] = min(dp[i][j], dp[l][j-1] + max((long)0, h.at(i)-h.at(l)));
      }
    }
  }
  long ans = 1e16;
  rep(i,n){
    ans = min(ans, dp[i][m]);
    //cout << dp[i][m] << endl;
  }
  /*rep(i,n){
    rep(j,m+1){
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }*/
  cout << ans << endl;
}


Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}


int main() {
    ll N;
    cin >>N;
    ll sum = 0;
    for (int i = 1; i <= N; ++i) {
        if(i % 3 == 0 || i % 5 == 0){

        }else{
            sum += i;
        }
    }
    cout << sum << endl;
}



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

const int INF = 1 << 30;

struct Dinic
{
  struct edge
  {
    int to, cap, rev;
    bool alive;
  };
 
  vector< vector< edge > > graph;
  vector< int > used;

  Dinic(int n)
  {
    graph.resize(n);
  }
 
  void add_edge(int from, int to, int cap)
  {
    graph[from].push_back((edge){to, cap, (int)graph[to].size(), true});
    graph[to].push_back((edge){from, cap, (int)graph[from].size() - 1, true});
  }

  int dfs(int idx, const int t, int flow)
  {
    if(idx == t) return(flow);
    used[idx] = true;
    for(int i = 0; i < graph[idx].size(); i++) {
      edge& e = graph[idx][i];
      if(!e.alive) continue;
      if(e.cap > 0 && !used[e.to]) {
        int d = dfs(e.to, t, min(flow, e.cap));
        if(d > 0) {
          e.cap -= d;
          graph[e.to][e.rev].cap += d;
          return(d);
        }
      }
    }
    return(0);
  }

  int max_flow(int s, int t, int lim)
  {
    int flow = 0;
    while(lim > 0) {
      used.assign(graph.size(), 0);
      int f = dfs(s, t, lim);
      if(f == 0) break;
      flow += f;
      lim -= f;
    }
    return(flow);
  }

  bool back_edge(int from, int to)
  {
    for(edge& e : graph[from]) {
      if(e.to == to && e.alive) {
        if(e.cap == 0 && max_flow(from, to, 1) == 0) {
          max_flow(from, 0, 1);
          max_flow(graph.size() - 1, to, 1);
          return(1);
        } else {
          return(0);
        }
      }
    }
  }
  void remove_edge(int from, int to)
  {
    for(edge& e : graph[from]) {
      if(e.to == to && e.alive) {
        e.alive = false;
        graph[e.to][e.rev].alive = false;
        return;
      }
    }
  }

};


int main()
{
  int N, E, Q;
  cin >> N >> E >> Q;
  Dinic graph(N);
  while(E--) {
    int F, T;
    cin >> F >> T;
    --F, --T;
    graph.add_edge(F, T, 1);
  }
  int flow = graph.max_flow(0, N - 1, INF);
  while(Q--) {
    int M, A, B;
    cin >> M >> A >> B;
    --A, --B;
    if(M == 1) {
      graph.add_edge(A, B, 1);
      flow += graph.max_flow(0, N - 1, 1);
    } else {
      flow -= graph.back_edge(A, B);
      flow -= graph.back_edge(B, A);
      graph.remove_edge(A, B);
    }
    cout << flow << endl;
  }
}

Measured memory_bytes: 3928
while True:
    m, f, r = map(int, input().split())
    if (m, f, r) == (-1, -1, -1):
        break
    if m == -1 or f == -1:
        grade = "F"
    else:
        total = m + f
        if total >= 80:
            grade = "A"
        elif total >= 65:
            grade = "B"
        elif total >= 50:
            grade = "C"
        elif total >= 30:
            if r >= 50:
                grade = "C"
            else:
                grade = "D"
        else:
            grade = "F"
    print(grade)



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 4611686018427387903;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	int n, k; cin >> n >> k;
	VI a(n); REP(i,n) cin >> a[i];
	sort(ALL(a));
	int ans=0;
	REP(i,k)
		ans+=a[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3616
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using INT = mp::cpp_int;
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
//#define mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1ll << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1ll << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return -1;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));
INT N, A, B, C, D;
map<INT, INT> dp;
INT cost(INT x)
{
    if (x == 0)
        return 0;
    if (x == 1)
        return D;
    if (dp[x] != 0)
        return dp[x];
    INT res = 10000000000000000000;
    INT u5 = (x + 4) / 5;
    INT d5 = x / 5;
    INT u3 = (x + 2) / 3;
    INT d3 = x / 3;
    INT u2 = (x + 1) / 2;
    INT d2 = x / 2;
    res = min(res, D * x);
    res = min(res, D * (x - d5 * 5) + C + cost(d5));
    res = min(res, D * (u5 * 5 - x) + C + cost(u5));
    res = min(res, D * (x - d3 * 3) + B + cost(d3));
    res = min(res, D * (u3 * 3 - x) + B + cost(u3));
    res = min(res, D * (x - d2 * 2) + A + cost(d2));
    res = min(res, D * (u2 * 2 - x) + A + cost(u2));
    return dp[x] = res;
}
int main()
{
    cout << fixed << setprecision(30);
    ll T;
    cin >> T;
    while (T--)
    {
        INT n, a, b, c, d;
        cin >> n >> a >> b >> c >> d;
        N = n;
        A = a;
        B = b;
        C = c;
        D = d;
        INT ans = cost(N);
        putout(ans);
        dp.clear();
    }
    return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

template<typename T, typename U>
struct segtree {
	ll n, H;
	
	vector<T> value;
	vector<U> prop;
	vector<bool> dirty;

	segtree<T,U>(vector<T> leaves): n(sz(leaves)) {
		H = 32 - __builtin_clz(2*n-1);

		value.resize(2*n);
		copy(all(leaves),begin(value)+n);
		FORD(i,1,n) value[i] = value[2*i] + value[2*i+1];
		
		dirty.resize(n,false);
		prop.resize(n);
	}

	void apply(ll i, U &upd) {
		value[i] = upd(value[i]);
		if (i < n) prop[i] = prop[i] + upd, dirty[i] = true;
	}

	void rebuild(ll i) {
		for (i /= 2; i; i /= 2) value[i] = prop[i](value[2*i] + value[2*i+1]);
	}

	void propagate(ll i) {
		FORD(h,1,H+1) if (dirty[i >> h]) {
			ll j = i >> h;
			apply(2*j,prop[j]), apply(2*j+1,prop[j]);
			prop[j] = U(), dirty[j] = false;
		}
	}

	void update(ll i, ll j, U upd) {
		i += n, j += n;
		propagate(i), propagate(j-1);
		for (ll l = i, r = j; l < r; l /= 2, r /= 2) {
			if (l & 1) apply(l++,upd);
			if (r & 1) apply(--r,upd);
		}
		rebuild(i), rebuild(j-1);
	}
	
	T query(ll i, ll j) {
		i += n, j += n;
		propagate(i), propagate(j-1);
		T resl, resr;
		for (; i < j; i /= 2, j /= 2) {
			if (i & 1) resl = resl + value[i++];
			if (j & 1) resr = value[--j] + resr;
		}
		return resl + resr;
	}
};

struct node {
	ll x = oo;
	node operator+(node n) { return {min(x,n.x)}; }
};

struct update {
	ll y = 0;
	node operator()(node n) { return {n.x+y}; }
	update operator+(update u) { return {y+u.y}; }
};

struct interval {
	ll l, r, v;
	bool operator<(interval i) { return r < i.r; }
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n, m;
	cin >> n >> m;
	
	vector<interval> a(m);
	for (auto &i: a) cin >> i.l >> i.r >> i.v;
	sort(all(a));
	
	segtree<node,update> S(vector<node>(n+1,{0}));
	
	ll j = 0;
	FOR(x,1,n+1) {
		ll old_value = S.query(x,x+1).x;
		ll new_value = S.query(0,x).x;
		S.update(x,x+1,{new_value-old_value});
		
		for (; j < m && a[j].r == x; j++) {
			S.update(0,a[j].l,{a[j].v});
		}
	}
	ll res = -S.query(0,n+1).x;
	FOR(i,0,m) res += a[i].v;
	cout << res << endl;
}



Measured memory_bytes: 11264
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 410000
using namespace std;
main(){
    string s;
    cin>>s;
    ll t[30]={};
    rep(i,s.size()){
        t[(int)(s[i]-'a')]++;
    }
    ll ans=0;
    ll p=s.size();
    ans=p*(p-1)/2;
    rep(i,26){
        ans-=t[i]*(t[i]-1)/2;
    }
    cout<<++ans;
}

Measured memory_bytes: 640
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.regex.Pattern;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();

		String S = sc.next();
		String T = sc.next();

		if(S.equals(T.substring(0,T.length() - 1)) && isHalfUpperAlphanumeric(T.substring(T.length() - 1))) {
			System.out.print("Yes");
		} else {
			System.out.print("No");
		}

	}

    public static boolean isHalfUpperAlphanumeric(String str) {
        return Pattern.matches("^[a-z]+$", str);
    }

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		}else{
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
}

Measured memory_bytes: 33472
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))
if a.count(0) == 0:
    hu_count = 0
    min = 10 ** 9
    for i in range(0,n):
        if a[i] < 0:
            hu_count += 1
            a[i] = -1 * a[i]
        if min > a[i]:
            min = a[i]
    if hu_count % 2 == 0:
        print(sum(a))
    else:
        print(sum(a) - min - min)
else:
    for i in range(0,n):
        if a[i] < 0:
            a[i] = -1 * a[i]
    print(sum(a))

Measured memory_bytes: 14464
/*******************
AUTHOR: HUMBLE_LOSER
*******************/

#include <iostream>
#include <cstdio>
#include <cassert>
#include <math.h>
#include <ctime>
#include <bitset>
#include <iomanip>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <vector>
#include <boost/algorithm/string.hpp>

using namespace std;

#define PI acos(-1)
#define EXP 2.7182818284590452353602874713527
#define endl '\n'
#define ll long long
#define llu long long unsigned
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define vvi vector<vi>
#define vvii vector<vii>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define sz(v) int(v.size())
#define eps 1e-5
#define forr(i,a,b) for(int i = int(a) ; i<= int(b) ; i++ )
#define rof(i,a,b)  for(int i = int(a) ; i>= int(b) ; i-- )
#define rep(i,n) for(int i=0 ; i<int(n) ; i++ )
#define all(v) (v).begin(),(v).end()
#define inf 0x3f3f3f3f
#define mod 1000000007
#define zero(x) memset(&x,0,sizeof(x))
#define minus(x) memset(&x,0xff,sizeof(x))
#define infinity(x) memset(&x,0x3f,sizeof(x))
#define boost cin.tie(0); ios_base::sync_with_stdio(0); 
#define trace1(x) cerr << #x <<" = "<< x <<endl;
#define trace2(x,y) cerr << #x <<" = "<< x <<" , "<< #y <<" = "<< y <<endl;
#define trace3(x,y,z) cerr << #x <<" = "<< x <<" , "<< #y <<" = "<< y <<" , "<< #z <<" = "<< z <<endl;
#define trace_arr(a,i,n) cerr << #a <<" : " ; forr(_i,i,n) cerr << a[_i] << " "; cerr << endl;
#define trace_mat(a,i,n,j,m) cerr << #a <<" :\n" ; forr(_i,i,n){forr(_j,j,m) cerr << setw(6) << a[_i][_j] << " "; cerr << endl;}cerr<<endl;
#define test_case int __T;cin >> __T; forr(tc, 1 , __T)     
#define code_jam_output cout << "Case #" << tc << ": " 

template<class T, class U>
ostream& operator<<(ostream& out, const pair<T, U>& a) {out << "[" << a.first << " " << a.second << "]"; return out;}
template<class T>
ostream& operator<<(ostream& out, const vector<T>& a) {out << "[ "; for (auto &it : a)out << it << " "; out << "]"; return out;}
template<class T>
ostream& operator<<(ostream& out, const set<T>& a) {out << "[ "; for (auto &it : a)out << it << " "; out << "]"; return out;}
template<class T>
ostream& operator<<(ostream& out, const multiset<T>& a) {out << "[ "; for (auto &it : a)out << it << " "; out << "]"; return out;}
template<class T, class U>
ostream& operator<<(ostream& out, const map<T, U>& a) {for (auto &it : a)out << it.first << " -> " << it.second << " | "; return out;}
template<class T, class U>
ostream& operator<<(ostream& out, const multimap<T, U>& a) {for (auto &it : a)out << it.first << " -> " << it.second << " | "; return out;}

int x_dir[4] = { -1,0,1,0}; // standard x-y axis NORTH - EAST - SOUTH - WEST
int y_dir[4] = { 0,1,0,-1};

int main() 
{
    int a,b;
    cin >> a >> b;
    cout << (a+b)%24;
    return 0;
}

Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
typedef long long ll;
using namespace std;

const int INF = 10e8;
void TemplateMatching(){

	int n, m;
	cin >> n >> m;
	vector<string> a(n);
	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	vector<string> b(m);
	for (size_t i = 0; i < m; i++)
	{
		cin >> b[i];
	}


	for (int rs = 0; rs < n - m + 1; rs++)
	{
		for (int cs = 0; cs < n - m + 1; cs++)
		{
			bool check = true;
			for (int mr = 0; mr < m; mr++)
			{
				for (int mc = 0; mc < m; mc++)
				{
					if (a[rs + mr][cs + mc] != b[mr][mc]) {
						check = false;
						break;
					}
				}
			}
			if (check) {
				cout << "Yes" << endl;
				return;
			}
		}
	}
	cout << "No" << endl;
}

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



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    string s; cin >> s;
    map<char, int> mp;
    for(int i = 0; i < 26; i++) {
        mp[(char)(97 + i)] = 0;
    }
    for(int i = 0; i < s.size(); i++) {
        mp[s[i]]++;
    }

    if(s.size() < 26) {
        for(auto i = mp.begin(); i != mp.end(); i++) {
            if(i -> second == 0) {
                s.push_back(i -> first);
                cout << s << endl;
                return 0;
            }
        }
    }

    for(int i = s.size() - 1; i >= 0; i--) {
        char c = s[i];
        mp[c] = 0;
        s.pop_back();
        for(auto j = mp.begin(); j != mp.end(); j++) {
            if(j -> second == 0 && ((int)c < (int)(j -> first))) {
                s.push_back(j -> first);
                cout << s << endl;
                return 0;
            }
        }
    }

    cout << -1 << endl;
    return 0;
}


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

int main()
{
    string text;
    getline(cin, text);

    for (int i = 0; i <= text.size(); i++)
    {
        if (isupper(text[i]))
            text[i] = tolower(text[i]);
        else if (islower(text[i]))
            text[i] = toupper(text[i]);
    }

    cout << text << endl;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  vp ans;
  int rem = n;
  if(n%2 == 1)rem--;
  
  for(int i = 1;i<=n;i++){
    for(int j = 1;j<=n;j++){
      if(j<=i || j == rem) continue;
      ans.push_back(P(i,j));
    }
    rem--;
  }
  cout<<ans.size()<<endl;
  for(auto it : ans){
    cout<< it.fi << " " << it.se <<endl;
  }
  return 0;
}

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

int main(void) {
	int X;
	cin >> X;
	int ans = 0;
	for (int i = 1; i <= 8; ++i) {
		int p = 2000 - (200 * i);
		if (X >= p) {
			ans = i;
			break;
		}
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3604
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
v1=v[0:n:2]
v2=v[1:n:2]
cc1=Counter(v1)
c1=cc1.most_common()
cc2=Counter(v2)
c2=cc2.most_common()
if c1[0][0]!=c2[0][0]:
    print(n-c1[0][1]-c2[0][1])
if c1[0][0]==c2[0][0]:
    if len(c1)==len(c2)==1:
        print(n//2)
    if len(c1)==1 and len(c2)!=1:
        print(n-c1[0][1]-c2[1][1])
    if len(c2)==1 and len(c1)!=1:
        print(n-c1[1][1]-c2[0][1])    
    if len(c1)>1 and len(c2)>1:    
        print(n-max(c1[1][1]+c2[0][1],c1[0][1]+c2[1][1]))
        

Measured memory_bytes: 28156
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <limits>
#include <type_traits>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

unsigned gcd(unsigned a, unsigned b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}


template<bool left> int nearest(vector<INT> &l, INT pos)
{
	int begin = 0, end = l.size() - 1;

	while (1) {
		int half = (begin + end) / 2;
		if (pos < l[half])
		{
			end = half;
		}
		else
		{
			begin = half;
		}
		if (end - begin < 2)
		{
			if (left)
			{
				return begin;
			}
			else
			{
				return end;
			}
		}
	}
}


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

	vector<INT>s(a);
	vector<INT>t(b);
	vector<INT>x(q);
	for (size_t i = 0; i < a; i++)
	{
		cin >> s[i];
	}
	for (size_t i = 0; i < b; i++)
	{
		cin >> t[i];
	}
	for (size_t i = 0; i < q; i++)
	{
		cin >> x[i];
	}

	for (size_t i = 0; i < q; i++)
	{
		INT cost;
		{
			INT s0 = nearest<true>(s, x[i]);
			INT tl = nearest<true>(t, s[s0]);
			INT tr = nearest<false>(t, s[s0]);
			cost = abs(x[i] - s[s0]) + min(abs(s[s0] - t[tl]), abs(t[tr] - s[s0]));
		}
		{
			INT s0 = nearest<false>(s, x[i]);
			INT tl = nearest<true>(t, s[s0]);
			INT tr = nearest<false>(t, s[s0]);
			cost = min(cost, abs(s[s0] - x[i]) + min(abs(s[s0] - t[tl]), abs(t[tr] - s[s0])));
		}
		{
			INT t0 = nearest<true>(t, x[i]);
			INT sl = nearest<true>(s, t[t0]);
			INT sr = nearest<false>(s, t[t0]);
			cost = min(cost, abs(x[i] - t[t0]) + min(abs(t[t0] - s[sl]), abs(s[sr] - t[t0])));
		}
		{
			INT t0 = nearest<false>(t, x[i]);
			INT sl = nearest<true>(s, t[t0]);
			INT sr = nearest<false>(s, t[t0]);
			cost = min(cost, abs(t[t0] - x[i]) + min(abs(t[t0] - s[sl]), abs(s[sr] - t[t0])));
		}
		cout << cost << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3712
import itertools

count = int(input())

l1 = tuple(map(int, input().split()))
l2 = tuple(map(int, input().split()))


diff = []
for i in range(count):
    diff.append(i + 1)
data = itertools.permutations(diff)

q1, q2 = 1, 1
ans = 0
for i in data:
    if i == l1:
        ans += q1
    else:
        q1 += 1
    
    if i == l2:
        ans -= q2
    else:
        q2+= 1
    
print(abs(ans))

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

using namespace std;
typedef long long ll;
typedef long double ld;

const int N = 5050;
ll p[N], c[N];
int k, n;
int see[N];
int len, start;

ll calc(int pos, int count) {
  ll ans = 0;
  for (int i=0; i<count; ++i) {
    ans += c[pos];
    pos = p[pos];
  }
  return ans;
}

ll solve(int beg) {
  memset(see, 0, sizeof see);

  int pos = beg;
  for (int i=1; i<=n+1; ++i) {
    if (see[pos]) {
      len = i-see[pos];
      start = pos;
      break;
    }
    see[pos] = i;
    pos=p[pos];
  }
  ll ans = -1e9;
  ll cur = 0;
  pos = beg;
  ll rep = 0;
  for (int i=0; i<min(n,k); ++i) {
    if (i+1 == see[start]) {
      rep = cur;
    }
    cur += c[pos];
    pos = p[pos];
    ans = max(ans, cur);
  }

  pos = start;
  int iloop = (k-see[start]+1-len)/len;
  rep += calc(start, len)*iloop;
  for (int i=max(1, see[start]+iloop*len); i<=k; ++i) {
    //cerr << " I " << i << endl;
    rep += c[pos];
    ans = max(rep, ans);
    pos = p[pos];
  }
  return ans;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n >> k;
  for (int i=1; i<=n; ++i) {
    cin >> p[i];
  }
  for (int i=1; i<=n; ++i) {
    cin >> c[i];
  }
  ll ans = -1e9;
  for (int i=1; i<=n; ++i) {
    ans = max(ans, solve(i));
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3752
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  int N, M; cin>>N>>M;
  vector<ll> x(N), y(N), z(N), a(N);
  REP(i,N) cin>>x[i]>>y[i]>>z[i];
  ll ans = 0;
  for(int xx = -1; xx <= 1; xx += 2) {
    for(int yy = -1; yy <= 1; yy += 2) {
      for(int zz = -1; zz <= 1; zz += 2) {
        REP(i,N) {
	  ll work = 0;
          work += (ll)xx * x[i];
          work += (ll)yy * y[i];
          work += (ll)zz * z[i];
          a[i] = work;
        }
        sort(a.begin(),a.end());
	ll work	= 0;
	REP(i,M) {
          work += a[N-1-i];
        }
        ans = max(ans, work);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
    double x1,y1,x2,y2;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    printf("%.8lf\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));

return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int N, A;
  ci(N, A);
  if(A >= N % 500){
    co("Yes");
  }
  else{
    co("No");
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k>0){
        if(k%2==1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k/=2;
    }
    return ans;
}
ll inv(ll a){
	return powmod(a, MOD-2);
}

int main()
{
	int n;
	cin>>n;
	ll a[100001];
	for(int i=1; i<=n; i++) cin>>a[i];
	ll f[100001]; f[0]=1;
	for(ll i=1; i<=n; i++) f[i]=f[i-1]*i%MOD;
	ll invf[100001];
	invf[n]=inv(f[n]);
	for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
	ll s[100001];
	for(ll m=0; m<n; m++){
		s[m]=f[n]*inv((ll)n-m)%MOD;
	}
	ll s2[100001]; s2[0]=0;
	ll ans=0;
	for(int i=1; i<=n; i++){
		s2[i]=s2[i-1]+a[i]; s2[i]%=MOD;
	}
	for(int m=0; m<n; m++){
		if(m==n-1){
			ans+=(s[m]*s2[n]);
			ans%=MOD;
			continue;
		}
		ans+=(s[m]*(s2[n]+MOD-s2[n-m-1]+s2[m+1]));
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <queue>
#include <vector>
#define lld long long
#define PB push_back
#define F first
#define S second
#define jizz cin.tie(0);ios_base::sync_with_stdio(0);
#define endl '\n'
using namespace std;
typedef pair<int,int> Pair;

int main(){jizz
	int n;cin >> n;
	cout << 24-n + 24 << endl;
	return 0;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
const int mod = 998244353; //1e9+7;
struct Mint {
   int val;
   Mint inv() const {
       int tmp, a = val, b = mod, x = 1, y = 0;
       while(b) tmp = a / b, a -= tmp * b, swap(a, b), x -= tmp * y, swap(x, y);
       return Mint(x);
   }
public:
   Mint() :val(0) {}
   Mint(ll x) :val(x >= 0 ? x % mod : x % mod + mod) {}
   int mtoi() { return this->val; }
   Mint pow(ll t) { Mint res = 1; while(t){if(t&1)res *= *this;*this *= *this;t >>= 1;}return res; }
   Mint& operator+=(const Mint& x) { if ((val += x.val) >= mod) val -= mod; return *this; }
   Mint& operator-=(const Mint& x) { if ((val += mod - x.val) >= mod) val -= mod; return *this; }
   Mint& operator*=(const Mint& x) { val = (ll)val * x.val % mod; return *this; }
   Mint& operator/=(const Mint& x) { return *this *= x.inv(); }
   bool operator==(const Mint& x) const { return val == x.val; }
   bool operator!=(const Mint& x) const { return val != x.val; }
   bool operator<(const Mint& x) const { return val < x.val; }
   bool operator<=(const Mint& x) const { return val <= x.val; }
   bool operator>(const Mint& x) const { return val > x.val; }
   bool operator>=(const Mint& x) const { return val >= x.val; }
   Mint operator+(const Mint& x) const { return Mint(*this) += x; }
   Mint operator-(const Mint& x) const { return Mint(*this) -= x; }
   Mint operator*(const Mint& x) const { return Mint(*this) *= x; }
   Mint operator/(const Mint& x) const { return Mint(*this) /= x; }
};
struct factorial {
   vector<Mint> Fact, Finv;
public:
   factorial(int maxx) {
       Fact.resize(maxx+1,Mint(1)),Finv.resize(maxx+1); rep(i,0,maxx)Fact[i+1]=Fact[i]*Mint(i+1);
       Finv[maxx]=Mint(1)/Fact[maxx]; rrep(i,maxx,0)Finv[i-1]=Finv[i]*Mint(i);
   }
   Mint fact(int n,bool inv) { if(inv) return Finv[n]; else return Fact[n]; }
   Mint nPr(int n,int r) { if(n<0||n<r||r<0) return Mint(0); else return Fact[n]*Finv[n-r]; }
   Mint nCr(int n,int r) { if(n<0||n<r||r<0) return Mint(0); else return Fact[n]*Finv[r]*Finv[n-r]; }
};
//template end



int main(){
   int a,b,c; cin>>a>>b>>c;
   printf("%d\n",max(0,b+c-a));
   return 0;
}
//山頂でAC

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

int main(){
 
 string qwe,ans;

 int hit,blow,count;

     count = 0;
 
 while(1){
    cin >> qwe >> ans;
    if(qwe[0]=='0'&&ans[0]=='0') break;
    hit = 0 ;
    blow = 0;


   for(int i=0; i<4; i++){
      
       for(int g=0; g<4; g++){

           if(qwe[i] == ans[g]){
               
                if(i == g)
                      hit++;
                else
                      blow++;
            }
       }
    }
   
   cout << hit << " " << blow << endl;
   count++;
  }

 /* hit = 0 ;
  blow = 0;

  while(hit != 4){
    if(count == 0){
      break;
    } 
    cin >> qwe >> ans;
    hit = 0 ;
    blow = 0;

   for(int i=0; i<4; i++){
      
       for(int g=0; g<4; g++){

           if(qwe[i] == ans[g]){
               
                if(i == g)
                      hit++;
                else
                      blow++;
            }
       }
    }
   
   cout << hit << " " << blow << endl;
   
   count--;
 }*/

 return 0;
}

Measured memory_bytes: 1180
//%std
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define y1 ysgh
#define endl '\n'
inline int read()
{
	int out = 0, fh = 1;
	char jp = getchar();
	while ((jp > '9' || jp < '0') && jp != '-') jp = getchar();
	if (jp == '-')
		fh = -1, jp = getchar();
	while (jp >= '0' && jp <= '9') out = out * 10 + jp - '0', jp = getchar();
	return out * fh;
}
void print(int x)
{
	if (x >= 10)
		print(x / 10);
	putchar('0' + x % 10);
}
void write(int x, char c)
{
	if (x < 0)
		putchar('-'), x = -x;
	print(x);
	putchar(c);
}
const int N = 2e5 + 10;
int n, c[100][100], mxa = -9, mxb = -9;
double t;
int Max(int x, int y)
{
	return max(x, y);
}
int main()
{
	n = read();
	ll ans = 0;
	for (int i = 1; i <= n; ++i)
	{
		scanf("%lf", &t);
		ll x = (ll)(round((t * (1e9))));
		int a = -9, b = -9;
		while (x % 2 == 0)
			x /= 2, ++a;
		while (x % 5 == 0)
			x /= 5, ++b;
		for (int A = Max(-9, -a); A <= mxa; ++A)
			for (int B = Max(-9, -b); B <= mxb; ++B)
				ans += c[A + 9][B + 9];
		++c[a + 9][b + 9];
		mxa = max(mxa, a), mxb = max(mxb, b);
	}
	cout << ans << endl;
	return 0;
}



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

using namespace std;
int k, i=0;
long long int t;
queue<long long int> q;


int main() {
    scanf(" %d", &k);
    for (i=1;i<10;i++) {
        q.push(i);
    }
    for (i=0;i<k;i++) {
        t = q.front(); q.pop();
        int t1 = t % 10;
        if (t1 != 0) q.push(10 * t + t1 - 1);
        q.push(10*t + t1);
        if (t1 != 9) q.push(10 * t + t1 + 1);
    }
    printf("%lld", t);
    return 0;
}

Measured memory_bytes: 1792
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int q; cin >> q;
    multiset<int> L, R;
    ll totL = 0, totR = 0, totB = 0;

    //*
    auto f = [&](auto & itl){
        R.insert(*itl);
        totR += *itl;
        totL -= *itl;
        L.erase(itl);
    };

    auto g = [&](auto & itr){
        L.insert(*itr);
        totL += *itr;
        totR -= *itr;
        R.erase(itr);
    };
    //*/
    
    while(q--){
        int t; cin >> t;
        if(t == 1){
            int a, b; cin >> a >> b;
            totB += b;
            if(L.empty()){
                L.insert(a); R.insert(a);
                totL += a;
                totR += a;
            }else{
                auto itl = L.end();
                itl--;
                auto itr = R.begin();
                if(a <= *itl){
                    L.insert(a); L.insert(a);
                    totL += 2*a;
                    f(itl);
                }else if(a >= *itr){
                    R.insert(a); R.insert(a);
                    totR += 2*a;
                    g(itr);
                }else{
                    L.insert(a); R.insert(a);
                    totL += a;
                    totR += a;
                }                
            }
            // cout << "totL, totR, totB = " << totL << ", " << totR << ", " << totB << endl;
        }else{
            ll l = *L.rbegin();
            ll ans = (totR - totL) / 2;
            cout << l << " " << ans + totB << endl;
        }
    }
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 22228