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

#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) REP(i, 0, n)
#define ALL(r) (r).begin(), (r).end()

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

const long long INF = 1LL << 60;

void Main();

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

void Main() {
    int n;
    long long h[100100];
    long long dp[100100];

    cin >> n;
    rep(i, n) cin >> h[i];
    rep(i, n) dp[i] = INF;
    dp[0] = 0;

    rep(i, n) {
        if (i-1 >= 0) chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        if (i-2 >= 0) chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }

    cout << dp[n-1] << endl;
}


Measured memory_bytes: 5160
n = int(input())
divs = [1] * (n+1)
for i in range(2,n+1):
    if divs[i] != 1:continue
    for x in range(n//i,0,-1):
        cnt = 1
        while x * i**cnt < n+1:
            ind = x * (i ** cnt)
            divs[ind] = divs[x]*(cnt+1)
            cnt += 1
xs = divs[1:]
ans = 0
for i,x in enumerate(xs):
    ans += (i+1)*x
print(ans)

Measured memory_bytes: 224988
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll  = long long;
using ii  = pair<int, int>;
using vi  = vector<int>;
using vd  = vector<double>;
using vb  = vector<bool>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

long long n;
vector<long long> a;

long long solve(int x);

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        a.push_back(x);
    }
    cout << min(solve(0), solve(1)) << endl;
    return 0;
}

long long solve(int x) {
    long long ans = 0, now = 0;
    for (long long i = 0; i < n; ++i) {
        now += a[i];
        if ((i % 2 ^ x) && (now >= 0)) {
            ans += now + 1;
            now = -1;
        }
        if (!(i % 2 ^ x) && (now <= 0)) {
            ans -= now - 1;
            now = 1;
        }
    }
    return ans;
}

Measured memory_bytes: 1400
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
    string S;
    cin >> S;
    int count = 0;
    for(int i = 0; i < 3; i++) {
        if(S[i] == 'R')
        count++;
    }
    if(count == 2 && S[1] != 'R') {
        count--;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3620
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } bool DEBUG = 0;
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //
void solve(){
    int n = scan!int;
    int[] ts = scan!int(n);
    int[] vs = scan!int(n);

    int[] hs = new int[](ts.sum * 2 + 1);
    hs.fill(200);

    int tsum = 0;
    foreach(int i; 0 .. n){
        int t = ts[i] * 2, v = vs[i] * 2;
        foreach(int k; 0 .. hs.length.to!int){
            if(k < tsum) hs[k].lowerTo(v + tsum - k);
            else if(k < tsum + t) hs[k].lowerTo(v);
            else hs[k].lowerTo(v + k - tsum - t);
        }
        tsum += t;
    }
    foreach(int k; 0 .. hs.length.to!int){
        hs[k].lowerTo(k);
        hs[k].lowerTo(tsum - k);
    }
    log("hs:", hs);
    log("hs:", iota(ts.sum + 1).map!(i => hs[i * 2] / 2).array);

    real ans = 0.0;
    foreach(k; 0 .. hs.length - 1){
        ans += (hs[k].to!real + hs[k + 1].to!real) / 8.0;
    }
    writefln("%10.6f", ans);

}

Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    string S;
    cin >> S;
    string ans="Yes";
    int E=max(C,D);
    for(int i=A-1;i<E-1;i++){
        if(S.at(i)=='#' && S.at(i+1)=='#'){
            ans="No";
        }
    }
    bool z=true;
    for(int i=B-1;i<D-1;i++){
        if(S.at(i)=='.' && S.at(i+1)=='.' && S.at(i-1)=='.'){
            z=false;
        }
    }
    if(z){
        if(E>D){
            if(S.at(D-2)=='#' || S.at(D)=='#'){
                ans="No";
            }
        }
        
    }
    cout << ans << endl;




}


Measured memory_bytes: 592
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>

using namespace std;

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


const int LIT = 1e9 + 7;
int n, m;
char arr[1001][1001];
int bfs_visited[1001][1001];

struct pos
{
    int x;
    int y;
    int cnt;
    bool operator<(pos a) const {
        return cnt > a.cnt;
    }
};

void solve() {
    int h, w;
    pair<int, int> start, end;
    cin >> h >> w >> start.first >> start.second >> end.first >> end.second;

    for (int i = 1; i <= h; i++) {
        string x;
        cin >> x;
        for (int j = 1; j <= w; j++) {
            arr[i][j] = x[j - 1];
            bfs_visited[i][j] = LIT;
        }
    }

    priority_queue<pos> q;
    q.push({ start.second, start.first, 0 });
    bfs_visited[start.first][start.second] = 0;
    while (!q.empty()) {
        pos cur = q.top();
        q.pop();


        for (int i = 0; i < 4; i++) {
            int nx = cur.x + dx[i];
            int ny = cur.y + dy[i];

            if (nx < 1 || ny < 1 || nx > w || ny > h || arr[ny][nx] == '#') continue;
            if (bfs_visited[ny][nx] > bfs_visited[cur.y][cur.x]) {
                bfs_visited[ny][nx] = bfs_visited[cur.y][cur.x];
                q.push({ nx ,ny ,cur.cnt});
            }
        }

        for (int j = -2; j <= 2; j++) {
            for (int i = -2; i <= 2; i++) {
                if (i == 0 && j == 0) continue;
                int nx = cur.x + i;
                int ny = cur.y + j;

                if (nx < 1 || ny < 1 || nx > w || ny > h || arr[ny][nx] == '#') continue;
                if (bfs_visited[ny][nx] > bfs_visited[cur.y][cur.x] + 1) {
                    bfs_visited[ny][nx] = bfs_visited[cur.y][cur.x] + 1;
                    q.push({ nx ,ny ,cur.cnt + 1 });
                }
            }
        }

    }

    if(bfs_visited[end.first][end.second] == LIT) cout << -1;
    else cout << bfs_visited[end.first][end.second];
}

int main() {
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 8596
N = int(input())

def main():
    d = {}
    for _ in range(N):
        n = input()
        if not n in d.keys():
            d[n] = 0
        d[n] += 1
    
    ans = sum(map(lambda v: v % 2, d.values()))
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 17888
n = int(input())
s = list('N' + input())
all_e = s.count('E')
all_w = s.count('W')
now_e, now_w = 0, 0
ans = float('inf')
me = ''
for i in s:
    me = i
    if i == 'E':
        now_e += 1
    elif i == 'W':
        now_w += 1
    need = (all_e - now_e) + now_w
    if ans > need:
        ans = need
print(ans)


Measured memory_bytes: 5964
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <map>
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;

int main() {
    cout.setf(ios::fixed, ios::floatfield);
    cout.setf(ios::showpoint);
    cout.precision(12);
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    int X;
    cin >> X;

    int best = 1;
    for (int i = 2; i * i <= X; ++i) {
        int j = i * i;
        while (j <= X) {
            if (j > best) best = j;
            j *= i;
        }
    }

    cout << best << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define vv(T) std::vector<std::vector<T>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

void	putbit(int n)
{
	if (!n)
		return ;
	else
	{
		int b = n % 2; 
		if (b < 0)
			b += 2;
		n -= b;
		putbit(n/-2);
		b ? cout << 1 : cout << 0;
	}

}

int		main(void)
{
	int n;
	cin >> n;
	if (n)
		putbit(n);
	else
		cout << 0;
	cout << endl;
}



Measured memory_bytes: 3640
#include <string>
#include <cstdio>
#include <cstdlib>
char S[9];main(){int q,n,r,i;std::string s;for(scanf("%d",&q);q--;printf("%d\n",r))for(r=0,scanf("%d",&n);n>9;r++)for(sprintf(S,"%d",n),s=S,n=0,i=1;i<s.length();i++)n=std::max(n,atoi(s.substr(0,i).c_str())*atoi(s.substr(i).c_str()));}

Measured memory_bytes: 1076
/************************************************
* Author        :RunningTime
* Created Time  :2017/7/29 20:05:07
* File Name     :B.cpp
 ************************************************/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    int n, ans = 1;
    cin >> n;
    while (ans*2 <= n) ans <<= 1;
    cout << ans << '\n';
    return 0;
}


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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

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

    int n, t; cin >> n >> t;

    vector<int> imos(t + 1, 0);
    for (int i = 0; i < n; i++) {
        int l, r; cin >> l >> r;
        imos[l]++, imos[r]--;
    }

    int ans = imos[0];
    for (int i = 1; i <= t; i++) {
        imos[i] += imos[i - 1];
        ans = max(ans, imos[i]);
    }

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



Measured memory_bytes: 3356
Sd=input()
T=input()
lS=len(Sd)
lT=len(T)
ret =[]
for i in range(lS-lT+1):
  S=list(Sd[:])
  Td='?'*i+T+'?'*(lS-lT-i)
  for j in range(lS):
    if Sd[j]=='?' and Td[j]=='?':
      S[j]='a'
    elif Sd[j]=='?' and Td[j]!='?':
      S[j]=Td[j]
    elif Sd[j]!='?' and Td[j]=='?':
      continue
    elif Sd[j]!='?' and Td[j]!='?':
      if Sd[j]!=Td[j]:
        S[j]='X'
        break
      else:
        continue
  if not 'X' in S:
    ret.append(''.join(S))
if len(ret)==0:
  print('UNRESTORABLE')
else:
  ret.sort()
  print(ret[0])

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

struct UnionFind{
	int size;
	vector<int> par,rank;
	void Init(int n){
		size=n;
		par.assign(n,0);
		rank.assign(n,0);
		REP(i,0,n) par[i]=i;
	}
	int Find(int x){
		if(par[x]==x) return x;
		return par[x]=Find(par[x]);
	}
	bool Unite(int x,int y){
		x=Find(x); y=Find(y);
		if(x==y) return false;
		if(rank[x]<rank[y]){
			par[x]=y;
		}else{
			par[y]=x;
			if(rank[x]==rank[y]) ++rank[x];
		}
		--size;
		return true;
	}
};

struct Edge{
	int u,v,w;
};

bool Comp(const Edge &e1,const Edge &e2){
	return e1.w<e2.w;
}

void Solve(){
	while(true){
		int n,m;
		cin >> n >> m;
		if(n==0&&m==0) break;
		
		vector<Edge> edges(m);
		REP(i,0,m){
			int a,b,w;
			cin >> a >> b >> w;
			--a; --b;
			//edges.push_back(Edge{a,b,w});
			edges[i]={a,b,w};
		}
		
		sort(edges.begin(),edges.end(),Comp);
		int ans=INF;
		REP(i,0,m){
			UnionFind uf; uf.Init(n);
			int maxi=0;
			REP(j,i,m){
				Edge &e=edges[j];
				if(uf.Unite(e.u,e.v)) maxi=max(maxi,e.w);
			}
			if(uf.size==1) ans=min(ans,maxi-edges[i].w);
		}
		if(ans==INF) ans=-1;
		cout << ans << endl;
	}
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	Solve();
	return 0;
}

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

using namespace std;
//using Graph = vector<vector<int>>;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<string, int> P;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define REP(i,n)  for(int i=0; i<(n); i++)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
/*int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}*/
int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}
LL sum(LL a, LL b){
    LL cnt=0;
    cnt=(b-a+1)*(a+b)/2;
    return cnt;
}
/*LL yaku(int x){
    vector<pair<LL, LL> a=[];
    LL xh;
    if(x==1){
        pair<LL, LL> tmp;
        tmp=MP(1,1);
        return tmp;
    }
    else{
        FOR(i, 1, x/2+1){
            if(x%i==0){
                a.append(MP(i,x/i));
            }
        }
    }
    return a;

}*/
LL cul(int a, int b){
    LL f = pow(a,4)+pow(a,3)*b+pow(a,2)*pow(b,2)+a*pow(b,3)+pow(b,4);
    return f;
} 
int main(){
   double r;
   cin >> r;
   double m = r*r*PI; 
   double l = 2.0*r*PI;
   printf("%f %f",m,l);
}


    





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

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<long long> a(n),b(n);
	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i];
	}
	
	long long p=0;
	
	for(int i=n-1;i>=0;i--){
		a[i]+=p;
		if(a[i]%b[i]==0)continue;
		if(a[i]<b[i]){
			p+=b[i]-a[i];
		}else if(a[i]>b[i]){
			p+=b[i]-a[i]%b[i];
		}
	}
	
	cout << p << endl;	
		
	return 0;
}


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

int a,b,c;
set<int> st;

int main(){
    cin >> a >> b >> c;
    int t = a % b;
    if(t == c){
        cout << "YES\n";
        return 0;
    }
    st.insert(t);
    t = (t + a) % b;
    while(st.count(t) == 0){
        if(t == c){
            cout << "YES\n";
            return 0;
        }
        t = (t + a) % b;
    }
    cout << "NO\n";

    return 0;
}


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


void solve(long long a, long long b, long long c, long long d, long long e, long long k){
    bool flag = true;
    if (e-a > k) flag = false;
    if (flag) {
        cout << "Yay!" << endl;
    }
    else
    {
        cout << ":(" << endl;
    }
    
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long c;
    scanf("%lld",&c);
    long long d;
    scanf("%lld",&d);
    long long e;
    scanf("%lld",&e);
    long long k;
    scanf("%lld",&k);
    solve(a, b, c, d, e, k);
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PI;
const LL N=200005;
LL n;
LL a[N],b[N];
LL ans=0,sum=0;
PI c[N];
LL tot;
bool cmp (PI x,PI y)	{return x.first>y.first;}
bool in[N];
int main()
{
	scanf("%lld",&n);
	for (LL u=1;u<=n;u++) 
	{
		scanf("%lld%lld",&a[u],&b[u]);
		ans=ans+a[u]+b[u];sum=sum+a[u];
		c[++tot]={a[u],u};c[++tot]={b[u],u};
	}
	sort(c+1,c+1+tot,cmp);
	LL mx=0;
	mx=max(sum,ans-sum);sum=0;
	bool tf=false;
	memset(in,false,sizeof(in));
	for (LL u=1;u<=n;u++)
	{
		if (in[c[u].second]) tf=true;
		sum=sum+c[u].first;
		in[c[u].second]=true;
	}
	if (tf) mx=max(mx,sum);
	else
	{
		for (LL i=n+1;i<=tot;i++)
		{
			if (c[i].second!=c[n].second) mx=max(mx,sum+c[i].first-c[n].first);
			else mx=max(mx,sum+c[i].first-c[n-1].first);
		}
	}
	printf("%lld\n",ans-mx);
	return 0;
}

Measured memory_bytes: 6400
import java.util.*;

public class Main {

    static int DAT_SIZE = (1<<24)-1;

    static long[] data = new long[DAT_SIZE];
    static long[] datb = new long[DAT_SIZE];

    static void add(int a, int b, long x, int k, int l, int r) {
        if (a<=l && r<=b) {
            data[k] += x;
        } else if (l<b && a<r) {
            datb[k] += (Math.min(b, r) - Math.max(a, l))*x;
            add(a, b, x, k*2+1, l, (l+r)/2);
            add(a, b, x, k*2+2, (l+r)/2, r);
        }
    }

    static long sum(int a, int b, int k, int l, int r) {
        if (b<=l || r<=a) {
            return 0;
        } else if (a<=l && r<=b) {
            return data[k]*(r-l)+datb[k];
        } else {
            long res = (Math.min(b, r) - Math.max(a, l)) * data[k];
            res += sum(a, b, k*2+1, l, (l+r)/2);
            res += sum(a, b, k*2+2, (l+r)/2, r);
            return res;
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int D = Integer.parseInt(sc.next());
        int A = Integer.parseInt(sc.next());
        ArrayList<long[]> list = new ArrayList<long[]>();
        for (int i=0;i<N;i++) {
            long X = Long.parseLong(sc.next());
            long H = Integer.parseInt(sc.next());
            long[] add = {X, (H+A-1)/A};
            list.add(add);
        }
        Collections.sort(list, (o1, o2)->Long.compare(o1[0], o2[0]));
        for (int i=0;i<N;i++) {
            add(i, i+1, list.get(i)[1], 0, 0, N);
        }
        long ans = 0;
        for (int i=0;i<N;i++) {
            long[] obj = {list.get(i)[0]+2*D+1, 0L};
            int index = ~Collections.binarySearch(list, obj, (o1, o2)->o1[0]>=o2[0]?1:-1);
            long cnt = sum(i, i+1, 0, 0, N);
            if (cnt<=0) continue;
            add(i, index, -cnt, 0, 0, N);
            ans += cnt;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 350128
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<ctype.h>
#include<algorithm>
typedef long long int ll;
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {X;}
#define TF(f) {f;}
#define END {}
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,a) for (int i=1;i<=(a);i++)
const ll MOD = (10*10*10*10*10*10*10*10*10+7);

    string A,B,C;
    int N,M,K,X,Y,W,H;
    int ans;
    string S;
    int temp[100]={0};
    bool f=true;
    bool fir=true;

int main(){
    cin>>N;
    N<1200?cout<<"ABC":cout<<"ARC";

}
/*A.size()!=0&&B.size()!=0&&C.size()!=0*/


Measured memory_bytes: 256
function main(input){
  input = input.trim();
  let list = input.split("");
  let sum = 0;
  let answer = "";
  for(let i=0; i<list.length; i++){
    sum += parseInt(list[i]);
  }
  if(sum%9===0){
    answer = "Yes";
  }else{
    answer = "No";
  }
  console.log(answer);
}
 main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 34616
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    int N, M;
    cin >> N >> M;

    int x = N * (N - 1) / 2;
    int y = M * (M - 1) / 2;

    cout << x + y << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <stack>
#include <cctype>
#include <cmath>

using namespace std;

/* typedef */

typedef long long ll;

/* class */
class Info {
public:
    int x, y;
    Info() {};
    Info(int arg_x, int arg_y) : x(arg_x), y(arg_y) {};

    bool operator<(const Info &I) const{
        if (x != I.x) {
            return x < I.x;
        } else {
            return y < I.y;
        }
    }
};

/* constant */

const int INF = 1 << 30;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */

/* function */
/* main */
// Not using pair 
// Use class
int main() {

    int n; cin >> n;
    vector<Info> I(n);
    int x, y;
    for (int i = 0; i < n; i++) {
        cin >> x >> y;
        I[i] = Info(x, y);
    }
    
    sort(I.begin(), I.end());

    for (int i = 0; i < n; i++)
        cout << I[i].x << ' ' << I[i].y << '\n';

}
/* 
// Using pair
int main() {

    int n; cin >> n;
    vector< pair<int, int> > p(n);
    int x, y;
    for (int i = 0; i < n; i++) {
        cin >> x >> y;
        p[i] = make_pair(x, y);
    }
    
    sort(p.begin(), p.end());

    for (int i = 0; i < n; i++)
        cout << p[i].first << ' ' << p[i].second << '\n';


}
*/



Measured memory_bytes: 3620
#coding:utf-8
#!/usr/bin/python

n,a,b=map(int,raw_input().split())

N=pow(10,9)+7
#n=1000000000
#a=141421
#b=173205

def modpow(b,e,m): 

    result=1

    while(e!=0): 
          if(e&1==1): 
             result=(result*b)%m 
          e>>=1
          b=(b*b)%m
    
    return result

def combination(n,r,N):
    bunshi=1
    for i in range(n-r+1,n+1):
        bunshi=(bunshi*i)%N
    bunbo=1
    for i in range(1,r+1):
        bunbo=(bunbo*i)%N
    return bunshi*modpow(bunbo,N-2,N)

#pow(2,n)-nCa-nCb-1
#nCr=n!/((n-r)!*r!)だから
#bunshi=n*n-1*・・・*n-r+1
#bunbo=1*・・・*r
#Nが素数だから、フェルマーの小定理より
#modpow(a,N-1,N)=1
#a*pow(a,N-2)=pow(a,N-1)=1(modN)
#より。aのmodNでの逆元はpow(a,N-2)になる。
#r!の逆元が欲しいから、modpow(bunbo,N-2,N)を掛ける。

print (modpow(2,n,N)-combination(n,a,N)-combination(n,b,N)-1)%N

Measured memory_bytes: 9348
#include<bits/stdc++.h>
#define up(j,k,i) for(i=j;i<k;i++)
#define down(j,k,i) for(i=j;i>k;i--)
#define pp(n) printf("%lld\n",n)
#define ps(s) printf("%s",s)
#define is(n) scanf("%lld",&n)
#define ips(n) scanf("%lld",n)
#define ss(s) scanf("%s",s)
#define cool 0
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define f(i) cout<<i<<endl;
#define pll pair<lld,lld> 
#define pi acos(-1)
#ifdef G
#define dg(x) cout<<#x<<' '<<x<<endl;
#define dg2(x,y) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<endl;
#define dg3(x,y,z) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<endl;
#define dg4(x,y,z,zz) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<' '<<#zz<<' '<<zz<<endl;
#else
#define dg(x) ;
#define dg2(x,y) ;
#define dg3(x,y,z) ;
#define dg4(x,y,z,zz) ;
#endif
#define ds(n,m) scanf("%lld %lld",&n,&m)
#define ts(n,m,k) scanf("%lld %lld %lld",&n,&m,&k)
#define yes printf("YES\n")
#define no printf("NO\n")
typedef long double ld;
typedef long long int lld;
using namespace std;
const lld M =1e4+7;
const lld mod=1e9+7;
const lld infi =LLONG_MAX;
lld ans,k,n,x,y,m,mymax=LLONG_MIN,mymin=LLONG_MAX,b,c,z,sum;
lld a[M];
lld cal(lld node)
{
  lld i;
  lld cnt=0;
  up(1,n+1,i)
  {
    cnt+=abs(node-a[i]);
  }
  return cnt;
}
int main()
{
      lld i,j;
        is(n);
        up(1,n+1,i)is(a[i]);
        sort(a+1,a+1+n);
        up(2,n+1,i)
        {
          ans+=(a[i]-a[i-1]);
        }
        pp(ans);
        return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	int N, M; cin >> N >> M;
	int A[1010] = {};
	rep(i, 1, N + 1)cin >> A[i];
	rep(k, 1, M + 1) rep(i, 1, N) if (A[i] % k > A[i + 1] % k)swap(A[i], A[i + 1]);
	rep(i, 1, N + 1)cout << A[i] << endl;;
	return 0;
}

Measured memory_bytes: 3052
#include <iostream>

using namespace std;
const int maxn =  2e5 +10;
int n, f[maxn];
int ans[3];
char s[maxn];
int l[4][maxn];
int _cnt(int x){
    int rec = 0;
    while(x > 0){
        if(x & 1) rec ++;
        x >>= 1;
    }
    return rec;
}
int main(){
    cin >> n >> s;
    l[0][0] = l[1][0] = l[2][0] = 1;
    f[0] = 0;
    for(int i = 1; i < maxn; ++i){
        f[i] = f[i % _cnt(i)] + 1;
    }
    //for(int i = 1; i < 10; ++i) cout << f[i] << endl;
    int cnt1 = 0;
    for(int i = n - 1; i >= 0; --i){
        if(s[i] == '1') cnt1++;
    }
    if(cnt1 == 0){
        l[0][0] = l[1][0] = l[2][0] = 0;
    }
    if(cnt1 == 1){
        l[0][0] = l[1][0] = 0;
    }
    if(cnt1 == 2){
        l[0][0] = 0;
    }
    for(int i = 1; i <= n; ++i){
        if(cnt1 > 1)
            l[0][i] = (l[0][i - 1] << 1) % (cnt1 - 1);
        if(cnt1 > 0)
            l[1][i] = (l[1][i - 1] << 1) % (cnt1);
        l[2][i] = (l[2][i - 1] << 1) % (cnt1 + 1);
    }
    for(int i = 0; i < n ; ++i){
        if(s[i] == '0') continue;
        if(cnt1 > 1){
            ans[0] += l[0][n - 1 - i];
            ans[0] %= (cnt1 - 1);
        }
        if(cnt1 > 0){
            ans[1] += l[1][n - 1 - i];
            ans[1] %= cnt1;
        }
        ans[2] += l[2][n - 1 - i];
        ans[2] %= (cnt1 + 1);
    }
    for(int i = 0; i < n; ++i){
        if(s[i] == '1'){
            if(cnt1 == 1){
                cout << "0\n";
                continue;
            }
            int x = ans[0];
            int p = ((x - l[0][n - 1 - i]) % (cnt1 - 1) + cnt1 - 1) % (cnt1 - 1);
            //cout << p << "\n";
            cout << f[p] + 1 << "\n";
        }
        if(s[i] == '0'){
            int x = ans[2];
            int p = ((x + l[2][n - 1 - i]) % (cnt1 + 1) + cnt1 + 1) % (cnt1 + 1);
            //cout << p << "\n";
            cout << f[p] + 1 << "\n";
        }
    }
}


Measured memory_bytes: 6900
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {

	int a,b=0;
	int p[101];

	cin >> a;
	for (int i = 0; i < 101; i++) {
		if (i < a) {
			cin >> p[i];
		}
		else
		{
			p[i] = 0;
		}
	}
	sort(p, p+101);
	for (int i = 101; i > 0;i--) {
		if (p[i] > p[i - 1]) {
			b++;
			//cout << p[i] << endl;
		}
		
	}

	cout << b;

	return 0;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a=1,b=1,c=0;
	for(int j=0;j<9;j++){
		for(int i=0;i<9;i++){
			c=a*b;
			cout<<a<<'x'<<b<<"="<<c<<endl;
			b++;
		}
		b=1;
		a++;
	}

	return 0;
}


Measured memory_bytes: 3084
n = int(input())
moji = "abcdefghijklmnopqrstuvwxyz"
#print(len(moji))

lis = [[0]]
for i in range(n-1):
  temp = []
  for s in lis:
    next = max(s) + 1
    for j in range(0, next+1):
      temp.append(s + [j])
  else:
    lis = temp
#print(lis)

for s in lis:
  for char in s:
    print(moji[char], end="")
  print()

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

int main(void)
{
    int N;
    ll ans1 = 0,sum = 0,ans2 = 0;
    cin >> N;
    vector<ll> a(N);

    rep(i, N)
        cin >> a[i];

    //偶数番目が生の時
    rep(i,N){
        sum += a[i];

        if(i%2 == 0 && sum <= 0){
            ans1 += abs(sum)+1;
            sum = 1;
        }

        else if(i%2 == 1 && sum >= 0){
            ans1 += abs(sum)+1;
            sum = -1;
        }
    }

    sum = 0;

    rep(i,N){
        sum += a[i];

        if(i%2 == 0 && sum >= 0){
            ans2 += abs(sum)+1;
            sum = -1;
        }

        else if(i%2 == 1 && sum <= 0){
            ans2 += abs(sum)+1;
            sum = 1;
        }
    }

    cout << min(ans1,ans2) << endl;

    
    return 0;
}

Measured memory_bytes: 4032
import java.util.*;



public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int l = scanner.nextInt();
    int r = scanner.nextInt();
    int d = scanner.nextInt();
    int ans = 0;

    for(int i = l; i <= r; i++){
      if(i % d ==0){
        ans++;
      }
    }
    


    System.out.println(ans);
    
    scanner.close();
    return;
  }
  
}


Measured memory_bytes: 35560
#include<stdio.h>
int main(){
    int a,b,c,d,e,f;
    scanf("%d%d%d",&a,&b,&c);
    d=a+b;
    e=b+c;
    f=a+c;

    if(d<=e&&d<=f){
        printf("%d\n",d);
    }
    else if(e<=d&&e<=f){
        printf("%d\n",e);
    }
    else if(f<=d&&f<=e){
        printf("%d\n",f);
    }

    return 0;
}

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

// priceをキーに降順でソート
//sort(fruits.begin(), fruits.end(),
//     [](const fruit& x, const fruit& y) { return x.price > y.price;});

/*
int main() {
    long long int S;
    int r;
    std::cin >> r;
    S= 3*r*r;
    std::cout << S << std::endl;
    return 0;
}
 */

/*
int main(){
    int K, D;
    int ans;
    std::cin >> K >> D;
    ans = (K+2*D)/(2*D+1);
    std::cout << ans << std::endl;
}
 */

int main(){
    int N;
    int max=0;
    int sem_max=0;
    std::cin >> N;
    int A[N];
    for(int i=0; i<N; i++){
        std::cin >> A[i];
    }
    for(int i=0; i<N; i++){
        if(A[i]>max){
            sem_max = max;
            max=A[i];
        }
        else if(A[i]>sem_max){
            sem_max=A[i];
        }
    }
    for(int i=0; i<N; i++){
        if(A[i]==max){
            std::cout << sem_max << std::endl;
        }
        else{
            std::cout << max << std::endl;
        }
    }
    return 0;
}


Measured memory_bytes: 2432
import os

def main():
	n = int(input())
	list_a = make_divisors(n)
	min_num = 1000000000000
	for i in range(0,len(list_a),2):
		if n//list_a[i] == list_a[i]:
			min_num = list_a[i] * 2 - 2
			break
		if min_num < (list_a[i] + list_a[i+1] - 2):
			pass
		else:
			min_num = list_a[i] + list_a[i+1] - 2
	print(min_num)
	
			


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

	
if __name__ == "__main__":
	main()


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

using namespace std;

int ones, twos, zeros, n;
int main(){
	cin >> n;
	for(int i = 0; i<n; i++){	
		int a; cin >> a;
		if(a % 4 == 0) twos++;
		else if(a % 2 == 0) ones++;
		else zeros++;
	}
	if(ones > 0 and zeros > twos) cout << "No";
	else if(zeros > twos+1) cout << "No";
	else cout << "Yes";
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
using namespace std;

const int MAX = 14348907; // 3 ^ 15

int N,M,init;
bool memo[MAX];
vector<int> v[3];

struct state{
  int n,bit;
  state(int n=0, int bit=init):n(n),bit(bit){}
};

int calcBit(int n, int pos){
  return (int)pow(3,(double)pos) * n;
}

int calcN(int bit, int pos){
  return (bit / (int)pow(3,(double)pos)) % 3;
}

void add(int &bit, int pos, int n){
  bit -= calcBit(calcN(bit,pos), pos);
  bit += calcBit(n, pos);
}

void bfs(){
  queue<state> Q;
  state u,v;
  int max[3];
  fill(memo,memo+MAX,false);
  memo[init] = true;
  for(Q.push(u); !Q.empty();){
    u = Q.front();
    Q.pop();

    max[0] = max[1] = max[2] = -1;
    for(int i=N-1;i>=0;i--){
      if(max[calcN(u.bit,i)] == -1) max[calcN(u.bit,i)] = i;
    }

    if(max[1] == -1 && (max[0] == -1 || max[2] == -1)){
      //for(int i=0;i<N;i++) cout << calcN(u.bit,i) << ' ';
      cout << u.n << endl;
      return;
    }
    if(u.n >= M) break;

    if(max[0] > max[1]){
      v = u;
      add(v.bit, max[0], 1);
      v.n++;
      if(!memo[v.bit] ){
	memo[v.bit] = true;
	Q.push(v);
      }
    }
    if(max[1] > max[0]){
      v = u;
      add(v.bit, max[1], 0);
      v.n++;
      if(!memo[v.bit]){
	memo[v.bit] = true;
	Q.push(v);
      }
    }
    if(max[2] > max[1]){
      v = u;
      add(v.bit, max[2], 1);
      v.n++;
      if(!memo[v.bit]){
	memo[v.bit] = true;
	Q.push(v);
      }
    }
    if(max[1] > max[2]){
      v = u;
      add(v.bit, max[1], 2);
      v.n++;
      if(!memo[v.bit]){
	memo[v.bit] = true;
	Q.push(v);
      }
    }
  }
  cout << -1 << endl;
}


int main(){
  while(cin >> N >> M && (N|M)){
    init = 0;
    for(int i=0;i<3;i++){
      int x;
      cin >> x;
      for(int j=0;j<x;j++){
	int c;
	cin >> c;
	c--;
	v[i].push_back(c);
	add(init, c, i);
      }
    }
    bfs();
  }
}

Measured memory_bytes: 15272
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

count = 0
for i in range(N-1, -1, -1):
    if A[i + 1] > 0:
        if A[i + 1] >= B[i]:
            A[i + 1] -= B[i]
            count += B[i]
            B[i] = 0
        else:
            B[i] -= A[i + 1]
            count += A[i + 1]
            A[i + 1] = 0
            

    if A[i] >= B[i]:
        A[i] -= B[i]
        count += B[i]
        B[i] = 0
    else:
        B[i] -= A[i]
        count += A[i]
        A[i] = 0

print(count)


Measured memory_bytes: 19004
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


  
int main(){
  
  int n;
  cin>>n;
  long long a,b;
  vector<pair<long long,long long>> ba;
  REP(i,n){
    cin>>a>>b;
    ba.push_back(make_pair(b,a));
  }
  sort(ba.begin(),ba.end());
  bool flag = true;
  long long time=0;
  REP(i,n){
    time += ba[i].second;
    if(time>ba[i].first){
      flag = false;
      break;
    }
  }
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 6512
#include<iostream>
#include<cstring>
#include<queue>
#include<algorithm>
#include<stack>
using namespace std;
int cy(int a[]){
    int ten=1,cnt=0;
    for(int i=7;i>=0;i--){
        cnt+=a[i]*ten;
        ten*=10;
    }
    return cnt;
}
int ten(int i){
    int cnt=1;
    for(int j=0;j<i;j++)cnt*=10;
    return cnt;
}
void cx(int a){
    stack<int>S;
    for(int i=8;i>0;i--){
        if(i!=8)cout<<" ";
        cout<<(a%ten(i)-a%ten(i-1))/ten(i-1);
    }
    cout<<endl;
    return;
}
int main(){
    int mery[8]={4,1,4,1,2,1,2,1},k[8],push[8];
    while(cin>>k[0]){
        for(int i=1;i<8;i++)cin>>k[i];
        vector<int>V;
        int mini=0;
        for(int i=0;i<8;i++){
            int cnt=0;
            for(int j=0;j<8;j++){
                push[j]=mery[(i+j)%8];
                if(mery[(i+j)%8]<k[j])cnt+=mery[(i+j)%8];
                else cnt+=k[j];
            }

            int x=cy(push);
            if(mini<cnt){
                V.clear();
                V.push_back(x);
                mini=cnt;
            }
            else if(mini==cnt)V.push_back(x);
        }
        sort(V.begin(),V.end());
        cx(V[0]);
    }

}

Measured memory_bytes: 1220
from itertools import permutations

n, m = map(int, input().split())
G = [set() for _ in range(n)]
for _ in range(m):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  G[a].add(b)
  G[b].add(a)
ans = 0
for l in permutations(range(n)):
  if l[0] != 0:
    continue
  for i in range(n-1):
    if l[i+1] not in G[l[i]]:
      break
  else:
    ans += 1
print(ans)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

const int n=20;
int x;
vi u,v,w;

void f(int s,int t,int c){
	u.push_back(s);
	v.push_back(t);
	w.push_back(c);
}

int main(){
	cin>>x;
	int t=1;
	for(int i=1;i<n-1;i++){
		f(i,i+1,0);
		f(i,i+1,t);
		t*=2;
	}
	t=0;
	for(int i=0;i<n-1;i++) if(x&1<<i){
		f(i+1,n,t);
		t+=1<<i;
	}
	if(x&1<<(n-1)){
		f(n-1,n,t);
		f(n-1,n,t+(1<<(n-2)));
	}
	int m=u.size();
	cout<<n<<' '<<m<<endl;
	for(int i=0;i<m;i++) cout<<u[i]<<' '<<v[i]<<' '<<w[i]<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define pi (acos(-1))
#define ull  unsigned long long
#define ld long double
///freopen("input.txt","r",stdin);
///freopen("output.txt","w",stdout);
#define M 100000
ll LCM(ll a, ll b)
{
    ll g = __gcd(a,b);
    return (a*b)/g ;
}
string numtostr(ll n)
{
    ostringstream str1 ;
    str1 << n ;
    return str1.str();
}
ll strtonum(string s)
{
    ll x ;
    stringstream str1(s);
    str1 >> x ;
    return x ;
}
int h1,m1,h2,m2,a;
int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>h1>>m1>>h2>>m2>>a;
    cout<<h2*60+m2-(h1*60+m1)-a<<'\n';
    return 0;
}


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

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> v;

    int cnt = 0;
    for (int i = 0; i < H; i++) {
        string str;
        cin >> str;

        bool flg = false;
        for (auto c : str) {
            if (c == '#') {
                flg = true;
                break;
            }
        }
        if (flg) {
            v.push_back(str);
        }
    }

    vector<vector<char> > v2(v.size());
    for (int i = 0; i < W; i++) {
        bool flg = false;
        for (int j = 0; j < v.size(); j++) {
            if (v[j][i] == '#') {
                flg = true;
                break;
            }
        }
        if (flg) {
            for (int j = 0; j < v.size(); j++) {
                v2[j].push_back(v[j][i]);
            }
        }
    }

    for (auto a : v2) {
        for (auto b : a) {
            cout << b;
        }
        cout << endl;
    }
}

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

ll solve(ll a){
    if(a < 0) return 0;
    
    if(a%2 == 1){
        if(a%4 == 3) return 0;
        else return 1;
    }

    if(a%2 == 0){
        return (solve(a-1) ^ a);
    }

    return 0;
}

int main(void){
    ll A, B; cin >> A >> B;

    cout << (solve(B) ^ solve(A-1)) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
#define endl "\n"
//#define int long long
#define ALL(x) begin(x),end(x)
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return ((fact(i - 1)) * i) % MOD;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された
    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}

/*signed*/int main(void) {   
    string s;
    cin >> s;
    int n;
    cin >> n;
    for (int i = 0; i < s.size(); i = i + n) {
        cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int N;
  cin >> N;
  cout << (N+1)/2 << endl;
  return 0;
}

Measured memory_bytes: 3156