akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

class Dice{
public:
	int f[6];
	Dice(){}
	
	void roll(int x, int y, int z, int w){
		int c=f[x]; f[x]=f[y]; f[y]=f[z]; f[z]=f[w]; f[w]=c;
	}
	void rollE(){roll(0,3,5,2);}
	void rollS(){roll(0,4,5,1);}
	void rooll(){roll(1,2,4,3);}
};
int check(Dice d1, Dice d2){
	for (int i=0; i<4; i++){
		for (int j=0; j<4; j++){
			for (int k=0; k<4; k++){
				if (d1.f[0]==d2.f[0] && d1.f[1]==d2.f[1] && d1.f[2]==d2.f[2] && d1.f[3]==d2.f[3] && d1.f[4]==d2.f[4] && d1.f[5]==d2.f[5]){
					cout << "Yes" << endl;
					return 0;				
				}
				d2.rooll();
			}
			d2.rollS();
		}
		d2.rollE();
	}
	cout << "No" << endl;
	return -1;
}

int main(){
	Dice d1,d2;
	for (int i=0; i<6; i++){
		cin >> d1.f[i];
	}
	for (int i=0; i<6; i++){
		cin >> d2.f[i];
	}	
	check(d1,d2);
	
	return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

const string ky = "keyence";
const int m = ky.size();

void solve() {
  string s;
  cin >> s;
  int n = s.size();
  for (int i = 1; i < n - 1; i++) {
    for (int j = i; j < n; j++) {
      string t = s.substr(0, i);
      string u = s.substr(j);
      if ((t + u) == ky) {
        cout << "YES" << endl;
        return;
      }
    }
  }
  cout << "NO" << endl;
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 3632
import bisect
import numpy as np

N = int(input())
_A = list(map(int, input().split()))
_B = list(map(int, input().split()))
_C = list(map(int, input().split()))

# O(NlogN)
AI = sorted(_A)
BI = sorted(_B)
CI = sorted(_C)

BJ = []

# O(NlogN)
for bi in BI:
    bj = bisect.bisect_left(AI,bi)
    BJ.append(bj)
    
# O(N)
BJ = np.cumsum(BJ)

ans = 0

# O(NlogN)
for ci in CI:
    cj = bisect.bisect_left(BI, ci)
    if cj != 0:
        ans += BJ[cj-1] 

print(ans)

Measured memory_bytes: 32484
n,x = gets.split.map!(&:to_i)
a = gets.split.map!(&:to_i)

ans = 0
pre = a.shift
a.each do |e|
    if pre + e > x then
        c = pre + e - x
        ans += c
        pre = e > c ? e - c : 0
    else
        pre = e
    end
end

puts ans

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

  #define ll long long
  #define int long long
  #define f(i,l,n) for(ll i=l;i<n;i++)
  #define E "\n"
  #define bp __builtin_popcount
  const int M = 1e9+7;

  
  int32_t main()
  {

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

   
    int n;
    cin >> n;
    vector<int> a(n+1,0);
    int sum=0;
    f(i,0,n) cin >> a[i],sum=(sum+a[i])%M;

    int ans=0;

    f(i,0,n-1)
    {
      sum=(sum-a[i]+M)%M;
      ans=(ans+(a[i]*sum)%M)%M;
    }
    cout<<ans;

    return 0;
  }

Measured memory_bytes: 4832
#include <iostream>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;


lli pt(int a, lli f){
  	if(f==0) return 0;
  	if(a==0) return 1;
	if(f<=pow(2, (lli)a+1)-2) return pt(a-1, f-1);
	return pt(a-1, f-pow(2,(lli)a+1)+1)+pow(2,a);
}

int main(){
	int N;
	lli X;
	cin>>N>>X;
	lli ans=pt(N,X);
	cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;

int n,a,b,d;
int h[d5];

bool isOK(int key){
    int cnt=0;
    for(auto it:h){
        cnt+=(max(it-key*b,0LL)+d-1)/d;
    }
    if(cnt>key)return false;
    else return true;
}

int meguru(){
    int low=-1;
    int high=mod;
    while(abs(high-low)>1){
        int mid=(high+low)/2;
        if(isOK(mid))high=mid;
        else low=mid;
    }
    return high;
}
signed main(){
    int n;
    cin>>n>>a>>b;
    d=a-b;
    fill(h,h+n,0);
    for(int i=0;i<n;i++)cin>>h[i];
    int res=meguru();
    cout<<res<<endl;
}

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

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> as(n);
    vector<vector<pair<int, int>>> axys(n);
    for(int i=0; i<n; i++)
    {
        cin >> as.at(i);
        vector<pair<int, int>> xys(as.at(i));
        for(int j=0; j<as.at(i); j++)
        {
            int a, b;
            cin >> a >> b;
            xys.at(j) = make_pair(a-1, b);
        }
        axys.at(i) = xys;
    }

    int ans = 0;
    for(int bit=0; bit < (1<<n); bit++)
    {
        int cnt = 0;
        vector<int> isshos(n, 0);
        for(int i=0; i<n; i++)
        {
            if(bit & (1<<i))
            {
                isshos.at(i) = 1;
                cnt++;
            }
        }
        // for(auto num : isshos) cout << num << ' ';
        // cout << '\n';
        for(int i=0; i<n; i++)
        {
            if(isshos.at(i) == 0) continue;
            for(auto xys : axys.at(i))
            {
                if(isshos.at(xys.first) != xys.second)
                {
                    // cout << i << ": " << xys.first << ", " << xys.second << '\n';
                    cnt = 0;
                }
            }
        }
        chmax(ans, cnt);
    }
    cout << ans << '\n';

    return 0;
}

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

void solve(){
  int n, m, x; cin >> n >> m >> x;
  vector<int> a(m);
  for(int i = 0; i < m; i++) cin >> a[i];
  int ans1 = 0, ans2 = 0;
  for(int i = 0; i < m; i++){
    if(a[i] < x) ans1++;
    else ans2++;
  }
  cout << min(ans1, ans2) << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define REP(i, n) for(int i=0; i<n; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll mod = 1e9+7;

struct edge{
    int to;
    int cost;
};
using graph = vector<vector<edge>>;

int main(){
    int n; cin >> n;
    vector<ll> h(n);
    REP(i, n){
        cin >> h[i];
    }
    int cur_height = h[0];
    int ans = 0;
    int tmp_ans = 0;
    for(int i=1; i<n; i++){
        if(h[i]<=cur_height){
            tmp_ans += 1;
        }else{
            ans = max(ans, tmp_ans);
            tmp_ans = 0;
        }
        cur_height = h[i];
    }
    ans = max(ans, tmp_ans);
    cout << ans << endl;
    return 0;
}

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

using ll=long long;
struct Edge{
    int to;
    ll w;
};
const ll INF=1e17;
using Graph=vector<vector<Edge>>;
class Solver{
    int n,m,k;
    vector<ll> p;
    vector<ll> c;
    vector<ll> j;
    Graph g;
    vector<ll> res;
    
    vector<ll> Dijkstra(vector<ll> d){
        int n=d.size();
        using Item=pair<ll,int>;
        priority_queue<Item,vector<Item>,greater<>> que;
        for(int i=0;i<n;i++) que.push(make_pair(d[i],i));
        while(!que.empty()){
            auto tmp=que.top(); que.pop();
            int v=tmp.second;
            if(d[v]<tmp.first) continue;
            for(auto& e:g[v]){
                if(d[e.to]>d[v]+e.w){
                    d[e.to]=d[v]+e.w;
                    que.push(make_pair(d[e.to],e.to));
                }
            }
        }
        return d;
    }
    public:
    Solver(int n,int m,int k):n(n),m(m),k(k),p(n),c(n),j(n),g(n),res(k,-INF){
        for(int i=0;i<n;i++) cin>>p[i];
        for(int i=0;i<n;i++) cin>>c[i],c[i]--;
        for(int i=0;i<n;i++) cin>>j[i];
        for(int i=0;i<m;i++){
            int u,v,t; cin>>u>>v>>t;
            u--,v--;
            g[u].push_back(Edge{v,t});
            g[v].push_back(Edge{u,t});
        }
    }
    void solve(){
        vector<ll> d1(n,INF);
        d1[0]=0;
        d1=Dijkstra(d1);
        auto d2=d1;
        for(int i=0;i<n;i++) d2[i]-=p[i];
        auto d3=Dijkstra(d2);
        for(int i=0;i<n;i++){
            res[c[i]]=max(res[c[i]],j[i]-d1[i]-d3[i]);
        }
        return;
    }
    void print(){
        for(int i=0;i<k;i++){
            cout<<res[i]<<endl;
        }
    }
};
int main(){
    int n,m,k;
    cin>>n>>m>>k;
    Solver solver(n,m,k);
    solver.solve();
    solver.print();
    return 0;
}


Measured memory_bytes: 24212
#include<iostream>
using namespace std;
void swap(int *a,int *b)
{
	int t;
	t=*a;
	*a=*b;
	*b=t;
}
int main()
{
	int x,y,z;
	cin>>x>>y>>z;
	swap(&x,&y);
	swap(&x,&z);
	cout<<x<<" "<<y<<" "<<z<<endl;
	return 0;
 } 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  int n,a[100]={},b[20]={},m=0,M=0;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    b[a[i]/400]++;
  }
  for(int i=0; i<13; i++) {
    if(i<8&&b[i]>0) {
      m++;
      M++;
    }
    if(i>=8) {
      M+=b[i];
    }
  }
  m=max(m,1);
  cout << m << " " << M << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int D, N;
		D = sc.nextInt();
		N = sc.nextInt();

		if (N == 100) N++;
		System.out.println((int)(Math.pow(100, D) * N));
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> bulb(N), count(N, 0);
    for (int i = 0; i < N; i++) {
        cin >> bulb[i];
    }
    count[0] = 1;
    for (int i = 1; i < N; i++) {
        if (bulb[i-1] != bulb[i]) {
            count[i] = count[i-1] + 1;
        } else {
            count[i] = 1;
        }
    }
    auto solve = [=](){
        vector<int> v;
        int mx = 1;
        for (int i = N-1; i >= 0; i--) {
            mx = max(mx, count[i]);
            if (count[i] == 1) {
                v.push_back(mx);
                mx = 1;
            }
        }
        if (v.size() == 1) {
            return v[0];
        }
        
        int res = 0;
        for (size_t i = 0; i < v.size()-1; i++){
            res = max(res, v[i]+v[i+1]);
            if (i+2 < v.size()) {
                res = max(res, v[i]+v[i+1]+v[i+2]);
            }            
        }
        return res;
    };

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

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
	vi a(7);
	rep(i,7) cin >> a[i];
	ll ans[4] = {},mi = min({a[0],a[3],a[4]});
	ans[0] = a[0]/2*2+a[3]/2*2+a[4]/2*2;
	a[0] -= mi,a[3] -= mi,a[4] -= mi;
	ans[1] = mi*3+a[0]/2*2+a[3]/2*2+a[4]/2*2;
	if(mi){
		mi--,a[0]++,a[3]++,a[4]++;
		ans[2] = mi*3+a[0]/2*2+a[3]/2*2+a[4]/2*2;
	}
	
	cout << a[1] + max({ans[0],ans[1],ans[2],ans[3]}) << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
robots = []
for _ in range(n):
  x, l = map(int, input().split())
  robots.append((x+l, x-l))
robots.sort()

hand = robots[0][0]
count = 1
for robot in robots[1:]:
  if hand <= robot[1]:
    hand = robot[0]
    count += 1
print(count)

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

int main () {
  int n=0, i=0;
  int alice =0;
  int bob = 0;
  cin >> n;
  vector<int> a(n);
  for (i=0;i<n;++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int bc = 0;
  int ac = 0;
  vector<int> ba(n);
  vector<int> aa(n);
  for (i=0;i<n;++i) {
    if (i % 2 == 0) {
      ba[bc]= a[i];
      bc++;
    }
    else {
      aa[ac] = a[i];
      ac++;
    }
  }
  int res = 0;
  sort(ba.begin(), ba.end());
  sort(aa.begin(), aa.end());
  for (i=0;i<n;++i) {
    res = res + aa[i] - ba[i];
  }
  if (res <= 0) res *= -1;
  printf("%i", res);
  return 0;
}

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

int main(){
	int n;
  	cin>>n;
  	vector<int>v(n),c(n);
  	for(int i=0;i<n;i++)
      cin>>v[i];
  	for(int i=0;i<n;i++)
      cin>>c[i];
  	int ans=0;
  	for(int i=0;i<n;i++)
    {
      	if(v[i]>c[i])
          ans+=(v[i]-c[i]);
    }
  	cout<<ans;
  	return 0;
}


Measured memory_bytes: 256
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e18;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

char mp[100][100];
int main() {
	cin >> H >> W;
	rep(i, H){
		rep(j, W){
			cin >> mp[i][j];
		}
	}

	rep(i, W+2){
		cout << "#";
	}
	cout << endl;
	rep(i, H){
		cout << "#";
		rep(j, W){
			cout << mp[i][j];
		}
		cout << "#\n";
	}
	rep(i, W+2){
		cout << "#";
	}
	cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=998244353;
const ll MAX_N=500010;
const ll INF=100100100100100;


int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(), a.end());
    vector<bool> visited(1001001,true);
    for(int i=0;i<n-1;i++){
        if(a[i]==a[i+1]) visited[a[i]]=false;
    }
    int ans=0;
    for(int i=0;i<n;i++){
        int num=a[i];
        if(i>0 && a[i]==a[i-1]) continue;
        if(visited[num]) ans++;
        for(int times=1;num*times<1001001;times++){
            visited[num*times]=false;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define dbg(x) cout<<#x<<" : "<<x<<endl;
#define d coult<<"LINE "<<__LINE__<<endl;
using namespace std;
int main(){
	int n,k;
	int a[300000]={};
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		//pre[i]=pre[i-1]*a[i];
	}
	for(int i=2;i<=n-k+1;i++){
		if(a[i+k-1]>a[i-1])cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}

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





int main() {
  int A,B,C;
  cin>>A>>B>>C;
  vector<int> vec(0);
  
  for (int i=0;i<B;i++){
    vec.push_back((i*A)%B);
  }
  
  int vecsize=int(vec.size());
  
  string answer="NO";
  
  
  for (int i=0;i<vecsize;i++){
    if (vec.at(i)==C){
      answer="YES";
      break;
    }
  }
  
  cout<<answer<<endl;
  
    
  
  
}












Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const ll INF = 1ll << 60;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]) {
    cin >> n >> m;
    vector<vi> g(n, vi(n, MOD));
    REP(i, n) g[i][i] = 0;
    vector<tuple<int, int, int>> e;
    REP(i, m) {
        int u, v, w;
        cin >> u >> v >> w; u--; v--;
        e.emplace_back(u, v, w);
        g[u][v] = g[v][u] = w;
    }
    REP(k, n)
        REP(i, n)
            REP(j, n)
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
    int ans = 0;
    for (auto it : e) {
        int u, v, w; tie(u, v, w) = it;
        ans += g[u][v] < w;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>

int main() {
  std::map<int,int> mp;
  int a,b,c;
  std::cin >> a >> b >> c;
  mp[a] += 1;
  mp[b] = 1;
  mp[c] = 1;
  std::cout << mp.size() << std::endl;
}

Measured memory_bytes: 256
import numpy as np

def getNearestValue(list, num):
    """
    概要: リストからある値に最も近い値を返却する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]


judge = 753

S = int(input())
tmp = S
lst = []
thrp = []
while S > 0:
    lst.append(str(S%10))
    S //= 10 # 必須
lst.reverse()

for i in range(len(str(tmp))-2):
    thrp.append(int(lst[i] + lst[i+1] + lst[i+2]))

result = getNearestValue(thrp,judge)

result -= judge
print(abs(result))


Measured memory_bytes: 13836
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	int x;
	cin>>x;
	if(x>=30){
		cout<<"Yes";
	} 
	else{
		cout<<"No";
	}
	re 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}


int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n){
		cin >> a[i];
	}
	int ans = 0;
	rep2(i, 1, n - 1)
	{
		vector<int> t = {a[i - 1], a[i], a[i + 1]};
		sort(all(t));
		if(t[1] == a[i])
			ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
d = len(str(n))
a = [9, 0, 900, 0, 9000]
c = 0
for i in range(1, d):
  if i % 2 == 1:
  	c += 9 * (10**(i-1))
  
if d == 1:
  c += n
else:
  c += n - int('9'*(d-1)) if d % 2 == 1 else 0

print(c)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

double calc(int xi,int yi,int xj,int yj) {
  return sqrt((double)((xi-xj)*(xi-xj)+(yi-yj)*(yi-yj)));
}
int perm(int n){
  int ans = 1;
  for(int i = 1;i <= n;i++) {
    ans *= i;
  }
  return ans;
}

int main(void) {
  int n;
  cin >> n;
  vector<int> v(n),x(n),y(n);
  for(int i = 0;i < n;i++){
    cin >> x[i] >> y[i];
    v[i] = i+1;
  }

  double sum = 0;
  
  do {
    for(int i = 0;i < n - 1;i++){
      sum += calc(x[v[i]-1],y[v[i]-1],x[v[i+1]-1],y[v[i+1]-1]);
    }
  } while (next_permutation(v.begin(), v.end()));

  cout << fixed << setprecision(6);
  cout << sum / double(perm(n)) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MAX_N = 100010;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/
int main(){
    int n; cin >> n;
    
    int count = 0;
    int coa = 0, cob = 0, coab = 0;
    string s;

    for(int i = 0; i < n; i++){
        cin >> s;
        for(int j = 0; j < s.length() - 1; j++){
            if(s[j] == 'A' and s[j + 1] == 'B') count++;
        }
        if(s[0] == 'B' and s[s.length() - 1] != 'A') coa++;
        if(s[0] != 'B' and s[s.length() - 1] == 'A') cob++;
        if(s[0] == 'B' and s[s.length() - 1] == 'A') coab++; 
    }
    if(coab == 0){
        cout << count + min(coa, cob) << endl;
    }else if(coa + cob != 0){
        cout << count + min(coa, cob) + coab << endl; 
    }else if(coa + cob == 0){
        cout << count + coab - 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3608
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		Num[] arr = new Num[n];
		for (int i = 0; i < n; i++) {
			Num o = new Num();
			o.a = Integer.parseInt(br.readLine());
			o.i = i;
			arr[i] = o;
		}
		br.close();

		Arrays.parallelSort(arr);

		int cnt = 0;
		for (int i = 0; i < n; i++) {
			if (arr[i].i % 2 != i % 2) {
				cnt++;
			}
		}
		System.out.println(cnt / 2);
	}

	static class Num implements Comparable<Num>{
		int a, i;
		public int compareTo(Num o) {
			return a - o.a;
		}
	}
}


Measured memory_bytes: 35228
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#define all(x) x.begin(), x.end()
#define rep(n) for (int i=0; i<n; ++i)

using namespace std;

int main(void){
  int N;
  cin >> N;
  vector<int> a(N);
  rep(N) cin >> a[i];
  int max = *max_element(all(a));
  int min = *min_element(all(a));
  cout << max - min << endl;
  return 0;
}


Measured memory_bytes: 256
//
//  main.c
//  c
//
//  Created by ????????? on 2016/12/10.
//  Copyright ?? 2016??´ ?????????. All rights reserved.
//

#include <stdio.h>

int main(){
    long long a, b, r, lcm, x, y;
    while (scanf("%lld %lld",&a,&b) != EOF) {
        x=a;
        y=b;
        for (;;) {
            r=x%y;
            if (r==0)
                break;
            x=y;
            y=r;
        }
        lcm=a*b/y;
        printf("%lld %lld\n",y,lcm);
    }

    return 0;
}

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

long long modexp(int x, long long e, int m) {
    long long ans = 1, p = x % m;
    while (e > 0) {
        if (e % 2 != 0) ans = (ans * p) % m;
        p = (p * p) % m;
        e >>= 1;
    }
    return ans;
}

int main() {
    int n, m; cin >> n >> m;
    long long f[3*n+1], fi[3*n+1];
    f[0] = 1;
    for (int i = 1; i <= 3*n; i++) f[i] = f[i-1] * i % m;
    fi[3*n] = modexp(f[3*n], m-2, m);
    for (int i = 3*n-1; i >= 0; i--) fi[i] = (fi[i+1] * (i+1)) % m;
    int inv3 = modexp(3, m-2, m), inv2 = modexp(2, m-2, m);
    long long ans = 0, A = 1;
    for (int a = 0; a <= n; a++, A = A * inv3 % m) {
        long long C = A;
        for (int b = 0; a + b <= n && 3*a + 2*b <= 3*n; b++, C = C * inv2 % m) {
            ans += f[3*n] * C % m * fi[3*(n-a)-2*b] % m * fi[a] % m * fi[b] % m;
        }
    }
    cout << ans % m << endl;
}


Measured memory_bytes: 3260
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int r = sc.nextInt();
		int s = sc.nextInt();
		int p = sc.nextInt();
		String t = sc.next();
		sc.close();

		HashMap<String, Integer> points = new HashMap<String, Integer>();
		points.put("r", p);
		points.put("s", r);
		points.put("p", s);
		List<String> texts = new ArrayList<String>();
		long point = 0L;
		for (int i = 0; i < n; i++) {
			String text1 = t.substring(i, i + 1);
			if (i >= k && texts.get(i - k).equals(text1)) {
				text1 = "";
			}
			texts.add(text1);
			if (!text1.equals("")) {
				point += points.get(text1);
			}
		}
		System.out.println(point);
	}
}


Measured memory_bytes: 32392
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

int main(){
	FAST_IO;
    int n,W;
    cin >> n >> W;
    int w[n], v[n]; 
    for(int i=0; i < n; i++){
        cin >> w[i] >> v[i];
    }
    ll dp[n+1][W+1]; 
    for(int i =0; i <= n; i++){
        for(int wt = 0; wt <= W; wt++){
            if(i==0 || wt == 0)
                dp[i][wt] = 0;
            else if(wt >= w[i-1]){
                dp[i][wt] = max(dp[i-1][wt] ,(v[i-1] + dp[i-1][wt - w[i-1]])); 
            }
            else{
                dp[i][wt] = dp[i-1][wt]; 
            }
        }
    }

    cout << dp[n][W] << endl; 

    return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
#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 all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;
ll rec(ll n) {
  if (n == 1) {
	  return 1;
	} else {
	  return 1 + 2 * rec(n / 2);
	}
}

int main() {
  ll h;
  cin >> h;
  cout << rec(h) << endl;
  return 0;
}


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

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll n;cin>>n;
    ll a[n];
    vector<ll> b;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        b.push_back(a[i]-i-1);
    }
    sort(b.begin(),b.end());
    ll j;
    j=n/2;
    ll ans=0;
    for(ll i=0;i<n;i++){
        ans+=abs(b[i]-b[j]);
    }
    cout<<ans<<endl;
    
    return 0;
}



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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
map <int, int> f;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int n;
    int cnt = 0;
    cin >> n;
    FOR(i, 1, n)
    {
        int t = i;
        while(t % 2 == 0)
        {
            t /= 2;
            f[2]++;
        }
        for(int j = 3; j <= sqrt(t); j += 2)
        {
            int d = 0;
            while(t % j == 0)
            {
                t /= j;
                d++;
            }
            if(d) f[j] += d;
        }
        if(t > 2) f[t]++;
    }
    ll res = 1;
    for(auto i : f)
    {
       // if(i.se > 2)cout << i.fi << " " << i.se << endl;
        res = (res * (i.se + 1)) % MOD;
    }
    cout << res;
    return 0;
}


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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << ":" << #x << " = " << (x) << endl;
#else
#define dbg
#endif

#pragma endregion Macros

int main()
{
    int X;
    cin >> X;
    string ans;
    if (X >= 30) {
        ans = "Yes";
    }else{
        ans = "No";
    }
    cout << ans << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>

int f(std::vector<int> a) {
    int min = -1;
    for (int i = 0; i < a.size(); i++) {
        int count = 0;
        while (a[i] % 2 == 0 && (min == -1 || min >= count)) {
            a[i] /= 2;
            count++;
        }
        if (min == -1 || min > count) {
            min = count;
        }
    }
    return min;
}

int main() {

    int n;
    std::cin >> n;

    std::vector<int> a;
    for (int i = 0; i < n; i++) {
        int tmp;
        std::cin >> tmp;
        a.push_back(tmp);
    }

    int result = f(a);
    std::cout << result << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    char s[200005];
    scanf("%s", s);
    int i;
    int b[200005];
    b[0] = 0;
    for (i = 0; i < n; i++)
    {
        if (s[i] == '#')
            b[i + 1] = b[i] + 1;
        else
            b[i + 1] = b[i];
    }
    int w[200005];
    w[n] = 0;
    for (i = n - 1; i >= 0; i--)
    {
        if (s[i] == '.')
            w[i] = w[i + 1] + 1;
        else
            w[i] = w[i + 1];
    }
    int ans = 300005;
    for (i = 0; i <= n; i++)
        if (ans > w[i] + b[i])
            ans = w[i] + b[i];
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
//#include<iostream>
//#include<cstdio>
//#include<cstring>
//#include<string>
//#include<queue>
//#include<cmath>
//#include<algorithm>
#define debug1 cout<<"?"<<endl;
#define debug2 cout<<"?"<<i<<endl;
#define PII pair<int,int>
typedef long long ll;
const int maxn=1e4+9;
const double pi=acos(-1);
const int mod=998244353;
const int INF=0x3f3f3f3f;
const double ep=1e-7;
using namespace std;
char s[maxn];
int len;
inline ll dfs(int pos,int cnt)
{
	if(cnt==0)return 1;
	if(len-pos+1<cnt)return 0;
	int num=s[pos]-'0';
	if(!num)return dfs(pos+1,cnt);
	ll base=1,ans;
	for(int i=0;i<cnt-1;i++)base=base*9*(len-pos-i);
	if(cnt==3)base/=2;
	ans=base,base=1;
	if(len-pos+1==cnt)
	{
		return (num-1)*ans+dfs(pos+1,cnt-1);
	}
	for(int i=0;i<cnt;i++)base=base*9*(len-pos-i);
	if(cnt==2)base/=2;
	if(cnt==3)base/=6;
	return (num-1)*ans+base+dfs(pos+1,cnt-1);
}
int main()
{
	int i,j,k;
	scanf("%s%d",s+1,&k);
	len=strlen(s+1);
	printf("%lld\n",dfs(1,k));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;
#define watch(x) cout << #x << " is " << x << endl;
#define print(a, l, r) \
    for (int i = l; i < r; i++) cout << a[i] << (i == (r - 1) ? endl : " ");
const long long M = 1000000007;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n;
    cin >> n;

    string s;
    cin >> s;

    ll ans = 0;

    ll i = 0, j = n - 1;

    while (i < j) {
        if (s[i] == 'W' && s[j] == 'R') {
            i++;
            j--;
            ans++;
        } else if (s[i] == 'W' && s[j] == 'W') {
            j--;
        } else if (s[i] == 'R' && s[j] == 'R') {
            i++;
        } else {
            i++, j--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3720
n, k = map(int, input().split())
ans = 0

if k == 0:
	print(n ** 2)
else:
	for i in range(k + 1, n + 1):
		div = n // i
		ans += (i - k) * div
		if n % i != 0:
			ans += max(n + 1 - ((n // i) * i + k), 0)

	print(ans)

Measured memory_bytes: 3060
/*
考虑把序列差分。那么每次操作可以改变两个位置的差分值
分情况讨论改变两个位置a和b的代价
1、|a - b|是奇质数：代价是1
2、|a - b|是2：用5和3来做，5 - 3 = 2。代价是2 
3、|a - b|是大于2的偶数：根据哥德巴赫猜想，可以表示成两个质数之和。代价是2 
4、|a - b|是1：用3和2来做，3 - 2 = 1。代价是3 
5、|a - b|是奇合数：拆成3和一个偶数分别考虑。代价是3
把所有差分值是1的位置按照奇偶分成两部分，首先尽量用第1种方法来消（二分图最大匹配）。剩下的尽量同奇偶的位置之间用2、3来消。最后要么被消完了要么还要用一次4或5 
*/

#include <set>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

namespace G
{
	const int Max_V(205);
	const int Max_E((205 + 105 * 105) * 2);
	const int INF(0X3F3F3F3F);
	int V, S, T;
	int Head[Max_V], Total, To[Max_E], Next[Max_E], Cap[Max_E];
	inline void Add_Edge(const int &tot, const int &s, const int &t, const int &c)
	{
		To[tot] = t, Next[tot] = Head[s], Head[s] = tot, Cap[tot] = c;
	}
	inline void Add_Link(const int &s, const int &t, const int &c)
	{
		Total += 2, Add_Edge(Total, s, t, c), Add_Edge(Total ^ 1, t, s, 0);
	}
	int Cur[Max_V], Dist[Max_V];
	int Q[Max_V];
	bool BFS()
	{
		int ft(1);
		memset(Dist, 0, sizeof(Dist)), Dist[S] = 1, Q[Q[0] = 1] = S;
		int u;
		while (ft <= Q[0])
		{
			u = Q[ft++];
			for (int i = Head[u], v;i;i = Next[i])
				if (Cap[i] && !Dist[v = To[i]])
				{
					Dist[v] = Dist[u] + 1, Q[++Q[0]] = v;
					if (v == T)
						return true;
				}
		}
		return false;
	}
	int DFS(const int &u, int a)
	{
		if (u == T || a == 0)
			return a;
		int Ans(0), f;
		for (int &i = Cur[u], v;i;i = Next[i])
			if (Dist[v = To[i]] == Dist[u] + 1 && (f = DFS(v, min(a, Cap[i]))) > 0)
			{
				Ans += f, Cap[i] -= f, Cap[i ^ 1] += f;
				if ((a -= f) == 0)
					break;
			}
		return Ans;
	}
	int Dinic()
	{
		int Ans(0);
		while (BFS())
		{
			for (int i = 1;i <= V;++i)
				Cur[i] = Head[i];
			Ans += DFS(S, INF);
		}
		return Ans;
	}
}

bool isprime(int n)
{
	if (n <= 1)
		return false;
	for (int d = 2;d * d <= n;++d)
		if (n % d == 0)
			return false;
	return true;
}

inline int Abs(const int &x)
{
	return x >= 0 ? x : -x;
}

const int Max_N(105);
int A[Max_N << 1], B[Max_N << 1];
set<int> S;

void init()
{
	int N, X;
	for (scanf("%d", &N);N--;)
	{
		scanf("%d", &X);
		if (S.count(X))
			S.erase(X);
		else
			S.insert(X);
		if (S.count(X + 1))
			S.erase(X + 1);
		else
			S.insert(X + 1);
	}
	for (set<int>::iterator it = S.begin();it != S.end();++it)
		if ((*it) & 1)
			A[++A[0]] = *it;
		else
			B[++B[0]] = *it;
}

void work()
{
	G::V = S.size() + 2, G::S = S.size() + 1, G::T = S.size() + 2;
	for (int i = 1;i <= A[0];++i)
		G::Add_Link(G::S, i, 1);
	for (int i = A[0] + 1;i <= A[0] + B[0];++i)
		G::Add_Link(i, G::T, 1);
	for (int i = 1;i <= A[0];++i)
		for (int j = 1;j <= B[0];++j)
			if (isprime(Abs(A[i] - B[j])))
				G::Add_Link(i, A[0] + j, 1);
	int Ans = G::Dinic();
	A[0] -= Ans, B[0] -= Ans;
	Ans += (A[0] / 2) * 2, Ans += (B[0] / 2) * 2;
	if (A[0] & 1)
		Ans += 3;
	printf("%d", Ans);
}

int main()
{
	init();
	work();
	return 0;
}

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

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#define ABS(x, y) ((x) > (y) ? ((x) - (y)) : ((y) - (x)))

#define MOD(x, y) ((x) % (y))
#define DIVCEIL(x, y) (((x) + ((y) - 1)) / (y))
#define DIVFLOOR(x, y) (((x) + ((y) / 2)) / (y))
#define DIVROUND(x, y) ((x) - MOD(x, y) >= MOD(x, y) ? DIVCEIL(x, y) : DIVFLOOR(x, y))

constexpr int N = 5;

int main() {
  int orders[N];
  for (int i{}; i < N; ++i) cin >> orders[i];
  sort(orders, orders+N, [](int l, int r) {
    l %= 10;
    if (!l) l = 10;
    r %= 10;
    if (!r) r = 10;
    return l > r;
  });

  int ans{};
  int i{};
  for (; i < N - 1; ++i)
    ans += DIVCEIL(orders[i], 10) * 10;
  ans += orders[i];

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


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

using pi = pair<int, int>;
int main() {
    while (true) {
        int N, M;
        cin >> N >> M;
        if(N == 0)return 0;
        vector<pi> P(N);
        rep(i,N)
        {
            int a, b; cin >> a >> b;
            P[i] = pi(b, a);
        }
        sort(P.begin(), P.end());
        long long ans = 0;
        for(int i = N - 1; i >= 0; i--)
        {
            if(M >= P[i].second)
            {
                M -= P[i].second;
            }
            else
            {
                ans += P[i].first * (P[i].second - M);
                M = 0;
            }
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define ll long long
#define increase(a) sort(a.begin(), a.end())
#define decrease(a) sort(a.rbegin(), a.rend())
#define loop(n) for(ll i = 0; i<n; i++)
using namespace std;

int main(){
    ll n; cin>>n;
    vector<ll> arr(n);
    loop(n) cin>>arr[i];
    ll min = arr[0], count = 0;
    loop(n){
        (arr[i]<=min)?(count++):(1);
        (arr[i]<min)?(min=arr[i]):(1);
    }
    cout<<count;
    return 0;
}

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





int main(){
  int n, m, s[220], t, a[3];
  
  while(1){
    int sum1 = 0, sum2 = 0, c = 0, b, min = 0;
    cin>>n>>m;
    if(n == 0 && m == 0) break;
    
    for(int i = 1; i <= n; i++){
      cin>>s[i];
      sum1 += s[i];
    }
    
    for(int i = n + 1; i <= n + m; i++){
      cin>> s[i];
      sum2 += s[i];
    }

    t = fabs(sum1 - sum2);
    
    for(int i = 1;  i <= n; i++){
      for(int j = n + 1; j <= n + m; j++){
	if(sum1 + s[j] - s[i] == sum2 + s[i] - s[j]){
	  if(c == 0){
	    a[0] = s[i]; a[1] = s[j];
	    min = s[i] + s[j];
	    c++;
	  } else {
	    if(s[i] + s[j] <= min) {
	      min = s[i] + s[j];
	      a[0] = s[i]; a[1] = s[j];
	    }
	    
	  }
	}
	
      }
      
    }

    if(c == 0) cout<<"-1"<<endl;
    else cout<<a[0]<<" "<<a[1]<<endl;
    
  }
  return 0;
}



Measured memory_bytes: 3072
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int64 MOD = 1000000007;

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

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

  vl b = a;
  sort(all(b));

  vl tentou(n);

  for (int i = 0; i < n; ++i) {
    int cnt = 0;
    for (int j = 0; j < i; ++j) {
      if (a[i] < a[j]) ++cnt;
    }
    tentou[i] = cnt;
  }

  vl usiro(n);

  b.push_back(INF64);

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (b[j] == b[i] && b[j + 1] != b[i]) {
        usiro[i] = n - 1 - j;
      }
    }
  }

  //int64 ans = 0;

  int64 tsum = accumulate(all(tentou), int64());
  tsum %= MOD;

  if (k == 1) {
    cout << tsum << endl; return 0;
  }

  int64 usum = accumulate(all(usiro), int64());

  int64 ans = tsum * k;
  ans %= MOD;

  int64 x = k * (k - 1) / 2;
  x %= MOD;
  x *= usum;
  x %= MOD;

  ans += x;
  ans %= MOD;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#define ll long long
using namespace std;
int main()
{
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    double s = w * h / 2.0;
    bool a = (x * 2 == w);
    bool b = (y * 2 == h);
    int ans = 0;
    if(a&b){
        ans = 1;
    }else{
        ans = 0;
    }
    cout << s << " " << ans << endl;
    return 0;
}

Measured memory_bytes: 256
a, b, c, k = list(map(int, input().split()))
# a = list(map(int, input().split()))
# abc = [int(input()) for i in range(5)]
#n = int(input())
# n, m = list(map(int, input().split()))
if a+b >= k:
    if k >= a:
        print(a)
    else:
        print(k)
else:
    print(a-(k-(a+b)))


Measured memory_bytes: 9188
#pragma region Template
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rbf(i, v) for (auto& (i) : (v))
#define All(x) (x).begin(),(x).end()
#define COL(x) cout << x << endl
#define CO(x) cout << x
//#define int long long

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = INT64_MAX >> 1;
const int INF = INT_MAX >> 1;

inline int sqr(int x) { return (x * x); }
inline void printd(double x) { printf("%.10lf\n", x); }
inline void upsort(VI& x) { sort((x).begin(), (x).end()); }
inline void downsort(VI& x) { sort((x).begin(), (x).end(), greater<int>()); }
inline int absdiff(int a, int b) { return (a - b) * (static_cast<int>(a > b)*2 - 1); }
int gcd(int a, int b) { // 最大公約数
	if (a < b) return gcd(b, a);
	int r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
inline int lcm(int a, int b) { return a * b / gcd(a, b); } // 最小公倍数
#pragma endregion

// n種類のものから重複を許してr個選ぶ時の全パターンを辞書順に生成する
bool combination_repetition(int n, int r, std::vector<int>& idx, std::stack<std::pair<int,int>>& rn_st) {
	using namespace std;
	if (idx.empty()) {
		idx = vector<int>(r, 0);
		rn_st.push(make_pair(0, 0));
	}
	else if (rn_st.empty()) {
		if(*idx.begin() == n-1) return false;
		//if (*(idx.end()-1) == 0) rn_st.push(make_pair(0, 0));
		if (idx == vector<int>(r, 0)) rn_st.push(make_pair(0, 0));
		else rn_st.push(make_pair(0, *idx.begin() + 1));
	}

	pair<int, int> r_n;
	while (true) {
		r_n = rn_st.top();
		rn_st.pop();
		idx[r_n.first] = r_n.second;
		if (r_n.first >= r-1) break;
		for (int i = n-1; i >= r_n.second; i--) {
			rn_st.push(make_pair(r_n.first + 1, i));
		}
	}
	return true;
}

signed main()
{	
	int N, M, Q;
	cin >> N >> M >> Q;
	VI a(Q), b(Q), c(Q), d(Q);
	VVI dabc(Q, VI(4));
	rep(i, Q) cin >> dabc[i][1] >> dabc[i][2] >> dabc[i][3] >> dabc[i][0];

	int summax = 0;
	VI idx(N,0);
	stack<pair<int, int>> rn_st;
	do {
		int sum = 0;
		rep(i, Q) {
			if (dabc[i][3] == idx[dabc[i][2] - 1] - idx[dabc[i][1] - 1]) sum += dabc[i][0];
		}
		summax = max(sum, summax);
	} while (combination_repetition(M, N, idx, rn_st));
	COL(summax);

	return 0;
}

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

using namespace std;

const static inline void rec(int data) {
  if(data == 0) return;
  int next = abs(data) % 2;
  if(data < 0) next = (2 - next) % 2;
  rec((data - next) / -2);
  cout << next;
}

int main() {
  int N;
  cin >> N;
  if(N == 0) {
    cout << 0 << endl;
    return 0;
  }
  rec(N);
  cout << endl;
}


Measured memory_bytes: 256
n=int(input())
H=[list(map(int,input().split())) for i in range(n)]
dp=[[0 for i in range(3)] for i in range(n)]
for i in range(3):
    dp[0][i]=H[0][i]
for i in range(n-1):
    for j in range(3):
        if j==0:
            dp[i+1][0]=max(dp[i][1]+H[i+1][0],dp[i][2]+H[i+1][0])
        if j==1:
            dp[i+1][1]=max(dp[i][0]+H[i+1][1],dp[i][2]+H[i+1][1])
        if j==2:
            dp[i+1][2]=max(dp[i][0]+H[i+1][2],dp[i][1]+H[i+1][2])
print(max(dp[n-1][0],dp[n-1][1],dp[n-1][2]))

Measured memory_bytes: 50176
import sys
from bisect import bisect_left
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

N = int(readline())
A = map(int, read().split())

a = [-1] * N

for i in A:
    n = bisect_left(a, i)
    a[n - 1] = i

print(N - a.count(-1))

Measured memory_bytes: 14056