akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;


int main() {
    int k,n;
    cin>>k>>n;
    vector<int>a(n);
    int MAX=0;
    for(int i=0;i<n;i++){
        cin>>a.at(i);
        // MAX=max(MAX,a.at(i+1)-a.at(i));
    }
    for(int i=0;i<n-1;i++){
        MAX=max(MAX,a.at(i+1)-a.at(i));
    }
    // cout<<MAX<<endl;
    MAX=max(MAX,k-a.at(n-1)+a.at(0));
    cout<<k-MAX<<endl;







    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    a=a+b;
    if(a%2==0)
    {
        a=a/2;
        printf("%d\n",a);
    }
    else
    {
        printf("IMPOSSIBLE\n",a);
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long llint;
const llint MOD = 998244353;
int main() {
    llint A, B;
    cin >> A >> B;
    if(A > B)
        swap(A, B);
    int common = 1;
    for(int i = 2; i <= sqrt(A); i++) {
        if(A % i == 0) {
            while(A % i == 0) {
                A /= i;
            }
            if(B % i == 0) 
                common++;
        }
    }
    if(A != 1 && B % A == 0)
        common++;
    cout << common;
} 

Measured memory_bytes: 256
/*
 * @Author: Kaizyn
 * @Date: 2020-06-13 20:58:04
 * @LastEditTime: 2020-06-22 11:15:32
 */ 
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const int N = (1<<18)+7;
const int M = 1e5+7;
const int MID = 9;

int n, m, q;
int v[N], w[N];
int a[N], lg2[N], sumv[N], sumw[N];
int dp[10][M];
int res[M];
vector<pii> query[N];

void bfs(const int &u, const int &dep) {
  if (u > n) return;
  if (dep <= MID) {
    // memset(dp[dep], 0, sizeof dp[dep]);
    for (int i = 0; i <= m; ++i) {
      dp[dep][i] = dp[dep-1][i];
      if (i >= w[u]) dp[dep][i] = max(dp[dep][i], dp[dep-1][i-w[u]]+v[u]);
    }
    for (const pii &p : query[u]) {
      res[p.first] = dp[dep][p.second];
    }
  } else {
    a[dep-MID-1] = u;
    for (const pii &p : query[u]) res[p.first] = dp[MID][p.second];
    if (query[u].size()) for (int i = 1, j; i < 1<<(dep-MID); ++i) {
      j = i&-i;
      sumv[i] = sumv[i^j]+v[a[lg2[j]]];
      sumw[i] = sumw[i^j]+w[a[lg2[j]]];
      for (const pii &p : query[u]) {
        if (sumw[i] > p.second) continue;
        res[p.first] = max(res[p.first], dp[MID][p.second-sumw[i]]+sumv[i]);
      }
    }
  }
  bfs(u<<1, dep+1);
  bfs(u<<1|1, dep+1);
}

inline void solve() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> v[i] >> w[i];
  }
  cin >> q;
  for (int i = 1, x, L; i <= q; ++i) {
    cin >> x >> L;
    query[x].emplace_back(i, L);
    m = max(m, L);
  }
  bfs(1, 1);
  for (int i = 1; i <= q; ++i) {
    cout << res[i] << endl;
  }
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  for (int i = 0; i <= 18; ++i) lg2[1<<i] = i;
  int T = 1;
  // cin >> T;
  for (int t = 1; t <= T; ++t) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 18788
#include <stdio.h>

int main(void)
{
	int n, k;
	int count = 0;

	scanf("%d", &n);

	scanf("%d", &k);

	while (n > 0) // N を K で割った答えが0になるまで繰り返す
	{
		n = n / k;
		//桁数をカウントする
		count = count + 1;
	}

	printf("%d", count);

	return 0;
}

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

int N;
string S;

int main(){
    cin >> N;
    cin >> S;

    for(int i = 0; i < S.length(); i++){
        S[i] = (S[i] - 'A' + N) % 26 + 'A';
    }

    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define int         int64_t
#define ii          pair<int,int>
#define dd          pair<double,double>
#define vi          vector<int>
#define pb          push_back
#define all(x)      (x).begin(), (x).end()
#define checkBit(v, p)      (v&(1LL << p))
#define loop(i,a,b) for(int i = a;i < int(b);i++)
#define x           first
#define y           second
using namespace std;

int inf = 4e18, mod = 1e9+7;

int32_t main()
{
    ios_base::sync_with_stdio(false); cout << fixed <<setprecision(0);
    int n,sum; cin >> n;
    string s; cin >> s;
    int l = s.size();
    vi p2(n+1);
    vector<vi> dp(n+1, vi(n+1,0));
    p2[0] = dp[0][0] = 1;
    for(int i=1;i <= n; i++){
        dp[i][0] = 1;
        p2[i] = p2[i-1] * 2 % mod;
        for(int j = 1;j<=n;j++){
            dp[i][j] = dp[i-1][j] + (i - 1 - (j - 1) * 2 > 0 ? dp[i-1][j-1] : 0);
            dp[i][j] %= mod;
        }
    }
    sum = p2[(n - l) / 2] * ((n - l) % 2 ? 0 :dp[n][(n - l) / 2]) % mod;
    sum += p2[(n - l - 1) / 2] * ((n - l - 1) % 2 ? 0 :dp[n - 1][(n - l - 1) / 2]) % mod;
    for(int i = 1, er;i < n; i++){
        int tmp = 0;
        for(int j = 0; j < i; j++){
            tmp = (tmp + dp[i][j] * p2[j] % mod) % mod;
        }
        er = n - i - 1 - l;
        if(er % 2 == 0 && er >= 0)
            sum = (sum + tmp * dp[n - i - 1][er / 2] % mod * p2[er / 2] % mod) % mod;
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 195840
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n, k; cin >> n >> k;
  VI h(n), dp(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
    if (i == 0) continue;
    dp[i] = 2e9;
    for (int j = 1; j <= k; j++) {
      if (i - j >= 0) {
        dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
      }
    }
  }
  cout << dp[n - 1] << endl;

  return 0;
}


Measured memory_bytes: 1024
program main
  implicit none
  integer, parameter :: imax = 1010000
  integer :: d, n, i, cnt
  read(*, *) d, n
  cnt = 0
  do i = 1, imax
    if (d == 0) then
      if (mod(i, 100) /= 0) cnt = cnt + 1
    else if (d == 1) then
      if (mod(i, 100) == 0 .and. mod(i, 10000) /= 0) cnt = cnt + 1
    else if (d == 2) then
      if (mod(i, 10000) == 0 .and. mod(i, 1000000) /= 0) cnt = cnt + 1
    else
      stop 1
    end if
    if (cnt == n) then
      write(*, "(i0)") i
      stop 0
    end if
  end do
end program main


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

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 


struct V {
    double x;
    double y;
    explicit V(double init_x = 0, double init_y = 0) : x(init_x), y(init_y) {}
    V(const V& rhs) : x(rhs.x), y(rhs.y) {}
    V& operator=(const V& rhs) {
        if (this != &rhs) {
            x = rhs.x;
            y = rhs.y;        
        }
        return *this;
    }
    double norm() const { return sqrt(x*x+y*y); }
};

inline double innerProduct(const V& lhs, const V& rhs) { return (lhs.x * rhs.x + lhs.y * rhs.y); }
inline V operator+(const V& lhs, const V& rhs) { return V(lhs.x + rhs.x, lhs.y + rhs.y); }

struct M {
    double a;
    double b;
    double c;
    double d;
    explicit M(double init_a = 0, double init_b = 0, double init_c = 0, double init_d = 0) : a(init_a), b(init_b), c(init_c), d(init_d) {}
    M(const M& rhs) : a(rhs.a), b(rhs.b), c(rhs.c), d(rhs.d) {}
    M& operator=(const M& rhs) {
        if (this != &rhs) {
            a = rhs.a;
            b = rhs.b;        
            c = rhs.c;
            d = rhs.d;        
        }
        return *this;
    }
};

inline M rotationMatrix(double angle) 
{
    double c = cos(angle);
    double s = sin(angle);
    return M(c, -s, s, c);
}

inline V operator*(const M& m, const V& v)
{
    return V(m.a * v.x + m.b * v.y, m.c * v.x + m.d * v.y);
}

inline M operator*(const M& lhs, const M& rhs)
{
    return M(lhs.a * rhs.a + lhs.b * rhs.c, lhs.a * rhs.b + lhs.b * rhs.d, lhs.c * rhs.a + lhs.d * rhs.c, lhs.c * rhs.b + lhs.d * rhs.d);
}


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

    vector<V> e(N);
    for (int i = 0; i < N; ++i) {
        cin >> e[i].x >> e[i].y;
    }

    double ans = 0;
    const double EPS = 0.00000000000000000000001;
    const double cos_EPS = cos(EPS);
    const double sin_EPS = sin(EPS);
    const double cos_90 = 0;
    const double sin_90 = 1.0;

    const M m_p_EPS = rotationMatrix(EPS);
    const M m_n_EPS = rotationMatrix(-EPS);
    const M m_p_90(0, -1, 1, 0);
    const M m_n_90(0, 1, -1, 0);
    const M m1 = m_p_EPS * m_p_90;
    const M m2 = m_p_EPS * m_n_90;
    const M m3 = m_n_EPS * m_p_90;
    const M m4 = m_n_EPS * m_n_90;

    for (const V& v: e) {
        vector<V> dir(6);
        dir[0] = m1 * v; 
        dir[1] = m2 * v; 
        dir[2] = m3 * v; 
        dir[3] = m4 * v;
        dir[4] = m_p_EPS * v;
        dir[5] = m_n_EPS * v;
        for (const V& d: dir) {
            V vSum;
            for (const V& t: e) {
                if (0 <= innerProduct(t, d)) {
                    vSum = vSum + t;
                }
            }
            ans = max(ans, vSum.norm());
        }
    }

    printf("%.30f\n", ans);

    return 0;
}


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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp make_pair
#define pb push_back

const long long MOD = 1000000007;
const long long INF = 1LL<<60;


int main(){
    cout << fixed << setprecision(12);
    ll r;
    cin >> r;
    cout << r*r << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    vei a(3); rep(i,3) cin >> a[i];
    sort(all(a));
    rep(i,3) {
        if(i != 2) cout << a[i] << " ";
        else cout << a[i] << endl;
    }
    
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF int(1e9+7)

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

int main()
{
	IO_OP;
	
	int n;
	cin >> n;
	cout << "Christmas";
	for(int i=0;i<25-n;i++)
		cout << " Eve";
	cout << endl;
}



Measured memory_bytes: 256
h, w = gets.split.map(&:to_i)

table = []
h.times do
  str = gets.chomp.chars
  unless str.all? {|c| c == '.'}
    table << str
  end
end

new_table = []
table.transpose.each do |t|
  if t.include?('#')
    new_table << t
  end
end

new_table.transpose.each do |t|
  puts t.join
end


Measured memory_bytes: 14612
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef struct pair<int,int> P;
typedef long long ll;
bool k[100001]={};
int a[100001]={};
int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if((b-a)==(c-b)){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h1,k1,h2,k2;
  int a,b,c,d;
  cin >> h1 >> k1 >> h2 >> k2;
  cin >> a >> b >> c >> d;
  int hiroshi = a * h1 + h1 / 10 * c + b * k1 + k1 / 20 * d;
  int kenjiro = a * h2 + h2 / 10 * c + b * k2 + k2 / 20 * d;
  if(hiroshi > kenjiro) cout << "hiroshi" << endl;
  else if (hiroshi == kenjiro) cout << "even" << endl;
  else cout << "kenjiro" << endl;
}


Measured memory_bytes: 3192
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)

using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

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

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

    vector<int> col(w, 0);
    vector<int> row(h, 0);

    set<pair<int, int>> s;
    rep(i, m) {
        int h, w;
        cin >> h >> w;
        col[--w]++;
        row[--h]++;
        s.insert(make_pair(h, w));
    }
    int max_val = 0;
    rep(i, h) {
        max_val = max(max_val, row[i]);
    }
    vector<int> max_idy;
    rep(i, h) {
        if (row[i] == max_val) {
            max_idy.push_back(i);
        }
    }
    int max_val2 = 0;
    rep(i, w) {
        max_val2 = max(max_val2, col[i]);
    }
    vector<int> max_idx;
    rep(i, w) {
        if (col[i] == max_val2) {
            max_idx.push_back(i);
        }
    }
    int res = 0;
    for (auto e1 :max_idy ) for (auto e2 : max_idx ) {
        auto it = s.find(make_pair(e1, e2));
        int flag =0;
        if ( it != s.end()) {
            res = max(res, max_val + max_val2 - 1);
        } else {
            res = max(res, max_val + max_val2);
            flag = 1;
            break;
        }
        if (flag) break;
    }

    wcout << res << endl;


    
}

Measured memory_bytes: 23796
#include <iostream>
#include <string.h>
#include <vector>
#include <queue>
#include <functional>
#include <algorithm>
#include <utility>
#include <cmath>
#include <iomanip>
using namespace std;

const int MAXV = 10000 + 16;
const int MAXE =  MAXV * 10;
const int INF = 0x3f3f3f3f;
typedef long long LL;
typedef pair<int, int> P; // 坐标点

int N, M;
int V, E;
struct Edge {
	int from, to;
	double cost;
	Edge(int _from=0, int _to=0, double _cost=0) :from(_from), to(_to), cost(_cost){}
};
P p[MAXV];
Edge edge[MAXE];
int father[MAXV];
int height[MAXV];
bool cmp(const Edge& a, const Edge& b) {
	return a.cost > b.cost;
}
void Init(int n) {
	for (int i = 0; i < n; ++i) {
		father[i] = i;
		height[i] = 0;
	}
}
int Find(int x) {
	if (father[x] == x)
		return x;
	else
		return father[x] = Find(father[x]);
}
void Unite(int x, int y) {
	x = Find(x);
	y = Find(y);
	if (x == y)
		return;
	if (height[x] < height[y]) {
		father[x] = y;
	} else {
		father[y] = x;
		if (height[x] == height[y])
			++height[x];
	}
}
bool same(int x, int y) {
	return Find(x) == Find(y);
}
double Kruskal() {
	Init(MAXV);
	sort(edge, edge + E, cmp);
	double res = 0;
	for (int i = 0; i < E; ++i) {
		Edge e = edge[i];
		if (!same(e.from, e.to)) {
			Unite(e.from, e.to);
		}
		else {
			res += e.cost;
		}
	}
	return res;
}
void solve() {
	double res = Kruskal();
	printf("%.3f\n", res);
}


int main(int argc, char const *argv[])
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	while (scanf("%d%d", &N, &M) != EOF) {
		V = N; E = M;
		for (int i = 0; i < N; ++i) {
			scanf("%d%d", &p[i].first, &p[i].second);
		}
		int from, to, cost;
		for (int i = 0; i < M; ++i) {
			scanf("%d%d", &from, &to);
			--from; --to;
			int dx = p[from].first - p[to].first;
			int dy = p[from].second - p[to].second;
			double dist = sqrt(dx * dx + dy * dy);
			edge[i] = Edge(from, to, dist);
		}
		solve();
	}
	//system("pause");
	return 0;
}



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

int main(){
    i64 ans = 1000;
    string s,t;
    cin>>s>>t;
    for(i64 i=0;i<=s.size()-t.size();i++){
        i64 a=0;
        for(i64 j=0;j<t.size();j++){
            if(s[i+j]!=t[j]){
                a++;
            }
        }
        ans = min(ans,a);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;


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


int main(){
  int N, M, C;
  cin >> N >> M >> C;
  std::vector<int> B(M);
  std::vector<vector<int>> A(N,vector<int>(M));
  REP(i,M) cin >> B[i];
  REP(i,N)REP(j,M) cin >> A[i][j];
  int count = 0;
  REP(i,N){
    int F = 0;
    REP(j,M) F += A[i][j]*B[j];
    F += C;
    if(F > 0)count++;
  }
  cout << count <<endl;
}


Measured memory_bytes: 256
S = input()[::-1]
T = list(['maerd', 'remaerd', 'esare', 'resare'])
while(1):
    if len(S) == 0:
        print('YES')
        break
    elif S[:5] in T:
        S = S[5:]
    elif S[:6] in T:
        S = S[6:]
    elif S[:7] in T:
        S = S[7:]
    else:
        print('NO')
        break


Measured memory_bytes: 3188
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;

const int MAX_N = 100001;
char s[MAX_N];
char buf1[4] = {'S','S','W','W'};
char buf2[4] = {'S','W','S','W'};
int main(void){
  int N;
  cin >> N;
  cin >> s;
  char ret[MAX_N];

  bool flg = false;

  for(int idx=0; idx<4; idx++){
    ret[0] = buf1[idx];ret[1] = buf2[idx];
    for(int i = 1; i < N-1; i++){
      if((s[i] == 'o' && ret[i] == 'S')||(s[i] == 'x' && ret[i] == 'W')){
        ret[i+1] = ret[i-1];
      }else{
        if(ret[i-1]=='S')ret[i+1]='W';
        else ret[i+1]='S';
      }
    }
    ret[N] = '\0';
    bool flg1 = false;
    bool flg2 = false;
    if((s[N-1] == 'o' && ret[N-1] == 'S')||(s[N-1] == 'x' && ret[N-1] == 'W')){
      if(ret[N-2]==ret[0]) flg1 = true;
    }else{
      if(ret[N-2]!=ret[0]) flg1 = true;
    }
    if((s[0] == 'o' && ret[0] == 'S')||(s[0] == 'x' && ret[0] == 'W')){
      if(ret[N-1]==ret[1]) flg2 = true;
    }else{
      if(ret[N-1]!=ret[1]) flg2 = true;
    }
    flg = flg1 & flg2;
    if(flg==true)break;
  }
  if(flg){
    cout << ret << "\r\n";
  }else{
    cout << "-1\r\n";
  }
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define vl vector<ll int>
#define vs vector<string>
#define vi vector<int>
#define mi map<int,int>
#define mc map<char,int>

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

using namespace std;

int main(){
     ios_base::sync_with_stdio(false);cin.tie(NULL);
     int n,m=1;
     cin>>n;
     vs A(n);
     vs B;
     for(auto &x:A)cin>>x;
     map<string,int> map1;
     for(auto x:A)map1[x]++;
     //for(auto x:map1)cout<<x.first <<" " <<x.second <<"\n";
     for(auto x:map1){
		 m=max(m,x.second);
	 }
	 for(auto x:map1)
	 if(x.second==m){
		 B.push_back(x.first);}
		 else{continue;}
		 for(auto x:B)cout<<x <<"\n";
}


Measured memory_bytes: 33460
import java.util.*;
import java.lang.*;

class Main{
  public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int N = Integer.parseInt(sc.next());
      int[] a = new int[N];
      int[] b = new int[N];
      for(int i = 0; i<N; i++) a[i] = Integer.parseInt(sc.next());
      for(int i = 0; i<N; i++) b[i] = Integer.parseInt(sc.next());
      for(int i = 1; i<N; i++) a[i] = a[i]+a[i-1];
      for(int i = N-2; i>=0; i--) b[i] = b[i]+b[i+1];
      int sum = Integer.MIN_VALUE/2;
      for(int i = 0; i<N; i++) sum = Math.max(sum, a[i]+b[i]);
      System.out.println(sum);
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define pll pair<ll,ll>
#define vll vector<pll>
#define vl vector<ll>
#define f first
#define s second
#define N 50000
#define pb push_back
#define mp make_pair
#define MAP map<ll,ll>
#define INF 1000000000
#define mod 1000000007
#define foo(i,a,b) for(ll i=(a);i<=(b);i++)
#define rep(i,a,b) for(ll i=(a);i>=(b);i--)
#define sl set<ll> 
#define sll set<pll>
#define ub upper_bound
#define lb lower_bound
using namespace std;

//<<-----Declare Variable Here------->>//
ll x;
 
//<<-----Implement Functions Here---->>//
 
 
//<<-----Start of Main--------------->>//
void MAIN(){
	cin>>x;
	ll a=(x/500)*1000;
	ll b=((x%500)/5)*5;
	cout<<a+b;

}

int main(){
	fastio;
 	ll t=1;
	//cin>>t;
	while(t--){
		MAIN();
	}
 
    // #ifndef ONLINE_JUDGE
    // cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    // #endif
}

Measured memory_bytes: 256
using System;

namespace code_festival_2017_quala_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            Console.WriteLine(s.Length >= 4 && s.Substring(0, 4) == "YAKI" ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 13140
import math
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

a = min(A)

count = 0
answer = 0

A.append(a)
for i in range(N+1):
    if A[i] == a:
        if count != 0:
            answer += math.ceil(count / (K-1))
            if count % (K-1) != 0:
                for j in range(1, K - (count % (K-1))):
                    if i+j < N+1:
                        A[i+j] = a
            count = 0
    else:
        count += 1

print(answer)



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

using namespace std;

typedef long long LL;
const int N = 110;

int main() {	
	LL x, c = 100;
	LL cnt = 0;
	scanf("%lld", &x);
	while (c < x) {
		c = (LL)(c*1.01);
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1);
#define dumpii(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%d, %d)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpiii(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%d, %d, %d)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

template<typename a>
struct S009 {
  a pow(a x, long n) {
    if( n == 0 ) return a(1);
    a t = pow(x, n / 2);
    return t * t * (n % 2 ? x : a(1));
  }
};

template<long p = 1000000007>
struct S010 {
  long x;
  S010() : x(0) {}
  S010(long x_) : x(x_ % p) {}
  S010 operator + (S010 y) { return S010<p>((x + y.x) % p); }
  S010 operator += (S010 y) { x = (x + y.x) % p; return *this; }
  S010 operator - (S010 y) { return S010<p>((x - y.x) % p); }
  S010 operator -= (S010 y) { x = (x - y.x) % p; return *this; }
  S010 operator * (S010 y) { return S010<p>((x * y.x) % p); }
  S010 operator *= (S010 y) { x = (x * y.x) % p; return *this; }
  S010 operator / (S010 y) { S009<S010> s; return *this * s.f(x, p - 2); }
  S010 operator /= (S010 y) { S009<S010> s; x = (*this * pow(x, p - 2)); return *this; }
};
template<long p>
S002& operator >= (S002& r, S010<p>& x) {
  long y;
  r >= y;
  x = S010<p>(y);
  return r;
}

template<typename a>
struct S016 {
  std::vector<a> xs;
  S016(long n) {
    xs.resize(n + 1);
    xs[0] = a(1);
    for(long i = 1; i <= n; ++i) {
      xs[i] = xs[i-1] * i;
    }
  }
  a operator [] (long i) {
    return xs[i];
  }
};

struct Solver {
  long n;
  std::vector<std::string> xs;
  std::vector<std::string> ys;
  Solver() {
    S002 r;
    r >= n;
  }
  void solve() {
    S016<S010<>> s(n);
    printf("%ld\n", s[n].x);
  }
};
 
int main() {
  for(;;) std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

Measured memory_bytes: 1024
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	xs <- replicateM 5 readInt
	k <- readInt
	let
		a = head xs
		e = last xs
	putStrLn $ which "Yay!" ":(" $ e - a <= k

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

ll f(ll a, ll b){
    string s=to_string(a),t=to_string(b);
    ll na=s.size(),nb=t.size();
    return max(na,nb);
}

int main(void)
{
    ll a,b,c,x,y,ans=0;
    cin>>a>>b>>c>>x>>y;
    ans += min(x,y)*min(a+b,2*c);
    if(x>=y){
        x-=y;
        ans += min(x*a,2*c*x);
    }else{
        y-=x;
        ans += min(y*b,2*c*y);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N, l, r;
  cin >> N;
  
  int S=0; //合計人数
  for (int i=0; i<N; i++) {
    cin >> l >> r;
    S += (r-l+1);
  }
  cout << S << endl;
}


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


int main() {
	int n,k,q;
    cin>>n>>k>>q;
    vector<int> tr(q);
    vector<int> a(n);
    
    rep(i,n){
        a[i]=0;
    }
    rep(i,q){
        cin>>tr[i];
        a[tr[i]-1]++;
    }
	
    rep(i,n){
        //cout<<a[i];
        if(a[i]>q-k)  cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    
}


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

int main(){
  string S;
  cin >> S;
  if(((S[0]==S[1])&&(S[2]==S[3])&&(!(S[0]==S[2])))||
     ((S[0]==S[2])&&(S[1]==S[3])&&(!(S[0]==S[1])))||
     ((S[0]==S[3])&&(S[1]==S[2])&&(!(S[0]==S[1])))) 
 
  {
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  return 0;
}

    

Measured memory_bytes: 256
#include<iostream>
#include<stack>
using namespace std;
int main()
{
	stack < int > s;
	int n;
	while (cin>>n){
		if (n == 0){
			int c = s.top();
			cout << c << endl;
			s.pop();
		}
		else{
			s.push(n);
		}
	}
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

int main(){
    int n; cin>>n;
    bool dp[110]; rep(i,110) dp[i]=0;
    dp[0]=dp[4]=dp[7]=1;
    for(int i=1;i<110;i++){
        if(i>=4) dp[i]=(dp[i]||dp[i-4]);
        if(i>=7) dp[i]=(dp[i]||dp[i-7]);
        // cout<<dp[i]<<endl;
    }
    cout<<(dp[n]?"Yes":"No")<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main{
    public static void main (String[] args){
        int area=0, len=0;
         
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
         
        area = a*b;
        len = a*2+b*2;
         
        System.out.println(area+" "+len);
    }
}

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

int main() {
  int64_t Q, H, S, D;
  cin >> Q >> H >> S >> D;
  int64_t N;
  cin >> N;

  Q *= 4;
  H *= 2;
  int64_t cost = min(Q, H);
  cost = min(S, cost);
  
  int64_t total = 0;
  if( (N/2 * D) < (N/2 * cost * 2) ){
    total = N/2 * D;
    if(N % 2 == 1){
      total += cost;
    }
  }
  else{
    total = N * cost;
  }
  cout << total << 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;

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

  ll n;
  cin >> n;
  vll a(n);
  rep(i, n) {
    cin >> a[i];
  }

  ll money = 1000;
  ll stock = 0;

  ll l = 0, r = 1;
  while (r < n) {
    while (a[r - 1] >= a[r]) {
      r++;
      if (r == n)
        goto end;
    }
    l = r - 1;
    stock = money / a[l];
    money -= a[l] * stock;
    money += a[r] * stock;
    stock = 0;
    r++;
  }
  money += stock * a[n - 1];

end:
  cout << money << endl;

  return 0;
}


Measured memory_bytes: 3648
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
int main()
{
	owo
	ll h,w;
	cin>>h>>w;
	set<pii>st;
	multiset<int>mst;
	for(int i=0;i<w;i++){
		st.insert({i,i}); // {a,b} a=current point,b=starting point
		mst.insert(0); //how many ways are there to reach destination with x moves?
	}
	for(int i=0;i<h;i++){
		int l,r;
		cin>>l>>r;
		l--;r--;
		auto it = st.lower_bound({l,-1});
		int mx=-1;	
		while(it != st.end() && it->fi <= r){
			mx = max(mx,it->se);
			mst.erase(mst.find(it->fi-it->se));
			st.erase(it);
			it = st.lower_bound({l,-1});
		}
		if(mx != -1 && r+1<w){   // mx is our starting point
			st.insert({r+1,mx});
			mst.insert({r+1-mx});
		}
		if(mst.empty())cout<<-1<<'\n';
		else cout<<*mst.begin()+i+1<<'\n';
	}
		
}



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


int main()
{
	string s;
	set<char>S;
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		S.insert(s[i]);
	}
	if(S.size()==s.length())cout<<"yes"<<endl;
	else cout<<"no"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i, N) for (int i = 0; i < N; ++i)
typedef long long int LL;

LL N, K, x[51], y[51];
LL ans = LLONG_MAX;

int main()
{
	in >> N >> K;
	rep(i, N) { in >> x[i] >> y[i]; }

	rep(i, N)
	{
		rep(j, N)
		{
			rep(k, N)
			{
				rep(l, N)
				{
					LL min_x = std::min({ x[i],x[j],x[k],x[l] });
					LL min_y = std::min({ y[i],y[j],y[k],y[l] });
					LL max_x = std::max({ x[i],x[j],x[k],x[l] });
					LL max_y = std::max({ y[i],y[j],y[k],y[l] });
					LL cou = 0;
					rep(m, N)
					{
						if (min_x <= x[m] && min_y <= y[m] && x[m] <= max_x && y[m] <= max_y) { ++cou; }
					}
					if (cou == K) { ans = std::min(ans, (max_x - min_x)*(max_y - min_y)); }
				}
			}
		}
	}

	out << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void) {
    string S;
    cin >> S;
    if(S == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
    return 0;
}


Measured memory_bytes: 3596
n,m=map(int,input().split())
a=[0]+list(map(int,input().split()))
a[0]%=m
for i in range(1,n+1):
	a[i]+=a[i-1]
	a[i]%=m
a.sort()
p=0
s=0
for i in range(1,n+1):
	if a[i]-a[p]:
		l=a[i]
		p=i-p
		s+=p*(p-1)
		p=i
p=n-p
s+=p*(p+1)
print(int(s/2))

Measured memory_bytes: 14252
#include <iostream>
#include <algorithm>
#include <string>
#include <set>

#include <regex>
#include <locale>
#include <iomanip>

using namespace std;
using ll = long long;

#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##_Len=int(b);i<i##_Len;++i)
#define rep(...) OVERLOAD3(__VA_ARGS__,REPI,REP,)(__VA_ARGS__)
#define ALL(x) (x).begin(),(x).end()

int main () {
  string s;
  cin >> s;
  cout << (s.find("9") != string::npos ? "Yes" : "No") << endl;
}

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

using namespace std;
int main() {
  string s; 
  int n;
  unordered_map <string, int> m;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> s;
    m[s] ++;
  }
  string z[4] = {"AC", "WA", "TLE", "RE"};
  for (int i = 0; i < 4; ++i) {
    cout << z[i] << " x " << m[z[i]] << endl; 
  }
  return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

#define pb push_back

int X,Y,N;
int b[100], k[100];
int c[10][10], f[10][10], ans[10][10];
int cnt;

vector<int> bx[101],by[101];

bool isputs(int x, int y, int n, int a, int b)
{
	if(x+bx[a][b] > X || y+by[a][b] > Y) return false;

	for(int i=y; i<y+by[a][b]; i++)
	for(int j=x; j<x+bx[a][b]; j++)
	{
		if(c[j][i]!=0 && c[j][i]!=n) return false;
		if(f[j][i]!=0) return false;

		f[j][i]=n;
	}
	
	return true;
}

void dfs(int n)
{
	if(cnt>=2) return;
	
	if(n==N) 
	{
		cnt++;
		memcpy(ans, f, sizeof(ans));
		return;
	}

	int p=b[n], a=k[n];
	int t[10][10];
	memcpy(t,f,sizeof(t));

	for(int i=0; i<Y; i++)
	for(int j=0; j<X; j++)
	{
		if(f[j][i]!=0) continue;
		for(int l=0; l<bx[a].size(); l++)	
		{	
			if(isputs(j,i,p,a,l)) dfs(n+1);

			memcpy(f,t,sizeof(f));
		}
	}
}

int main()
{
	for(int x=1; x<=10; x++)
	for(int y=1; y<=10; y++)
	{
		int n=x*y;
		bx[n].pb(x);
		by[n].pb(y);
	}

	while(cin >> X >> Y >> N, (X||Y||N))
	{
		vector<pair<int,int> > data;

		cnt=0;
		for(int i=0; i<N; i++)
		{
			cin >> b[i] >> k[i];
			data.push_back(make_pair(k[i],b[i]));
		}

		sort(data.begin(), data.end(), greater<pair<int,int> >());
		for(int i=0; i<N; i++)
		{
			b[i]=data[i].second;
			k[i]=data[i].first;
		}
	

	
		for(int i=0; i<Y; i++)
		for(int j=0; j<X; j++)
			cin >> c[j][i];

		memset(f,0,sizeof(f));
		
		dfs(0);
		if(cnt == 1)
		{
			for(int i=0; i<Y; i++)
			{
				for(int j=0; j<X; j++)
					cout << ans[j][i] << (j==X-1?"":" ");
				cout << endl;
			}
		}
		else cout << "NA" << endl;
	}
		
}

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

typedef pair <int, int> ii;

const int Maxn = 200005;

int n;
ii p[Maxn];

bool Less(const ii &a, const ii &b)
{
    if (a.second != b.second) return a.second < b.second;
    return a.first < b.first;
}

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d %d", &p[i].first, &p[i].second);
    sort(p, p + n, Less);
    int cur = 0;
    for (int i = 0; i < n; i++) {
        cur += p[i].first;
        if (cur > p[i].second) { printf("No\n"); return 0; }
    }
    printf("Yes\n");
    return 0;
}


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

int main() {
	int q;cin>>q;
//	long long a[q],b[q];
	long long a,b;
	for(int i = 1; i <= q; i++)
	{
		cin >> a >> b;
		long long ans;
		long long pr = a * b;
		long long t = sqrt(pr);
		if(t * (t + 1) < pr)
			ans = t * 2 - 1;
		else if(t * t == pr)
		{
			if(a == b)
				ans = (t - 1) * 2;
			else
				ans = (t - 1) * 2 - 1;
		}
		else
			ans = (t - 1) * 2;
		cout << ans << endl;
	}
//	for(int i=0;i<q;i++){
//		cin>>a[i]>>b[i];
//	}
//
//	for(int i=0;i<q;i++){
//		long long ans=0;
//		long long s=a[i]*b[i];
//		long long max=b[i];
//		long long min=a[i];
//		if(a[i]>b[i]){
//			max=a[i];
//			min=b[i];
//		}
//		ans=2*(min-1);
//		long long k=sqrt(s);
//		if(k*k==s){
//			ans=2*(k-1)-1;
//		}else{
//			if(k*(k+1)<s){
//				ans=2*k-1;
//			}else{
//				ans=2*k-2;
//			}
//		}
//		if(k==min){
//			ans=2*(min-1);
//		}
//		cout<<ans<<endl;
//
//	}
	return 0;
}


Measured memory_bytes: 256
def solve():
    hm = {}
    for i in a:
        if not str(i) in hm:
            hm[str(i)] = 1
    print(n - len(hm))
    return



n, k = [int(s) for s in input().split(" ")]
d = []
a = []
for i in range(k):
    d.append(int(input()))
    a.extend([int(s) for s in input().split(" ")])
solve()


Measured memory_bytes: 67964
main(z,a,b,c,X,Y,A,f,i,j){for(;scanf("%d%d%d",&a,&b,&c),a;printf("%d %d\n",X,Y))
for(A=99999999,f=i=0;!f;i++)
	for(j=0;j<=i;j++)
		if(z=a*j-b*(i-j),a*j+b*(i-j)==c||z==c||z==-c)
			if(f=1,A>a*j+b*(i-j))A=a*j+b*(i-j),X=j,Y=i-j;
exit(0);}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
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;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        // cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    cin >> a >> b;
    set<int> d, cd;
    FORE(x, a) d.insert(x);
    FORE(x, b) cd.insert(x);
    if (SZ(d) == SZ(cd)) {
        // fは全単射
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
        vector<int> ans1, ans2;
        REP(i, n) {
            if (!CONTAIN(cd, a[i])) {
                ans1.push_back(1);
                ans2.push_back(2);
            } else {
                ans1.push_back(b[i]);
                ans2.push_back(b[i]);
            }
        }
        cout << ans1 << endl;
        cout << ans2 << endl;
    }
    return 0;
}




Measured memory_bytes: 14124
#include<stdio.h>
#define MAX 100

void inputData(int *R, int *N)
{
	scanf("%d", N);
	for (int i = 0; i < *N; i++)
	{
		scanf("%d", &R[i]);
	}
}

void traceData(int *R, int N)
{
	int i;
	for (i = 0; i < (N - 1); i++)
	{
		printf("%d ", R[i]);
	}
	printf("%d\n", R[i]);
}

int bubbleSort(int *R, int N)
{
	int isSwapping = 1;
	int swappingCount = 0;

	while (isSwapping)
	{
		int j = 1;
		isSwapping = 0;
		for (int i = N - 1; i >= j; i--)
		{
			if (R[i - 1] > R[i])
			{
				int temp = R[i];
				R[i] = R[i - 1];
				R[i - 1] = temp;
				isSwapping = 1;
				swappingCount++;
			}
		}
		j++;

	}
	return swappingCount;
}

int main(void)
{
	int R[MAX], N;
	inputData(R, &N);
	int t = bubbleSort(R, N);
	traceData(R, N);
	printf("%d\n", t);
	return 0;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

void solve() {
  int N, K;
  cin >> N >> K;
  vector<int> H(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  vector<int> dp(N, INF);
  dp[0] = 0;
  for (int i = 1; i < N; i++) {
    for (int j = 1; j <= min(i, K); j++) {
      dp[i] = min(dp[i], dp[i - j] + abs(H[i - j] - H[i]));
    }
  }
  cout << dp[N - 1] << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cout << fixed << setprecision(12);

  solve();

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
using namespace std;

long long sum_plus(string s) {
    long long ans = 0;
    char* endptr;
    ans+= strtoll(s.c_str(), &endptr, 10);
 
    for (int i = 1; i < s.size(); i++) {
        string left = s.substr(0, i);     
        ans += strtoll(left.c_str(), &endptr,10)*(pow(2,(s.size()-i-1))) + sum_plus(s.substr(i));
    }
    return ans;
}
int main() {
    string s;
    cin >> s;
    cout << sum_plus(s) << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define lint long long int
#define rep(i,n) for(int i=0;i<int(n);i++)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define fill(a,x) fill(a.begin(),a.end(),x)
#define pb push_back
#define AlphabetNUM 26
#define vint vector<int>
using namespace std;

template<typename T>istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename T>T gcd( T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<typename T>bool chmax(T& a,T b){if(a<b){a=b;return true;}else{return false;}}
template<typename T>bool chmin(T& a,T b){if(a>b){a=b;return false;}else{return true;}}
template<typename T>T lcm(T a, T b){return a * b / gcd(a, b);}
template<typename T>void out(T data){cout<<data<<endl;}

int main(){
  lint n,w;
  cin>>n>>w;
  lint wei[n];
  lint val[n];
  rep(i,n)cin>>val[i]>>wei[i];
  lint dp[n+1][w+1];
  memset(dp,0,sizeof(dp));
  rep(i,n){
    rep(j,w+1){
      dp[i+1][j]=dp[i][j];
      if(j-wei[i]>=0){
        dp[i+1][j]=max(dp[i][j],dp[i][j-wei[i]]+val[i]);
      }
    }
  }
  out(dp[n][w]);
  return 0;
}


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

int main() {
    string s;
    cin >> s;
    int n=s.size();
    int a,z;
    for (int i=0;i<n;i++) {
        if (s[i]=='A') {
            a=i;
            break;
        }
    }
    for (int i=n-1;i>=0;i--) {
        if (s[i]=='Z') {
            z=i;
            break;
        }
    }
    cout << z-a+1 << endl;
}

Measured memory_bytes: 640