akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int	main(void)
{
  	int	x;
  	int	y;
  	int z;
  	int num;
  
  	num = scanf("%d %d %d", &x, &y, &z);
  	printf("%d %d %d", z, x, y);
  	return (0);
  
}

Measured memory_bytes: 128
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())

const int INF = 1e9;


// code
// ------------------------------------------------
int main() {

  int x;

  cin >> x;

  int u,b,c;

  u = (x / 500) * 1000;

  x = x % 500;

  u = u +  (x / 5) * 5;

  cout << u;


  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <numeric>

#define rep(i, a, b) for (ll i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef unordered_map<string, ll> u_map;

// input
void input() {}
template <class Head, class... Tail>
void input(Head &&a, Tail &&... b)
{
    cin >> a;
    input(forward<Tail>(b)...);
}

template <class V>
void input(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &i) { input(i); });
}

// output
template <class V>
void output(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &x) { cout << x << " "; });
    cout << endl;
}

// math functions
ll mpow(ll a, ll n, ll p)
{
    ll x = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            x = a * x % p;
        }
        a = a * a % p;
        n >>= 1;
    }

    return x;
}

ll mfact(ll n, ll p)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
    {
        res = res * i % p;
    }
    return res;
}

ll mcomb(ll n, ll r, ll p)
{
    if (n == 0 && r == 0)
    {
        return 1;
    }
    if (n < r || n < 0 || r < 0)
    {
        return 0;
    }

    ll a = mfact(n, p);
    ll b = mfact(n - r, p);
    ll c = mfact(r, p);
    return (((a * mpow(b, p - 2, p)) % p) * mpow(c, p - 2, p)) % p;
}

ll gcd(ll a, ll b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

int main()
{
    ll N;
    input(N);

    vector<ll> cnt(1e5 + 1, 0);

    vector<ll> a(N);
    ll sum = 0;
    rep(i, 0, N)
    {
        ll data;
        cin >> data;

        sum += data;

        cnt[data] += 1;
    }

    ll Q;
    input(Q);

    rep(i, 0, Q)
    {
        ll b, c;
        input(b, c);

        ll m = b * cnt[b];
        ll p = c * cnt[b];

        sum += p - m;

        cnt[c] += cnt[b];
        cnt[b] = 0;

        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 4752
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
 
#include <bits/stdc++.h>
 
using namespace std;
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  
#define pb push_back
#define in insert
#define f first
#define s second
#define ll long long
#define dd double
  
const int mod = 1e9 + 7;
const int N = 2e5 + 7;
const int inf = 2e9;
const ll INF = 1e18;

map<int, int> m;

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	// freopen("*.in", "r", stdin);freopen("*.out", "w", stdout);
	int x, n, ans, mmin = inf;
	cin >> x >> n;
	for (int i = 0; i < n; i++) {
		int p;
		cin >> p;
		m[p] = 1;
	}

	for (int i = -200; i <= 200; i++) {
		if (m[i]) continue;
		if (abs(i - x) == mmin) {
			ans = min(ans, i);
		}
		if (abs(i - x) < mmin) {
			mmin = abs(i - x);
			ans = i;
		}
	} 
	cout << ans;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=998244353;
//const ll mod=1e9+7;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; }
    mint& operator-=(const mint a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { mint res(*this); return res+=a; }
    mint operator-(const mint a) const { mint res(*this); return res-=a; }
    mint operator*(const mint a) const { mint res(*this); return res*=a; }
    mint pow(ll t) const { if (!t) return 1; mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; }
    // for prime mod
    mint inv() const { return pow(mod-2); }
    mint& operator/=(const mint a) { return (*this) *= a.inv(); }
    mint operator/(const mint a) const { mint res(*this); return res/=a; }
};

vector<ll> inv,fact,invfact;
void mod_build(int n){  
  fact.resize(n+1); inv.resize(n+1); invfact.resize(n+1);
  fact[0]=inv[0]=invfact[0]=1; inv[1]=1;
  rep(i,n){
    fact[i+1]=fact[i]*(i+1)%mod;
    if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
    invfact[i+1]=invfact[i]*inv[i+1]%mod;
  }
}
ll perm(int n,int k){ if(n<0||k<0||k>n){ return 0; } else { return fact[n]*invfact[n-k]%mod; } }
ll comb(int n,int k){ if(n<0||k<0||k>n){ return 0; } else { return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod; }}
ll modpow(ll x,ll n){
  x%=mod; ll res=1;
  while(n>0){ if(n&1){res=res*x%mod;} x=x*x%mod; n>>=1; }
  return res;
}
ll modinv(ll a){ return modpow(a, mod-2); }

int main(){
  ll n,m,k;
  cin >> n >> m >> k;
  mod_build(mx);
  mint ans = 0;
  for(int i=0; i<=k; i++){
    mint tmp = m * modpow((m-1),n-1-i);
    tmp *= comb(n-1,i);
    ans += tmp;
  }
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 7952
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
//#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)

ll A,B;


int main()
{
	cin>>A>>B;
	int ans=0;
	while(A<=B){
		ans++;
		A*=2LL;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 764
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

n = int(input())
print(l[n-1])


Measured memory_bytes: 2940
import java.util.Scanner;
import java.util.ArrayList;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> a = new ArrayList<Integer>();
        for(int i = 0;i < N;i++){
            a.add(sc.nextInt());
        }
        long min = 100000000;
        for(int y = -100;y <= 100;y++){
            long sum = 0;
            for(int i = 0;i < N;i++){
                sum += (a.get(i) - y)*(a.get(i) - y);
            }
            min = Math.min(min,sum);
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 21588
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 200000

long long p[30];
void init(long long k){
p[0]=k;
f(i,29){
p[i+1]=p[i]*p[i];
p[i+1]=p[i+1]%MOD;
}
return;
}

long long po(long long x){
long long re=1;
f(i,30){
if(x%2==1){
re=re*p[i];
re=re%MOD;
}
x=x/2;
}
return re;
}



int main(){
vector<long long>a;
vector<long long>b;
	long long n,k;
	long long x,s, ans;

	scanf("%lld %lld", &n,&k);
init(k);
x=1;
while((x*x)<=n){
if(n%x==0){
a.push_back(x);
a.push_back(n/x);
}
x++;
}
sort(a.begin(),a.end());

f(i,a.size()){
x=(a[i]+1)/2;
s=po(x);
f(j,i){
if(a[i]%a[j]==0){
s+=(MOD-b[j]);
s=s%MOD;
}
}
b.push_back(s);
}
ans=0;
f(i,a.size()){
if(a[i]%2==0){
s=b[i]*(a[i]/2);
s=s%MOD;
ans+=s;
ans=ans%MOD;
}
else{
s=b[i]*a[i];
s=s%MOD;
ans+=s;
ans=ans%MOD;
}
}

	printf("%lld\n", ans);


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
#define int long long
#define MAX 100001
int a[MAX], b[MAX], c[MAX];
int n;

signed main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }

  sort(a, a + n);
  sort(c, c + n);
  int count = 0;
  for (int i = 0; i < n; i++) {
    int *ap = lower_bound(a, a + n, b[i]);
    int *cp = upper_bound(c, c + n, b[i]);
    count += (ap - a) * (c + n - cp);
    //cout << ap - a << " " << cp - c << endl;
  }
  cout << count << endl;
  return 0;
}


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

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> A(N),B(N);
    for ( int64_t i = 0; i < N; ++i){
        cin >> A.at(i) >> B.at(i);
    }
    
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    int64_t ans = 0;
    
    if ( N % 2 == 1 ){
        //奇数の場合
        int64_t idx = (N+1)/2;
        int64_t min = A.at(idx-1);
        int64_t max = B.at(idx-1);
        ans = max - min + 1;
    } else {
        //偶数の場合
        int64_t idx = N/2;
        int64_t Amin = A.at(idx-1);
        int64_t Bmin = B.at(idx-1);
        int64_t Amax = A.at(idx);
        int64_t Bmax = B.at(idx);
        int64_t min = Amin + Amax;
        int64_t max = Bmin + Bmax;
        
        int64_t lng = max - min + 1;
        
        ans = lng;
        
        
    }
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6364
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cctype>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<ctime>
#include<list>
#include<deque>
#include<bitset>
#include<fstream>
#define ld double
#define ull unsigned long long 
#define ll long long 
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair 
#define INF 1000000000
#define MOD 1000000007
#define MAXN 1000100
using namespace std;

vector<pii >G[MAXN];
vector<int>all[MAXN],newG[MAXN];
int n,m,newn,q[MAXN],was[MAXN],dist[MAXN],ptr[MAXN];

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++)
	{
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);x--;y--;
		G[x].push_back(pii(z,y));
		G[y].push_back(pii(z,x));
		all[z].push_back(x);
		all[z].push_back(y);
	}
	
	for(int i=0;i<n;i++)
	{
		was[i]=-1;
		sort(G[i].begin(),G[i].end());
		ptr[i]=0;
	}
	newn=n;
	
	for(int color=0;color<MAXN;color++)
	{
		if((int)all[color].size()==0)continue;
		for(int i=0;i<all[color].size();i++)
		{
			int x=all[color][i];
			if(was[x]==color)continue;
			
			queue<int>qu;
			was[x]=color;
			q[0]=x;
			qu.push(x);
			int e=1;
			while (!qu.empty())
			{
				int u=qu.front();
				qu.pop();
				while (ptr[u]<G[u].size())
				{
					int j=ptr[u],uu=G[u][j].first;
					if(uu!=color)break;
					int uuu=G[u][j].second;
					if(was[uuu]!=color)
					{
						q[e++]=uuu;
						qu.push(uuu);
						was[uuu]=color;
					}
					ptr[u]++;
				}
					
			}
			for(int j=0;j<e;j++)
			{
				newG[q[j]].push_back(newn);
				newG[newn].push_back(q[j]);
			}
			newn++;
		}
	}
	
	for(int i=0;i<newn;i++)dist[i]=-2;
	
	queue<int>qu;
	qu.push(0);
	dist[0]=0;
	
	while (!qu.empty())
	{
		int x=qu.front();
		qu.pop();
		for(int i=0;i<newG[x].size();i++)
		{
			int y=newG[x][i];
			if(dist[y]==-2)
			{
				dist[y]=dist[x]+1; 
				qu.push(y);
			}
		}
	}
	
	printf("%d\n",dist[n-1]/2);
	

	return 0;	
}  

Measured memory_bytes: 104064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    
    vector<int> ans(4);
    rep(i, n) {
        if (s[i]=="AC") ans[0]++;
        if (s[i]=="WA") ans[1]++;
        if (s[i]=="TLE") ans[2]++;
        if (s[i]=="RE") ans[3]++;
    }
    string x[4] = {"AC", "WA", "TLE", "RE"};
    rep(i, 4) {
        cout << x[i] << " x " << ans[i] << endl;;
    }
    
    
    return 0;
}


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

int main(){
	int N,M,X,Y,x,y;
	cin >> N >> M >> X >> Y;
	int maxx=-10000,miny=10000;
	for (int i = 0; i < N; ++i) {
		cin >> x;
		if(maxx < x) maxx = x;
	}
	for (int i = 0; i < M; ++i) {
		cin >> y;
		if(miny > y) miny = y;
	}
	if(maxx < miny && X < miny && maxx < Y) cout << "No War" << endl;
	else cout << "War" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <utility>
#include <map>
#include <stack>
#include <set>
#include <vector>
#include <queue>
#include <deque>
#include <sstream>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define LL long long
#define Pair pair<int,int>
#define LOWBIT(x) x & (-x)
using namespace std;

const int MOD=1e9+7;
const int INF=0x7ffffff;
const int magic=348;

int cnt[200048];
int a[100048];
int n;

int main ()
{
	int i;
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		a[i]++;
		cnt[a[i]-1]++;
		cnt[a[i]]++;
		cnt[a[i]+1]++;
	}
	int maxn=-1,max_pos;
	for (i=0;i<=100050;i++)
		if (cnt[i]>maxn)
		{
			maxn=cnt[i];
			max_pos=i-1;
		}
	printf("%d\n",maxn);
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
	int a ,b , c;
    scanf("%d %d %d" , &a , &b , &c);

	if(a < b ){
		if(b<c){
		  printf("Yes\n");
	    } else {
	        printf("No\n");
	    }
    }else {
	   printf("No\n");
		}
    return 0;
}

Measured memory_bytes: 580
#include <stdio.h>
     
int main(){
   int n,m;
   scanf("%d%d",&n,&m);
   for(int i=0; i<m; i++){
    	int t;
    	scanf("%d", &t);
    	n-=t;
    }
    if(n<0)
    puts("-1");
    else printf("%d", n);
 }

Measured memory_bytes: 1696
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__));in(name)
#define vvv(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
#define SYOU(x) fixed<<setprecision(x) //小数点桁数を指定する
inline int scan(){ return getchar(); }
inline void scan(int &a){ scanf("%d", &a); }
inline void scan(unsigned &a){ scanf("%u", &a); }
inline void scan(long &a){ scanf("%ld", &a); }
inline void scan(long long &a){ scanf("%lld", &a); }
inline void scan(unsigned long long &a){ scanf("%llu", &a); }
inline void scan(char &a){ cin >> a; }
inline void scan(float &a){ scanf("%f", &a); }
inline void scan(double &a){ scanf("%lf", &a); }
inline void scan(long double &a){ scanf("%Lf", &a); }
inline void scan(vector<bool> &vec){ for(unsigned i = 0; i < vec.size(); i++) { int a; scan(a); vec[i] = a; } }
inline void scan(string &a){ cin >> a; }
template<class T> inline void scan(vector<T> &vec);
template<class T, size_t size> inline void scan(array<T, size> &vec);
template<class T, class L> inline void scan(pair<T, L> &p);
template<class T, size_t size> inline void scan(T (&vec)[size]);
template<class T> inline void scan(vector<T> &vec){ for(auto &i : vec) scan(i); }
template<class T, size_t size> inline void scan(array<T, size> &vec){ for(auto &i : vec) scan(i); }
template<class T, class L> inline void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template<class T, size_t size> inline void scan(T (&vec)[size]){ for(auto &i : vec) scan(i); }
template<class T> inline void scan(T &a){ cin>>a; }
inline void in(){}
template <class Head, class... Tail> inline void in(Head &head, Tail&... tail){ scan(head); in(tail...); }
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;
int main(){
    INT(a);
    cout << a*a*a + a*a + a << endl;
}

Measured memory_bytes: 3720
import numpy as np
N, M = map(int, input().split())
H = list(map(int, input().split()))
ans = [1 for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    if H[a - 1] > H[b - 1]:
        ans[b - 1] = 0
    if H[b - 1] > H[a - 1]:
        ans[a - 1] = 0
    if H[b - 1] == H[a - 1]:
        ans[a - 1] = 0
        ans[b - 1] = 0
print(np.count_nonzero(np.array(ans)))


Measured memory_bytes: 38392
#include <bits/stdc++.h>
 
using namespace std;
 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
    ~debug() { cerr << endl; }
    eni(!=) cerr << boolalpha << i; ris; }
    eni(==) ris << range(begin(i), end(i)); }
    sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
    }
    sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
    }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<long double> vld;
typedef long long ll;
typedef long double ld;
#define PI 3.14159265358979323846
#define sqr(a) ((a) * (a))
#define len(V) (int)V.size()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define fix(a) fixed << setprecision(a)
#define readv(x) for(auto &_ : (x)) {cin >> _;}
#define printv(x) for(auto &_ : (x)) {cout << _ << ' ';} cout << endl
#define EPS 1e-6
#define MAXN 100047

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	ll n, x; cin >> n >> x;
	vi a(n); readv(a);
	
	sort(all(a));
	int res = 0;
	FOR(i, 0, n){
		if (i == n-1 && a[i] != x) break;
		if(a[i] <= x){
			res++;
			x -= a[i];
		}
	}
	
	cout << res << endl;
	
	return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int n,res=0;
  string s;
  size_t pos;
  cin >> n;
  cin >> s;
  pos=s.find("ABC");
  while(pos!=string::npos){
    res++;
    pos=s.find("ABC",pos+3);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.lang.AssertionError
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val MOD = 1_000_000_007L

class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val N = ns().map{it-'0'}
    out.println(if (N.sum() % 9 == 0) "Yes" else "No")
  }













































  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n) { ni() + offset }
  }
  private fun nal(n: Int, offset: Int = 0): LongArray {
    val res = LongArray(n)
    for (i in 0 until n) {
      res[i] = nl() + offset
    }
    return res
  }

  private fun na2(n: Int, offset: Int = 0): Array<IntArray> {
    val a  = Array(2){IntArray(n)}
    for (i in 0 until n) {
      for (e in a) {
        e[i] = ni() + offset
      }
    }
    return a
  }

  private inline fun map(n: Int, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private inline fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private inline fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private inline fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private inline fun debugDim(A: Array<LongArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }
  private inline fun debugDim(A: Array<IntArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }

  private inline fun assert(b: Boolean) = run{if (!b) throw AssertionError()}
}

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}


Measured memory_bytes: 40512
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<deque>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const double PI=acos(-1.0);
const double eps=1e-6; 
const ll mod=1e9+7;
const int inf=0x3f3f3f3f;
const int maxn=1e5+10;
const int maxm=100+10;
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll w[maxm],v[maxm];
ll dp[maxn];
int main()
{
	io();
	int N,W;
	cin>>N>>W;
	for(int i=1;i<=N;++i)
		cin>>w[i]>>v[i];
	for(int i=0;i<=W;++i)
		dp[i]=0;
	for(int i=1;i<=N;++i)
		for(int j=W;j>=w[i];--j){
			dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
		}
		cout<<dp[W]<<endl;
	return 0;
}


Measured memory_bytes: 1024
# coding: utf-8
# Your code here!
N,A=map(int,input().split())

X=list(map(int,input().split()))

dp=[[0]*2501 for i in range(50)]

for x in X:
    for i in range(49)[::-1]:
        for index,item in enumerate(dp[i]):
            if item!=0:
                dp[i+1][index+x]+=dp[i][index]
    dp[0][x]+=1

ans=0
for i in range(50):
    ans+=dp[i][A*(i+1)]

print(ans)


Measured memory_bytes: 4596
#include <bits/stdc++.h>
#include <boost/math/constants/constants.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

int main(){
    using namespace std;
    double pi = boost::math::constants::pi<double>();
    constexpr unsigned long dig = 20;
    unsigned long N, L;
    cin >> N >> L;
    vector<unsigned long> T(N);
    copy_n(istream_iterator<unsigned long>(cin), N, T.begin());
    double x{0}, y{0};
    vector<double> C(N), S(N);
    transform(T.begin(), T.end(), C.begin(), [&pi, &L](auto t){return cos(pi * t / L);});
    transform(T.begin(), T.end(), S.begin(), [&pi, &L](auto t){return sin(pi * t / L);});
    for(long i = 1; i < N; ++i){
        for(long j = 0; j < i; ++j){
            long t = N + 2 * (j - i);
            x += t * (C[i] * C[j] - S[i] * S[j]);
            y += t * (C[i] * S[j] + C[j] * S[i]);
        }
    }
    unsigned long t = N * (N - 1) * (N - 2) / 6;
    x /= t;
    y /= t;
    cout << setprecision(15) << fixed << endl;
    cout << x << " " << y << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    int64_t N;
    cin >> N;
    if (N < 3) {
        cout << N << endl;
    } else {
        int64_t max_ = 0;
        int64_t sum_ = 0;
        map<int, bool>d;
        for (int64_t i=1; i<N; i++) {
            sum_ += i;
            max_ = i;
            d[i] = true;
            if (i == N) {
                break;
            } else if (sum_ > N) {
                d[sum_-N] = false;
                break;
            }
        }

        for (auto c:d) {
            if (c.second) {
                cout << c.first << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
 
using namespace std;
using S = set<long long>;
using D = deque<long long>;
using L = vector<long long>;
using M = map<int,long long>;
using A = vector<vector<long long>>;
using Q = priority_queue<long long>;
using U = unordered_map<int,long long>; //mapとの違いはkeyの順番を保持していない

#define sorted(vector) sort(vector.begin(),vector.end()) //O(nlongn)
#define sortedreverce(vector) sort(vector.rbegin(),vector.rend()) //O(nlongn)
#define vmin(vector) *min_element(vector.begin(),vector.end()) //O(N)
#define vmax(vector) *max_element(vector.begin(),vector.end()) //O(N)
#define vsum(vector) accumulate(vector.begin(),vector.end(),0) //O(N)
#define vcount(vector,a) count(vector.begin(), vector.end(),a) //O(N)
#define bisect_left(vector,a) (lower_bound(vector.begin(),vector.end(),a)-vector.begin())
#define bisect_right(vector,a) (upper_bound(vector.begin(),vector.end(),a)-vector.begin())
#define vfind(vector,a) find(vector.begin(), vector.end(), a) != vector.end() //遅いからあんまり使うな
//存在確認はmap!!!!!!!!!!!!!か配列に埋め込んでcontinueで回避
//__gcd(a,b)はコンパイラがGCC時のみ


vector<long long> divisor_enumetarion(long long n){
    vector<long long> divisors;
    for(int i=1 ; i*i<=n ; i++){
        if(n%i == 0){
            divisors.push_back(i);
            if(i != n/i){
                divisors.push_back(n/i);
            }
        }
    }
    return divisors;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    long long n;
    cin>>n;
    L l(n,0);
    for(int i=0  ;i<n  ;i++){
        cin>>l[i];
    }
    sortedreverce(l);
    L l2=divisor_enumetarion(l[0]);
    L l3=divisor_enumetarion(l[1]);
    long long tmp,ans=0;
    
    for(auto x:l2){
//        cout<<x;
        tmp=0;
        for(int j=0  ;j<n  ;j++){
            tmp+=l[j]%x==0;
        }
        if (tmp>=n-1) ans=max(ans,x);
    }
    for(auto x:l3){
        tmp=0;
        for(int j=0  ;j<n  ;j++){
            tmp+=l[j]%x==0;
        }
        if (tmp>=n-1) ans=max(ans,x);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef struct pair<int,int> P;
typedef struct pair<int,P> P2;

vector<ll> v[28];
vector<ll> v2;

int dp[100001]={};
const ll INF=1000000000000000001;
int main() {

	int k;
	cin>>k;
	for(int i=0;i<k+1;++i)dp[i]=10000000;
	queue<P> que;
	que.push(P(1,1));
	while(!que.empty()){
		P p1=que.front();que.pop();
		int cost=p1.first;
		int pos=p1.second;
		if(dp[pos]>cost){
			dp[pos]=cost;
			int np=(pos*10)%k;
			que.push(P(cost,np));
			np=(pos*10+1)%k;
			que.push(P(cost+1,np));
		}
	}
	cout<<dp[0]<<endl;

	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define mx 100001
typedef long long L;
L n,k,mDis=0,bck=-1,dist=0;
char str[mx+5];
queue<L>q;
void solve(){
	L i,flg=0;
	for(i=0;i<n;i++){
		if(str[i]=='0'){
			while(i<n && str[i]=='0')i++;
			q.push(i-1);
			while(i<n&&str[i]=='1')i++;
			i--;
			if(q.size()==k){flg=1;
				mDis=(i-bck);
				dist=max(mDis,dist);
				bck=q.front();q.pop();
			}
		}
	}
	if(flg==0){
		dist=n;
	}
}

int main()
{
	scanf("%lld%lld",&n,&k);
	scanf("%s",&str);
	solve();
	printf("%lld\n",dist);
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

long long i,j,k,N,n,a,b,ans;

const long long MOD = 1000000007;



/////繰り返し二乗法
//// N^P(mod M)の計算

long long power(long long X,long long P,long long M)
{
  long long s;
  
  if(P==0)
  {
    return 1;
  }
  else if(P%2==0)
  {
    s=power(X,P/2,M);
    s*=s;
    s%=M;
    return s;
  }
  else
  {
    s=power(X,P-1,M)*X;
    s%=M;
    return s;
  }
}

///二項係数

long long comb(long long X,long long Y)
{
  long long s,t,u;
  
  s=1;
  for(t=1;t<=Y;t++)
  {
    s*=t;
    s%=MOD;
  }
  
  s=power(s,MOD-2,MOD);
    
  u=1;
  for(t=X;t>=X-Y+1;t--)
  {
    u*=t;
    u%=MOD;
  }
  
  s=s*u;
  s%=MOD;
  
  return s;
}

int main()
{
  cin >>n>>a>>b;
  
  ans=power(2,n,MOD)-1;
  ans-=comb(n,a);
  if(ans<0)
  {
    ans+=MOD;
  }
  ans-=comb(n,b);
  if(ans<0)
  {
    ans+=MOD;
    
  }
  
  cout<<ans;
  
}

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

using namespace std;

const int MAXN = 101;
const int INF = 1e7;
int arr[MAXN],sum[MAXN];
int n,ans;

int main() {

	cin >> n;

	ans = INF;

	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		if (i == 0)sum[i] = arr[i];
		else sum[i] = sum[i - 1] + arr[i];
	}

	for (int i = 0; i < n; i++) {
		int a = sum[i];
		int b = sum[n - 1] - sum[i];
		int diff = abs(a - b);

		ans = min(ans, diff);
	}

	cout << ans << "\n";

	

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<map>
using namespace std;
#define ll long long
ll d[100010];
int a[100010];
map<ll,int>p;
int main()
{
    int n;
    ll m,maxi=0;
    scanf("%d%lld",&n,&m);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    for(int i=1;i<=n;i++)
        d[i]=d[i-1]+a[i];
    for(int i=1;i<=n;i++)
        d[i]%=m;
    for(int i=0;i<=n;i++)/*******如果前缀和为m的倍数，则选择方案不为C(N,2)，应考虑首项0即C(N+1,2)***********/
        p[d[i]]++;
    for(int i=1;i<=n;i++)
    {
        if(p[d[i]]>1)
        {
            int t=p[d[i]];
            p[d[i]]=-1;
            maxi+=(ll)t*(t-1)/2;
        }
    }
    printf("%lld\n",maxi);
    return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
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; }
using Graph = vector<vector<int>>;
struct edge{int from,to,cost;};
signed main(){
  double a;
  cin>>a;
  cout<<setprecision(14)<<(a*a*a)/27<<endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(i,e) for(ll i=0;i<e;i++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT32_MAX;
ll i;


int main(){
    ll X,Y;
    cin>>X>>Y;
    cout<<X+Y/2<<endl;
}


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

main () {
  ll n, m;
  scanf("%lld %lld", &n, &m);

  ll ans;
  //nとmが2以上の場合
  //1.  四隅のカードは4回ひっくり返る
  //    従って、それらの最終状態は表
  //2.  四隅を除く辺上のカードは6回ひっくり帰る
  //    従って、それらの最終状態は表
  //3.  四辺に含まれない内部のカードは9回ひっくり返る
  //    従って、それらの最終状態は裏
  //->以上より、内部に存在するカードの枚数が答えとなる。
  if (n > 1 && m > 1) {
    ans = (n - 2) * (m - 2);
  }
  //それ以外の場合でどちらかが2以上のとき（一列になっているとき）
  //1.  端点は2回ひっくり返る
  //    従って、表
  //2.  端点以外は3回ひっくり返る
  //従って、答えは端点以外の数
  else if (n > 1 || m > 1) {
    ans = n * m - 2;
  }
  //それ以外の場合は1
  else {
    ans = 1;
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 256
N, Y = map(int,input().split())

def answer():
    for n_10000 in range(N+1):
        for n_5000 in range(N+1):
            n_1000 = N - n_10000 - n_5000
            if n_1000 < 0:
                continue
            if n_10000 * 10000 + n_5000 * 5000 + n_1000 * 1000 == Y:
                return (n_10000, n_5000, n_1000)
    return (-1, -1, -1)
                
print(" ".join(list(map(str,answer()))))

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
	long long n,d,x,y,s=0;
	cin>>n>>d;
	for(int i=0;i<n;i++)
	{
		cin>>x>>y;
		if(x*x+y*y<=d*d)s++;
	}
		
	cout<<s;
	return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

typedef long long ll;
typedef long double ld;


int main(){
    ll N;
    cin >> N;
    
    vector<ll> L(N,0);
    rep(i,N) cin >> L[i];
    ll ans = 0;
    sort(all(L));
    
    
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < i; ++j) {
            for (int k = 0; k < j; ++k) {
                if (L[k] != L[j] and L[i] != L[j] and
                    L[k] + L[j] > L[i]) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}


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

int main()
{

ll n;
cin>>n;
int A[100+2], B[100+2][100+2];
for(int i=1;i<=n;i++)cin>>A[i];
for(int i=1;i<=n;i++)
{
    for(int j=1;j<=n;j++)
    {
        B[i][j]=A[i]*A[j];
        if(i==j)B[i][j]=0;
    }
}
ll sum=0;
for(int i=1;i<=n;i++)
{
    for(int j=1;j<=n;j++)
    {
    sum+=B[i][j];
    B[j][i]=0;
    }

}

cout<<sum;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i<N; i++)
#define RVROOP(i, N) for(int i=N; i>=0; i--)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
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 k=0, d=1;
  int ans=0;
  while(k<N){
    if(A[k]==d){
      d++;
    }
    else{
      ans++;
    }
    k++;
  }
  if(ans>N-1){
    ans=-1;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

const string YES = "";
const string NO  = "";

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

    int x, a, b;

    cin >> x >> a >> b;

    x -= a;

    while (x >= b) {
        x -= b;
    }

    cout << x << endl;

    return 0;
}



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

int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }

int main() {
    string S, T;
    cin >> S >> T;



    int intAmari = S.length() - T.length();

    int intSlen = S.length();
    int intTMin = T.length();

    int intCount = 0;

    for (int i = 0; i <= intAmari; ++i)
    {

        intCount = 0;

        for (int num = 0;num < T.length();num++)
        {
            if (S.substr(num + i, 1) != T.substr(num, 1))
            {
                intCount++;
            }
        }

        intTMin = min(intTMin, intCount);
    }

    cout << intTMin;

    return 0;
}

Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(reader.readLine());
		boolean flag = false;
		outer:
		for (int A = 1; A <= 9; A++) {
			for (int B = 1; B <= 9; B++) {
				if (N == A * B) {
					System.out.println("Yes");
					flag = true;
					break outer;
				}
			}
		}
		if (!flag) {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % moder;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), moder - 2, moder) % moder * mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/


signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a < c && c < b)cout << "Yes" << endl;
	else if (b < c && c < a)cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
//#define TEST

int main(int argc, char** argv) {
    //ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\stdout", "w", stdout);
    }

    int N, K;
    cin >> N >> K;
    vector<int> v(N);
    FOR(i, N)
        cin >> v[i];

    ll sol = 0;
    for(int putback = 0; putback < K; putback++){
        for(int a=0; a<=K-putback && a <= N; a++){
            int b = K-putback-a;
            vector<int> u;
            FOR(i, a)
                u.push_back(v[i]);
            for(int i=v.size()-1; i>v.size()-1-b && i>=a; i--)
                u.push_back(v[i]);

            sort(u.begin(), u.end());
            ll sum = 0;
            int canput = putback;
            for(int ui : u) {
                if (ui >= 0)
                    sum += ui;
                else {
                    if (canput > 0)
                        canput--;
                    else
                        sum += ui;
                }
            }
            sol = max(sol, sum);
        }
    }
    cout << sol << '\n';

    if (argc == 2 && atoi(argv[1]) == 123456789)
        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}


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

int main(void) {
	int n, s, a = 0, b = 0; cin >> n;
	vector<int> v;
	for (int i = 0; i < n; i++) {
		cin >> s;
		v.push_back(s);
	}
	int max;
	for (int i = 0; i < n; i++) {
		max = *max_element(v.begin(), v.end());
		if (i % 2 == 0) { a += max; }
		else { b += max; }
		*max_element(v.begin(), v.end()) = 0;
	}
	cout << a - b;

	return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import Data.List
import Text.Printf
import qualified Data.ByteString.Char8 as C

getInts :: IO [Int]
getInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  [n] <- getInts
  ps <- replicateM n getInts
  let as = sort $ map (\[x, y] -> x + y) ps
      bs = sort $ map (\[x, y] -> x - y) ps
      f xs = last xs - head xs
  printf "%d\n" $ maximum [f as, f bs]


Measured memory_bytes: 99116
/*
 * atcoder/abc136/e.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
void solve();
int main() { solve(); return 0; }

vector<ll> dividers(ll n) {
  vector<ll> D;
  for (int i=1; i*i<=n; i++) {
    if (n%i==0) {
      D.push_back(i);

      if (i*i!=n) D.push_back(n/i);
    }
  }
  return D;
}

int n, k;
ll s = 0;
vector<ll> A, D;
bool check(ll d) {
  vector<ll> R, acc_l, acc_u;
  for (auto&& a: A) {
    if (a%d != 0) R.push_back(a%d);
  }
  sort(R.begin(), R.end());
  int m = R.size();
  acc_l.resize(m+1);
  acc_u.resize(m+1);

  acc_l[0] = acc_u[0] = 0;
  for (int i=1; i<=m; i++) {
    acc_l[i] = acc_l[i-1] + R[i-1];
    acc_u[i] = acc_u[i-1] + (d - R[i-1]);
  }

  ll min = 100000000000;
  for (int i=0; i<=R.size(); i++) {
    chmin(min, max(acc_l[i], acc_u[m] - acc_u[i]));
  }

  return min <= k;
}

void solve() {
  cin >> n >> k;
  A.resize(n);
  loop(i,0,n) {
    cin >> A[i];
    s += A[i];
  }

  D = dividers(s);
  sort(D.rbegin(), D.rend());

  for (auto&& d: D) {
    if (check(d)) {
      cout << d << endl;
      return;
    }
  }

  cout << -1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  double xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2;
  while( cin >>xa1>>ya1>>xa2>>ya2>>xb1>>yb1>>xb2>>yb2 ){
  if(!(xb2 < xa1 || xa2 < xb1 || ya1 > yb2 || ya2 < yb1 ))cout << "YES"<<endl;
  else cout << "NO" << endl;
  }
  return 0;
}

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

int main(){
	int n, d;
	cin >> n >> d;
	int a = n/(2*d+1);
	if(n%(2*d+1) != 0) a++;
	cout << a << endl;
}

Measured memory_bytes: 256
(n,s),a,b=$<.map{_1.split.map &:to_i}
b.reverse!
n.times{|i|$*[v=a[i]]||=i;v!=b[i]||(s=v;$r=i)}
puts n<(a+b).count(s)?:No:[:Yes,$r?(t=[s])*(k=[$*[s],b[..$r].count(s)].min)+(b-t)+t*=b.count(s)-k:b]

Measured memory_bytes: 59504
n=int(input())
a=[i for i in input().split(" ")]
b=a.copy()
flg=1

while flg:
    flg=0
    for j in range(n-1,0,-1):
        if a[j][1] < a[j-1][1]:
           a[j-1],a[j]=a[j],a[j-1]
           flg=1  

for i in range(n):
    mi=i
    for j in range(i,n):
        if b[j][1] < b[mi][1]:
            mi = j
    if i != mi:
        b[i],b[mi]=b[mi],b[i]

print(" ".join([str(i) for i in a]))
print("Stable")
print(" ".join([str(i) for i in b]))
if a==b:
    print("Stable")
else:
    print("Not stable")

Measured memory_bytes: 7832
N,M=map(int,input().split())
X=sorted(list(map(int,input().split())))
if N>=M:
  print(0)
  exit()
else:
  D=[0]*M
  for i in range(M-1):
    D[i]=X[i+1]-X[i]
  print(sum(sorted(D)[:M-N+1]))

Measured memory_bytes: 13968
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>

using namespace std;

#define FOR(i,a,b) for(long long int i=(a);i<(b);i++)
#define REP(i,N) for(long long int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI 3.14159265358479

typedef long long ll;

int n, k, a, b;

int main(){
	cin >> n >> k;
	REP(i, k){
		cin >> a >> b;
		if (a > n / 2){
			a = n - a + 1;
		}
		if (b > n / 2){
			b = n - b + 1;
		}
		(min(a, b) % 3 == 0) ? cout << 3 << endl : cout << min(a, b) % 3 << endl;
	}
}

Measured memory_bytes: 1164
#include <stdio.h>

inline int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a%b);
}

inline int lcm(int a, int b) {
    if (a < b)
        return a * b / gcd(b, a);
    return a * b / gcd(a, b);
}

int main() {
    int n, i, a, l;

    scanf("%d", &n);
    scanf("%d", &a);

    l = a;
    for (i = 1; i < n; i++) {
        scanf("%d", &a);
        l = lcm(a, l);
    }
    printf("%d\n", l);

    return 0;
}

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

m = 1000
k = 0
for i in range(N-1):
    if A[i] > A[i+1]:
        m += k * A[i]
        k = 0
    elif A[i] < A[i+1]:
        m += k * A[i]
        k = m // A[i]
        m -= k * A[i]
    else:
        pass
m += (k * A[-1])
print(m)


Measured memory_bytes: 9124
/*****************************************************

Code by: Vichitr
Compiled On: 23rd March 2019

*****************************************************/

#include<bits/stdc++.h>
#define MAX 9223372036854775807
#define endl "\n"
#define ll long long
#define int long long
#define pb push_back
#define pf pop_front
#define mp make_pair
#define loop(i,n) for(int i=0;i<n;i++)
#define fast ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define ip pair<int, int>
#define N 100007
const ll MOD = 1e9+7;
const ll SZ = 107;

vector<int> adj[N];
int dp[N];

int solve(int i)
{
    if(dp[i]!=-1)
        return dp[i];
    dp[i] = 0;
    for(auto j: adj[i])
        dp[i] = max(dp[i], 1+solve(j));
    return dp[i];
}

signed main()
{
    fast;

    int n, m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int x, y;
        cin>>x>>y;
        adj[x].pb(y);
        //adj[y].pb(x);
    }
    memset(dp, -1, sizeof(dp));
    int ans = 0;
    for(int i=1;i<=n;i++)
    {
        ans = max(ans, solve(i));
    }    
    cout<<ans;
    return 0;
}


Measured memory_bytes: 7936
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int x;
    cin >> x;
    vector<int> a(x+1);
    if(x==1)cout << 1 << endl;
    else{
    for(int i=2;i<=x;i++){
        int num1=i;
        int num2=i;
        while(num1*num2<=x){
            num1=num1*num2;
            a.at(num1)++;
        }
    }
    for(int i=x;i>=0;i--){
        if(a.at(i)>0){
            cout << i << endl;
            break;
        }
    }
    }
}


Measured memory_bytes: 3624
#include<iostream>

using namespace std;

int main(){

	int ans;

	int a[4],temp,kake,op[4];


	cin >>temp;

	kake=1000;

	for(int i=0; i<4; i++){
		
		a[i] =temp/kake;

		//cout <<a[i] <<endl;
		temp=temp-kake*a[i];
		kake=kake/10;
		
	}


	for(int k=-1; k<2; k=k+2){
		for(int j=-1; j<2; j=j+2){
			for(int i=-1; i<2; i=i+2){

				ans=a[0]+a[1]*k+a[2]*j+a[3]*i;
				op[0]=k;
				op[1]=j;
				op[2]=i;
				if(ans == 7) {

					for(int l=0; l<4; l++){

						cout<<a[l];
						if(op[l] >= 0 && l<3) cout <<"+";
						else if(op[l] < 0 && l<3) cout <<"-";

						if(l==3){
							
							cout <<"=7" <<endl;
							return 0;
						}
					}
				

			}
		}


	}
	}

}

Measured memory_bytes: 256