akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
#include <iostream>
#include <iomanip>

using namespace std;

typedef long long int LL;
typedef unsigned long long int ULL;
typedef pair<int,int> II;
typedef vector<II> VII;
typedef vector<int> VI;
typedef vector<VI> VVI;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

const int INF=1e9;
const LL INFF=1e17;
const double EPS=1e-9;
const LL MOD=1e9+7;
const int N=110;
int main(){
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 int h,w,n,a[N*N],c[N][N],start=0,curr=0;
 cin >> h >> w >> n;
 REP(i,n)cin >> a[i];
 REP(i,h){
  if(start==0){
   REP(j,w){
    c[i][j]=curr+1;
    a[curr]--;
    if(!a[curr])curr++;
   }
   start=w-1;
  }
  else{
   for(int j=w-1;j>=0;j--){
    c[i][j]=curr+1;
    a[curr]--;
    if(!a[curr])curr++;
   }
   start=0;
  }
 }
 REP(i,h){REP(j,w)cout << c[i][j] << " ";cout << '\n';}
 return 0;
}


Measured memory_bytes: 384
while True:
  try:
    n = int(input())
    count = 0
    for a in range(10):
      for b in range(10):
        for c in range(10):
          for d in range(10):
            if a + b + c + d == n:
              count += 1
    print(count)
  except EOFError:
    break


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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  ll n, k;
  cin >> n >> k;

  vector<ll> vp(n), vc(n);
  for (int i = 0; i < n; ++i) {
    cin >> vp[i];
    vp[i]--;
  }

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

  vector<vector<ll>> pts_by_src(n);
  for (int i = 0; i < n; ++i) {
    vector<ll> used(n, false);
    ll cur = i, pt = 0;
    while (!used[cur]) {
      used[cur] = true;
      pt += vc[vp[cur]];
      pts_by_src[i].push_back(pt);
      cur = vp[cur];
    }
  }

  ll ans = pts_by_src.front().front();
  for (auto &pts : pts_by_src) {
    if (pts.back() <= 0) {
      ll sz = min(k, static_cast<ll>(pts.size()));
      ll pt = *max_element(pts.begin(), pts.begin() + sz);
      ans = max(ans, pt);
    } else {
      ll sz = k / pts.size(), md = k % pts.size();
      if (md == 0) {
        sz--;
      }

      ll pt = sz * pts.back();
      ll max_pt = md > 0 ? *max_element(pts.begin(), pts.begin() + md)
                         : *max_element(pts.begin(), pts.end());
      if (max_pt >= 0 || sz <= 0) {
        pt += max_pt;
      }

      ans = max(ans, pt);
    }
  }

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

Measured memory_bytes: 218908
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

#define int long long

#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define rrep(i, n) for (int i=(int)n-1;i>=0;--i)
#define rrep1(i, n) for (int i=n;i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)r;++i)
#define rrange(i, l, r) for (int i=(int)r-1;i>=(int)l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}
constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}

signed main()
{
	int K,A,B;cin>>K>>A>>B;
	for (int i = A; i <= B; ++i) {
		if (i % K == 0) {
			cout << "OK\n";
			return 0;
		}
	}
	cout<<"NG\n";
}



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

int main() {
    int a,b,c,d,e;    

    cin >> a >> b >> c >> d >> e;

    if (a==0){
        cout << 1 << endl;
    }
    else if(b == 0){
        cout << 2 << endl;
    }
    else if(c == 0){
        cout << 3 << endl;
    }    
    else if(d == 0){
        cout << 4 << endl;
    }
    else {
        cout << 5 << endl;
    }

}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int l = sc.nextInt();
		
		int[][] A = new int[n][m];
		for(int i=0; i<n; i++) {
			for(int j=0; j<m; j++) {
				A[i][j] = sc.nextInt();
			}
		}
		
		int[][] B = new int[m][l];
		for(int j=0; j<m; j++) {
			for(int k=0; k<l; k++) {
				B[j][k] = sc.nextInt();
			}
		}
		
		long[][] C = new long[n][l];
		for(int i=0; i<n; i++) {
			for(int k=0; k<l; k++) {
				long sum = 0;
				for(int j=0; j<m; j++){
					sum += A[i][j] * B[j][k];
				}
				C[i][k] = sum;
				
				if(k != l-1) {
					System.out.print(C[i][k] + " ");
				} else {
					System.out.println(C[i][k]);
				}
			}
		}
	}

}

Measured memory_bytes: 54340
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;

#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()

ll n, k, m, M = 1e9 + 7;

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

    cin >> n;

    vl a(n);
    rep(i, n) cin >> a[i];

    sort(all(a));

    ll h = n / 2;
    if(a[h - 1] == a[h]) return cout << 0 << endl, 0;

    cout << a[h] - a[h - 1] << endl;
}

Measured memory_bytes: 3952
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 入力
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();

        int[] c = new int[n+1];
        int[][] a = new int[n+1][m+1];
        for (int i = 0; i < n; i++) {
            c[i]= sc.nextInt();
            for (int j = 0; j < m; j++) {
                a[i][j] = sc.nextInt();
            }
        }

        int ans = 12345678;
        int all = 1<<n;
        // 000...0（n桁） から 111...1（n桁） までループ(bit全探索)
        for (int mask = 0; mask < all; mask++) {
            int[] level = new int[m];
            int cost = 0;
            for (int i = 0; i < n; i++) {
                // 各ビットでループさせて1の場合足し込む
                if (((mask>>i) & 0x1) == 1) {
                    cost += c[i];
                    for (int j = 0; j < m; j++) {
                        level[j] += a[i][j];
                    }
                }
            }
            boolean ok = true;
            for (int j = 0; j < m; j++) {
                if (level[j] < x) {
                    ok = false;
                }
            }
            if (ok) {
                ans = Math.min(ans, cost);
            }
        }
        if(ans == 12345678) {
            // 出力
            System.out.println(-1);
        } else {
            // 出力
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 37480
# coding: utf-8
def main():
    s = input()
    if s == 'SUN':
        print(7)
    elif s == 'MON':
        print(6)
    elif s == 'TUE':
        print(5)
    elif s == 'WED':
        print(4)
    elif s == 'THU':
        print(3)
    elif s == 'FRI':
        print(2)
    elif s == 'SAT':
        print(1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
h, w = map(int, input().split())
maze = [input() for _ in [0] * h]
visited = [[0] * w for _ in [0] * h]


def bfs(start, visited, maze, lim_y, lim_x):
    queue = [start]
    visited[start[0]][start[1]] = 1
    distance = {(start[0], start[1]): 0}
    while queue:
        y, x = queue.pop(0)
        for i, j in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
            y_, x_ = y + i, x + j
            if -1 < y_ < lim_y and -1 < x_ < lim_x and maze[y_][x_] == '.' and visited[y_][x_] == 0:
                queue.append([y_, x_])
                visited[y_][x_] = 1
                distance[(y_, x_)] = distance[(y, x)] + 1
    return max(distance.values())


max_distance = 0

all_yx = [[j, i] for i in range(w) for j in range(h)]

for start in all_yx:
    if maze[start[0]][start[1]] == '.':
        max_distance = max(max_distance, bfs(
            start, visited, maze, h, w))
        visited = [[0] * w for _ in [0] * h]

print(max_distance)


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

using namespace std;

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define Get(t, i) get<(i)>((t))
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)

const int inf = 1 << 25;
const ll INF = 1LL << 55;

struct UnionFind
{
  vector<int> data;
  UnionFind(int sz):data(sz, -1){};
  int size(int x) { return -data[find(x)]; }
  int find(int x) { return data[x] < 0 ? x : data[x] = find(data[x]); }
  bool same(int x, int y) { return find(x) == find(y); }
  int unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x != y) {
      if(data[x] < data[y]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return -data[x];
  }
};

// Biconnected Components (lowlink)
struct BICC
{
  UnionFind uf;
  vector< vector<int> > graph, tree;
  vector<Pi> edges;
  vector<bool> vis;
  vector<int> ord, low, cmp;
  vector<int> articulation;
  vector<Pi> bridge;
  BICC(int sz):uf(sz), graph(sz), vis(sz, false), ord(sz), low(sz), cmp(sz){}
  void add_edge(int u, int v)
  {
    graph[u].emplace_back(v);
    graph[v].emplace_back(u);
    edges.emplace_back(minmax(u, v));
  }
  void dfs(int u, int p, int& k)
  {
    vis[u] = true;

    ord[u] = low[u] = k++;

    bool is_articulation = false;
    int cnt = 0;

    for(auto v : graph[u]) {
      if(!vis[v]) {
    cnt++;
    dfs(v, u, k);
    low[u] = min(low[u], low[v]);
    if(~p && ord[u] <= low[v]) is_articulation = true;
    if(ord[u] < low[v]) bridge.emplace_back(minmax(u, v));
    else uf.unite(u, v);
      } else if(v != p) {
    low[u] = min(low[u], ord[v]);
      }
    }

    if(p == -1 && cnt > 1) is_articulation = true;
    if(is_articulation) articulation.push_back(u);
  }
  void compose()
  {
    int k = 0;
    dfs(0, -1, k);

    int num = 0;
    vector<int> conn(graph.size());
    for(int i = 0; i < graph.size(); i++) {
      if(i == uf.find(i)) conn[i] = num++;
    }

    tree.resize(num);
    for(int i = 0; i < graph.size(); i++) {
      cmp[i] = conn[uf.find(i)];
    }
    for(auto e : edges) {
      int x = cmp[e.first], y = cmp[e.second];
      if(x == y) continue;
      tree[x].emplace_back(y);
      tree[y].emplace_back(x);
    }
  }
};


int main()
{
  int V, E; cin >> V >> E;
  BICC bicc(V);
  while(E--) {
    int s, t;
    cin >> s >> t;
    s--;t--;

    bicc.add_edge(s, t);
  }
  bicc.compose();
  sort(all(bicc.bridge));
  if(bicc.bridge.size()==0)cout<<"0"<<endl;
  else {
    cout<<bicc.bridge.size()<<endl;
  }
  return 0;
}


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

using namespace std;
using ll = long long;
const int N = 3005;

const int mod = 998244353;
int add(int a, int b) {
	return a + b < mod ? a + b : a + b - mod;
}

int n, s;
int a[N];

int dp[N][N];

int f(int i, int j) {
	if(j < 0) return 0;
	if(j == 0) return n - i + 1;
	if(i == n) return 0;
	int &ans = dp[i][j];
	if(~ans) return ans;
	return ans = add(f(i + 1, j), f(i + 1, j - a[i]));
}


int main() {
	memset(dp, -1, sizeof dp);
	scanf("%d %d", &n, &s);

	for(int i = 0; i < n; i++) scanf("%d", a + i);

	int ans = 0;

	for(int i = 0; i < n; i++) {
		ans = add(ans, f(i, s));
	}

	printf("%d\n", ans);
}


Measured memory_bytes: 39216
#import sys
#input = sys.stdin.readline
M = 10**9+7
n = int(input())
l = list(map(int,input().split()))
o = [0]*61
z = [0]*61
for i in l:
    a = bin(i)[2:]
    j = 0
    while(j < len(a)):
        if a[j] == "1":
            o[len(a)-j-1] += 1

        j += 1

cnt = 0
b = 1
for j in range(len(o)):
    cnt = (cnt+(o[j]*(n-o[j])*b)%M)%M
    b *= 2

print(cnt)

Measured memory_bytes: 124112
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


struct SEG{
  typedef ll Type;
  int segn2;
  Type inf;
  vector<Type> data, flipData;
  
  SEG(int n){
    inf = 0; //init value
    for(segn2=1;segn2<n;segn2*=2);
    data.assign(segn2*2,inf);
    flipData.assign(segn2*2,1);
  }
  
  //get minimum value [a,b]
  Type query(int a,int b,int l=0,int r=-1,int k=0){
    if(r==-1) r+=segn2;
    if(a<=l && r<=b) return data[k]  * flipData[k];
    if(r<a || b<l) return inf;
    return (query(a,b,l,(l+r)/2,k*2+1) + query(a,b,(l+r)/2+1,r,k*2+2)) * flipData[k];
  }
  
  //set kth number x
  void set(int k,Type x){
    k+=segn2-1;
    data[k]=x;
    while(k>0){
      k=(k-1)/2;
      data[k] = data[k*2+1] * flipData[k*2+1] + data[k*2+2] * flipData[k*2+2];
    }
    return;
  }

  void flip(int a,int b,int l=0,int r=-1,int k=0){
    if(r==-1) r+=segn2;
    if(a<=l && r<=b){ flipData[k] *= -1; return; }
    if(r<a || b<l) return;
    flip(a,b,l,(l+r)/2,k*2+1);
    flip(a,b,(l+r)/2+1,r,k*2+2);
    data[k] = data[k*2+1] * flipData[k*2+1] + data[k*2+2] * flipData[k*2+2];
  }
};

int main(){
  int K, N, Q;
  int a[SIZE];
  
  scanf("%d%d%d", &K, &N, &Q);

  SEG seg(N);
  int counter = 0;
  
  for(int i=0;i<N;i++){
    scanf("%d", a+i);
    if(a[i])
      seg.set(i, a[i]);
    else
      seg.flip(i+1 , N);
    counter += a[i] == 0;
  }

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

    if(!a[x]) seg.flip(x+1, N);
    if(!a[y]) seg.flip(y+1, N);
    swap(a[x], a[y]);
    seg.set(x, a[x]);
    seg.set(y, a[y]);
    if(!a[x]) seg.flip(x+1, N);
    if(!a[y]) seg.flip(y+1, N);

    ll ans = (seg.query(0,N)%K+K + K-1)%K;
    ans = K - ans;
    
    if(counter%2) ans *= -1;
    
    printf("%lld\n", ans);
  }
  
  return 0;
}



Measured memory_bytes: 7328
#include<stdio.h>


int main()
{
	char a[4];
	int b = 700;
	scanf("%s", a);
	for (int i = 0; i < 3; i++)
	{
		if (a[i] == 'o')
			b += 100;
	}
	printf("%d\n", b);
	
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <bitset>
const int N = 5005; 
using namespace std; 

int n, k, a[N]; 
bitset<N> sum; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

bool check(int mid)
{
	if(a[mid] >= k) return 0; 
	sum.reset(), sum[0] = 1;
	for(int i = 1; i <= n; i++) if(i != mid && a[i] < k) sum |= sum << a[i];
	for(int i = k - a[mid]; i < k; i++)
		if(sum[i]) return 0; 
	return 1; 
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp.in", "r", stdin);
#endif
	n = read <int> (), k = read <int> ();
	for(int i = 1; i <= n; i++) a[i] = read <int> ();
	sort(a + 1, a + n + 1);
	int l = 1, r = n, mid, ans = 0; 
	while(l <= r)
	{
		mid = (l + r) >> 1; 
		if(check(mid)) ans = mid, l = mid + 1; 
		else r = mid - 1; 
	}
	printf("%d\n", ans); 
	return 0; 
}


Measured memory_bytes: 3184
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int X,i,s;

int main()
{
	scanf("%d",&X);
	for(i=0,s=0;s<X;i++,s+=i);
	printf("%d\n",i);
}


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

int n;
void rotation(vector<P>& vec) {
    rep(i,vec.size()) {
        int x = vec[i].first;
        int y = vec[i].second;
        vec[i].first = -y;
        vec[i].second = x;
    }

}
bool ok(vector<vector<P> >& vec,int index) {
    if(vec[0].size() != vec[index].size()) return false;
    bool ret = false;
    rep(i,4) {
        rotation(vec[index]);
        rep(j,2) {
            reverse(vec[index].begin(), vec[index].end());
            bool f = true;
            //sort(vec[index].begin(),vec[index].end());

            P diff;
            diff.first = vec[0][0].first - vec[index][0].first;
            diff.second = vec[0][0].second - vec[index][0].second;
            rep(j,vec[index].size()) {
                P tmp;
                tmp.first = vec[0][j].first - vec[index][j].first;
                tmp.second = vec[0][j].second - vec[index][j].second;
                if(tmp.first != diff.first) f = false;
                if(tmp.second != diff.second) f = false;
            }
            ret |= f;
        }
    }
    rep(i,vec[index].size()) {
        vec[index][i].first -= vec[index].back().first;
        vec[index][i].first -= vec[index].back().first;
    }

    rep(i,4) {
        rotation(vec[index]);
        rep(j,2) {
            reverse(vec[index].begin(), vec[index].end());
            bool f = true;
            //sort(vec[index].begin(),vec[index].end());

            P diff;
            diff.first = vec[0][0].first - vec[index][0].first;
            diff.second = vec[0][0].second - vec[index][0].second;
            rep(j,vec[index].size()) {
                P tmp;
                tmp.first = vec[0][j].first - vec[index][j].first;
                tmp.second = vec[0][j].second - vec[index][j].second;
                if(tmp.first != diff.first) f = false;
                if(tmp.second != diff.second) f = false;
            }
            ret |= f;
        }
    }
    return ret;

}
void solve() {
    vector<vector<P> > vec(n+1);
    rep(i,n+1) {
        int m;
        cin>>m;
        vec[i].resize(m);
        rep(j,m) {
            int x,y;
            cin>>x>>y;
            vec[i][j] = P(x,y);
        }
    }
    //sort(vec[0].begin(), vec[0].end());

    rep(i,n+1) {
        if(!i) continue;
        if(ok(vec,i)) {
            cout<<i<<endl;
        }
    }


}
int main() {
    while(cin>>n) {
        if(!n) return 0;
        solve();
        cout<<"+++++"<<endl;
    }

    return 0;
}

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

#define int           long long
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (long long )(1e18+1)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii>

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){
    cerr << name << " = " << arg1 << endl;
}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args){
    const char *name = strchr(names, ',');
    cerr.write(names, name-names) << " = " << arg1 << endl;
    _F(name+2, args...);
}
template<typename T1, typename T2> istream& operator>>(istream& in, pair<T1, T2> &q){
    in >> q.F >> q.S; return in;
}
template<typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> &q){
    out << q.F << " " << q.S; return out;
}
template< typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F+p2.F, p1.S+p2.S};
}
template< typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F-p2.F, p1.S-p2.S};
}

void solve(){
    int s, w;
    cin >> s >> w;
    if(w >= s){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   

    int t = 1;
    start = clock(); 

    cout << fixed << setprecision(12);

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif

    //cin >> t;

    for(int i = 1; i <= t; ++i){
        //cout << "Case #" << i << ": "; 
        solve();
       // cout << endl;
    }
    //cerr << time(start);
    return 0;
}

Measured memory_bytes: 3640
function Main(input) {
  input = input.split("\n");
  tmp = input[1].split(' ').map(Number);
  var min = 1000000;
  var max = -1000000;
  var sum = 0;
  for(var i = 0; i < input[0]; i++){
    if(tmp[i] < min) min = tmp[i];
    if(tmp[i] > max) max = tmp[i];
    sum += tmp[i];
  }
  console.log(min + ' ' + max + ' ' + sum);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 17560
from collections import Counter

N = int(input())
Ss = list(map(int, input().split()))
dic = Counter(Ss)
Ss = set(Ss)
Ss = list(Ss)
Ss.sort()

cnt = 0
for i in range(len(Ss)):
  for j in range(i+1, len(Ss)):
    for k in range(j+1,len(Ss)):
      if Ss[i] + Ss[j] > Ss[k]:
        cnt += dic[Ss[i]]*dic[Ss[j]]*dic[Ss[k]]
        
print(cnt)

Measured memory_bytes: 68556
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
struct Edge {
	int from, to, cost;

	bool operator<(Edge e) {
		return cost < e.cost;
	}
};


// 最大公約数
int gcd(int a, int b)
{
	if (b == 0) return a;
	else return gcd(b, a % b);
}

int main() {
	int N, K;
	cin >> N >> K;
	vi a(N);
	int ma = 0, mi = INF;
	
	rep(i, N) {
		cin >> a[i];
		ma = max(ma, a[i]);
		mi = min(mi, a[i]);
	}
	if (K > ma) {
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}

	if (N == 1) {
		if (K == a[0]) {
			cout << "POSSIBLE" << endl;
		}
		else {
			cout << "IMPOSSIBLE" << endl;
		}
		return 0;
	}
	int g = gcd(a[0], a[1]);
	repl(i, 2, N) {
		g = gcd(g, a[i]);
	}
	if (K%g == 0) {
		cout << "POSSIBLE" << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main(void){

  int n,q;
  cin >> n >> q;
  vector<int>acc(n+1, 0);
  string s;
  cin >> s;
  for(int i=1;i<=n;i++){
    acc[i]=(s[i-1]=='A' && s[i]=='C');
    acc[i]+=acc[i-1];
  }

  while(q--){
    int l,r;
    cin >> l >> r;
    l-=1,r-=1;
    cout << acc[r] - acc[l-1] - (l>0 && s[l-1]=='A' && s[l]=='C') << endl;
  }

  return 0;
}


Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

	public static void main(String[] args) throws IOException
	{
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		for(;;)
		{
			String str = br.readLine();
			double a = Double.parseDouble(str.substring(0, str.indexOf(" ")));
			int i = str.indexOf(" ");
			String  b = str.substring(i + 1, str.indexOf(" ", i + 1));
			double c = Double.parseDouble(str.substring(str.indexOf(" ", i + 1)));
			double d = 0;;
			if(b.equals("?"))break;
			else if(b.equals("+")) d = a + c;
			else if(b.equals("-")) d = a - c;
			else if(b.equals("*")) d = a * c;
			else if(b.equals("/")) d = a / c;
			System.out.println((int)d);
		}
	}

}



Measured memory_bytes: 24540
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define vt vector
#define pq priority_queue
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)
// #define multicase
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int N = 1e3 + 5;

int n, k, ans;

void solve() {
    int T = 1;
  #ifdef multicase
    cin >> T;
  #endif
    for(int tc = 1; tc <= T; tc++) {
        cin >> n >> k;
        ans = 1;
        while(n--) ans = min(ans * 2, ans + k);
        cout << ans << "\n";
    }
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    solve();
    
}

Measured memory_bytes: 3648
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
using namespace std;

int main() {
	int N, c = 0, a = 1, ans = 0;
	cin >> N;
	for (int i = 1; i <= N; i += 2)
	{
		while (a != i + 1)
		{
			if (i%a == 0)c++;
			a++;
			//cout << a;
		}
		if (c == 8)ans++;
		c = 0;
		a = 1;
	}
	cout << ans;
}


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

int main(void)
{
    int N, K, S;
    cin >> N >> K >> S;


    for (int i = 0; i < N; i++)
    {
        if(i < K){
            cout << S;
        } else {
            if(S < 1e9){
                cout << S + 1;
            } else {
                cout << 1;
            }
        }

        if(i < N-1) cout << ' ';
    }

    cout << endl;

    return 0;
}


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

int n;
int a[100010] , f[100010] , g[100010];
int main()
{

    ios::sync_with_stdio(0);
    cin >> n;
    for (int i = 1 ;  i <= n ; i++)
        cin >> a[i];

    f[0] = 0;
    for (int i = 1 ;  i <= n ; i++)
        f[i] = __gcd(f[i-1] , a[i]);
    
    g[n+1] = 0;
    for (int i = n ; i >= 1 ; i--)
        g[i] = __gcd(g[i+1], a[i]);    
    
    int res = 0;
    for (int i = 1 ; i <= n ; i++)
        res = max(res , __gcd(f[i-1],g[i+1]));
    
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

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

    vector<int> a(n, 0);
    for (auto i = 0; i < k; i++) {
        int d; cin >> d;
        for (auto j = 0; j < d; j++) {
            int p; cin >> p;
            a[p - 1]++;
        }
    }

    int ans = 0;
    for (auto i = 0; i < n; i++) {
        if(a[i] == 0) ans++;
    }

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

Measured memory_bytes: 3624
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")
// -------------------</optimizations>--------------------
#include <iostream>
#include <bitset>
#include <algorithm>        // sort()
#include <vector>           // for vectors
#include <map>              // for ordered map
#include <unordered_map>
#include <list>             // for list
#include <iomanip>          // for setprecision()
#include <cmath>            // for pow(), sqrt(), log(), log10(), ....
#include <cstring>          // for memset()
#include <unordered_set>    // for unordered_set
#include <climits>          // for INT_MAX & INT_MIN
#include <set>              // for ordered set

#define C ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long ll;
#define INF INT_MAX
#define NINF INT_MIN
#define MOD 1000000007
const double pi=acos(-1); // value of pi


bool isVowel(char ch) {
    if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u') {
        return 1;
    }
    return 0;
}

bool compare(pair<ll, ll> a, pair<ll, ll> b) {
    return a.second<b.second;
}


bool isPrime(ll n) {
    for(ll i=3; i*i<=n; i+=2) {
        if(n%i==0) {
            return false;
        }
    }
    return true;
}

map<ll, list<ll>> m;
// map<ll, ll> m;

int main() {
    C
//     freopen("input.txt","r",stdin);
// 	freopen("output.txt","w",stdout);
    int t=1;
    // cin >> t;
    while(t--) {
        ll ans=0;
        string a, b;
        cin >> a >> b;
        ll n=a.length();
        for(ll i=0; i<n; i++) {
            if(a[i]!=b[i]) {
                ans++;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3452
N = int(input())
A = [int(x) for x in input().split(' ')]
assert(len(A) == N)
s = sum(A)
Ls = 0
ans = -1

for i in range(N-1):
    Ls += A[i]
    Rs = s - Ls
    diff = abs(Rs - Ls)
    if ans == -1 or diff < ans:
        ans = diff
print(ans)

Measured memory_bytes: 26060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e9;
const int MOD = 1e9 + 7;

#define MAX_N 100000

int n;
ll a,b;
ll h[MAX_N];

bool isOK(ll x){
    ll cnt = 0;
    REP(i,n){
        cnt += max((ll)0, (h[i] - b * x + a - b - 1) / (a - b));
    }
    if(cnt <= x){
        return true;
    }else{
        return false;
    }
}

signed main(){
    cin >> n >> a >> b;
    REP(i,n){
        cin >> h[i];
    }
    ll ng = -1;
    ll ok = INF + 1;
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        if(isOK(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#define MAX_N 107
typedef long long ll;

int N;
ll X, a[MAX_N], sum;

int main () {
    scanf("%d%lld", &N, &X);
    for (int i = 1;i <= N; ++i)
        scanf("%lld", a + i), sum += a[i];
    if (sum <= X) {
        printf("%d\n", sum == X ? N : N - 1);
    } else {
        int res = 0;
        std::sort(a + 1, a + N + 1);
        for (int i = 1;i <= N; ++i)
            if (a[i] <= X)
                res++, X -= a[i];
        printf("%d\n", res);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

vecint gen(int n) {
  if (n == 1) {
    vecint res = {3, 5, 7};
    return res;
  } else {
    vecint r = gen(n-1);
    vecint res = {3, 5, 7};
    int ary[3] = {3,5,7};
    for (int m : r) {
      REP(i,3) {
        res.push_back(m*10 + ary[i]);
      }
    }
    return res;
  }
}

int main()
{
  int n;
  cin>>n;
  vecint res = gen(9);
  vector<int> s;
  for (int m : res) {
    string str = to_string(m);
    vecint cnt(10, 0);
    REP(i,str.size()) {
      ++cnt[str[i]-'0'];
    }
    if (!cnt[3]||!cnt[5]||!cnt[7]) continue;
    s.push_back(m);
  }
  sort(ALL(s));
  s.erase(unique(ALL(s)), end(s));
  cout << (upper_bound(ALL(s), n) - begin(s)) << endl;
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int n;
int main(){
	scanf("%d",&n);
	while(n--){
		int money,year,way;
		double rate;
		scanf("%d",&money);
		scanf("%d",&year);
		scanf("%d",&way);
		int c,d=0,ans;

		while(way--){
			int flag,factorage;
			int y=year;
			scanf("%d",&flag);
			scanf("%lf",&rate);
			scanf("%d",&factorage);
                if(flag==0){
				int a=money,b,q=0;
				while(y--){
					b=(int)a*rate;
					a-=factorage;
					q+=b;
				}
				a+=q;
				c=a;
			}
			if (flag==1) {
				int  a=money,b;
				while (y--) {
					b=(int)a*rate;
					a=a+b-factorage;
					}
				c=a;
			}
			if (c>d) {
				d=c;
			}
			
		}
		printf("%d\n",d);		
	}
	return 0;
	
}



Measured memory_bytes: 1904
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
// using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;

//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define bug2(v1,v2)               cerr<<#v1<<" = "<<(v1)<< ' ' << #v2<<" = "<<(v2)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const double pi = 3.14159265359;
const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
//const ll mod = 998244353 ;
const ll mod = 1000000007;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return (((a+mod)%mod)*(b+mod)%mod)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline ll modInverse(ll n, ll p){ return power(n, p-2)%p; }

/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 
void stArt()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}
void eNd()
{
	#ifndef ONLINE_JUDGE
  	cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  	#endif
}

//////////////////// start /////////////////////////////////
 

ll i,j,k,l,m,r,n;
//ll a[MAX],b[MAX];

int main()
{
 
stArt();
fast
//cout << setprecision(15) << fixed;

cin >> n;
k = n + n*n + n*n*n;
cout << k;

eNd();
  return 0;
 
}


Measured memory_bytes: 3588
// 2013/05/13 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int L, A, B, C, D;
	cin >> L;
	cin >> A;
	cin >> B;
	cin >> C;
	cin >> D;

	int E = A/C;
	if(A%C!=0){
		E++;
	}

	int F = B/D;
	if(B%D!=0){
		F++;
	}

	if(E>F){
		cout << L-E << '\n';
	}
	else{
		cout << L-F << '\n';
	}

	return 0;
}

Measured memory_bytes: 1160
/*
            _ _  ___            __ _ _  _       _     
 _   _  ___| | |/ _ \__      __/ _| | || |  ___| |__  
| | | |/ _ \ | | | | \ \ /\ / / |_| | || |_/ __| '_ \ 
| |_| |  __/ | | |_| |\ V  V /|  _| |__   _\__ \ | | |
 \__, |\___|_|_|\___/  \_/\_/ |_| |_|  |_| |___/_| |_|
 |___/                 

 */

#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
#define MOD 1000000007
#define INF 1000000000000000007
#define MAXN 300005


signed main(){
	fast
	int n;cin>>n;
	vector<int> v;
	int temp;
	For(i, 0, n){
		cin>>temp;
		v.pb(temp);
	}
	v[0]--;
	int flag=0;
	For(i, 1, n){
		if(v[i]>v[i-1]){
			v[i]--;
		}else if(v[i]<v[i-1]){
			flag=1;
			break;
		}
	}
	// tr(v){
	// 	cout<<*it<<" ";
	// }
	if(flag){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}
    return 0;
}
    



Measured memory_bytes: 1400
s = input()
n = len(s)
e = n//2
o = n - e
w = 0
l = 0
for i in range(o):
    p = 2*i
    if s[p] == 'p':
        l += 1
for j in range(e):
    q = 2*j + 1
    if s[q] == 'g':
        w += 1
ans = w - l
print(ans)

Measured memory_bytes: 3316
while True:
    try:
        A = list(map(int, input().split()));
    except EOFError:
        break;
    B = list(map(int, input().split()));

    h = 0;
    b = 0;
    for i in range(0,4):
        if A[i] == B[i]:
            h += 1;
        else:
            for j in range(0,4):
                if A[j] == B[i]:
                    b += 1;
    print(h,b);


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

int main(){

    // 読み込み
    while(1){
        int n, sum;
        cin >> n >> sum;
        if(0 == n && 0 == sum){
            break;
        }
        // cout << n << sum;

        int count = 0;

        // 計算
        for(int i = 1; i <= n; i++){
            for(int j = i + 1; j <= n; j++){
                for(int k = j + 1; k <= n; k++){
                    if(sum == (i + j + k)){
                        // cout << i << j << k << endl;
                        count++;
                    }
                }
            }
        }
        cout << count << endl;

        // 出力
    }





    return 0;
}


Measured memory_bytes: 3076
#pragma G++ optimize(2)
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define LL long long
#define O4 __inline__ __attribute__((always_inline))
#define inf 0x7fffffff
#define UL unsigned LL
#define LD long double
#ifdef ONLINE_JUDGE
#define getchar nc
#endif
#define int LL
namespace FastIO{
	O4 char nc(){
		static char buf[100000],*p1=buf,*p2=buf;
		return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
	}
	O4 int read(){
		char t;int u=0,k=1;t=getchar();
		while(t<'0'||t>'9'){if(t=='-')k=-1;t=getchar();}
		while(t>='0'&&t<='9'){u=u*10+t-'0';t=getchar();}
		return u*k;
	}
	template <typename T>
	O4 void read(T &u){
		char t;T k=1;u=0;t=getchar();
		while(t<'0'||t>'9'){if(t=='-')k=-1;t=getchar();}
		while(t>='0'&&t<='9'){u=u*10+t-'0';t=getchar();}
		if(t=='.'){
			T mass=0.1;t=getchar();
			while(t>='0'&&t<='9'){u+=mass*(t-'0');mass/=10;t=getchar();}
		}u*=k;
	}
	O4 int read(char asd[]){
		char t=getchar();int u=0;
		while(t==' '||t=='\n'||t=='\r')t=getchar();
		if(t==EOF)return -1;
		while(t!=' '&&t!='\n'&&t!=EOF&&t!='\r')asd[u++]=t,t=getchar();
		asd[u]='\0';return u;
	}
	char sr[1<<23],z[23];int C=-1,Z;
	O4 void wer(int x,char T){
		int y=0;if(x<0)y=1,x=-x;
		while(z[++Z]=x%10+'0',x/=10);if(y)z[++Z]='-';
		while(sr[++C]=z[Z],--Z);sr[++C]=T;
	}
	O4 void wer(char T[],char QWQ){
		for(int i=0;T[i]!='\0';i++)sr[++C]=T[i];
		sr[++C]=QWQ;
	}
	O4 void wer(char T){sr[++C]=T;}
	O4 void out(){fwrite(sr,1,C+1,stdout);C=-1;}
}
using namespace std;
using namespace FastIO;
const int N=1e5+5;
int n,m;
int val[N],sum[N],A[N],B[N],fa[N],id[N],F[N];
bool vis[N];
vector <int> Map[N];
int get_fa(int x){return fa[x]==x?x:fa[x]=get_fa(fa[x]);}
signed main(){
	n=read();m=read();
	for(int i=1;i<=n;i++){
		A[i]=read();B[i]=read();
		A[i]=max(A[i]-B[i],0ll);
		fa[i]=id[i]=i;
	}
	while(m--){
		int a=read(),b=read();
		Map[a].push_back(b);
		Map[b].push_back(a);
	}
	sort(id+1,id+1+n,[](int a,int b){return A[a]<A[b];});
	for(int i=1;i<=n;i++){
		int x=id[i];sum[x]=B[x];
		vector <int> load;vis[x]=1;
		for(int to:Map[x]){
			if(!vis[to])continue;
			int a=get_fa(x),b=get_fa(to);
			if(a==b)continue;
			load.push_back(b);
			sum[x]+=sum[b];fa[b]=a;
		}
		F[x]=sum[x]+A[x];
		for(int to:load)F[x]=min(F[x],sum[x]-sum[to]+max(F[to],A[x]));
	}
	cout<<F[id[n]];
	return 0;
}

Measured memory_bytes: 14788
#include<bits/stdc++.h>
using namespace std;
#define int  long long int
#define fi first
#define se second
#define pb push_back
#define soo(v) sort(v.rbegin(),v.rend())
#define so(v) sort(v.begin(),v.end())
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define endl '\n'
#define dbv(v) cout<<endl;cout<<#v<<"-->> ";for(auto it:v){cout<<it<<" ";}cout<<endl;
#define dbm(m)cout<<endl;cout<<#m<<"-->> ";for(auto it:m){cout<<it.fi<<" "<<it.se<<endl;}
#define dbs(s)cout<<endl;cout<<#s<<"-->> ";for(auto it:s){cout<<it<<" ";}cout<<endl;
#define mod 2019
#define db1(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl;
#define mx 1e18
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v)  *min_element(v.begin(),v.end())
#define double long double
#define re(s) reverse(s.begin(),s.end())
#define io std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
int powe(int x,int n)
{
  if(n==0)return 1;
  if(n%2==0)
    return powe((x%mod*x%mod)%mod,n/2)%mod;
  return (x%mod*powe((x%mod*x%mod)%mod,(n-1)/2))%mod;
}
int gcd(int A,int B)
{
  if(B==0)return A;
  return gcd(B,A%B);
}
int32_t main()
{
  io
int a,b;
cin>>a>>b;
cout<<a*b<<endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
using namespace std;
struct m_type {
    int C, S, F;
};
int main() {
    int n;
    cin>>n;
    vector<m_type> v(n);
    int i, j;
    for (i = 0; i + 1 < n; ++i) cin>>v[i].C>>v[i].S>>v[i].F;
    for (i = 0; i < n; ++i) {
        if (i + 1 == n) cout<<0<<endl;
        else {
            int t = v[i].S + v[i].C;
            for (j = i + 1; j + 1 < n; ++j) {
                if (t < v[j].S) t = v[j].S + v[j].C;
                else {
                    if ((t - v[j].S)  % v[j].F == 0) t += v[j].C;
                    else t += v[j].F - ((t - v[j].S) % v[j].F) + v[j].C;
                }
            }
            cout<<t<<endl;
        }
    }
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  if(s[2] == s[3] && s[4] == s[5])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

ll d;
vll c(26);
vvll s;

void create_first_answer(vll& ans) {
  vll last(26, -1);

  rep(today, d) {
    vll cand(26);

    rep(j, 26) {
      cand[j] = s[today][j] + c[j] * (today - last[j]);
    }

    ll choice = distance(cand.begin(), max_element(all(cand)));
    ans[today] = choice;
    last[choice] = today;
  }
}

ll update_diff(ll idx, const vll& choice) {
  ll last = -1;
  ll total = 0;
  rep(today, d) {
    if (choice[today] == idx) {
      last = today;
      total += s[today][idx];
    } else {
      total -= c[idx] * (today - last);
    }
  }
  return total;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  cin >> d;
  rep(i, 26) {
    cin >> c[i];
  }

  s = vvll(d, vll(26));
  rep(i, d) {
    rep(j, 26) {
      cin >> s[i][j];
    }
  }

  srand(s[0][0]);

  vll ans(d);

  create_first_answer(ans);

  vll score_con(26);
  ll score = 0;

  rep(i, 26) {
    score_con[i] = update_diff(i, ans);
    score += score_con[i];
  }

  rep(i, 100000) {
    vll cand = ans;
    vb changed(26);

    rep(j, (rand() % 3) + 1) {
      ll tgt = (i * 3 + j) % d;
      cand[tgt] = rand() % 26;

      changed[ans[tgt]] = true;
      changed[cand[tgt]] = true;
    }

    ll cs = score;
    vll score_cand = score_con;
    rep(i, 26) {
      if (changed[i]) {
        cs -= score_cand[i];
        score_cand[i] = update_diff(i, cand);
        cs += score_cand[i];
      }
    }
    if (cs > score) {
      ans = cand;
      score_con = score_cand;
    }
  }

  rep(i, d) {
    cout << ans[i] + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define frw(i, a, b) for(int i = a; i < b; i++)
#define bck(i, a, b) for(int i = a; i > b; i--)
#define fi first
#define se second
#define pub push_back
#define in insert
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) int(a.size())
#define pii pair<int, int>
#define pll pair<ll, ll>
#define plll pair<ll, pll>
#define vpll vector<pll>
#define vpii vector<pii>

int main(){
	ios::sync_with_stdio(0);
	int n; cin >> n;
	vi a(n + 1, 0), dp(n + 1, 0);
	frw(i, 1, n + 1)	cin >> a[i];
	dp[2] = abs(a[2] - a[1]);
	frw(i, 3, n + 1)	dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
	cout << dp[n];
}

Measured memory_bytes: 1024
A,B,C,D = input().split()
a = int(A)
b = int(B)
c = int(C)
d = int(D)

while True:
    c = c - b 
    if c<=0:
        print("Yes")
        break
    a = a - d
    if a<=0:
        print("No")
        break


Measured memory_bytes: 9176