akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <string>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N, M, K;
    cin >> N >> M >> K;
    set<int> poss;
    REP(n, N+1) {
        REP(m, M+1) {
            int tmp = m * N + n * M - m * n * 2;
            poss.insert(tmp);
        }
    }
    cout << (poss.count(K) ? "Yes" : "No") << endl;

    return 0;
}


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

template <typename T>
struct RangeTree {
	int N; vector<T> node_vals;
	T base_value;
	int ceil_pow_2(int v) { // Nearest power of two upper bound.
		int p; for (p = 1; p < v; p *= 2) {} return p;
	}
	RangeTree(int sz, T base) : base_value(base), N(ceil_pow_2(sz)) {
		node_vals.resize(2*N-1, base_value);
	}
	T combine(T a, T b) { return max(a, b); } // Could be min or +.
	T query(int l, int r, int nid, int nl, int nr) {
		if (l == nl && r == nr)
			return node_vals[nid];
		int mid = (nl+nr)/2; T result = base_value;
		if (l <= mid)
			result = combine(result, query(l, min(r, mid), 2*nid+1, nl, mid));
		if (r > mid)
			result = combine(result, query(max(l, mid+1), r, 2*nid+2, mid+1, nr));
		return result;
	}
	T query(int l, int r) { return query(l, r, 0, 0, N-1); }
	void update(int index, T value, int nid, int nl, int nr) {
		if (nl == nr) { node_vals[nid] = value; return; }
		int mid = (nl+nr)/2;
		if (index <= mid) 	update(index, value, 2*nid+1, nl, mid);
		else				update(index, value, 2*nid+2, mid+1, nr);
		node_vals[nid] = combine(node_vals[2*nid+1], node_vals[2*nid+2]);
	}
	void update(int index, T value) { update(index, value, 0, 0, N-1); }
	// Optional
	void print() {
		for (int i : node_vals)
			cout << i << " ";
		cout << endl;
	}
};

const int maxv = 300000;


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	for (int &e : A) cin >> e;
	RangeTree<int> rt(maxv*2+5, 0);
	for (int i = N-1; i >= 0; --i) {
		int ans = rt.query(A[i]-K+maxv, A[i]+K+maxv)+1;
		rt.update(A[i]+maxv, ans);
	}
	cout << rt.query(0, maxv*2+2) << endl;
}

Measured memory_bytes: 12712
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
using namespace std;

typedef long long ll;
ll mod = 1000000007;

int main() {
    ll n,m;
    cin>>n>>m;
    multiset<ll> st;
    for (ll i = 0; i < n; i++) {
        ll v; cin>>v;
        st.insert(-v);
    }
    for (ll i = 0; i < m; i++) {
        ll v = *st.begin();
        v /= 2;
        st.erase(st.begin());
        st.insert(v);
    }                   
    ll ans = 0;
    for (const auto& v : st) ans -= v;
    cout<<ans<<"\n";    
}

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

const int MOD = 1e9+7;

int modPow(ll a, ll n, ll mod) {
  if(n == 0) return 1;
  if(n == 1) return a % mod;
  if(n % 2 == 1) return (a * modPow(a, n-1, mod)) % mod;
  ll t = modPow(a, n/2, mod);
  return (t*t) % mod;
}

int main(){
  int n;
  cin >> n;
  ll ans = modPow(10, n, MOD);
  ans -= (modPow(9, n, MOD) *2) % MOD;
  ans += modPow(8, n, MOD);
  cout << (ans+MOD)%MOD << endl;
  return 0;
}

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

int main(){
  int a,b,S;
  cin >> S;
  a = S/100;
  b = S%100;
  if(a > 12||a==0){
    if(b <= 12&&b > 0)
      cout << "YYMM" <<endl;
    else
      cout << "NA" << endl;
  }
  if(a<=12&&a>0){
    if(b<=12&&b>0){
      cout << "AMBIGUOUS" << endl;
    }
    if(b>12||b==0){
      cout << "MMYY" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

struct union_find {
  vector<int> rank_, size_, rid_;
  union_find(int n) { rank_.resize(n); rid_.assign(n, -1); size_.resize(n, 1); }
  void operator()(int u, int v) {
    u = operator[](u), v = operator[](v);
    if(u == v) { return; }
    size_[u] = size_[v] = size_[u] + size_[v];
    if(rank_[u] < rank_[v]) { rid_[u] = v; }
    else { rid_[v] = u; if(rank_[u] == rank_[v]) { rank_[u]++; } }    
  }
  int operator[](int x) { if(rid_[x] < 0) return x; else return rid_[x] = operator[](rid_[x]); }
  int size_of(int x) { return size_[x]; }
};

using edge = tuple<int, int, double>;
vector<edge> edges;

int main() {

  int N, M; cin >> N >> M;
  vector<complex<double>> pts;
  rep(i, N) {
    double x, y; cin >> x >> y;
    pts.emplace_back(x, y);
  }
  rep(i, M) {
    int x, y; cin >> x >> y; x--, y--;
    edges.emplace_back(x, y, abs(pts[x] - pts[y]));
  }

  union_find uf(N);

  sort(all(edges), [&](const edge& a, const edge& b){ return get<2>(a) > get<2>(b); });

  double cost = 0.0;

  rep(i, M) {
    int x, y; double c; tie(x, y, c) = edges[i];
    if(uf[x] == uf[y])
      cost += c;
    else 
      uf(x, y);
  }

  printf("%.10f\n", cost);

  return 0;
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = n; i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
	rep(i, 5) {
		int x; cin >> x;
		if (x == 0) {
			cout << i+1 << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3524
#include <iostream>
#include <cstring>
using namespace std;
struct s
{ int nr;
  char l;
};
char s1[200004],s2[200004];
s l1[40],l2[40];
int n,k1,k2;
bool ok;
int main()
{ cin>>s1>>s2;
  n=strlen(s1);
  for(int i=0;i<n;i++)
  { int j;
    ok=0;
    for(j=1;j<=k1 && !ok;j++)
      if(l1[j].l==s1[i])
         ok=1,j--;
    if(!ok)
       k1++,l1[k1].nr=1,l1[k1].l=s1[i];
    else
       l1[j].nr++;
    ok=0;
    for(j=1;j<=k2 && !ok;j++)
      if(l2[j].l==s2[i])
         ok=1,j--;
    if(!ok)
       k2++,l2[k2].nr=1,l2[k2].l=s2[i];
    else
       l2[j].nr++;
    if(k1!=k2)
    { cout<<"No";
      return 0;
    }
    ok=1;
    for(int i=1;i<=k1 && ok;i++)
      if(l1[i].nr!=l2[i].nr)
         ok=0;
    if(!ok)
    { cout<<"No";
      return 0;
    }
  }
  cout<<"Yes";
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define lb long double
#define f(i,a,b) for(ll i = a;i <= b;i ++)
#define fi(i,a,b) for(ll i = a;i >= b;i --)
using namespace std;
ll n,dem;
int main()
{
    cin >> n;
    f(i,1,n)
    {
        if(i % 3 != 0 && i % 5 != 0) dem += i;
    }
    cout << dem;
    return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
#include<functional>
#include<unordered_map>
#include<cmath>
#include<cstdlib>
#include<cassert>
using namespace std;

int main() {
	int N, ans = 1;
	cin >> N;
	while (ans * 2 <= N) {
		ans *= 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: i64 = read();
    let b: i64 = read();
    let c: i64 = read();
    if a == b {
        println!("{}", c);
        return;
    }
    if c == b {
        println!("{}", a);
        return;
    }
    if a == c {
        println!("{}", b);
        return;
    }
}


Measured memory_bytes: 2140
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

vector<vector<int> > path_list(8,vector<int>(0));
int ans=0;
int N,M;
int dfs(vector<int> passed, int cnt, int node){
    if(passed[node]==1)return 0;
    else{
        cnt++;
        passed[node]=1;
    }

    if(cnt==N){
        ans++;
        return 0;
    }

    for(int i=0; i<(int)path_list[node].size(); i++){
        dfs(passed, cnt, path_list[node][i]);
    }
}

int main(){
    cin >> N >> M;
    
    for(int i=0; i<M; i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        path_list[a].push_back(b);
        path_list[b].push_back(a);
    }
    vector<int> passed(8,0);
    dfs(passed, 0, 0);

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) (max(x,y)-min(x,y))
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;

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

  string s;
  cin >> s;
  int ans = 0, Ssum = 0;
  rep(i, s.size()){
    if(s[i] == 'S'){
      Ssum ++;
    } else {
      if(Ssum != 0){
	ans += 2;
	Ssum --;
      }
    }
  }
  cout << s.size() - ans << '\n';
  return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  int b[n];
  int c[n-1];
  int sum = 0;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  for(int i=0; i<n; i++) {
    cin >> b[i];
  }
  for(int i=0; i<n-1; i++) {
    cin >> c[i];
  }
  for(int i=0; i<n; i++) {
    sum += b[a[i]-1];
    if(a[i] + 1 == a[i+1]) {
      sum += c[a[i]-1];
    }
  }
  cout << sum << endl;
  
}


Measured memory_bytes: 256
N, K, *A = map(int, open(0).read().split())

A = [0] + A
visited = [-1] * (N + 1)

pre = 0
cycle = 0

cur = 1
for i in range(N):
    visited[cur] = i

    cur = A[cur]
    if visited[cur] >= 0:
        pre = visited[cur]
        cycle = i + 1 - visited[cur]
        break

cur = 1
for _ in range(min(K, pre + ((K - pre) % cycle))):
    cur = A[cur]

print(cur)


Measured memory_bytes: 31808
#include <stdio.h>

int main() {
    int i, j, k;
    int people, foods;
    int temp, count = 0;
    int klist[30] = {0};
    int chklist[30] = {0};
    int AK[30][30] = {0};
    
    scanf("%d",&people);
    scanf("%d",&foods);
    
    for (i = 0; i < people; i++) {
        scanf("%d",&klist[i]);
        for (j = 0; j < klist[i]; j++) {
            scanf("%d",&AK[i][j]);
        }
    }

    for (k = 1; k <= foods; k++) {
        temp = 0;
        for (i = 0; i < people; i++) {
            for (j = 0; j < klist[i]; j++) {
                if(k == AK[i][j]) {
                    chklist[k] += 1;
                }
            }
        }
        if (chklist[k] == people) {
            count += 1;
        }
    }
    
    printf("%d",count);
    
    return 0;
}

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

int n = 0, a[200000] = { 0 };
char s[200001];
bool f = 0;

int partition(int a[200000], char s[200001], int p, int r) {
	int x = a[r - 1];
	int i = p - 1;

	for (int j = p; j < r; j++) {
		if (a[j - 1] <= x) {
			i++;
			swap(a[i - 1], a[j - 1]);
			swap(s[i - 1], s[j - 1]);
		}
	}
	swap(a[i], a[r - 1]);
	swap(s[i], s[r - 1]);

	if (r > i + 1 && (i - p + 2) % (r - i - 1) != 0)
		f = true;

	return i + 1;
}

void QuickSort(int a[200000], char s[200001], int p, int r) {
	if (p < r) {
		int q = partition(a, s, p, r);
		QuickSort(a, s, p, q - 1);
		QuickSort(a, s, q + 1, r);
	}
}

int main()
{
	cin >> n;

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

	QuickSort(a, s, 1, n);

	if (f)
		cout << "Not stable" << endl;
	else
		cout << "Stable" << endl;

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

    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------
ll dp[1 << 15][15];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<vector<ll>> g(n, vector<ll>(n, LLINF));
    for (int i = 0; i < m; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        g[a][b] = c;
    }
    for (int i = 0; i < (1 << 15); i++)
    {
        for (int j = 0; j < 15; j++)
        {
            dp[i][j] = LLINF;
        }
    }
    dp[0][0] = 0;
    for (int S = 1; S < (1 << n); S++)
    {
        for (int v = 0; v < n; v++)
        {
            if (S & (1 << v) == 0)
            {
                continue;
            }
            int sub = S ^ (1 << v);
            for (int u = 0; u < n; u++)
            {
                chmin(dp[S][v], dp[sub][u] + g[u][v]);
            }
        }
    }
    cout << (dp[(1 << n) - 1][0] == LLINF ? -1 : dp[(1 << n) - 1][0]) << endl;
}


Measured memory_bytes: 7032
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

template<typename T,bool directed>
struct Dinic{
  struct edge {
    int to;
    T cap;
    int rev;
    edge(){}
    edge(int to,T cap,int rev):to(to),cap(cap),rev(rev){}
  };

  vector< vector<edge> > G;
  vector<int> level,iter;

  Dinic(){}
  Dinic(int n):G(n),level(n),iter(n){}

  int add_edge(int from,int to,T cap){
    G[from].emplace_back(to,cap,G[to].size());
    G[to].emplace_back(from,directed?0:cap,G[from].size()-1);
    return G[to].back().rev;
  }

  void bfs(int s){
    fill(level.begin(),level.end(),-1);
    queue<int> que;
    level[s]=0;
    que.emplace(s);
    while(!que.empty()){
      int v=que.front();que.pop();
      for(int i=0;i<(int)G[v].size();i++){
        edge &e=G[v][i];
        if(e.cap>0&&level[e.to]<0){
          level[e.to]=level[v]+1;
          que.emplace(e.to);
        }
      }
    }
  }

  T dfs(int v,int t,T f){
    if(v==t) return f;
    for(int &i=iter[v];i<(int)G[v].size();i++){
      edge &e=G[v][i];
      if(e.cap>0&&level[v]<level[e.to]){
        T d=dfs(e.to,t,min(f,e.cap));
        if(d==0) continue;
        e.cap-=d;
        G[e.to][e.rev].cap+=d;
        return d;
      }
    }
    return 0;
  }

  T flow(int s,int t,T lim){
    T fl=0;
    while(1){
      bfs(s);
      if(level[t]<0||lim==0) break;
      fill(iter.begin(),iter.end(),0);

      while(1){
        T f=dfs(s,t,lim);
        if(f==0) break;
        fl+=f;
        lim-=f;
      }
    }
    return fl;
  }

  T flow(int s,int t){
    return flow(s,t,numeric_limits<T>::max()/2);
  }
};

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int n;
  cin>>n;
  vector<int> ps(n),qs(n);
  for(int i=0;i<n;i++) cin>>ps[i];
  for(int i=0;i<n;i++) cin>>qs[i];

  int S=n*2,T=n*2+1;
  Dinic<int, true> G(n*2+2);

  vector<int> xs(n,-1),ys(n,-1);
  for(int i=0;i<n;i++){
    if(~xs[i]) continue;
    int j=i;
    while(xs[j]<0) xs[j]=i,j=ps[j];
  }
  for(int i=0;i<n;i++){
    if(~ys[i]) continue;
    int j=i;
    while(ys[j]<0) ys[j]=n+i,j=qs[j];
  }

  int ans=n;
  for(int i=0;i<n;i++){
    if(i==ps[i] and i==qs[i]){
      ans--;
      continue;
    }

    if(i==ps[i]){
      G.add_edge(S,ys[i],1);
      continue;
    }

    if(i==qs[i]){
      G.add_edge(xs[i],T,1);
      continue;
    }

    G.add_edge(xs[i],ys[i],1);

    if(ps[i]==qs[i])
      G.add_edge(ys[i],xs[i],1);
  }

  ans-=G.flow(S,T);
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    string s = to_string(i);
    ans += ((int) s.size() % 2 == 1);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
S = input()

for i in range(len(S)):
    if (i + 1) % 2 == 0:
        if "L" == S[i] or "U" == S[i] or "D" == S[i]:
            pass
        else:
            print("No")
            exit()
    else:
        if "R" == S[i] or "U" == S[i] or "D" == S[i]:
            pass
        else:
            print("No")
            exit()
print("Yes")

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <queue>

using std::cin;
using std::cout;
using std::endl;

using std::string;

using std::pair;
using std::make_pair;

using std::vector;
using std::priority_queue;
using std::sort;
using std::lower_bound;
using std::upper_bound;
using std::find_if;
using std::copy;
using std::copy_if;

using std::next_permutation;

vector<int> dijkstra(int s,vector<vector<int>> & len){
    vector<int> d;
    vector<int> q;
    for(int i=0;i<len.size();i++){
        d.push_back(i==s?0:INT_MAX/2);
        q.push_back(i);
    }

    while(!q.empty()){
        auto min=std::min_element(q.begin(),q.end(),
                [&d](auto u,auto v)->bool{ return d[u] < d[v]; });
        int u=*min;
        q.erase(min);
        for(int v=0;v<len.size();v++){
            if(len[u][v]==0){
                continue;
            }
            d[v]=std::min(d[v],d[u]+len[u][v]);
        }
    }
    return d;
}

int N,M,R;
vector<int> r;
vector<vector<int>> c;

vector<vector<int>> table;

int dist(vector<int> & v){
    int sum=0;
    for(int i=0;i<v.size()-1;i++){
        sum+=table[v[i]][v[i+1]];
    }
    return sum;
}

int search(){
    sort(r.begin(),r.end());
    int min=dist(r);
    while(next_permutation(r.begin(),r.end())){
        min=std::min(min,dist(r));
    }
    return min;
}

void make_table(){
    table=vector<vector<int>>(N,vector<int>(N,-1));
    for(int i:r){
        table[i]=dijkstra(i,c);
    }
}

int main(){
    cin >> N >> M >> R;
    c=vector<vector<int>>(N,vector<int>(N,0));
    for(int i=0;i<R;i++){
        int _r;
        cin >> _r;
        _r--;
        r.push_back(_r);
    }

    for(int i=0;i<M;i++){
        int _a,_b,_c;
        cin >> _a >> _b >> _c;
        _a--;
        _b--;
        c[_a][_b]=_c;
        c[_b][_a]=_c;
    }

    make_table();

    cout << search() << endl;

    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
ll gcd(ll a,ll b){
	if(b==0)
	return a;
	return gcd(b,a%b);
}
string toBin(ll a) {
	string res = "";
	while (a) {
		res += char((a & 1) + '0');
		a >>= 1;
	}
	reverse(res.begin(), res.end());
	return res;
}
const int mod = 1e9+7;
ll expo(ll base,ll pow){
    ll ans = 1;
    while(pow!=0){
        if(pow&1==1){
            ans = ans*base;
            ans = ans%mod;
        }
        base *= base;
        base%=mod;
        pow/=2;
    }
    return ans;
}
ll inv(ll x){
    return expo(x,mod-2);
}
bool isPal(string ss){
    int len = ss.length();
    for(int i = 0 ; i<len/2 ; i++){
	int comp = len-i-1;
	if(ss[i]!=ss[comp])
		return false;
	}
    return true;
}
double pi = 3.141592653589793238462643;
double error = 0.0000001;
/* -------Template ends here-------- */

const int M = 1001;
int isP[M];
void pre(){
    isP[1] = 1;
    for(int i = 2 ; i<M ; i++){
        if(isP[i] == 1)
            continue;
        for(ll j = i*i ; j<M;  j+=i){
            isP[j] = 1;
        }
    }
}
int main(){
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
   // pre();
    string str;
    cin>>str;
    int up = 0 , dw = 0,  ri = 0 , le = 0;
    for(int i = 0 ; i<str.length() ; i++){
        up += (str[i] == 'N');
        dw += (str[i] == 'S');
        ri += (str[i] == 'E');
        le += (str[i] == 'W');
    }

    if(up > 0 && dw == 0){
        cout<<"No";
        return 0;
    }

    if(up == 0 && dw > 0){
        cout<<"No";
        return 0;
    }

    if(ri > 0 && le == 0){
        cout<<"No";
        return 0;
    }

    if(ri == 0 && le > 0){
        cout<<"No";
        return 0;
    }

    cout<<"Yes";

















}














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

const int INF = 2e9;

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    ll ans = 0;
    rep(i,n){
        rep(j,i)ans += d[j]*d[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from fractions import gcd

A,B,C,D,E,F=map(int,input().split())

sugar=[]
g=gcd(C,D)
for i in range(0,3000):
    if i>=C*D and i%g==0:
        sugar.append(i)

for i in range(0,D):
    for j in range(0,C):
        if C*D>i*C+j*D:
            sugar.append(i*C+j*D)

sugar.sort()

ans=(-1,1)
for i in range(F//(100*A)+1):
    for j in range(F//(100*B)+1):
        if F>100*A*i+100*B*j:
            x=F-(100*A*i+100*B*j)
            y=(A*i+B*j)*E
            sugarupper=min(x,y)

            start=0
            end=len(sugar)
            while end-start>1:
                test=(end+start)//2
                if sugarupper>=sugar[test]:
                    start=test
                else:
                    end=test

            if sugarupper>=sugar[end]:
                s=sugar[end]
            else:
                s=sugar[start]

            m,n=ans
            if n*s>m*(100*A*i+100*B*j+s):
                ans=(s,100*A*i+100*B*j+s)

print(ans[1],ans[0])


Measured memory_bytes: 65132
import math.abs
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val A, B, C, D = in.nextInt

  println(
    if (abs(A - C) <= D || (abs(A - B) <= D && abs(B - C) <= D)) "Yes"
    else "No"
  )
}

Measured memory_bytes: 55276
h, w = [ int(v) for v in input().split() ]
field = [ list(input()) for i in range(h) ]
ansfield = [ [ "#" for j in range(w)] for i in range(h)]
for i in range(h):
	for j in range(w):
		if field[i][j] == ".":
			ansfield[i][j] =  str(sum([ [ field[i][j] for j in range(max(j-1,0),min(w,j+2)) ].count("#") for i in range(max(i-1,0),min(h,i+2)) ]))

for i in range(h):
	print("".join(ansfield[i]))

Measured memory_bytes: 3188
L , R = map(int, input().split())

# 2019 = 3*673
answer = 2019

if R - L + 1 >= 2019:
    answer = 0
else:
    for x in range(L,R+1):
        for y in range(x+1,R+1):
            sumple = x * y
            test = sumple % 2019 
            if test < answer:
                answer = test

print(answer)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>


using namespace std;

int main() {
    long long int A, C, ans;
    long double B;
    cin >> A >> B;

    ans = A * B;

    cout << ans;

    return 0;

}


Measured memory_bytes: 3132
#include <stdio.h>
#include <string.h>

int main(void) {
	int n, i, tp=0, hp=0;
	char t[101], h[101];
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%s %s", &t, &h);
		if(strcmp(t, h) == 0){
			tp += 1;
			hp += 1;
		}
		else if(strcmp(t, h) < 0) hp += 3;
		else if(strcmp(t, h) > 0) tp += 3;
	}
	printf("%d %d\n", tp, hp);
	return 0;
}



Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int n;
    cin>>n;

    vector<pair<string,int>> p;
    vector<pair<string,int>> q;
    
    
    for(int i=0;i<n;i++){
        string s;
        int a;
        cin>>s>>a;
        a*=-1;
        p.push_back(make_pair(s,a));
        q.push_back(make_pair(s,a));
    }
    sort(p.begin(),p.end());
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(p[i].first==q[j].first && p[i].second==q[j].second){
                cout<<j+1<<endl;
            }
        }
    }
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(int argc, char **argv) {
	int n;
	string s;
	cin >> n >> s;
	int x = 0, res = 0;
	REP(i, n) {
		if (s[i] == 'I') ++x;
		else --x;
		res = max(res, x);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
const int MAX_X = 10000;
int prime[10000];

int main(){

	int i, k, n;

	int border[10];
	for( i = 2; i <= MAX_X; i++) {
		prime[i] = 1;
	}

	for(i = 2; i*i <= MAX_X; i++){
		if(prime[i]) {
			for(k = 2 * i; k <= MAX_X; k += i){
				prime[k] = 0;
			}
		}
	}

	while(1){
		scanf("%d", &n);
		if( n == 0) break;
		int max;
		for( i = n; i >= 2; i--){
			if( prime[i]){
				if( prime[i - 2]){
					max = i;
					break;
				}
			}
		}
		printf("%d %d\n", max -2, max);
	}
	return 0;
}

Measured memory_bytes: 1064
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define f(i,a,b) for(ll i=a; i<b; i++)
ll gcd(ll ina, ll inb) 
{     
    if (ina == 0) 
       return inb; 
    if (inb == 0) 
       return ina; 
   
    
    if (ina == inb) 
        return ina; 
   
    if (ina > inb) 
        return gcd(ina-inb, inb); 
    return gcd(ina, inb-ina); 
} 
ll lcm(ll in1, ll in2)
{ ll ans=1; ans=(in1*in2)/gcd(in1,in2); 
return ans;
}
int main()
{ ll n; cin>>n; ll a[n]; f(i,0,n) { cin>>a[i];}  
ll dp[n]; dp[0]=0; dp[1]=abs(a[1]-a[0]); f(j,2,n) { dp[j]=min(dp[j-1]+abs(a[j]-a[j-1]),dp[j-2]+abs(a[j]-a[j-2]));  }
cout<<dp[n-1]<<"\n"; }   






Measured memory_bytes: 5156
#include <cstdio>
#include <iostream>
#include <cassert>
#include <algorithm>    
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cmath>
#include <bitset>
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
// #define int long long
using namespace std;

typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef unsigned long long ull; 
typedef vector<int> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const int M = 1e9 + 7;
//__int128
const int maxn = 333;
std::vector<pii> G[maxn];
int n, m, L;
int d[maxn], l[maxn];
struct node
{
	int d, num, l;
	bool operator < (const node &r) const {
		if(d != r.d) {
			return d > r.d; 
		}
		return l < r.l;
	}
};
void bfs(int x) {
	d[x] = 0, l[x] = L;
	priority_queue<node> pq;
	pq.push({0, x, L});
	while(!pq.empty()) {
		auto t = pq.top(); pq.pop();
		int u = t.num, x = t.d, y = t.l;
		if(x > d[u] || (x == d[u] && y > l[u])) continue;
		for(auto i : G[u]) {
			if(i.se > L) continue;
			int v = i.fi;
			int td, tl;
			if(i.se <= l[u]) {
				td = x;
				tl = l[u] - i.se;
			}	else {
				td = x + 1;
				tl = L - i.se;
			}
			if(td > d[v] || (td == d[v] && tl <= l[v])) continue;
			d[v] = td;
			l[v] = tl;
			pq.push({td, v, tl});
		}
	}

}

signed main()
{
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n >> m >> L;
  for(int i = 0; i < m; ++i) {
  	int x, y, z;
  	cin >> x >> y >> z;
  	G[x].eb(pii(y, z));
  	G[y].eb(pii(x, z));
  }
  std::vector<pii> q[maxn];
  int Q;
  cin >> Q;
  for(int i = 0; i < Q; ++i) {
 		int x, y;
 		cin >> x >> y;
 		q[x].eb(pii(y, i));
  }
  std::vector<int> an(Q);
 	for(int i = 1; i <= n; ++i) {
 		if(q[i].empty()) continue;
	 	fill(d, d + n + 1, inf);
 		fill(l, l + n + 1, inf);
 		bfs(i);
 		for(pii j : q[i]) {
			an[j.se] = d[j.fi];
 		}
 	}
 	for(int i : an) {
 		if(i == inf) cout << -1 << endl;
 		else cout << i << endl;
 	}
	return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <fstream>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
constexpr ll mod = 1000000007;

int dig(int n) {
    int nn = n, r = 0;
    while (nn) {
        nn /= 10;
        r++;
    }
    if (n == 0) r++;
    return r;
}

int dn(int n, int d) {
    for (int i = 0; i < d; i++) n /= 10;
    return n % 10;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> sc(m);
    for (auto &e:sc) {
        cin >> e.first >> e.second;
    }
    for (int i = 0; i < 1000; i++) {
        if (dig(i) != n) continue;
        bool f = true;
        for (auto &e:sc) {
            if (dn(i, n - e.first) != e.second) {
                f = false;
            }
        }
        if (!f) continue;
        cout << i << endl;
        return 0;
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var PriorityQueue=(function(){
  function f(){return new PriorityQueue();}
  function PriorityQueue(){
    this.heap=[];
  }
  PriorityQueue.prototype.push=function(x){
    var h=this.heap,i=h.length,j;h.push(x);
    while(i){
      j=i-1>>1;
      if(h[j]<=x)break;
      h[i]=h[j],i=j;
    }
    h[i]=x;
  };
  PriorityQueue.prototype.pop=function(){
    var h=this.heap,r=h[0],x=h.pop(),l=h.length;
    if(l===0)return r;
    var i=0,j,k=l-->>1;
    while(i<k){
      j=(i<<1)+1;
      if(j<l&&h[j+1]<h[j])j++;
      if(x<=h[j])break;
      h[i]=h[j],i=j;
    }
    h[i]=x;
    return r;
  };
  return f;
})();

console.log(main());
function main(){
  var n = o.a();
  var m = o.a();
  var a = o.m(n);
  a.push([1e9,0]);
  a.sort((a,b)=>a[0]-b[0]);
  var ans = 0, j = 0;
  var pq = PriorityQueue();
  for(var i = 1; i <= m; i++){
    while(a[j][0] <= i){
      pq.push(-a[j++][1]);
    }
    if(pq.heap.length)ans -= pq.pop();
  }
  return ans;
}

Measured memory_bytes: 66156
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    n = f.read_int()
    a = [0] * n
    for i in xrange(n):
        a[i] = f.read_int()

    if a[0] != 0: return -1
    cur = 0
    ans = 0

    for i in xrange(1,n):
        if a[i] - cur > 1:
            return -1
        elif a[i] - cur == 1:
            ans += 1
        else:
            ans += a[i]
        cur = a[i]

    return ans


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


Measured memory_bytes: 12304
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<string>
using namespace std;

int main(){
  int a,b,c,x;
  cin>>a>>b>>c>>x;
  int ans=0;

  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      int y = (x-500*i-100*j)/50;
      if(y>=0&&y<=c)
        ans++;
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(N: int, M: int, H: "List[int]", A: "List[int]", B: "List[int]"):
    conns = [[] for _ in range(N)]
    ret = 0
    for i in range(M):
        conns[A[i] - 1].append(B[i] - 1)
        conns[B[i] - 1].append(A[i] - 1)
    for i in range(N):
        tmp = 0
        for con in conns[i]:
            if H[i] > H[con]:
                tmp += 1
        if tmp == len(conns[i]) or len(conns[i]) == 0:
            ret += 1
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    X = []
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, H, A, B)

if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
  int P, Q, R;
  cin >> P >> Q >> R;
  int ans = 1e9;
  ans = min(ans, P + Q);
  ans = min(ans, Q + R);
  ans = min(ans, P + R);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
/*
    Author : DemonStar
*/

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define loop(i, n) for(ll i = 0; i < n; i++)
#define pl pair<ll, ll>
#define vl vector<ll>
#define endl '\n'
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};


template <typename T, typename TT>
ostream &operator<<(ostream &os, const pair<T, TT> &t) {
    return os << t.first << " " << t.second;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &t) {
    for (auto &i : t) os << i << " ";
    return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &t : v) is >> t;
    return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, vector<pair<T1, T2>> &v) {
    for (pair<T1, T2> &t : v) is >> t.first >> t.second;
    return is;
}

const ll mod = 1e9 + 7;

int main()
{

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ll n;
    cin >> n;
    vl v(n);
    cin >> v;
    ll xr = 0;
    for (auto x : v) xr ^= x;
    vl ans;
    for (auto x : v) ans.push_back(x ^ xr);
    cout << ans << endl;

#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s";
#endif

    return 0;
}

Measured memory_bytes: 6752
d = int(input())
c, *s = [list(map(int, input().split())) for i in range(d+1)]
t = [0] * d


cand = [[0, [], [-1]*26]]
while 1:
    for I in range(len(cand)):
        scr, tt, lst = cand[0]
        del cand[0]
        for j in range(26):
            score = scr
            for col in range(26):
                if col==j:
                    score += s[len(tt)][j]
                    lst[j] = len(tt)
                score -= c[col] * (len(tt) - lst[col])
            cand.append([score, tt+[j], lst])
    cand.sort(key=lambda x:-x[0])
    if len(cand[0][1])==d: break
    cand = cand[:5]

for i in cand[0][1]:
    print(i+1)

Measured memory_bytes: 10268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
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; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

struct edge{
    int to,cost;
};

int main(){
    int n,m;cin>>n>>m;
    vector<vector<edge>> G(n);
    rep(i,m){
        int a,b,c;
        cin>>a>>b>>c;
        --a;--b;c=-c;
        G[a].push_back({b,c});
    }
    ll dist[n];
    rep(i,n)dist[i]=(1ll<<50);
    dist[0]=0;
    ll ans;
    rep(i,2*n){
        rep(j,n){
            if(dist[j]==(1ll<<50))continue;
            for(auto au:G[j]){
                if(dist[au.to]>dist[j]+au.cost)dist[au.to]=dist[j]+au.cost;
            }
        }
        if(i==(n-2))ans=(-dist[n-1]);
        if(i==(2*n-1)){
            if(ans!=(-dist[n-1]))cout<<"inf"<<endl;
            else cout<<ans<<endl;
        }
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int d;
	int i;
	long long inte;
	
	while (scanf("%d", &d) != EOF){
		inte = 0;
		
		for (i = 1; i < 600/d; i++){
			inte += (d) * (i*d)*(i*d);
		}
		
		printf("%d\n", inte);
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fr(i,a,n) for(i=a;i<n;i++)
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define ub upper_bound
#define lb lower_bound
#define map map<ll,ll>
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define bs binary_search
#define qll queue<ll>
#define sll set<ll>
 
 
int main()
{
    fastio;
    
       ll h1,s1,h2,s2;
       cin>>h1>>s1>>h2>>s2;
       ll x = h2%s1;
       if(x!=0)
       {
           x = h2/s1;
           x++;
       }
       x--;
       if(h1 - x*s2 <=0)
       cout<<"No"<<endl;
       else
       cout<<"Yes"<<endl;
       
       
        
}

Measured memory_bytes: 3600
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		HashSet h=new HashSet();
		h.add(a);
		h.add(b);
		h.add(c);
		if(h.size()==2) System.out.println("Yes");
		else System.out.println("No");
	}

}


Measured memory_bytes: 27068
N=input()

a = None

if(len(N) == 1):
    a = int(N)
elif(len(N) == 2):
    a = int(N[1])
else:
    a = int(N[2])

s = ""

if(a == 3):
    s = "bon"
elif(a == 0 or a ==1 or a==6 or a==8):
    s = "pon"
else:
    s="hon"

print(s)


Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define mp make_pair
#define mt make_tuple
#define X first
#define Y second
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define D double
#define ll long long
#define REP(i,a) for(int i=0;i<a;i++)
#define REP1(i,a,b) for(int i=a;i<b;i++)
#define REP2(i,a,b) for(int i=a;i<=b;i++)
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define RREP1(i,a,b) for(int i=a;i>b;i--)
#define RREP2(i,a,b) for(int i=a;i>=b;i--)
#define SREP(i,x) for(auto i:x)
#define MS0(x) memset((x),0,sizeof((x)))
#define MS1(x) memset((x),-1,sizeof((x)))
#define MSF(x) memset((x),127,sizeof(x))
#define pb push_back
#define LE(x) (int)((x).size())
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDD pair<D,D>
#define im guagua
#define RI(x) x=rit()
#define RII(a,b) a=rit(),b=rit()
#define RIII(a,b,c) a=rit(),b=rit(),c=rit()
#define debug 0
const int INF = 0x7F7F7F7F;
const double EPS = 1e-10 ;
const ll mod7 = 1e9+7;
const ll mod9 = 1e9+9;
using namespace std;
inline ll rit(){
    ll f=0,key=1;
    char c;
    do{
        c=getchar();
        if(c=='-') key=-1;
    }while(c<'0' || c>'9');
    do{
        f=f*10+c-'0';
        c=getchar();
    }while(c>='0' && c<='9');
    return f*key;
}
inline void fprt(D f){
    printf("%.08lf",f);
}
void init(){
}
const int Z = 100005;
int n;
string s;
int ans[Z];
inline int chk(int fs,int sd){
    ans[0] = ans[n] =  fs;
    ans[1] = sd;
    REP1(i,2,n){
        if(ans[i-1] == 0){
            if(s[i-1]=='o') ans[i] = ans[i-2];
            else ans[i] = 1-ans[i-2];
        }
        else{
            if(s[i-1] == 'o') ans[i] = 1-ans[i-2];
            else ans[i] = ans[i-2];
        }
    }
    int f;
    if(ans[0] == 0){
        if(s[0]=='o') f = ans[1];
        else f = 1-ans[1];
    }
    else{
        if(s[0]=='o') f = 1-ans[1];
        else f= ans[1];
    }
    if(f!=ans[n-1]) return 0;
    if(((ans[0]==ans[n-2]?0:1) ^ (s[n-1]=='o'?0:1) ^ (ans[n-1]==0?0:1))==0) return 1;
    else return 0;

    // return (f==ans[n-1]?1:0);

}
void read(){
    RI(n);
    cin>>s;
}
void solve(){
    if(chk(0,0)){
        REP(i,n){
            cout<<(ans[i]==0?'S':'W');
        }
        cout<<endl;
    }
    else if(chk(0,1)){
        REP(i,n){
            cout<<(ans[i]==0?'S':'W');
        }
        cout<<endl;

    }
    else if(chk(1,0)){
        REP(i,n){
            cout<<(ans[i]==0?'S':'W');
        }
        cout<<endl;

    }
    else if(chk(1,1)){
        REP(i,n){
            cout<<(ans[i]==0?'S':'W');
        }
        cout<<endl;
    }
    else cout<<-1<<endl;
}
int main(){
    int nn=1;
    // nn=rit();
    while(nn--){
        // while(cin>>n) 
            init(),read(),solve();
    }
    return 0;
}

Measured memory_bytes: 896
def resolve():
    import sys
    input = sys.stdin.readline
    # row = [int(x) for x in input().rstrip().split(" ")]
    # n = int(input().rstrip())
    n = int(input().rstrip())
    s = input().rstrip()

    x = 0
    max_x = 0
    for c in s:
        if c == "I":
            x+=1
            if x > max_x:
                max_x = x
        else:
            x -= 1


    print(max_x)




if __name__ == "__main__":
    resolve()


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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    ll n, k; cin >> n >> k;
    vector<ll> alis(n), flis(n);
    ll ans = 0;
    REP(i, 0, n){cin >> alis[i];}
    REP(i, 0, n){cin >> flis[i];}
    sort(ALL(alis));
    sort(ALL(flis), greater<>());
    ll right = 0, left = 1e14;
    while(left-right > 1){
        ll ck = k;
        ll mid = (right+left) / 2;
        //cout << mid << endl;
        REP(i, 0, n){
            ll cc = mid / flis[i];
            ck -= max(alis[i]-cc, 0LL);
        }
        if(ck >= 0){
            left = mid;
        }else{
            right = mid;
        }
    }
    ll ck = k;
    ll mid = right;
    REP(i, 0, n){
        ll cc = mid / flis[i];
        ck -= max(alis[i]-cc, 0LL);
    }
    if(ck > 0){
        REP(i, 0, n){
            ll cc = mid / flis[i];
            ans = max(ans, cc * flis[i]);
        }
    }else{
        mid = left;
        REP(i, 0, n){
            ll cc = mid / flis[i];
            ans = max(ans, cc * flis[i]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 6412