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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template<class T,class U> void chmax(T& a, U b) {if(a<b)a=b;}
template<class T,class U> void chmin(T& a ,U b) {if(b<a)a=b;}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;
    string s1,s2;
    cin >> s1 >> s2;
    rep(i, n) {
        cout << s1[i] << s2[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD 998244353
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}



int main() {
    ll n;
    cin >> n;
    ll a[n];
    ll ans=0;
    for (ll i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a,a+n);
    ans=a[n-1];
    ll f=(n-2)*2+1;
    for (ll i=n-3;i>=0;i--){
        ans+=a[f/2];
        if (a[i]<a[f/2]){
            f--;
        }

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


Measured memory_bytes: 5192
#include<bits/stdc++.h>
/*
CE 头文件 
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>

*/
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define mem(a,b) memset(a,b,sizeof (a))
#define ios std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0);
// ios和scanf,printf不能混用.即用ios必须全部cin,cout. 
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;

ll ksm(ll a,ll b){ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int N=110;
PII factor[N];
int n,k;

int main(){
	scanf("%d",&n);
	n--;
	ll ans=0;
	for(int i=1;i<=n;i++) {
        ans+=1ll*n/i;
    }
    
	printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 3812
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <numeric>

using namespace std;

int main(){
   long long x,y;
   cin>>x>>y;
   int ans=0;
   while(x<=y){
      x *=2;
      ans++;
   }
   cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define f first
#define s second
#define ld long double
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

vp prime_factorize(int n){
    vp ret;
    for(int p=2; p*p<=n; p++){
        if(n%p!=0) continue;
        int num=0;
        while(n%p==0){
            num++;
            n/=p;
        }
        ret.PB(MP(p,num));
    }
    if(n!=1) ret.PB(MP(n,1));
    return ret;
}

signed main(){
    int n; cin >> n;
    int res=0;
    vp pf=prime_factorize(n);
    for(auto p:pf){
        int num=1;
        while(p.second>=num){
            p.second-=num;
            num++;
            res++;
        }
    }
    cout<<res<<endl;
}

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

int main(){
  int num,t,x;
  double kizyun;
  double tmp;
  double near = 9999;
  int kekka;
  
  cin >> num >> t >> kizyun;
  
  for(int i = 0; i < num; i++){
    cin >> x;
    tmp = t - x * 0.006;
    
    if(fabs(kizyun - tmp) < fabs(kizyun - near)){
      near = tmp;
      kekka = i + 1;
    }
  }
  
  cout << kekka;
}

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

int main(){
  string S;
  cin >> S;
  if(S=="SUN") cout << "7" <<endl;
  else if(S=="MON") cout << "6" << endl;
  else if(S=="TUE") cout << "5" << endl;
  else if(S=="WED") cout << "4" << endl;
  else if(S=="THU") cout << "3" << endl;
  else if(S=="FRI") cout << "2" << endl;
  else if(S=="SAT") cout << "1" << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
 
ans = 'APPROVED'
for i in A:
    if i % 2 == 0:
        if i % 3 == 0:
            pass
        elif i % 5 == 0:
            pass
        else:
            ans = 'DENIED'
print(ans)

Measured memory_bytes: 9056
n = gets.chomp.to_i

arr = gets.chomp.split.map(&:to_i)
sorted = arr.sort
ans = [sorted[(n-1)/2], sorted[(n+1)/2]]

arr.each do |i|
  if i > ans[0]
    puts ans[0]
  else
    puts ans[1]
  end
end


Measured memory_bytes: 25316
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String S = in.next();
            S = S.replaceAll("eraser", "-");
            S = S.replaceAll("erase", "-");
            S = S.replaceAll("dreamer", "-");
            S = S.replaceAll("dream", "-");
            S = S.replaceAll("-", "");
            if (S.length() == 0)
                out.println("YES");
            else
                out.println("NO");
        }

    }
}



Measured memory_bytes: 43868
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <stdlib.h>     /* srand, rand */
#include <time.h>       /* time */
#define mt make_tuple
#define ll long long
#define ld long double
#define eb emplace_back
#define fi first
#define pb push_back
//#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define scanVec(vec) for(int i = 0; i < SZ(vec) ; i++){ cin >> vec[i];}
#define printVec(vec) for(int i = 0; i < SZ(vec) ; i++){ cout<<vec[i]<<" ";}
#define mod(a,b) ((a%b +b)%b)
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
//#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define lastEle(vec) vec[vec.size()-1] 
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) 
#define ll long long 
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define INF 1001001001
//#define PI 3.1415926535897932384626
 
using namespace std;
 using namespace __gnu_pbds;
 template <typename T>
 using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
 
/*
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
 */
//----------------------------------------------------------------------------------------------------------------------
 
void swap(int & a, int & b){
    auto temp = a;
    a = b;
    b = temp;
}
 
const ll MOD = 1e9 + 7;
 
ll inf = 1LL*1e17;
 
void no(){
    cout <<"NO" << endl;
   //exit(0);
}
 
void yes(){
    cout <<"YES" << endl; //exit(0);
}
 
const ll md = 998244353;


void sl(){
	ll n,a,b;
	cin >> n >> a >> b;
	ll ans = n / (a + b);
	ll rem = n % (a + b);
	rem = min(a,rem);
	cout << ans*a + rem << endl;
	
}
 
 
int main(){
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int ts = 0;
    if(ts == 1) cin >> ts;
    else ts = 1;
    while(ts--) sl(); 
    return 0;
} 


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BCakesAndDonuts solver = new BCakesAndDonuts();
        solver.solve(1, in, out);
        out.close();
    }

    static class BCakesAndDonuts {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();

            final int a = 4, b = 7;

            String answer = "No";
            for (int i = 0; i * a <= n; i++) {
                for (int j = 0; j * b <= n; j++) {
                    if (a * i + b * j == n) {
                        answer = "Yes";
                    }
                }
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    char c;
    cin >> c;
    if(isupper(c)) cout << 'A' << endl;
    else cout << 'a' << endl;

    return 0;
}











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

int main() {
  int N,M;
  cin>>N>>M;
  int count=0;
  vector<int> vec(N);
for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
      count+=vec.at(i);
  }
if(count<=N)
cout<<N-count<<endl;
else
{
    cout<<"-1"<<endl;
}

}



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

int main() {
 int N;
 cin >> N;
 vector<tuple<string, int, int>> res(N);
 for(int i=0; i<res.size(); i++) {
  string S;
  int P;
  cin >> S >> P;
  res.at(i) = make_tuple(S, P, i+1);
 }
  
 sort(res.begin(), res.end());
 for(int i=0; i<res.size(); i++) {
  for(int j=0; j<res.size()-i; j++) {
   	if(get<0>(res.at(i)) == get<0>(res.at(j+i)) && get<1>(res.at(i)) < get<1>(res.at(j+i))) {
     tuple<string, int, int> th = res.at(i);
     res.at(i) = res.at(j+i);
     res.at(i+j) = th;
    }
  }
 }
  for(int i=0; i<res.size(); i++) {
   int num = get<2>(res.at(i));
   cout << num << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int X;
	cin >> X;
	if (X / 100 * 5 >= X % 100) cout << "1" << endl;
	else cout << "0" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
const ll INF = 5e15;
int main(){
    ll H, W, N;
    cin >> H >> W >> N;
    vector<vector<ll>> rocks(W);
    for(ll i = 0; i < N; i++){
        ll x, y;
        cin >> x >> y;
        x--;
        y--;
        rocks[y].push_back(x);
    }
    for(auto &v : rocks) v.push_back(H);
    for(auto &v : rocks) sort(v.begin(), v.end());
    ll now = 0;
    ll ans = rocks[0][0];
    for(ll i = 1; i < W && now < H; i++){
        auto ite = upper_bound(rocks[i].begin(), rocks[i].end(), now);
        if(ite == rocks[i].end()){
            now = W;
            ans = min(ans, ((W - 1) * 2 + 1));
            break;
        }
        if(*ite == now + 1){
            ll idx = ite - rocks[i].begin();
            idx++;
            for(; idx < rocks[i].size(); idx++){
                if(rocks[i][idx] - rocks[i][idx - 1] > 1) break;
            }
            if(idx == rocks[i].size()){
                now = H - 1;
            }else{
                now = rocks[i][idx - 1] + 1;
            }
        }else{
            now++;
        }
        auto tmp = upper_bound(rocks[i].begin(), rocks[i].end(), now);
        ll pos = *tmp;
        //cout << i << ", " << now << ", " << pos << endl;
        ans = min(ans, (pos - 1) + 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12288
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

ll a[20];

int main(){
    int n, k;
    cin >> n >> k;
    rep(i, n) cin >> a[i];
    ll ans = LINF;
    for(ll bits = 0; bits < (1ll<<n); bits++){
        if (bits%2 == 0 || __builtin_popcount(bits) != k) continue;
        ll now = a[0], tmp = 0;
        for(int i = 1; i < n; i++){
            if (bits&(1<<i)){
                if (now >= a[i]) {
                    now += 1;
                    tmp += now - a[i];
                }
                else now = a[i];
            }
            else now = max(now, a[i]);
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3572
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int Z = sc.nextInt();
		System.out.print(Z + " ");
		System.out.print(X + " ");
		System.out.println(Y);
	}
}


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

using dbl=double;
using ll=long long;
using pii=pair<int, int>;
using pll=pair<ll, ll>;

#define sz(a) ((int)a.size())
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define forse(i,s,e) for(int i=(int)s;i<(int)e;i++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

const dbl PI=3.141592653589793;


void solve(){
	int l,r,d;
	cin >> l >> r >> d;
	int out=(r/d)-(l-1)/d;
	cout << out;
}

int main() {
//	ios::sync_with_stdio(0);
//	cin.tie(0); 
	int T=1;
//	cin >> T;
	for(int c=1;c<=T;c++){
		solve();
	}
}


Measured memory_bytes: 3648
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;



int main(){
  int data,a=1000,b=-1;
  for(int i=0;i<5;i++){
    cin>>data;
    a=min(a,data);
    b=max(b,data);
  }
  cin>>data;
  if(b-a<=data) cout<<"Yay!"<<endl;
  else cout<<":("<<endl;
}


Measured memory_bytes: 256
a,b = gets.split(" ").map(&:to_i)
  if a == 1 && b != 1
    puts "Alice"
  elsif a != 1 && b == 1 
    puts "Bob"
  elsif a > b
    puts "Alice"
  elsif a < b
    puts "Bob"
      else
    puts "Draw" 
  end

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

int main(){
  string s;
  cin >> s;
  if(s=="T"){
    cout << "A";
  }
  else if(s=="A"){
   cout << "T";
  }
  else if(s=="C"){
    cout << "G";
  }
  else if(s=="G"){
    cout << "C";
  }
  else{
    cout << "Error";
  }
}


Measured memory_bytes: 256
r=int(input())

for x in range(r):
    a,b,c=map(int,input().split())
    if (a**2+b**2==c**2) or (b**2+c**2==a**2) or (c**2+a**2==b**2):
        print("YES")
    
    else:
        print("NO")


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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	
	if (a==b && b==c) cout<<a<<" "<<b<<" "<<c<<'\n';
	else if (a==b && b<c) cout<<a<<" "<<b<<" "<<c<<'\n';
	else if (a==b && b>c) cout<<c<<" "<<a<<" "<<b<<'\n';
	else if (a<b && b==c) cout<<a<<" "<<b<<" "<<c<<'\n';
	else if (a>b && b==c) cout<<b<<" "<<c<<" "<<a<<'\n';
	else if (a==c && c>b) cout<<b<<" "<<a<<" "<<c<<'\n';
	else if (a==c && c<b) cout<<a<<" "<<c<<" "<<b<<'\n';
	else if (a<b && b<c) cout<<a<<" "<<b<<" "<<c<<'\n';
	else if (a<c && c<b) cout<<a<<" "<<c<<" "<<b<<'\n';
	else if (b<a && a<c) cout<<b<<" "<<a<<" "<<c<<'\n';
	else if (b<c && c<a) cout<<b<<" "<<c<<" "<<a<<'\n';
	else if (c<a && a<b) cout<<c<<" "<<a<<" "<<b<<'\n';
	else if (c<b && b<a) cout<<c<<" "<<b<<" "<<a<<'\n';
	// your code goes here
	return 0;
}

Measured memory_bytes: 3092
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main (){
  ll x;
  cin >> x ;
  ll count=0; 
  count = 2*(x/11);
  if (x%11 > 6) count =count+2;
  else if (x%11>0) count = count +1;
  cout << count;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    ll ans = 0;
    rep(0, i, N)
    {
        ll l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3596
// https://atcoder.jp/contests/abc092/tasks/arc093_a

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 1e5;
const int A_I_MAX = 5000;

int N;
int A[N_MAX + 2];
int d[N_MAX + 1];

void solve() {
  for (int i = N - 1; i >= 0; i--) A[i + 1] = A[i];
  A[0] = 0; A[N + 1] = 0;
  int dist = 0;
  REP(i, N + 1) {
    d[i] = abs(A[i + 1] - A[i]);
    dist += d[i];
  }
  // DUMP(A, N + 2);
  // DUMP(d, N + 1);
  // printf("dist:%d\n", dist);
  REP(i, N) {
    int ans = dist - d[i] - d[i + 1] + abs(A[i + 2] - A[i]);
    printf("%d\n", ans);
  }
}

void input() {
  scanf("%d", &N);
  REP(i, N) scanf("%d", A + i);
}

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


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

int main() {
	std::vector<int> array;
	for (int i = 0; i < 5; ++i) {
		int input;
		std::cin >> input;
		array.push_back(input);
	}
	std::sort(array.begin(), array.end());
	for (std::vector<int>::reverse_iterator it = array.rbegin();;) {
		std::cout << *it;
		++it;
		if (it == array.rend()) { break; }
		std::cout << ' ';
	}
	std::cout << '\n';
	return 0;
}

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

#define INF 1000000007
//#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define CLR(a) memset((a), 0, sizeof(a))

using ll = long long;
using namespace std;

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();
}

int main(void){

    int n;
    cin >> n;

    ll a[3*n];
    FOR(i,0,3*n){
        cin >> a[i];
    }
    sort(a, a+3*n);

    ll ans = 0;
    for(int i=3*n-2;i>n-1;i-=2){
        ans += a[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2688
#include <stdio.h>
int main()
{
    int n;
    int v[20], c[20];
    int sa = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &v[i]);
    }
    printf("\n");
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &c[i]);
    }
    for (int i = 0; i < n; i++)
    {
        if (v[i] - c[i] > 0)
            sa += v[i] - c[i];
    }
    printf("%d",sa);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int H, W; cin >> H >> W;
    char s[55][55];
    rep(i, H) rep(j, W) cin >> s[i][j];
    rep(i, H) {
        rep(j, W) {
            if(s[i][j] == '#') {
                if(i - 1 >= 0) if(s[i - 1][j] == '#') continue;
                if(j - 1 >= 0) if(s[i][j - 1] == '#') continue;
                if(i + 1 <= H - 1) if(s[i + 1][j] == '#') continue;
                if(j + 1 <= W - 1) if(s[i][j + 1] == '.') No();
            }
        }
    }
    Yes();
	return 0;
}

Measured memory_bytes: 256
time_list=[int(input()) for _ in range(5)]
mod10_list=[]
for i in time_list:
  if i%10==0:
    mod10_list.append(10)
  else:
    mod10_list.append(i%10)
for i in range(5):

  if time_list[i]%10==0:
    pass
  else:
    time_list[i]=((time_list[i]//10)+1)*10
ans=sum(time_list)-10+min(mod10_list)
print(ans)

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

int main(){
  int n;
  cin>>n;
  vector<double> p(n);
  for(int i=0;i<n;i++){
    cin>>p[i];
  }

  vector<vector<double>> dp =
    vector<vector<double>>(n+1, vector<double>(n+1, 0.0));
  dp[0][0] = 1.0;

  for(int i=0;i<n;i++){
    for(int j=0;j<=i;j++){
      dp[i+1][j+1] += dp[i][j]*p[i];
      dp[i+1][j] += dp[i][j]*(1-p[i]);
    }
  }

  double res = 0.0;
  for(int j=n;j>n/2;j--){
    res += dp[n][j];
  }

  cout << fixed << setprecision(10) << res << endl;
}


Measured memory_bytes: 70784
#include <stdio.h>

int main(void)
{
	int a,b,c,i,cnt;
	scanf("%d %d %d" ,&a,&b,&c);
	cnt=0;
	for(i=a; i<=b; i++){
		if(c%i==0){
			cnt++;
		}
	};
	printf("%d\n" ,cnt);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}

int power(int N, int M) {return M ? power(N * N, M / 2) * (M % 2 ? N : 1) : 1;}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int N;
    cin >> N;
    N--;

    int M = 1;
    int K = 1;
    while (1) {
        if (26*(power(26,K-1)-1)/25 <= N+1 && N+1 <= 26*(power(26,K)-1)/25) break;
        else K++;
    }
    N -= 26*(power(26,K-1)-1)/25;

    M = power(26,K-1);
    REP(i,K) {
        cout << (char) (N / M  + 'a');
        N %= M;
        M /=26;
    }
    cout << endl;
    
    /*
    while (N > M) M*=26;
    M/=26;

    while (M != 0) {
        cout << (char) (N / M  +  'a');
        N %= M;
        M/=26;
    }
    cout << endl;
    */

    
    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc171/abc171_c && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc171/abc171_c && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc171/abc171_c && sh shellscripts/submit_cpp.sh
*/


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

using namespace std;

int main(int argc, char const *argv[])
{
    int H,W,a[30][30]={0},x=3000000;

    cin>>H>>W;
    for(int i=0;i<H;++i){
        for(int j=0;j<W;++j){
            cin>>a[i][j];
        }
    }

    for(int i=0;i<H;++i){
        for(int j=0;j<W;++j){
            int tmp=0;
            for(int k=0;k<H;++k){
                for(int l=0;l<W;++l){
                    tmp+=a[k][l]*min(abs(i-k),abs(l-j));
                }
            }
            x=min(x,tmp);
        }
    }    

    cout<<x<<endl;

    return 0;
}



Measured memory_bytes: 3120
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#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 UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
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();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int T, X;
  double ans;
  cin >> T >> X;
  ans = (double)T / X;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
#define sort(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())

priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

llint dp[100005];

void solve(){
    int n,q;
    cin >> n;
    llint a;
    for(int i=0;i<n;i++){
        cin >> a;
        dp[a]++;
    }
    cin >> q;
    llint b,c;
    llint ans=0;
    llint k=0;
    for(llint x:dp){
        ans+=(x*k);
        k++;
    }
    for(int i=0;i<q;i++){
        cin >> b >> c;
        llint t=dp[b];
        ans-=(b*t);
        dp[b]=0;
        dp[c]+=t;
        ans+=(t*c);
        cout << ans << endl;
    }
    
}

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




Measured memory_bytes: 4416
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	int n;
	cin >> n;
	if(n == 0) break;
	vector< vector<int> > m(n,vector<int>(n,-1));
	int x,y,c;
	x = n/2;
	y = n/2;
	c = 1;
	y += 1;
	m[y][x] = c;

	while(c < n*n){
	    c++;
	    if(m[y][x] > 0){
		x = (x+1)%n;
		y = (y+1)%n;
		if(m[y][x] > 0){
		    x = (x-1+n)%n;
		    y = (y+1)%n;
		}
	    }
	    m[y][x] = c;
	}
	REP(i,n){
	    REP(j,n-1){
		printf("%4d",m[i][j]);
	    }
	    printf("%4d\n",m[i][n-1]);
	}
    }
    return 0;
}

Measured memory_bytes: 1208
def main():
    N,M = map(int, input().split())
    L = 1
    R = N
    for _ in range(M):
        l,r = map(int, input().split())
        L = max(L,l)
        R = min(R,r)

    print(max(0,R-L+1))


if __name__ == '__main__':
    main()



Measured memory_bytes: 44888
object Main{
  def check(num:Int):Int = {
    if(1 <= num && num <= 399)
      1
    else if(400 <= num && num <= 799)
      2
    else if(800 <= num && num <= 1199)
      3
    else if(1200 <= num && num <= 1599)
      4
    else if(1600 <= num && num <= 1999)
      5
    else if(2000 <= num && num <= 2399)
      6
    else if(2400 <= num && num <= 2799)
      7
    else if(2800 <= num && num <= 3199)
      8
    else
      10
  }

  def main(args:Array[String]) = {
    val list = scala.io.Source.stdin.getLines.toList
    val result = list(1).split(" ").map(_.toInt).map(n => check(n))
    val condition = result.filter(n => n >= 9).size
    val min = result.filter(n => n < 9).distinct.size
    val max = min + condition
    println(Math.max(min,1) + " " +  max)

    // if(max >= 8)
    //   println(Math.max(min,1) + " " +  8)
    // else
    //   println(Math.max(min,1) + " " + max)
  }
}

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

int main() {
    int n;
    int a[200001];
    int vis[1000010];
    scanf("%d", &n);
    for(int i=0; i<1000010; i++) {
        vis[i] = 0;
    }
    int one = 0;
    for(int i=0; i<n; i++) {
        scanf("%d", &a[i]);
        if(a[i] == 1) {
            one = 1;
        }
        vis[a[i]]++;
    }
    if(one == 1 && vis[1] > 1) {
        printf("0\n");
        return 0;
    } 
    else if(one == 1) {
        printf("1\n");
        return 0;
    }
    int nSum = 0;
    for(int i=0; i<n; i++) {
        int res = 1;
        if(vis[a[i]] > 1) {
            res = 0;
            continue;
        }
        if(a[i] != 2) {
            for(int j=2; j<=sqrt(a[i])+1; j++) {
                if(a[i] % j == 0) {
                    if(vis[j] >= 1 || vis[a[i]/j] >= 1){
                        res = 0;
                        break;
                    }
                }
            }
        }
        if(res) {
            nSum++;
        }
    }
    printf("%d\n", nSum);

    // sort(a, a+n);
    // int nSum = 0;
    // for(int i=0; i<n; i++) {
    //     bool res = 1;
    //     if(vis[a[i]] == -1) {
    //         int nn = i;
    //         if(i < (n-2)) {
    //             nn+=2;
    //         }
    //         else if(i < (n-1)) {
    //             nn++;
    //         }
    //         for(int j=0; j<=nn; j++) {
    //             if(i != j && a[i] % a[j] == 0) {
    //                 res = 0;
    //                 break;
    //             }
    //         }
    //         if(res) {
    //             nSum++;
    //         }
    //         vis[a[i]] = res;
    //     }
    //     else if(vis[a[i]] == 1) {
    //         nSum++;
    //     }
        
        
    // }
    // printf("%d\n", nSum);
    return 0;
}

Measured memory_bytes: 8436
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    string s; cin >> s;
    int ans = 0;
    string prev = "", now = "";

    REP(i,s.size()) {
        now += s[i];
        if (prev != now) {
            ans++;
            prev = now;
            now = "";
        }
    }

    cout << ans << endl;

    return 0;
}

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

void chmax(long long int* former_number,long long int* x) {//xよりもyが大きければ更新
    if (*former_number < *x) { long long int a = *former_number; *former_number = *x; *x = a; } else { /*no action*/ }
}
void chmin(long long int* former_number,long long int* x) {//xよりもyが大きければ更新
    if (*former_number > *x) { long long int a = *former_number; *former_number = *x; *x = a; } else {/* no action */}
}
const int INF = 100000000;
using ll = long long int;
using ul = unsigned long long int;
using vi = vector<int>;
#define all(v) v.begin(),v.end()
#define pb push_back


int main(){
    ll n,m,x;
    cin>>n>>m>>x;
    ll num=0,a;
    for(int i=0;i<m;i++){
        cin>>a;
        if(a>x){ num++; }
    }
    if(num>(m/2)){
        cout<<m-num<<endl;
    }else{
        cout<<num<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a>>b;
	if(abs(b-a)%2==1){
		cout<<"IMPOSSIBLE";
		return 0;
	}
	cout<<(a+b)/2;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        int N = sc.nextInt();
        int M = sc.nextInt();

        int min = 1;
        int max = N;
        for(int i=0; i<M; i++){
            int L = sc.nextInt();
            int R = sc.nextInt();
            if(L > min && L <= max) min = L;
            if(L > min && L > max) {
                System.out.println(0);
                return;
            }
            if(R < max && R >= min) max = R;
            if(R < max && R < min) {
                System.out.println(0);
                return;
            }
        }

        System.out.println(max-min+1);
    }
}

Measured memory_bytes: 63040
#include<bits/stdc++.h>
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x)  (long long)(x).size()
#define sqr(x) (x)*(x)
#define sof sizeof
#define resz resize
#define ins insert
#define lowerB lower_bound
#define upperB upper_bound
#define mkp make_pair
#define mkt make_tuple
#define act(a,v) (get<(long long)a>(v))
#define mod 1000000007
#define mod1 998244353
#define N 100003  //N idhar hai
#define inf 1e10
#define minf -1e18
#define min3(a,b,c) min(a,min(b,c));
#define max3(a,b,c) max(a,max(b,c));
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define sumall(v) accumulate(all(v),(ll)0)
#define suma accumulate
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION(n) std::cout.unsetf ( std::ios::floatfield );std::cout.precision((ll)n)
#define FileIO freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define PI M_PI
#define fi first
#define se second
#define here cout<<"RSSB"<<endl
#define showzero cout<<std::showpoint
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) ((a*b)/gcd(a,b))
#define bitcount( x ) __builtin_popcountll( x )
#define br "\n"
#define sp " "
using namespace  std ;
typedef double db;
typedef long long ll ;
typedef vector<int>vi ;
//typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
typedef vector<pll>vpll;
typedef vector<string>vstr;
typedef vector<bool>vbool ;
void READ(vll &v, ll n){ll a ;for(ll i=0 ; i<n ; i=i+1){cin>>a ;v.pb(a);}}
void PRINT(vll &v , ll a = 0){for(ll i=a ; i<v.size() ; i=i+1){/*v[i] = max((ll)0,v[i]);*/cout<<v[i]<<" " ;}cout<<"" ;}
double logy(ll n , ll b){if(b==0){return(-1);}if(n==1){return(0);}return((db)log10(n)/log10(b));}
long long power(long long k , long long n , long long m=mod){long long res = 1;while(n){if(n%2!=0){res = (res*k)%m ;}k = (k*k)%m ;n = n/2 ;}return(res) ;}
double power(double k , long long n ){double res = 1;while(n){if(n%2!=0){res = (res*k) ;}k = (k*k) ;n = n/2 ;}return(res) ;}
double distance(pll a , pll b){return((db)(sqrt( sqr(a.fi-b.fi) + sqr(a.se-b.se))));}
const ll dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const ll dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
vpll dr;
void call(){dr.pb(mkp(1,0));dr.pb(mkp(-1,0));dr.pb(mkp(0,1));dr.pb(mkp(0,-1));}
ll n,m,k,h;
bool ok = false;
int main()
{
    FastIO;
    PRECISION(10);
    //FileIO;
    ll a,b,c,d,i,j,t,x,y,z;//,x1,y1,z1,e,f;
    ll p,q,r,u,w ;
    char ch,chr ;
    string str,st,str1,str2,str3,str4;
    //ll a1=0,a2=0,b1=0,b2=0,c1=0 ;
    //cin>>str>>str1;
    //Stay Motivated!!
    //Never use i for two or more nested loops!!
    //Range Query + Constructive + DSU +  Graph Theory + Math + DP + Bitmasks + Geometry + Brute Force + Greedy + Implementation + Binary Search
    //LIS->https://ideone.com/Vzvbyu
	cin>>str>>str1;
	st = str1.substr(0,sz(str));
	if(st==str)
	{
	    cout<<"Yes\n";
	}
	else
	{
	    cout<<"No\n";
	}
}

Measured memory_bytes: 3676
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecVec = vector<Vec>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll n, m, v, p;
	cin >> n >> m >> v >> p;
	Vec a(n);
	rep(i, n) cin >> a[i];
	sort(all(a));
	Vec sum(n-p+1);
	rep(i, n-p+1){
		sum[i] += a[i];
		if(i) sum[i] += sum[i-1];
	}
	rep(i, n){
		if(i >= n-p){
			co(n-i);
			break;
		}

		ll s = sum[n-p]-sum[i], b = a[i]+m;
		ll rest = (v-p-i)*m;
		//coVec({i, s, b, rest, b*(n-p-i-1)-s});
		if(b < a[n-p]) continue;
		if(b*(n-p-i)-s >= rest){
			co(n-i);
			break;
		}
	}

	return 0;
}


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

int main() {
  int N,K;
  cin >> N >> K;
  
  vector<long long>h(N);
  for (int i = 0; i < N; i++) {
    cin >> h.at(i);
  }

  sort(h.begin(), h.end());
  
  vector<long long>dis(N - K + 1);
  for (int i = 0; i < N - K + 1; i++) {
    dis.at(i) = h.at(i + K - 1) - h.at(i);
  }
  
  sort(dis.begin(), dis.end());
  
  cout << dis.at(0) << endl;
}
  
  

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

int main() {
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  int ans=0;
  for(int i=0;i<n;i++) ans+=a[i]-1;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int H, W;
  int h, w;
  cin >> H >> W >> h >> w;

  cout << (H - h) * (W - w) << endl;
  return 0;
}



Measured memory_bytes: 256
n,k=map(int, input().split())
A=[int(i) for i in input().split()]
ng=0
ok = max(A)
while(ng+1!=ok):
    mid = (ok+ng)//2
    ans = 0
    for i in A:
        ans += 0--i//mid-1
    if(ans<=k):
        ok = mid
    else:
        ng = mid
print(ok)


Measured memory_bytes: 30508
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
#include<list>
using namespace std;

struct bridge {
	int vala;
	int valb;
	bridge(int ia, int ib) {
		vala = ia;
		valb = ib;
	}
};

// 数値 vala でソートするための比較演算子
bool cmp(const bridge& a, const bridge& b) {
	return a.vala < b.vala;
}

int main() {

	int N, M;
	cin >> N >> M;

	int a, b;
	vector<bridge> bd;
	for (int i = 0; i < M; i++) {
		cin >> a >> b;
		bd.push_back(bridge(a, b));
	}

	// 中の悪い島の関係を小さい島の値 a でソート
	sort(bd.begin(), bd.end(), cmp);

	// 貪欲法で橋をなくす必要がある島同士を探索
	vector<int> edgea = { bd[0].vala };
	vector<int> edgeb = { bd[0].valb };
	for (int i = 0; i < bd.size(); i++) {
		// これまで壊した橋の領域では足りない場合
		if (edgeb.back() <= bd[i].vala) {
			// 新しい範囲を追加
			edgea.push_back(bd[i].vala);
			edgeb.push_back(bd[i].valb);
		}
		// これまで壊した橋の領域を延ばせばいい場合
		else {
			if (edgeb.back() > bd[i].valb) {
				// 範囲の右端を与える b の値を更新
				edgeb[edgeb.size() - 1] = bd[i].valb;
			}
			if (edgea.back() < bd[i].vala) {
				// 範囲の右端を与える b の値を更新
				edgea[edgea.size() - 1] = bd[i].vala;
			}
		}
	}

	int ans = edgea.size();

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1400
#include <stdio.h>

int main(void) {
	int N, a, b, c, x, i;
	scanf("%d", &N);
	for(i = 0; i < N; i++){
		scanf("%d %d %d", &a, &b, &c);
		if(a < b){
			x = a;
			a = b;
			b = x;
		}
		if(a < c){
			x = a;
			a = c;
			c = x;
		}
		if(a*a == b*b + c*c) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include<stdio.h>

int main(){
  int x,y,r,a;

  scanf("%d%d",&x,&y);

  if(((1<=x)&&(x<=1000000000))&&((1<=y)&&(y<=1000000000))){
    if(y>x){
      a=y;
      y=x;
      x=a;
    }

  while(y>0){
    r = x % y;
    x = y;
    y = r;
  }

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

  return 0;
}

  



Measured memory_bytes: 2056