akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#define N 10000
using namespace std;

int main(){
  int n,nari[N],i,flag=-1;
  while(1){
    flag=-1;
    cin >> n;
    if(n == 0)break;
    
    for(i=0;i<n;i++){
      cin >> nari[i];
    }
    
    
    
    for(i=0;i<n;i++){
      // cout << "flag=" << flag << endl; 
      if(nari[i] == nari[i+1]-1 && i!=n-1){
	if(flag == -1)flag=i;
	
      }
      else{
	if(flag!=-1){
	  printf("%d-%d",nari[flag],nari[i]);
	  if(i != n-1){
	    printf(" "); 
	  }
	  flag=-1;

	}
	else{
	  printf("%d",nari[i]);
	  if(i != n-1){
	    printf(" ");  
	  }
      }
     
      }     

    }
    cout << endl;
  }
  
  
}

Measured memory_bytes: 0
package main

import (
	"fmt"
	"sort"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	arr := []int{a, b, c}
	// 昇順ソートして 5, 5, 7 で格納されれば良い
	sort.Ints(arr)
	if arr[0] == 5 && arr[1] == 5 && arr[2] == 7 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
const int maxn = 5050, mlg = 17, mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, vis[maxn], cyc, cursz, c[maxn];
vi g[maxn];
ll b = 0, gd = 0, ans = 0;
void dfs(int v, int p) {
	vis[v] = 1;
	cursz++;
	int cpar = 0;
	//cout << v << endl;
	for(auto &i : g[v]) {
		if(!vis[i]) dfs(i, v);
		else if(i != p || cpar++) cyc = 1;
	}
}
int dp[maxn], ndp[maxn];
void add(int &a, int b) {
	a += b;
	if(a >= mod) a -= mod;
}
ll bp(ll a, ll p) {
	ll r = 1;
	while(p) {
		if(p&1) r = r*a%mod;
		a = a*a%mod, p>>=1;
	}
	return r;
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	for(int t, i = 1; i <= n; i++) {
		cin >> t;
		if(t != -1) {
			g[t].pb(i);
			g[i].pb(t);
		}
	}
	memset(dp, 0, sizeof dp);
	dp[0] = 1;
	for(int i = 1; i <= n; i++) {
		if(vis[i]) continue;
		cyc = cursz = 0;
		dfs(i, i);
		//cout << i << " " << cyc << '\n';
		if(cyc) {b++; continue;}
		gd++;
		memset(ndp, 0, sizeof ndp);
		for(int i = 0; i <= n; i++) {
			add(ndp[i], dp[i]);
			add(ndp[i+1], dp[i]*1ll*cursz%mod);
		}
		swap(dp, ndp);
	}
	ll ans = bp(n-1, gd)*(n-b)%mod, nf = 1;
	for(int i = 1; i <= gd; i++) {
		if(i == 1) dp[i] -= gd;
		//cout << i << " == " << dp[i] << '\n';
		ll t = nf*dp[i]%mod;
		t = t*bp(n-1, gd-i)%mod;
		ans = (mod + ans - t)%mod;
		nf = nf*1ll*i%mod;
	}
	cout << ans;
}


Measured memory_bytes: 3952
#define IN_PC() freopen("C:\\Users\\hz\\Desktop\\in.txt","r",stdin)
#define IN_LB() freopen("C:\\Users\\acm2018\\Desktop\\in.txt","r",stdin)
#define OUT_PC() freopen("C:\\Users\\hz\\Desktop\\out.txt","w",stdout)
#define OUT_LB() freopen("C:\\Users\\acm2018\\Desktop\\out.txt","w",stdout)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int maxn = 200005;
const int INF = 0x3f3f3f3f;

int vis[maxn], ind1, ind2;

ll inv[maxn];

ll MOD = 1e9 + 7;

int main() {
//    IN_PC();
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    inv[0] = 1;
    inv[1] = 1;
    for(int i = 2; i <= n + 1; i++) {
        inv[i] = (MOD - MOD / i) * inv[MOD % i] % MOD;
    }
    for(int i = 1; i <= n + 1; i++) {
        int num;
        cin >> num;
        if(!vis[num])
            vis[num] = i;
        else {
            ind1 = vis[num];
            ind2 = i;
        }
    }
    ll c1 = n + 1, c2 = 1, d = ind2 - ind1;
    cout << (c1 - c2 + MOD) % MOD << endl;
    for(ll i = 2; i <= n; i++) {
        c1 = c1 * (n + 2 - i) % MOD * inv[i] % MOD;
        if(i - 1 <= n - d)c2 = c2 * (n - d + 2 - i) % MOD * inv[i - 1] % MOD;
        else c2 = 0;
        cout << (c1 - c2 + MOD) % MOD << endl;
    }
    cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using ll = long long;
using P = pair<int, int>;
using MATRIX = vector< vector<ll> >;
template <class T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <class T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}

template<class FT>
struct Dinic {
  const FT INF;

  struct edge {
    int to;
    FT cap;
    int rev;
    bool is_rev;
  };

  vector<vector<edge>> graph;
  vector<int> min_cost, iter;

  Dinic(int V) : INF(numeric_limits<FT>::max()), graph(V) {};

  void add_edge(int from, int to, FT cap, int idx = -1) {
    graph[from].emplace_back((edge) {to, cap, (int) graph[to].size(), false});
    graph[to].emplace_back((edge) {from, 0, (int) graph[from].size() - 1, true});
  }

  bool bfs(int s, int t) {
    min_cost.assign(graph.size(), -1);
    min_cost[s] = 0;
    queue<int> Q;
    Q.push(s);
    while(Q.size() && min_cost[t] == -1) {
      int v = Q.front();
      Q.pop();
      for(auto &e: graph[v]) {
        if(e.cap > 0 && min_cost[e.to] == -1) {
          min_cost[e.to] = min_cost[v] + 1;
          Q.push(e.to);
        }
      }
    }
    return min_cost[t] != -1;
  }

  FT dfs(const int v, const int t, FT flow) {
    if(v == t) return flow;
    for(int &i = iter[v]; i < graph[v].size(); i++) {
      edge &e = graph[v][i];
      if(e.cap > 0 && min_cost[v] < min_cost[e.to]) {
        FT 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;
  }

  FT max_flow(int s, int t) {
    FT flow = 0;
    while(bfs(s, t)) {
      iter.assign(graph.size(), 0);
      FT f = 0;
      while((f = dfs(s, t, INF)) > 0) flow += f;
    }
    return flow;
  }

  void print() {
    for(int i = 0; i < graph.size(); i++) {
      for(auto &e: graph[i]) {
        if(e.isrev) continue;
        auto &rev_e = graph[e.to][e.rev];
        cout << i << "->" << e.to << " (flow:" << rev_e.cap << "/" << e.cap + rev_e.cap << ")" << endl;
      }
    }
  }
};

int N;
int a[100], b[100], c[100], d[100];

int main() {
  cin >> N;
  Dinic<int> g(2 * N + 2);
  rep(i, N) {
    cin >> a[i] >> b[i];
  }
  rep(i, N) {
    cin >> c[i] >> d[i];
  }
  rep(i, N) {
    g.add_edge(2 * N, i, 1);
    g.add_edge(N + i, 2 * N + 1, 1);
  }
  rep(i, N) {
    rep(j, N) {
      if(a[i] < c[j] && b[i] < d[j]) {
        g.add_edge(i, N + j, 1);
      }
    }
  }
  cout << g.max_flow(2 * N, 2 * N + 1) << endl;
  return 0;
}

Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
int n;
double dp[303][303][303];
double f(int a,int b,int c)
{
    if(dp[a][b][c]!=-1)
        return dp[a][b][c];
    int res=a+b+c;
    if(!res)
    return 0;
    double ans=0;
    ans+=n;
    if(a)
    ans+=a*f(a-1,b,c);
    if(b)
    ans+=b*f(a+1,b-1,c);
    if(c)
    ans+=c*f(a,b+1,c-1);
    ans/=res;
    return dp[a][b][c]=ans;
}
int main()
{
    cin>>n;
    int a=0,b=0,c=0;
    for(int i=0;i<n;i++)
    {
        int t;
        cin>>t;
        if(t==1)
        a++;
        if(t==2)
        b++;
        if(t==3)
        c++;
    }
    for(int i=0;i<303;i++)
        for(int j=0;j<303;j++)
            for(int k=0;k<303;k++)
                dp[i][j][k]=-1;
    cout<<setprecision(10)<<f(a,b,c);
}

Measured memory_bytes: 217728
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

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

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


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する


int main() {
    int N;
    cin >> N;
//    vector<vector<bool> > flag(N, vector<bool>(N, false));
    vector<int> a(N);
    vector<int> pos(N + 1);

    REP(i, 0, N) {
//        cin >> a[i];
        scanf("%d",&a[i]);
        pos[a[i]] = i;
    }

    set<int> set1;
    set<int> rset;
//    set1.insert(-1);
    set1.insert(N);
    rset.insert(1);

    ll ans = 0;

    for (int i = 1; i <= N; i++) {
        set1.insert(pos[i]);
        rset.insert(-pos[i]);
        auto itA = rset.upper_bound(-pos[i]);
        auto itB = set1.upper_bound(pos[i]);
//        printf("i = %d,*itA = %d,*itB = %d\n", i, -*itA, *itB);
        ans += 1LL * i * (pos[i] + *itA) * (*itB - pos[i]);
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 20608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

struct State{
    int y, x, mask, b;
};

const int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
char f[60][51];

int dp[60][50][1<<12][4]={};
int vis[60][50]={};

int main()
{
    int H,W,K;
    cin >>H >>W >>K;

    memset(dp,-1,sizeof(dp));
    rep(i,6)
    {
        f[i][0]='.';
        for(int j=1; j<W; ++j) f[i][j]='#';
    }
    rep(i,H) scanf("%s", f[i+6]);
    H+=6;

    #define IN(y,x) (0<=y && y<H && 0<=x && x<W)
    queue<State> que;
    que.push({6,0,0,0});
    dp[6][0][0][0]=0;
    while(!que.empty())
    {
        State s = que.front();
        que.pop();

        int d[6];
        rep(i,6) d[i] = (s.mask>>(2*i))&3;

        int px[7],py[7];
        px[0] = s.x;
        py[0] = s.y;
        rep(i,6)
        {
            px[i+1] = px[i] - dx[d[i]];
            py[i+1] = py[i] - dy[d[i]];
        }
        rep(i,7) vis[py[i]][px[i]]=1;

        rep(i,4)
        {
            int nx = s.x+dx[i], ny = s.y+dy[i];
            int nb = s.b+(i>=2);
            if(nb<=K && IN(ny,nx) && f[ny][nx]!='#')
            {
                int add=max(0,f[ny][nx]-'0');
                if(vis[ny][nx]) add=0;

                int nmask = ((s.mask<<2)&((1<<12)-1)) + i;
                if(dp[ny][nx][nmask][nb] < dp[s.y][s.x][s.mask][s.b] + add)
                {
                    dp[ny][nx][nmask][nb] = dp[s.y][s.x][s.mask][s.b] + add;
                    que.push({ny,nx,nmask,nb});
                }
            }
        }

        rep(i,7) vis[py[i]][px[i]]=0;
    }

    int ans=0;
    rep(M,1<<12)rep(B,4) ans=max(ans,dp[H-1][W-1][M][B]);
    printf("%d\n", ans);
    return 0;
}

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

ll N, M;
vector<ll> A(100001, 0);
map<ll, ll> mp;

int main(void){
    
    cin >> N >> M;
    for(int i = 0; i < N; ++i) cin >> A[i];
    
    ll sum = 0, ans = 0;
    ++mp[0];
    
    for(int i = 0; i < N; ++i){
        sum += A[i];
        sum %= M;
        ans += mp[sum];
        ++mp[sum];
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  int N;in(N);
  vector<int>L(N);
  ins(L);
  sort(all(L));
  ull ans=0;
  up(i,0,N-1){
    up(j,i+1,N-1){
      up(k,j+1,N-1){
        if(L[k]>(L[i]-L[j])&&L[k]>(L[j]-L[i])&&L[k]<(L[i]+L[j]))ans++;
      }
    }
  }
  out(ans);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
n = int(input())
red = []
blue = []

for i in range(n):
    a, b = map(int, input().split())
    red.append((a, b))

for i in range(n):
    a, b = map(int, input().split())
    blue.append((a, b))

red.sort(key=lambda x:x[1], reverse=True)
blue.sort()
chk = [False] * n

for b in blue:
    for i, r in enumerate(red):
        if chk[i]:
            continue
        elif r[0] < b[0] and r[1] < b[1]:
            chk[i] = True
            break
print(sum(chk))


Measured memory_bytes: 3064
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve
struct dice_{
  int x[6];
  dice_(){}
  void input(){
    rep(i, 6)cin >> x[i];
  }
  void north(){
    int y[6];
    y[0] = x[1];
    y[1] = x[5];
    y[2] = x[2];
    y[3] = x[3];
    y[4] = x[0];
    y[5] = x[4];
    swap(x, y);
  }
  void south(){
    int y[6];
    y[0] = x[4];
    y[1] = x[0];
    y[2] = x[2];
    y[3] = x[3];
    y[4] = x[5];
    y[5] = x[1];
    swap(x, y);
  }
  void east(){
    int y[6];
    y[0] = x[3];
    y[1] = x[1];
    y[2] = x[0];
    y[3] = x[5];
    y[4] = x[4];
    y[5] = x[2];
    swap(x, y);
  }
  void west(){
    int y[6];
    y[0] = x[2];
    y[1] = x[1];
    y[2] = x[5];
    y[3] = x[0];
    y[4] = x[4];
    y[5] = x[3];
    swap(x, y);
  }
  void right(){
    int y[6];
    y[0] = x[0];
    y[1] = x[2];
    y[2] = x[4];
    y[3] = x[1];
    y[4] = x[3];
    y[5] = x[5];
    swap(x, y);
  }
  void left(){
    int y[6];
    y[0] = x[0];
    y[1] = x[3];
    y[2] = x[1];
    y[3] = x[4];
    y[4] = x[2];
    y[5] = x[5];
    swap(x, y);
  }
  void set(int a, int b){
    if(x[0] == a){
      rep(i, 4){
        left();
        if(x[1] == b)return;
      }
    }
    if(x[5] == a){
      north(); north();
      rep(i, 4){
        left();
        if(x[1] == b)return;
      }
    }
    north();
    if(x[0] == a){
      rep(i, 4){
        left();
        if(x[1] == b)return;
      }
    }
    south(); south();
    if(x[0] == a){
      rep(i, 4){
        left();
        if(x[1] == b)return;
      }
    }
    north(); east();
    if(x[0] == a){
      rep(i, 4){
        left();
        if(x[1] == b)return;
      }
    }
    west(); west();
    if(x[0] == a){
      rep(i, 4){
        left();
        if(x[1] == b)return;
      }
    }
    east();
  }
};

using dice = struct dice_;

int main(int argc, char const* argv[])
{
  dice d;
  d.input();
  int n;
  cin >> n;
  rep(i, n){
    dice dt = d;
    int a, b;
    cin >> a >> b;
    dt.set(a, b);
    cout << dt.x[2] << endl;
  }
	return 0;
}



Measured memory_bytes: 3108
#include<stdio.h>
#define MAX 1000001
#define INF 20000000
 
typedef struct{
  int A;
  char C;
}Card;
 
 
Card A[MAX];
Card B[MAX];
 
Card L[MAX/2+2],R[MAX/2+2];
 
void quickSort(int,int);
int partition(int,int);
 
void merge(int,int,int,int);
void mergeSort(int,int,int);
 
int main(){
  int i;
  int n;
  int c;
  int flag=1;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    scanf("%c",&c);
    scanf("%c%d",&A[i].C,&A[i].A);
    B[i].A=A[i].A;
    B[i].C=A[i].C;
  }
 
  quickSort(0,n-1);
  mergeSort(n,0,n);
   
  for(i=0;i<n;i++){
    if(B[i].A==A[i].A&&B[i].C!=A[i].C){
      flag=0;
      break;
    }
  }
 
  if(flag==1)printf("Stable\n");
  else if(flag==0)printf("Not stable\n");
 
  for(i=0;i<n;i++)printf("%c %d\n",A[i].C,A[i].A);
  return 0;
}
 
int partition(int p,int r){
  int i,j;
  int x;
  Card t;
 
  x=A[r].A;
  i=p-1;
   
  for(j=p;j<r;j++){
    if(x>=A[j].A){
      t=A[j];
      A[j]=A[i+1];
      A[i+1]=t;
      i++;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
  
  return i+1;
}
 
void quickSort(int p,int r){
  int q;
   
  if(p<r){
    q=partition(p,r);
    quickSort(p,q-1);
    quickSort(q+1,r);
  }
}
 
void merge(int n,int left,int mid,int right){
  int i,j,k;
  int n1;
  int n2;
 
  n1=mid-left;
  n2=right-mid;
 
  for(i=0;i<n1;i++) L[i]=B[left+i];
  for(i=0;i<n2;i++) R[i]=B[mid+i];
 
  L[n1].A=INF;
  R[n2].A=INF;
 
  i=0;
  j=0;
 
  for(k=left;k<right;k++){
    if(L[i].A<=R[j].A){
      B[k]=L[i];
      i++;
    }else{
      B[k]=R[j];
      j++;
    }
  }
}
 
void mergeSort(int n,int left,int right){
  int mid;
 
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(n,left,mid);
    mergeSort(n,mid,right);
    merge(n,left,mid,right);
  }
}



Measured memory_bytes: 4216
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    h,m,H,M,k = LI()
    t = 60*(H-h)+M-m
    print(max(0,t-k))
    return

#Solve
if __name__ == "__main__":
    solve()


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

using namespace std;

#define llint long long int
#define REP(i,s,l) for(llint i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main() {
    int person,food,index;
    index = 0;
    cin >> person >> food;

    vector<int> sukifood(food);

    REP(i,0,person){
        int foodkazu;
        cin >> foodkazu ;
        REP(t,0,foodkazu){
            int foodindex;
            cin >> foodindex;
            sukifood[foodindex-1]++;
        }
    }

    REP(i,0,food){
        if(sukifood[i] == person)index++;
    }

    cout << index <<endl;

    return 0;
}

Measured memory_bytes: 256
q=int(input())
n=10**5+10
d=[0]+[1 for _ in range(n)]

d[1]=0
f=2
while f*f<n+1:
  i=2
  while f*i<=n:
    d[f*i]=0
    i+=1
  f+=1
  while d[f]==0 and f*f<n+1:
    f+=1

e=[0 for _ in range(n+1)]
for i in range(1,n+1,2):
  if d[i]==1 and d[(i+1)//2]==1:
    e[i]=1

e[1]=0

import itertools
an=list(itertools.accumulate(e))

for i in range(q):
  l,r=map(int,input().split())
  print(an[r]-an[l-1])

Measured memory_bytes: 90064
# -*- coding: utf-8 -*-
import sys
from collections import deque
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
M=N**2
P=tuple(map(int1,input().split()))
d=[0]*M
for i in range(N):
    for j in range(N):
        d[i*N+j]=min(min(i,N-1-i),min(j,N-1-j))
used=[1]*M
ans=0
que=deque()
for p in P:
    ans+=d[p]
    used[p]=0
    que.append(p)
    while que:
        x=que.pop()
        for ddx in (-1,1,-N,N):
            nx=x+ddx
            if 0<=nx<M:
                if used[x]==0 and d[nx]-d[x]>=1:
                    d[nx]-=1
                    que.append(nx)
                elif used[x]==1 and d[nx]-d[x]>=2:
                    d[nx]-=1
                    que.append(nx)
print(ans)



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

using namespace std;

char s[100005];
int main() {
    long long ans = 0;
    long long x = 0, y = 0;
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        long long a, b;
        scanf("%lld %lld", &a, &b);
        if (a >= x && b >= y) x = a, y = b;
        else {
            long long factor = max((x + a - 1) / a, (y + b - 1) / b);
            x = factor * a;
            y = factor * b;
        }
    }

    printf("%lld\n", x + y);

    return 0;
}


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

int main(){
    int N,M;
    int A = 0;
	int B = 0;
    cin >> N >> M;
    vector<int> vec(N,0);
    vector<bool> check(N,false);
	vector<int> bvec(N,0);
    for(int i=0;i<M;i++){
        int p;
        string s;
        cin >> p >> s;
        if(s == "WA" && check[p-1] == false){
            bvec[p-1]++;
        }
        if(s == "AC" && check[p-1] == false){
            A++;
            B += bvec[p-1]++;
            check[p-1] = true;
        }
    }
    cout << A <<" "<< B << endl;
}

Measured memory_bytes: 1024
url = "https://atcoder.jp//contests/abc133/tasks/abc133_b"
import itertools
def main():
    n,d = list(map(int, input().split()))
    lis = []
    for i in range(n):
        t = list(map(int, input().split()))
        lis.append(t)
    count = 0
    for i in range(len(lis)):
        for j in range(i+1, len(lis)):
            if i == j:
                continue
            if float.is_integer(ret(lis[i], lis[j])):
                count += 1
    print(count)


import math
def ret(a,b):
    retval = 0
    idx = 0
    while True:
        if idx == len(a):
            break
        retval += abs(a[idx]-b[idx])**2
        idx += 1
    return math.sqrt(retval)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9004
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << ""; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll x;

	cin >> x;

	ll y = x - (x % 11);
	ll ans = y / 11 * 2;

	if (x % 11 != 0) {
		if (x % 11 <= 6) {
			ans += 1;
		}
		else {
			ans += 2;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll a,b,c;
  	ci(a>>b>>c);
  ll x=a%b;
  bool d=true;
  FOR(i,1,b){
    if((i*x)%b==c){
      co("YES")
        d=false;
        break;
    }
  }
  if(d) co("NO")
}

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

int bubbleSort (int *ary, int size) {
  bool flag = true;
  int tmp;
  int count = 0;
  while (flag) {
    flag = false;
    for (int j=size-1; j>=1; j--) {
      if (ary[j] < ary[j-1]) {
	// swap ary[j] and ary[j-1];
	tmp = ary[j];
	ary[j] = ary[j-1];
	ary[j-1] = tmp;
	flag = true;
	count++;
      }
    }
  }
  return count;
}

int main (int argc, char **argv) {
  int N;
  cin >> N;

  int* d;
  d = new int[N];
  for (int i = 0;i<N;i++){
    cin >> d[i];
  }

  int n = bubbleSort(d, N);

  for (int i = 0;i<N;i++){
    cout << d[i];
    if (i+1==N) cout << endl;
    else cout << " ";
  }
  
  cout << n << endl;
  delete d;
}

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

int main(){
	int a1,a2,a3,b1,b2,b3;
	int x[4][4];
	
	for(int i=1; i<=3; i++){
		for(int j=1; j<=3; j++){
			cin>>x[i][j];
		}
	}
	
	a1=0;
	b1=x[1][1];
	b2=x[1][2];
	b3=x[1][3];
	
	a2=x[2][1]-b1;
	a3=x[3][1]-b1;
	
	if(a2+b2==x[2][2] && a2+b3==x[2][3] && \
	   a3+b2==x[3][2] && a3+b3==x[3][3]){
		 cout<<"Yes"<<endl;
		 return 0;
	}
	
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef pair<LL,LL>PL;
const LL INF=1e18;
const LL MOD=1e9+7;
inline LL Pow(LL x,LL y)
{
    LL ans=1;
    while(y>0)
    {
        if(y&1)
            ans=ans*x%MOD;
        x=x*x%MOD;
        y>>=1;
    }
    return ans;
}
inline LL Inv(LL x)
{
    return Pow(x,MOD-2);
}
LL N,Q,i,j;
LL A[3010];
LL inv[3010][3010];
LL ans,sum;
LL inv2;
LL X,Y;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>N>>Q;
    for(i=0;i<N;i++)
        cin>>A[i];
    for(i=0;i<N;i++)
        for(j=0;j<N;j++)
            if(A[j]<A[i])
                inv[i][j]=1;
    inv2=Inv(2);
    ans=Pow(2,Q);
    while(Q-->0)
    {
        cin>>X>>Y;
        X--;
        Y--;
        inv[X][Y]=inv[Y][X]=inv2*(inv[X][Y]+inv[Y][X])%MOD;
        for(i=0;i<N;i++)
        {
            if(i==X||i==Y)
                continue;
            inv[i][X]=inv[i][Y]=inv2*(inv[i][X]+inv[i][Y])%MOD;
            inv[X][i]=inv[Y][i]=inv2*(inv[X][i]+inv[Y][i])%MOD;
        }
    }
    for(i=0;i<N;i++)
        for(j=i+1;j<N;j++)
            sum+=inv[i][j];
    sum%=MOD;
    cout<<ans*sum%MOD<<endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int result = 0;
  for (int i = 0; i < N; ++i) {
    int l, r;
    cin >> l >> r;
    result += r - l + 1;
  }
  cout << result << endl;
}

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

int main(){
    int k,s;
    int cnt = 0;

    cin >> k >> s;

    for(int i = 0; i <= k; i++){
        for(int j = 0; j <= k; j++){
            if(s - (i + j) >= 0){
                if(s - i - j <= k){
                    cnt++;
                }
            }
        }
    }

    cout << cnt << '\n';
    return 0;
}


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

int main(){

  int ht,st,ho,so;
  cin>>ht>>st>>ho>>so;
  bool turn = true;
  while(ht>0 && ho>0){
  
    if(turn){
    
      ho = ho-st;
      turn = false;
    }else{
    
      ht = ht - so;
      turn = true;
    }   
    
  }
  
  if(ho>0){cout<<"No"<<endl;}
  else {cout<<"Yes"<<endl;}
  
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
using namespace std;
int main(){
	
	int n;
	
	while(cin>>n,n!=0){
		int s=32;
		int k=0;
		int f=0;
		vector<int> a(n);
		for(int i=0;i<n;i++)
			cin>>a[i];
		
		while(s!=0){
			if(f==0){
				s-=(s-1)%5;
				f++;
			}
			else{
				s=s-a[k++];
				f=0;
				if(k==n)
					k=0;
			}
			if(s<0){
				s=0;
			}
				cout<<s<<endl;
		}
	}
	
}

Measured memory_bytes: 1192
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
//mapの使い方
#include <map>




ll n;

int main(){
  ll ans=0;
  cin>>n;
  vi p(n);
  vi pidx(n);
  map<long long, long long> nums;
  REP(i,n){
	  cin>>p[i];
	  p[i]--;
	  pidx[p[i]]=i;
	  nums[i]=p[i];
  }

  ll a,b,c,d,e;
	REP(i,n){
		auto itrb = nums.find(pidx[i]);
		c=itrb->first;
		itrb++;
		if (itrb==nums.end()){
			e=n;d=e;
		}else{
			d=itrb->first;
			itrb++;
			if (itrb==nums.end()){
				e=n;
			}else{
				e=itrb->first;
			}
		}

		itrb = nums.find(pidx[i]);
		if (itrb==nums.begin()){
			b=-1LL;a=b;
		}else{
			itrb--;
			b=itrb->first;
			if (itrb==nums.begin()){
				a=-1LL;
			}else{
				itrb--;
				a=itrb->first;
			}
		}
		ans+=((e-d)*(c-b)+(b-a)*(d-c))*(i+1LL);
		nums.erase(pidx[i]);
		//cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<"   "<<((e-d)*(c-b)+(b-a)*(d-c))<<endl;
	}
	


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

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

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ld t, x;
    cin>>t>>x;
    cout<<setprecision(30)<<(t/x)<<endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
#include<functional>
using namespace std;

int MOD = 1e9 + 7;

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

int main() {
	string s;
	cin >> s;

	int i = 0;
	while (i < s.size()) {
		if (s[i] == 'd' && s[i + 1] == 'r' && s[i + 2] == 'e' && s[i + 3] == 'a' && s[i + 4] == 'm') {

			if (s[i + 5] == 'e' && s[i + 6] == 'r' && s[i + 7] == 'a' && s[i + 8] == 's' && s[i + 9] == 'e' && s[i + 10] == 'r') i += 11;
			else if (s[i + 5] == 'e' && s[i + 6] == 'r' && s[i + 7] == 'a' && s[i + 8] == 's' && s[i + 9] == 'e') i += 10;
			else if (s[i + 5] == 'e' && s[i + 6] == 'r') i += 7;
			else i += 5;
		}
		else if (s[i] == 'e' && s[i + 1] == 'r' && s[i + 2] == 'a' && s[i + 3] == 's' && s[i + 4] == 'e' && s[i + 5] == 'r') i += 6;
		else if (s[i] == 'e' && s[i + 1] == 'r' && s[i + 2] == 'a' && s[i + 3] == 's' && s[i + 4] == 'e') i += 5;
		else {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

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

int main() {
  set <int> s;
  int N;
  cin >> N;
  
  for(int i = 0; i < N; i++){
    int d;
    cin >> d;
    
    s.insert(d);
  }
  
  cout << s.size() << endl;
  
}


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

#define trav(a, A) for (auto & a : A)
#define f first
#define s second

typedef long long ll;

const ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+5+7;

 
 
template <typename T>
T extGcd(T a, T b, T& x, T& y) {
    if (b == 0) {
        x = 1; y = 0; return a;
    }
    else {
        T g = extGcd(b, a % b, y, x);
        y -= a / b * x; return g;
    }
}
 
template <typename T>
T modInv(T a, T m) {
    T x, y;
    extGcd(a, m, x, y);
    return (x % m + m) % m;
}
 
template <typename T>
T modDiv(T a, T b, T m) {
    return ((a % m) * modInv(b, m)) % m;
}
 
template<typename T>
T modMul(T a, T b, T m) {
	T x = 0, y = a % m;
	while (b > 0) {
		if (b % 2 == 1) x = (x + y) % m;
		y = (y * 2) % m; b /= 2;
	}
	return x % m;
}
 
template<typename T>
T modExp(T a, T b, T m) {
    if (b == 0) return (T)1;
    T c = modExp(a, b / 2, m);
    c = (c * c) % m;
    if (b % 2 != 0) c = (c*a) % m;
    return c;
}
 

void solve(){
    int n;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0, eq = 0;
    for (auto &b: a) cin >> b, sum += b, sum %= MOD, eq += (b*b)%MOD, eq %= MOD;
    ll ans = ((sum*sum) % MOD) - eq;
    ans += MOD;
    ans %= MOD;
    ans = modDiv(ans, 2ll, MOD);
    cout << (ans+MOD) % MOD << '\n';
}

int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	ll i, j, n;
	int t = 1; //cin >> t;
	while(t--) solve();
	return 0;
}



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

int main(){
	int n,k;
	cin >> n >> k;
	int num = 1;
	for (int i = 0; i < n; i++){
		if (num * 2 < num + k){
			num = num * 2;
		} else{
			num = num + k;
		}
	}
	cout << num << endl;
}

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

typedef long double ld;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long> vl;
typedef vector<double> vd;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

#define pi 3.14159265358979
#define eps 1e-9
#define inf 1<<30
#define MOD 1000000007 // 1e9+7

int main()
{
	int A, B, C, X, Y;

	cin >> A >> B >> C >> X >> Y;

  long sumAB, sumBA, sum;
  int rem;

  sum   = A*X + B*Y;

  sumAB = 2*C*X;
  rem = Y - X;
  if(rem > 0) sumAB += rem * B;

  sumBA = 2*C*Y;
  rem = X - Y;
  if(rem > 0) sumBA += rem * A;

  cout << min(sum, min(sumAB, sumBA)) << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  
    int n;
	cin >> n;
  	int kosuu[10][10]={0};
	rep1(i,n+1){
    	string s = to_string(i);
      	int sento = (s[0]-'0');
      	int ushiro = (s[s.size()-1]-'0');
      	kosuu[sento][ushiro]++;
    }
  	ll x=0;
  	rep1(i,10){
      rep1(j,10){
        x+=kosuu[i][j]*kosuu[j][i];
      }
    }
  	cout << x << endl;
  	return 0;
}

Measured memory_bytes: 256
def abc175_b():
    n = int(input())
    l = list(map(int, input().split(' ')))
    cnt = 0

    for i in range(0, n - 2):
        for j in range(i + 1, n):
            for k in range(j + 1, n):

                # 辺の長さが同じ場合は却下
                if l[i] == l[j] or l[j] == l[k] or l[k] == l[i]:
                    continue
                # 三角形になるにはa+b>c,b+c>a,c+a>b
                if (l[i] + l[j] > l[k]) and (l[j] + l[k] > l[i]) and (l[k] + l[i] > l[j]):
                    cnt += 1
    print(cnt)

if __name__ == '__main__':
    abc175_b()

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

int main() {
  vector<int> a(3);
  for (int i = 0; i < 3; ++i) cin >> a[i];
  int x = a[2];
  sort(a.begin(), a.end());
  if (x != a[0] && x != a[2]) puts("Yes");
  else puts("No");
}


Measured memory_bytes: 256
#include <iostream>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

int main() {
    int n;
    LL a;
    int odd_num=0;
    int x2_num=0;
    int x4_num=0;

    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a;
        if(a%2!=0){
            odd_num++;
        }else if(a%4==0){
            x4_num++;
        }else{
            x2_num++;
        }
    }

    bool ok;
    if(x4_num>=odd_num){
        ok=true;
    }else if(x4_num+1==odd_num && x2_num%2==0){
        ok=true;
    }else{
        ok=false;
    }

    if(ok==true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


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

int main() {
  string s;
  cin >> s;

  int ans = 0;
  for (int i = 0; i < 3; i++) {
    if (s[i] == '1')
      ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
	#define lb lower_bound 
	#define ub upper_bound
	#define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define mi          map<int,int>
	#define mii         map<pi,int>
	#define vi vector<int> 
	#define vvi vector<vi>
	#define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)	
	#define all(c) (c).begin(),(c).end()
	#define sz(x)       (int)x.size() 
	#define PI 3.14159265358979323846
	
	 const int N =2e5+5;
	
	 int mod= 1e9+7;
	 int dx[4]={0,0,+1,-1};
	 int dy[4]={+1,-1,0,0};  
	 
	 
	int po(int a, int b) {
		a %= mod;
		int res = 1;
		while (b > 0) {
			if (b & 1)
				res = (res * a) % mod;
			a =(a*a) % mod;
			b >>= 1;
		}
		 return res;	
	   }

	  
	 void solve() {		 
		   string s;
		   cin>>s;
		   int len=sz(s);
		   rep(i,1,len) {
			     if(s[i]!=s[i-1])  {
					   cout<<"Yes\n";
					   return;
					 }
			   }
			   cout<<"No\n";
		   
	            
	 }
	
int32_t main() {
	cool;
	int t=1;
	//cin>>t;
	while(t--)
	   solve();
	   
	   
	   return 0;	   
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let n = get!(usize);
    let v = get!([usize]);
    // eprintln!("n: {}", n);
    // eprintln!("v: {:?}", v);
    let mut nv = Vec::new();
    for i in 0..n {
        let t = (v[i], i + 1);
        nv.push(t);
    }
    nv.sort_by(|a, b| a.0.cmp(&b.0));
    let mut ans = String::new();
    for i in 0..n {
        ans += &nv[i].1.to_string();
        if i != n - 1 {
            ans += " ";
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 8956
N=int(input().strip())
A=list(map(int,input().split()))
d={}
for a in A:
    if a not in d:
        d[a]=0
    d[a]+=1
ct=0
for k,v in d.items():
    if k>v:
        ct+=v
    elif k<v:
        ct+=v-k
print(ct)

Measured memory_bytes: 17780
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

double DP[305][305][305], N;
bool visited[305][305][305];

double Calc(int i, int j, int k){
  if (i < 0 || j < 0 || k < 0) return 0;
  if (visited[i][j][k]) return DP[i][j][k];

  if (i == 0 && j == 0 && k == 0) return 0;

  visited[i][j][k] = true;
  double ans = 0;
  double I = i, J = j, K = k;

  ans += Calc(i - 1, j, k) * I / (I + J + K);
  ans += Calc(i + 1, j - 1, k) * J / (I + J + K);
  ans += Calc(i, j + 1, k - 1) * K / (I + J + K);
  ans += N / (I + J + K);

  return DP[i][j][k] = ans;
}

int main(){
  cin >> N;
  int A = 0, B = 0, C = 0;
  for (int i = 0; i < N; i++){
    int a; cin >> a;
    if (a == 1) A++;
    else if (a == 2) B++;
    else if (a == 3) C++;
  }
  printf("%.8lf\n", Calc(A, B, C));

  return 0;
}


Measured memory_bytes: 246016
#include<bits/stdc++.h>
#pragma GCC optimize(2)
#define ll long long
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,n,a) for(int i=n;i>=a;i--)
#define endl '\n'
#define eps 0.000000001
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))
#define IO ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const int INF=0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const int maxn=2e5+5;
int n,k,a[maxn];
bool check(int x){
	int ok=0;
	rep(i,1,n){
		if(a[i]%x==0) ok+=(a[i])/x-1;
		else ok+=(a[i])/x;
	}
	return ok<=k;
}
int main(){
	cin>>n>>k;
	rep(i,1,n) cin>>a[i];
	int l=1,r=1e9;
	while(l<r){
		int mid=(l+r)>>1;
		if(check(mid)) r=mid;
		else l=mid+1;
	}
	cout<<l<<endl;
}


Measured memory_bytes: 4312
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define LINF (ll)1e17
#define INF 1e9
#define MOD 1e9+7
#define sMOD 1e5
#define fs first
#define sc second


signed main(){
	
	ll a,b,c,d,e,f;
	string s,t;
	ll A[10000],B[10000],C[10000];
	
	
	cin >> a >> b;
	
	if(b % a == 0) cout <<  a+b << endl;
	else cout << b-a << endl;
	
	return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long res = Integer.MAX_VALUE;

        for(long i = 1L; i*i<=N; i++) {
            if(N%i!=0) continue;
            if(N%i==0) {
                long len1 = String.valueOf(i).length();
                long len2 = String.valueOf(N/i).length();

                res = Math.min(res, Math.max(len1, len2));
            }
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 35924
# a%b >= K iff xb+K <= a < (x+1)b
# bごとに数えるだけ

N,K = map(int,input().split())
ans = 0

for b in range(K+1,N+1):
  cnt = 0
  x_max = N//b
  # 0 <= x < x_max
  # 各xに対してb-K個ある
  cnt += x_max * (b-K)
  # x = x_max
  lower = x_max*b+K
  if lower <= N:
    upper = min((x_max+1)*b-1,N)
    cnt += upper - lower + 1
  ans += cnt

# N=0除外
if K == 0:
  ans -= N
  
print(ans)

Measured memory_bytes: 3064
N,Q=map(int,input().split())
graph=[[] for _ in range(N+1)]
for _ in range(N-1):
    a,b=map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)
data=[0 for i in range(N+1)]
visited=[False for i in range(N+1)]
for i in range(Q):
    p,x=map(int,input().split())
    data[p]+=x
    
from collections import deque
d=deque()
e=deque()
visited[1]=True
d.append(1)
while d:
    while d:
        x=d.popleft()
        adder=data[x]
        for node in graph[x]:
            if visited[node]==False:
                visited[node]=True
                data[node]+=adder
                e.append(node)
            else:
                pass
    if e:
        d=e
        e=deque()
print(*data[1:])

Measured memory_bytes: 56088