akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int, int>;

int main() {
  int N, M;
  cin >> N >> M;
  vector<pp> V(N), P(M);
  for (int i=0; i<N; i++) {
    cin >> V[i].first >> V[i].second;
  }
  for (int i=0; i<M; i++) {
    cin >> P[i].first >> P[i].second;
  }
  
  int INF=1000000000, m, mv;
  for (int i=0; i<N; i++) {
    mv=INF;
    for (int j=0; j<M; j++) {
      if (mv>abs(V[i].first-P[j].first)+abs(V[i].second-P[j].second)) {
        mv=abs(V[i].first-P[j].first)+abs(V[i].second-P[j].second);
        m=j+1;
      }
    }
    cout << m << endl;
  }
  
}


Measured memory_bytes: 3640
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n;
  cin >> n;
  gram g(n+1);
  ll a,b,c;
  rep(i,n-1){
    cin >> a >> b >> c;
    g[a][b]=c;
    g[b][a]=c;
  }
  ll q, k;
  cin >> q >> k;
  ll klist[n+1];

  ll co =0;
  function<void(ll, ll,ll)> dfs = [&](ll p,ll v,ll cost) {
      co++;
      klist[v]=cost;
      for(auto next_v:g[v]){
          if(next_v.first==p)continue;
          dfs(v,next_v.first,cost + next_v.second);
      }
  };
  dfs(-1,k,0);
  ll x,y;
  rep(i,q){
    cin >> x >> y;
    pri(klist[x]+klist[y]);
  }
  return 0;
}



Measured memory_bytes: 26880
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
typedef double D;
typedef complex<D> P;
const D EPS = 1e-8;

int n,r,q,r2;
P p[30];
int cur;
D min_s[30],x,y;

inline D dot(const P &x, const P &y){return real(conj(x)*y);}

inline P rotate(const P &v, const D &s){
  return P(real(v)*cos(s) - imag(v)*sin(s), real(v)*sin(s) + imag(v)*cos(s) );
}

inline D arg(const P &a,const P &b,const P &c){return dot(b-a,c-a)/(abs(b-a)*abs(c-a));}

inline D rot_seta(const int &end){
  D seta = acos( 1 - norm(p[end]-p[cur])/r2 );
  P nxt = rotate(p[cur],-seta);
  return arg(p[cur],p[end],nxt);
}

int main(){
  while(scanf("%d%d%d",&n,&r,&q), n){
    r2 = 2*r*r;
    rep(i,n){
      scanf("%lf%lf",&x,&y);
      p[i] = P(x,y);
      if(abs(abs(p[i])-r)<EPS)cur = i;
    }
    
    vector<int> nxt(n,-1);
    bool f = false;

    rep(i,q){
      if(nxt[cur]>=0)f = true;

      if(!f){
	min_s[cur] = 5;
	rep(j,n){
	  if(cur==j)continue;
	  D s = rot_seta(j);
	  if(nxt[cur]<0 || s > min_s[cur]+EPS)nxt[cur] = j, min_s[cur] = s;
	}
	min_s[cur] = acos(min_s[cur]);
      }

      rep(j,n){
	if(j==cur || (f&&nxt[cur]<0))continue;
	p[j] = rotate(p[j]-p[cur],min_s[cur]) + p[cur];
      }
      printf("%.4lf %.4lf\n",p[nxt[cur]].real(), p[nxt[cur]].imag());

      if(i==0){
	int tmp = nxt[cur];
	nxt[cur] = -1;
	cur = tmp;
      }else{
	cur = nxt[cur];
      }
    }
  }
}

Measured memory_bytes: 1336
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

struct p{
    int i;
    int j;
};

int main(){

    int h, w; cin >> h >> w;

    char a[h][w];
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> a[i][j];
        }
    }

    queue<p> que;
    int d[h][w] = {};
    int dx[] = {-1, 0, 1, 0};
    int dy[] = {0, -1, 0, 1};

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(a[i][j] == '#'){
                p ptemp = {i, j};
                que.push(ptemp);
            }
        }
    }

    while(!que.empty()){

        p pnow = que.front();
        que.pop();

        for(int dir=0; dir<4; dir++){
            int inext = pnow.i + dx[dir];
            int jnext = pnow.j + dy[dir];

            if(inext < 0 || inext >= h){
                continue;
            }
            if(jnext < 0 || jnext >= w){
                continue;
            }

            if(a[inext][jnext] == '.'){
                a[inext][jnext] = '#';
                d[inext][jnext] = d[pnow.i][pnow.j] + 1;
                p ptemp = {inext, jnext};
                que.push(ptemp); 
            }
        }
    }

    int ans = 0;

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            ans = max(ans, d[i][j]);
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 13328
#include <iostream>

using namespace std;

int a, b;

int maxim;

int main()
{
    cin >> a >> b;
    if (a > b)
    {
        maxim += a;
        a--;
    }
    else
    {
        maxim += b;
        b--;
    }
    if (a > b)
        maxim += a;
    else
        maxim += b;
    cout << maxim;
    return 0;
}


Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("Ofast")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

using ll = long long;
using ull = unsigned long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}


double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

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

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

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int x;
	scanf("%d", &x);
	printyn(x >= 30);

	Please AC;
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
#define rep(i,a) for(int i=0;i<(int)(a);i++)
#define pb push_back
#define sz size()
using namespace std;
typedef vector<int> vi;

const int INF = 1e9;

struct edge{
  int from,to,cost,cap,rev;
  edge(int a,int b,int c,int d,int e)
    :from(a),to(b),cost(c),cap(d),rev(e){}
};

struct dinic{
  int n;
  vector< vector<edge> > graph;
  vi level,iter;

  dinic(int a=0):n(a){graph.resize(a);}

  void AddEdge(int s,int g,int c,int p){
    graph[s].pb( edge(s,g,c,p,graph[g].sz) );
    graph[g].pb( edge(g,s,-c,0,graph[s].sz-1) );
  }

  void DeleteEdge(int s, int g){
    int id = -1, rev = -1;
    rep(e,graph[s].sz){
      if(graph[s][e].to == g){
	id = e; rev = graph[s][e].rev;
      }
    }
    if(id<0)return;

    swap(graph[s][id],graph[s].back());
    swap(graph[g][rev],graph[g].back());
    graph[s][id].rev = rev;
    graph[g][rev].rev = id;
    graph[s].pop_back(); graph[g].pop_back();
  }

  void bfs(int s){
    level = vi(n,-1);
    level[s] = 0;
    queue<int> q; q.push(s);
    while(q.sz){
      int v = q.front(); q.pop();
      for(edge e: graph[v]){
	if(e.cap > 0 && level[e.to] < 0){
	  level[e.to] = level[v] + 1;
	  q.push(e.to);
	}
      }
    }
  }
  
  int dfs(int v, int t, int f){
    if(v==t)return f;
    for(int &i = iter[v];i<(int)graph[v].sz;i++){
      edge &e = graph[v][i];
      if(e.cap > 0 && level[v] < level[e.to]){
	int d = dfs(e.to,t,min(f,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 res = 0;
    for(;;){
      bfs(s);
      if(level[t]<0)return res;
      iter = vi(n,0);
      int f;
      while((f=dfs(s,t,INF))>0)res += f;
    }
  }
};

inline int min_path_cover(const vector<int> &a){
  int n = a.size();
  dinic d(2*n+2);

  rep(i,n)rep(j,n){
    if(i!=j && a[j] % a[i] == 0)d.AddEdge(i+1,n+j+1,1,1);
  }
  rep(i,n){
    d.AddEdge(0,i+1,1,1);
    d.AddEdge(n+i+1,2*n+1,1,1);
  }
  return n-d.max_flow(0,2*n+1);
}

int main(){
  int n;
  cin >> n;
  vi a(n);
  rep(i,n)cin >> a[i];

  //calc optimal
  int opt = min_path_cover(a);

  vi res, use(n,0);
  //calc lex_min
  rep(i,n){
    if(use[i])continue;
    vi tmp;
    for(int j=i+1;j<n;j++){
      if(!use[j] && a[j]%a[i] && a[i]%a[j])tmp.push_back(a[j]);
    }
    if(min_path_cover(tmp) >= opt-1-(int)res.size()){
      res.push_back(i);
      for(int j=i+1;j<n;j++){
	if(a[j]%a[i]==0 || a[i]%a[j]==0)use[j] = 1;
      }
    }
  }
  
  rep(i,res.size()){
    cout << res[i]+1 << (i+1==(int)res.size()?"\n":" ");
  }
}

Measured memory_bytes: 1304
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    for(auto& x: s) cin >> x;

    Vvec<ll> dp(H, vector<ll>(W));
    dp[0][0] = (s[0][0] == '.') ? 0 : 1;

    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(i==0 && j==0) continue;
            dp[i][j] = 1e9;
            if(s[i][j]=='.'){
                if(i!=0) dp[i][j] = min(dp[i][j], dp[i-1][j]);
                if(j!=0) dp[i][j] = min(dp[i][j], dp[i][j-1]);
            }
            else{
                if(i!=0){
                    if(s[i-1][j]=='.') dp[i][j] = min(dp[i][j], dp[i-1][j]+1);
                    else dp[i][j] = min(dp[i][j], dp[i-1][j]);
                }
                if(j!=0){
                    if(s[i][j-1]=='.') dp[i][j] = min(dp[i][j], dp[i][j-1]+1);
                    else dp[i][j] = min(dp[i][j], dp[i][j-1]);
                }
            }
        }
    }

    cout << dp[H-1][W-1] << endl;
    // for(int i=0; i<H; i++) debug(dp[i]);
}

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

#define _USE_MATH_DEFINES

#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <bitset>
#include <complex>
#include <limits>
#include <random>


using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

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

	int N;
	cin >> N;
	vector<int> A(N);
	rep(i, 0, N)cin >> A[i];

	int ans = 0;
	rep(i, 0, N)rep(j, i + 1, N)rep(k, j + 1, N)
	{
		set<int> ts;
		ts.insert(A[i]);
		ts.insert(A[j]);
		ts.insert(A[k]);
		if (SZ(ts) < 3)continue;
		int ma = max({ A[i],A[j],A[k] });
		int sum = A[i] + A[j] + A[k];
		sum -= ma;
		if (sum > ma)
		{
			ans++;
		}
	}

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

Measured memory_bytes: 3656
while 1:
    n = int(raw_input())
    if n == 0: break
    exist = set([])
    time = [0]*1000
    bless = [0]*1000
    for loop in xrange(n):
        md,hm,io,p = raw_input().split()
        h,m = map(int,hm.split(":"))
        t = 60*h+m
        p = int(p)
        if io == "I":
            time[p] = t
            exist.add(p)
        else:
            exist.remove(p)
            if p == 0:
                for i in exist: bless[i] += t-max(time[p],time[i])
            elif 0 in exist:
                bless[p] += t-max(time[0],time[p])
    print max(bless)
    

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

int main(){
  string s, t, u;
  int a, b;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  if(s == u){
    cout << a-1 << " "<<b << endl;
  }else{
    cout << a << " " << b-1 << endl;
  }
  return 0;
}


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

bool f(char ch)
{
    if(ch=='A'||ch=='T'||ch=='C'||ch=='G')return true;
    return false;
}

int main()
{
    char s[40];
    cin>>s;
    int ct=0,ans=0;
    for(int i=0;s[i];i++)
    {
        if(f(s[i]))ct++;
        else ct=0;
        ans=max(ans,ct);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement, groupby
from math import floor, ceil, sqrt, factorial, log
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
from itertools import product
import sys
stdin = sys.stdin
mod = 10**9 + 7


def ns(): return stdin.readline().rstrip()


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


n, m = na()

if n == 3:
    ans = [-1, -1, -1]
    for _ in range(m):
        s, c = na()
        if ans[s - 1] == -1:
            ans[s - 1] = c
        else:
            if ans[s - 1] != c:
                print(-1)
                quit()
    if ans[0] == 0:
        print(-1)
        quit()
    print(ans[0] if ans[0] != -1 else 1, end="")
    for i in range(1, 3):
        print(ans[i] if ans[i] != -1 else 0, end="")
    print()
elif n == 2:
    ans = [-1, -1]
    for _ in range(m):
        s, c = na()
        if ans[s - 1] == -1:
            ans[s - 1] = c
        else:
            if ans[s - 1] != c:
                print(-1)
                quit()
    if ans[0] == 0:
        print(-1)
        quit()
    print(ans[0] if ans[0] != -1 else 1, end="")
    for i in range(1, 2):
        print(ans[i] if ans[i] != -1 else 0, end="")
    print()
else:
    ans = [-1]
    for _ in range(m):
        s, c = na()
        if ans[s - 1] == -1:
            ans[s - 1] = c
        else:
            if ans[s - 1] != c:
                print(-1)
                quit()
    print(ans[0] if ans[0] != -1 else 0, end="")
    print()


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

int main(){
  
  string s,t;
  cin >> s >> t;
  vector<int> c(26),d(26);
  for(int i=0; i<s.size(); i++){
  	c[s[i]-'a']++;
    d[t[i]-'a']++;
  }
  sort(c.begin(),c.end());
  sort(d.begin(),d.end());
  
  bool flg=0;
  for(int i=0; i<26; i++){
  	if(c[i]!=d[i]){
    	flg=1; 
    	break;
  	}
  }
  if(flg) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
int main() {
    string S;
    cin >> S;
    int cnt = 0;
    int ok = 0;
    for(int i = 0; i < S.size(); i++) {
        if(S[i] == 'S') {
            ok++;
        }
        else if(S[i] == 'T' && ok == 0) {
            cnt++;
        }
        else if(S[i] == 'T' && ok > 0) {
            ok--;
        }
    }
    cout << cnt*2 << endl;
}

Measured memory_bytes: 640
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type StackData struct {
	data interface{}
	next *StackData
}

type Stack struct {
	sp  *StackData
	top int
}

func NewStack() *Stack {
	return &Stack{top: 0}
}

func (s *Stack) Push(data interface{}) {
	s.sp = &StackData{data: data, next: s.sp}
	s.top++
}

func (s *Stack) Pop() interface{} {
	if s.top > 0 {
		item := s.sp.data
		s.sp = s.sp.next
		s.top--
		return item
	}
	return nil
}

func (s *Stack) Peek() interface{} {
	if s.top > 0 {
		return s.sp.data
	}
	return nil
}

func (s *Stack) IsEmpty() bool {
	if s.top == 0 {
		return true
	}
	return false
}

func (s *Stack) Size() int {
	return s.top
}

type Pair struct {
	p   int64
	num int64
}

func primeFactorize(n int64) *Stack {
	s := NewStack()
	for p := int64(2); p*p <= n; p++ {
		if n%p != 0 {
			continue
		}
		num := int64(0)
		for n%p == 0 {
			num++
			n /= p
		}
		s.Push(Pair{p: p, num: num})
	}
	if n != 1 {
		s.Push(Pair{n, 1})
	}
	return s
}

const MAX = 210000
const MOD = 1000000007

var fac, finv, inv [MAX]int64

func COMinit() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1
	for i := int64(2); i < MAX; i++ {
		fac[i] = fac[i-1] * i % MOD
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD
		finv[i] = finv[i-1] * inv[i] % MOD
	}
}

func COM(n, k int64) int64 {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

func main() {
	sc.Split(bufio.ScanWords)

	N, M := int64(nextInt()), int64(nextInt())
	COMinit()
	vec := primeFactorize(M)
	res := int64(1)
	for !vec.IsEmpty() {
		p := vec.Pop().(Pair)
		num := p.num
		tmp := COM(num+N-1, N-1)
		res = (res * tmp) % MOD
	}

	fmt.Println(res)
}


Measured memory_bytes: 5504
package main

import (
	"fmt"
	"math"
)

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

	dp := make([]int, n+1)
	for i := range dp {
		dp[i] = math.MaxInt32
	}
	dp[0] = 0

	for i := 1; i <= n; i++ {
		for p := 1; p <= i; p *= 6 {
			dp[i] = min(dp[i], dp[i-p]+1)
		}
		for p := 1; p <= i; p *= 9 {
			dp[i] = min(dp[i], dp[i-p]+1)
		}
	}
	fmt.Println(dp[n])
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(i = 0; i < n; i++)
//2D::rep(i,j)rep(j,j)cin>>bin[i][j];
//vector<int> a(n)
#define Graph vector<vector<int>>
#define A1 cout<<"No"<<endl
#define A2 cout<<"Yes"<<endl
#define A3 cout<<ans<<
#define AA(i) cout<<i<<endl;
const int U=2e5+5;
const ll MOD=1000000007;
const int INF = 1001001001;

int main(){
    int N; cin >> N;
    vector<int> A(N+1);
    A[N] = 0;
    int i;
    ll ans=1000;
    ll anss = ans;
    ll x = 0;
    rep(i,N) cin >> A[i];
    for(i=0;i<N;i++){
        if(A[i] < A[i+1]){
            x = ans / A[i];
            ans = ans + (A[i+1]-A[i]) * x;
        }
    }
    AA(ans);
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
 
using namespace std;
 
int main()
{
    int min = 10000000, max = -10000000, x;
    for (int i = 0; i < 3; ++i)
    {
    	cin >> x;
    	if (x > max)
    		max = x;
    	if (x < min)
    		min = x;
    }
    cout << max-min << "\n";
    return 0;
}

Measured memory_bytes: 256
k=int(input())
if 400<= k <600:
  s=8
elif 600<= k <800:
  s=7
elif 800<= k <1000:
  s=6
elif 1000<= k <1200:
  s=5
elif 1200<= k <1400:
  s=4
elif 1400<= k <1600:
  s=3
elif 1600<= k <1800:
  s=2
elif 1800<= k <2000:
  s=1
print(s)

Measured memory_bytes: 9188
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>

#define ll long long
using namespace std;
static ll imin = std::numeric_limits<ll>::min();
static ll imax = std::numeric_limits<ll>::max();
#define rep(i, n) for(int i = 0; (i)<(n); ++(i))
#define rep1(i, n) for(int i = 1; (i)<(n); ++(i))
#define rev_rep(i, n) for(int i = (n) - 1; (i) >= 0; --(i))
#define range(a, i, b) for(int i = (a); (i) < (b); ++(i))
#define dump(x) cout << #x << ":" << x << "\n";
#define all(v) v.begin(), v.end()
#define readl(N) ll N; cin >> N
#define readlv(N, vec) vector<ll> vec(N); rep(i, N){cin >> vec[i];}
#define greater_than [](ll l, ll r){return l > r;}
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair);
template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair){
  os << '(' << pair.first << ',' << pair.second << ')';
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(ll i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::set<T>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

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

ll fact(ll n){
  ll res=1;
  while(n>=0){
    res*=n;
    n--;
  }
  return res;
}
    
ll pow(ll i, ll n){
  ll res=1;
  while(n>=0){
    res*=i;
    n--;
  }
  return res;
}

ll gcd(ll l, ll r){
  if(l<r){
    return gcd(r, l);
  }
  if(r == 0){
    return l;
  }
  return gcd(r, l % r);
}

template<class T>
vector<T> accum_sum(vector<T> a){
  vector<T> b(a.size() + 1);
  b[0] = a[0];
  rep(i, a.size()){
    b[i + 1] = b[i] + a[i];
  }
  return b;
}

#ifndef BOOST_TEST_MAIN
int main(int const argc, char const** argv){
  readl(N);
  ll res;
  cin >> res;
  rep1(i, N){
    ll x;
    cin >> x;
    res = gcd(x, res);
  }
  cout << res;
}
#endif


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	
	int i,N,T,A,nearest,n=1;
	int H[1010];
	double ans;

	scanf("%d", &N);
	scanf("%d %d", &T, &A);
	
	for(i=1;i<=N;i++)
	scanf("%d", &H[i]);
	
	ans=(T-A)/0.006;
	
	
	nearest=H[1];
	
	for(i=2;i<=N;i++){
		if((H[i]-ans)*(H[i]-ans)<(nearest-ans)*(nearest-ans)){
		nearest=H[i];
		n=i;}
	}
	
	
	printf("%d", n);
	
return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <set>
#include <map>
#include <list>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define MOD 1000000007
#define PI 3.1415926535897932
#define rep(i, n) for (int i = 0; i < n; i++)
#define repe(i, j, n) for (int i = j; i < n; i++)
#define repi(i, n) for (int i = 0; i <= n; i++)
#define repie(i, j, n) for (int i = j; i <= n; i++)
#define all(x) x.begin(), x.end()
#define println() cout << endl
#define P pair<int, int>
#define fi first
#define se second

typedef long long ll;

long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

void solve1()
{
    ll a, b, c, d; cin >> a >> b >> c >> d;

    ll ans = 0;
    cout << max({a*c, b*d, a*d, b*c}) << endl;
}

int main()
{
    solve1();
}


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

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	int W; cin >> W;
	cout << W * 32 << endl;
	return 0;
}

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

typedef long long ll;

ll memo[2][3001][3001];
bool vis[2][3001][3001];
ll arr[3001];

ll DEQUE(int bx, int i, int j)
{
	if(i == j)
	{
		if(!bx)
		return arr[i];	
		else return -arr[i];
	}	
	if(vis[bx][i][j])
	return memo[bx][i][j];
	ll ans = 0;
	if(!bx)
	ans = std::max(arr[i] + DEQUE(bx ^ 1, i+1, j), arr[j] + DEQUE(bx ^ 1, i, j-1));
	else ans = std::min(-arr[i] + DEQUE(bx ^ 1, i+1, j), -arr[j] + DEQUE(bx ^ 1, i, j-1));
	vis[bx][i][j] = 1;
	memo[bx][i][j] = ans;
	return ans;	
}

int main(void)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	memset(memo, -1, sizeof(memo));
	memset(vis, 0, sizeof(vis));
	int n;
	std::cin>>n;
	for(int i=1;i<=n;i++)
	std::cin>>arr[i];
	ll ans = DEQUE(0, 1, n);	
	std::cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 158848
a0=list(map(int, input().split()))
a1=list(map(int, input().split()))
a2=list(map(int, input().split()))
n=int(input())
b=[]
for i in range(n):
    b.append(int(input()))
ans=[]
for i in b:
    if (i in a0) == True:
        ans.append(a0.index(i))
    if (i in a1) == True:
        ans.append((a1.index(i))+3)
    if (i in a2) == True:
        ans.append((a2.index(i))+6)
if (0 in ans) and (1 in ans) and (2 in ans) == True:
    print("Yes")
elif (0 in ans) and (3 in ans) and (6 in ans) == True:
    print("Yes")
elif (0 in ans) and (4 in ans) and (8 in ans) == True:
    print("Yes")
elif (1 in ans) and (4 in ans) and (7 in ans) == True:
    print("Yes")
elif (2 in ans) and (5 in ans) and (8 in ans) == True:
    print("Yes")
elif (2 in ans) and (4 in ans) and (6 in ans) == True:
    print("Yes")
elif (3 in ans) and (4 in ans) and (5 in ans) == True:
    print("Yes")
elif (6 in ans) and (7 in ans) and (8 in ans) == True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
    IOS;
    string s;
    cin>>s;
    reverse(s.begin(),s.end());
    int n=s.size();
    int dp[n][2];
    memset(dp,M,sizeof(dp));
    dp[0][0]=(s[0]-'0');
    dp[0][1]=(10-(s[0]-'0'));
    for(int i=1;i<n;i++){
    	dp[i][0]=min(dp[i-1][0]+s[i]-'0',dp[i-1][1]+1+s[i]-'0');
    	dp[i][1]=min(dp[i-1][0]+10-(s[i]-'0'),dp[i-1][1]+9-(s[i]-'0'));
    }
    cout<<min(dp[n-1][0],dp[n-1][1]+1);
}

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

int main() {
    long long N, W;
    cin >> N >> W;
    vector<long long> w(N), v(N);
    for (int i = 0; i < N; ++i) cin >> w[i] >> v[i];
    
    vector<vector<long long>> dp(N+1, vector<long long>(W+1, 0));
    for (int i = 0; i < N; ++i) {
        for (int sum_w = 0; sum_w <= W; ++sum_w) {
            if (sum_w - w[i] >= 0) {
                dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w - w[i]] + v[i]);
            }

            dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }

    cout << dp[N][W] << endl;
}


Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;
const int N=105;
int dp[N][2][2][4],n,k;
char s[N];
int dfs(int i,int f1,int f2,int sum)
{
	if(sum>k)
		return 0;
	int &f=dp[i][f1][f2][sum];
	//printf("%d %d %d %d\n",i,f1,f2,sum);
	if(f!=-1)
		return f;
	f=0;
	if(i==n+1)
		return f=(f2==0&&sum==k);
	for(int j=0;j<=9;j++)
	{
		if(f1&&j>s[i]-'0')
			break;
		int nf1=(f1&&(j>=s[i]-'0')),nf2=(f2&&(j==0)),nsum=sum+(nf2==0&&j!=0);
		//printf("(%d %d %d %d)->(%d %d %d %d)\n",i,f1,f2,sum,i+1,nf1,nf2,nsum);
		f+=dfs(i+1,nf1,nf2,nsum);
	}
	//printf("#%d %d %d %d %d\n",i,f1,f2,sum,f);
	return f;
}
int main()
{
	memset(dp,-1,sizeof(dp));
	scanf("%s",s+1);
	n=strlen(s+1);
	scanf("%d",&k);
	printf("%d\n",dfs(1,1,1,0));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

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

    ll n = sz(s);

    if (n == 1) {
        cout << k/2 << endl;
        return 0;
    }


    ll cnt = 0;
    rep(i, n-1) {
        int tmp = 1;
        while (s[i] == s[i+1]) {
            tmp++;
            i++;
            if (i >= n-1) break;
        }
        cnt += tmp/2;
    }

    ll ans = 0;
    ans = cnt * k;

    int t = 0;
    int t2 = 0;
    if (s[0] == s[n-1]) {
        int i = 0;
        while (s[i] == s[i+1]) {
            t++;
            i++;
            if (i == n-1) break;
        }
        if (t == n-1) {
            cout << (n*k)/2 << endl;
            return 0;
        }
        if (t != n-1) { //全文字同じじゃない
            i = 0;
            while (s[n-1-i] == s[n-2-i]) {
                t2++;
                i++;
            }
        }
        // if (t == 1 || t2 == 1) {
        //     cout << ans << endl;
        //     return 0;
        // }
        //t += t2;
        // if (t%2 == 0) {
        if (t%2==0 && t2%2==0) {
            ans += k-1;
        }
    }

    cout << ans << endl;

}

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

using ll = long long;
using namespace std;

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

int main(void) {
	int a, p;
	cin >> a >> p;
	
	cout << (3 * a + p) / 2 << endl;
	
	return 0;
}


Measured memory_bytes: 256
//??????B?????????????????????????????????????????§???by Mikami
#include <stdio.h>
#include <stdlib.h>
#define MAX_LEN (1024)

#define CONSTANT     (0) 
#define BOP_ADD      (1) 
#define BOP_SUBTRACT (2)
#define BOP_MULTIPLY (3) 
#define BOP_DIVIDE   (4)
#define UOP_MINUS    (5)
#define UOP_PLUS     (6)

void throwError(char *msg){
	fprintf(stderr,"Error: %s\n",msg);
	exit(1);
}
typedef struct _NODE_{
	int type;
	int value;
	struct _NODE_ *l,*r;
} NODE;


char expr[MAX_LEN];
int pos;

NODE* S();
NODE* E();
NODE* T();
NODE* F();

NODE* S(){
	pos=0;
	NODE* res = E();
	if(expr[pos] != '\0') throwError("syntax error");
	return res;
}


NODE* E(){
	NODE *res = T();
	while( expr[pos] == '+' || expr[pos] == '-' ){
		NODE *tmp = (NODE*) malloc(sizeof(NODE));
		if( expr[pos] == '+'){
			pos++;
			tmp->type = BOP_ADD; 
			tmp->l = res;
			tmp->r = T();
		}else{
			pos++;
			tmp->type = BOP_SUBTRACT; 
			tmp->l = res;
			tmp->r = T();
		}
		res = tmp;
	}
	return res;
}


NODE* T(){
	NODE *res = F();
	while( expr[pos] == '*' || expr[pos] == '/' ){
		NODE *tmp = (NODE*) malloc(sizeof(NODE));
		if( expr[pos] == '*'){
			pos++;
			tmp->type = BOP_MULTIPLY; 
			tmp->l = res;
			tmp->r = F();
		}else{
			pos++;
			tmp->type = BOP_DIVIDE; 
			tmp->l = res;
			tmp->r = F();
		}
		res = tmp;
	}
	return res;
}

NODE* F(){
	if( expr[pos] == '(' ){
		pos++;
		NODE *res = E();
		if( expr[pos] != ')' ) throwError("syntax error");
		pos++;
		return res;
	}else if( expr[pos] == '-' ){
		pos++;
		NODE *tmp = (NODE*) malloc(sizeof(NODE));
		tmp->type = UOP_MINUS;
		tmp->l = F();
		tmp->r = NULL;
		return tmp;
	}else if( expr[pos] == '+' ){
		pos++;
		NODE *tmp = (NODE*) malloc(sizeof(NODE));
		tmp->type = UOP_PLUS;
		tmp->l = F();
		tmp->r = NULL;
		return tmp;	
	}else{ // number
		if( !(expr[pos] >= '0' && expr[pos] <= '9') ) throwError("syntax error");
		NODE *tmp = (NODE*) malloc(sizeof(NODE));
		tmp->type = CONSTANT;
		tmp->l = tmp->r = NULL;
		tmp->value = 0;
		while( expr[pos] >= '0' && expr[pos] <= '9' )
			tmp->value = tmp->value * 10 + expr[pos++] - '0';
		return tmp;
	}
}

int calc(NODE *root){
	int tmp;
	switch(root->type){
		case BOP_ADD:
			return calc(root->l)+calc(root->r);
		case BOP_SUBTRACT:
			return calc(root->l)-calc(root->r);
		case BOP_MULTIPLY:
			return calc(root->l)*calc(root->r);
		case BOP_DIVIDE:
			tmp = calc(root->r);
			if(tmp==0) throwError("Division by zero");
			return calc(root->l)/tmp;
		case UOP_PLUS:
			return +calc(root->l);
		case UOP_MINUS:
			return -calc(root->l);
		case CONSTANT:
			return root->value;
	};
	throwError("unknown");
	return -1;
}

int main(){
	int n;
	scanf("%d",&n);
	while(n--){
		scanf("%s",expr);
		expr[strlen(expr)-1] = '\0';
		NODE *root = S();
		printf("%d\n",calc(root));
	}
}

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

int main()
{
	long long int n, k, c = 0;
	cin >> n >> k;
	if(n == 0)
	{
		cout << 1 << endl;
		return 0;
	}
	while(n > 0)
	{
		n /= k;
		c++;
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        n = ni();
        a = new int[n];
        p = new boolean[n - 1];

        dp = new long[2][2][n];

        for (int i = 0; i < n; i++) {
            a[i] = ni();
            if (i < n - 1) p[i] = ns().equals("+");
        }

        dp[0][0][0] = a[0];
        dp[1][0][0] = dp[1][1][0] = dp[0][1][0] = Long.MIN_VALUE / 2;

        for (int i = 1; i < n; i++) {
            if (p[i - 1]) {
                dp[0][0][i] = Math.max(dp[0][0][i - 1] + a[i], dp[0][1][i - 1] + a[i]);
                dp[0][1][i] = dp[0][1][i - 1] - a[i];
                dp[1][0][i] = dp[1][1][i - 1] + a[i];
                dp[1][1][i] = dp[1][1][i - 1] + a[i];

            } else {
                dp[0][0][i] = dp[0][1][i - 1] + a[i];
                dp[0][1][i] = dp[0][0][i - 1] - a[i];
                long ret = Long.MIN_VALUE;
                for (int j = 0; j < 2; j++) {
                    for (int k = 0; k < 2; k++) {
                        if (j == 0 && k == 0) continue;
                        ret = Math.max(ret, dp[j][k][i - 1]);
                    }
                }
                dp[1][0][i] = Math.max(dp[0][1][i - 1] + a[i], ret + a[i]);
                dp[1][1][i] = Math.max(dp[0][1][i - 1] - a[i], ret + a[i]);
            }
        }

        long ans = Long.MIN_VALUE;

        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 2; j++) {
                ans = Math.max(ans, dp[i][j][n - 1]);
            }
        }

        out.println(ans);
    }

    int n;
    int[] a;
    boolean[] p;
    long[][][] dp;

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 34732
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
struct uf {
	vector<int> a;
	uf(int n) : a(n, -1) {}
	int root (int x) {
		return a[x] < 0 ? x : a[x] = root(a[x]);
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x != y) {
			if (a[x] > a[y]) swap(x, y);
			a[x] += a[y];
			a[y] = x;
		}
	}
};
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<int> in(n);
	for (int i = 0; i < n; i++) {
		cin >> in[i];
		in[i]--;
	}
	uf u(n);
	for(int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		u.unite(in[x], in[y]);
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += u.same(in[i], in[in[i]]);
	}
	cout << ans << '\n';
	return 0;	
}


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

using namespace std;
typedef long long ll;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
const ll mod = 1e9 + 7;
#define REP(i, o, n) for (ll i = o; i < n; i++)
#define rep(i, n) REP(i, 0, n)

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll a, ll b) { return a / gcd(b, a % b) * b; }

void actual() {
  int a, b, c, ans;
  cin >> a >> b >> c;
  ans = c - (a - b);

  if (ans < 0) {
    cout << 0 << endl;
  } else {
    cout << ans << endl;
  }
}


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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
					  cerr << "\n\n" << "Time elapsed: " << \
					  (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
					  return 0
#define ll long long int
#define ull unsigned long long int
#define db long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define pii pair<int , int>
#define pdd pair<db , db>
#define pll pair<ll , ll>
#define vpl vector<pll >
#define vll vector<ll >
#define mod 1000000007
#define inf 100000000000000007
#define eps 0.000001
#define stp fixed<<setprecision(20)
#define endl '\n'

vll adj[100005];
bool vis[100005];
ll in[100005];
ll pr[100005];

int main()
{
	fastio;
	#ifdef APNA_IO
		start_routine();
        freopen("input.txt", "rt", stdin);
        freopen("output.txt", "wt", stdout);
    #endif

	ll n,m;cin>>n>>m;

	for(ll i=0;i<n+m-1;i++)
	{
		ll x,y;cin>>x>>y;
		adj[x].pb(y);
		in[y]++;
	}

	ll root=0;
	for(ll i=1;i<=n;i++)
		if(in[i]==0)
			root=i;

	queue<ll> q;
	q.push(root);
	vis[root]=1;
	pr[root]=0;

	while(q.size())
	{
		ll x=q.front();
		q.pop();

		for(auto i:adj[x])
		{
			if(vis[i])
				continue;

			if(in[i]!=1)
			{
				in[i]--;
				continue;
			}

			vis[i]=1;
			pr[i]=x;
			q.push(i);
		}
	}

	for(ll i=1;i<=n;i++)
		cout<<pr[i]<<endl;
	
	
	#ifdef APNA_IO
		end_routine();
    #endif
}

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

int main(){
    long long N, H;
    cin >> N >> H;
    vector<long long> a(N+1), b(N+1);
    for( int i = 0; i < N; i++ ){
        cin >> a[i] >> b[i];
    }

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    long long ans = 0;
    int max_a = N, max_b = N;
    while( H > 0 ){
        if( a[max_a] < b[max_b] ){
            H -= b[max_b];
            max_b--;
            ans++;
        } else {
            ans += (H + a[max_a] - 1)/a[max_a];
            H = 0;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int Q_MAX = 200002;

int n, q;

int a1[Q_MAX], b1[Q_MAX];
int lg1;

int a2[Q_MAX], b2[Q_MAX];
int lg2;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> q;
    n -= 2;
    lg1++;
    a1[lg1] = n + 1;
    b1[lg1] = n + 1;
    lg2++;
    a2[lg2] = n + 1;
    b2[lg2] = n + 1;
    ll ans = 1LL * n * n;
    for(int i = 1; i <= q; i++)
    {
        int op, x;
        cin >> op >> x;
        x--;
        if(op == 1)
        {
            int l = 1, r = lg2;
            while(l < r)
            {
                int mid = ((l + r + 1) >> 1);
                if(b2[mid] < x)
                    r = mid - 1;
                else
                    l = mid;
            }
            if(x < b1[lg1])
            {
                lg1++;
                a1[lg1] = a2[l] - 1;
                b1[lg1] = x;
            }
            ans -= a2[l] - 1;
        }
        else
        {
            int l = 1, r = lg1;
            while(l < r)
            {
                int mid = ((l + r + 1) >> 1);
                if(a1[mid] < x)
                    r = mid - 1;
                else
                    l = mid;
            }
            if(x < a2[lg2])
            {
                lg2++;
                a2[lg2] = x;
                b2[lg2] = b1[l] - 1;
            }
            ans -= b1[l] - 1;
        }
    }
    cout << ans << "\n";
    return 0;
}


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

int main() {
    int A[101][101];

    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            A[i][j] = 0;
        }
    }

    int u, k;
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        int ad;
        for (int j = 0; j < k; j++) {
            cin >> ad;
            A[u-1][ad-1] = 1;
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (j != 0) cout << " ";
            cout << A[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3116
#include<cstdio>
#include<iostream>
#include<string>
#include <algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
using ll = long long;

ll m[10000];

int main(){
	int n, x,sum=0;

	cin >> n >> x;

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

	for (int i = 0; i < n; i++) {
		x = x - m[i];
	}

	int z = m[0];
	for (int i = 1; i < n; i++) {
		if (z > m[i]) {
			z = m[i];
		}
	}

	cout << n + (x / z) << endl;
	return 0;
}


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

listw = [0]
for i in range(N):
    listw.append(listw[-1]+1 if S[i] == "W" else listw[-1])

liste = [0]
for i in range(N):
    liste.append(liste[-1]+1 if S[i] == "E" else liste[-1])

list = [0]*N
for i in range(N):
    list[i] = listw[i] + liste[-1] - liste[i+1 if i != N-1 else -1]

list.sort()

print(list[0])


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

int main() {
    ll n; cin >> n;
    vector<ll> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    sort(a.begin(),a.end());
    ll cnt = 0;
    for(int i=0; i<n; i++) {
        for(int j=i+1; j<n; j++) {
            for(int k=j+1; k<n; k++) {
                if(a[i] == a[j] || a[j] == a[k] || a[k] == a[i]) continue;
                if(a[i] + a[j] > a[k]) cnt++;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3624