akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring>
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//2-dim:vector<vector<Type>> vv(n, vector<Type>(m, d));
//3-dim:vector<vector<vector<Type>>> vvv(n, vector<vector<Type>>(m, vector<Type>(l, d)));

signed main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n),b(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    sort(ALL(b),greater<int>());
    int now=0;
    int pl=n-1;
    rep(i,n){
        if(a[i]==b[i]){
            if(now<n&&b[now]!=a[i]&&a[now]!=b[i]){
                int tmp=b[now];
                b[now]=b[i];
                b[i]=tmp;
                now++;
            }else if(0<=pl&&b[pl]!=a[i]&&a[pl]!=b[i]){
                int tmp=b[pl];
                b[pl]=b[i];
                b[i]=tmp;
                pl--;
            }
        }
    }
    //rep(i,n) cout << b[i] << " ";
    rep(i,n){
        if(a[i]==b[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    rep(i,n) cout << b[i] << " ";
    cout << endl;
}




Measured memory_bytes: 4784
#include <stdio.h>
#include <string.h>
#define MAXLINE 100

int
main(void)
{
    int n, score1, score2, cmp;
    char card1[MAXLINE + 1], card2[MAXLINE + 1];

    score1 = score2 = 0;

    for (scanf("%d", &n); n > 0; n--) {
        scanf("%s %s", card1, card2);
        cmp = strcmp(card1, card2);
        if (cmp > 0)
            score1 += 3;
        else if (cmp < 0)
            score2 += 3;
        else
            score1++, score2++;
    }

    printf("%d %d\n", score1, score2);

    return 0;
}


Measured memory_bytes: 2104
#include "bits/stdc++.h"
#include <cmath>

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main() {
    int N;
    cin >> N;
    vector<int> A(N + 2);
    A[0], A.back() = 0;
    for(int i = 1; i < N + 1; i++) cin >> A[i];
    ll sum = 0;
    for(int i = 0; i < N + 1; i++) sum += abs(A[i + 1] - A[i]);
    for(int i = 1; i < N + 1; i++){
        int dif = abs(A[i + 1] - A[i - 1]) - abs(A[i] - A[i - 1]) - abs(A[i + 1] - A[i]);
        cout << sum + dif << endl;
    }

}

Measured memory_bytes: 1664
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

int main() {
	int n;
	cin >> n;
	cout << n / 3 << endl;
}

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

int main(){
	
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	
	if ( a == 0 )
		cout << '1' << endl;
	else if ( b == 0 )
		cout << '2' << endl;
	else if ( c == 0 )
		cout << '3' << endl;
	else if ( d == 0 )
		cout << '4' << endl;
	else 
		cout << '5' << endl;
}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
#include <set>
#include <vector>
using namespace std;
#define rep(i,n) for(ll i = 0; i < n; ++i)
#define Rep(i,n) for(ll i = 0; i <= n; ++i)
#define yes "yes"
#define Yes "Yes"
#define no "no"
#define No "No"

namespace mydef
{
  void say(string some){
    cout << some << "\n";
  }
} // namespace mydef
using namespace mydef;
typedef long long ll;
const int INF = 1001001001;
const long double PI=3.14159265358979323846;

//ここからいじる
vector<int> to[100005];

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  ll n, m, a, b;
  cin >> n >> m;
  rep(i, m){
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  queue<int> q;
  vector<int> dist(n, INF);
  vector<int> pre(n, -1);
  dist[0] = 0;
  q.push(0);
  while (!q.empty())
  {
    int v = q.front(); q.pop();
    for(int u : to[v]){
      if(dist[u] != INF) continue;
      dist[u] = dist[v] + 1;
      pre[u] = v;
      q.push(u);
    }
  }
  cout << "Yes" << "\n";
  rep(i, n){
    if(i == 0)continue;
    int ans = pre[i];
    ++ans;
    cout << ans << "\n";
  }
  
  return 0;
}  

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

int main() {
  ll n,k;cin>>n>>k;
  vector<P> v(n);
  rep(i,n){
    cin>>v.at(i).first>>v.at(i).second;
  }
  sort(v.begin(),v.end());
  ll sum = 0,i = 0;
  bool ok = true;
  while(ok){
    sum+=v.at(i).second;
    if (sum>=k){
      cout << v.at(i).first << endl;
      break;
    }
    i++;
  }
  return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>

int cnt[10001];

int main()
{
	int n;
	scanf("%d", &n);
	for (int x = 1; x * x <= n; ++x)
	{
		for (int y = 1; y * y <= n; ++y)
		{
			for (int z = 1; z * z <= n; ++z)
			{
				int d = x * x + y * y + z * z + x * y + y * z + z * x;
				if (d <= n)
				{
					cnt[d] += 1;
				}
			}
		}
	}
	for (int i = 1; i <= n; ++i)
	{
		printf("%d\n", cnt[i]);
	}
	return 0;
}


Measured memory_bytes: 1684
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N = 2e5 + 10;

LL n, k, ans;

int main() {
	cin >> n >> k;
	for (LL i = 1; i <= k; ++i) {
		if (3 * i % k == i % k) {
			LL x = n / k + (n % k >= i);
			//	cout <<x << endl;
			ans += x * x * x;
		}
	}
	cout << ans << endl;
}


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

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

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

    size_t N;
    cin >> N;

    vector<int64_t> h(N);
    for (auto &hi: h) cin >> hi;

    vector<int64_t> dp(N);
    for (size_t i = 1; i < N; ++i) {
        if (i == 1) {
            dp[i] = abs(h[i] - h[i - 1]);
        } else {
            int64_t value1 = dp[i - 1] + abs(h[i] - h[i - 1]);
            int64_t value2 = dp[i - 2] + abs(h[i] - h[i - 2]);
            dp[i] = min(value1, value2);
        }
    }

    cout << dp[N - 1] << "\n";

    return 0;
}


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

#define N (int)(1e5)
#define ll long long
#define MAX (ll)(1e9)

int n;
ll a[N+1];

ll solve(int o, bool print=false)
{
	ll x[N+1];
	x[0] = o;
	for(int i = 1; i <= n; i++)
	{
		x[i%n] = (2*a[(i+n-1)%n]) - x[(i+n-1)%n];
	}
	ll ok = 0;
	for(int i = 0; i < n; i++)
	{
		ok += a[i] - (x[i]/2 + x[(i+1)%n]/2);
	}
	if(print)
	{
		for(int i = 0; i < n; i++)
			cout << x[i] << " ";
		cout << endl;
	}
	return ok;
}

int main() {
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		//cout << a[i] << " ";
	}
	//cout << endl;
	ll lo = -1;
	ll hi = max(a[0],a[n-1])+1;
	while(hi-lo>1)
	{
		ll mid = (lo+hi)/2;
		ll ans = solve(2*mid);
		if(ans < 0)
		{
			lo = mid;
		}
		else
		{
			hi = mid;
		}
	}
	//cout << hi << endl;
	solve(2*hi,1);
	//solve(0,1);
	return 0;
}

Measured memory_bytes: 2816
import collections
N = int(input())
A = list(map(int, input().split()))
count = collections.Counter(A)
count = count.most_common()
count.sort()
count.reverse()
ans = []
for i in range(len(count)):
    if len(ans) == 0:
        if count[i][1] >= 4:
            ans.append(count[i][0])
            ans.append(count[i][0])
    if count[i][1] >= 2:
        ans.append(count[i][0])
        if len(ans) >= 2:
            break
if len(ans) < 2:
    print(0)
else:
    print(ans[0] * ans[1])


Measured memory_bytes: 21660
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define debug(x) cout << x << endl
#define PI acos(-1)
const int INF = 1e9;
const LL INF64 = 1e18;

const int NMAX = 1e5 + 5;

int main() {
	LL a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(a - c) <= d) {
		cout << "Yes" << endl;
		return 0;
	} else if (abs(a - b) <= d && abs(b - c) <= d) {
		cout << "Yes" << endl;
	} else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<string>
#define REP(i,a,b) \
for(int i=a; i<b; i++)
#include<bits/stdc++.h>
#include<algorithm>
#define ll long long int
typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define present(c,x) ((c).find(x) != (c).end())
#define tr(c,i) for(typeof(c.begin()) i = (c).begin(); i != (c).end();i++)
int main()
{
	int n,d;
	cin >> d >> n;
	int ans;
	if(d == 0)ans=n;
	if(d == 0 && n == 100)ans = 101;
	if(d == 1)ans = 100*n;
	if(d == 1 && n == 100)ans = 10100;
	if(d == 2)ans = 10000*n;
	if(d == 2 && n == 100)ans = 1010000;
	cout << ans;
}


Measured memory_bytes: 256
#include <stdio.h>
int CountDivisors(int a,int b, int c){
	
	int i,count=0;
	for(i=a;i<=b;i++){
		if(c%i==0){
			count++;
		}
	}
	return count;
}


int main(void)
{
	int a=0,b=0,c=0;
	int count=0;
	scanf("%d %d %d",&a,&b,&c);
	count=CountDivisors(a,b,c);
	printf("%d\n",count);
	
	return 0;
}

Measured memory_bytes: 596
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
using ll = long long;
using db = long double;
const int N = 1 << 17, MOD = 1e9 + 7;
int main(){
#ifdef ONLINE_JUDGE
  ios_base::sync_with_stdio(0);cin.tie(0);
#endif // ONLINE_JUDGE


  int n,  l;
  cin >> n >> l;
  int sum = n * (n - 1) / 2 + l * n;
  int mn = 1e9;
  for(int i = 0; i < n; i++){
      if(abs(l+i) < abs(mn))
      mn = l + i;
  }

  cout << sum - mn << '\n';


  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int L[55];
int sum[55];

int search(int MIN){
	int dp[55];
	memset(dp,-1,sizeof(dp));

	for (int i = 1;i <= n;i++){
		int next = INT_MAX;
		for (int j = i-1;j >= 0;j--){
			int a = sum[i]-sum[j];
			if(a >= MIN && (dp[j] != -1 || j == 0)){
				if(i == n && j == 0) continue;
				next = min(next,max(dp[j],a));
			}
		}
		dp[i] = next;
	}
	return dp[n]-MIN;
}

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

	cin >> n;

	sum[0] = 0;
	for (int i = 0;i < n;i++){
		cin >> L[i];
		sum[i+1] = sum[i]+L[i];
	}

	int ans = INT_MAX;
	for (int i = 0;i < n;i++){
		for (int j = i+1;j <= n;j++){
			ans = min(ans,search(sum[j]-sum[i]));
		}
	}

	cout << ans << endl;

	return 0;

}



Measured memory_bytes: 3180
#include <bits/stdc++.h>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INF=INT_MAX;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))



int main(){
	int n,m;
	cin>>n>>m;
	vector<int>c(m);
	vector<int>dp(n+1,INT_MAX);
	REP(i,m)cin>>c[i];
	SORT(c);
	dp[0]=0;
	REP(cost,n+1){
		REP(j,m)if(cost+c[j]<=n){
			dp[cost+c[j]]=min(dp[cost+c[j]],dp[cost]+1);
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 1292
def ascan; gets.split.map(&:to_i); end

vtx = [0,0,0,0]

3.times do |i|
    u,v = ascan
    u -= 1
    v -= 1
    vtx[u] += 1
    vtx[v] += 1
end

c1 = vtx.count(1)
c2 = vtx.count(2)

if c1 == 2 && c2 == 2
    puts "YES"
else
    puts "NO"
end

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

int main(){
	string week[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	string f;
	cin >> f;
	int ans;
	rep(i,7){
		if(f == week[i]) ans = 7-i;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int dy[4]={1,0,-1,0};
int dx[4]={0,1,0,-1};
vector<vector<int>> graph;

bool sort_sec(const pair<int,int> &a,const pair<int,int> &b){
   if(a.second<b.second){
      return true;
   }
   return false;
}

void swap(int *a,int *b){
   int temp=*a;
   *a=*b;
   *b=temp;
}

int main(void){
   int N,W;
   cin>>N>>W;
   vector<long long> w(N),v(N);
   for(int i=0;i<N;i++){
      cin>>w[i]>>v[i];
   }
   vector<vector<long long>> dp(N+1,vector<long long>(W+1));
   for(int i=0;i<=N;i++){
      for(int j=0;j<=W;j++){
         dp[i][j]=0;
      }
   }
   for(int i=0;i<N;i++){
      for(int j=0;j<=W;j++){
         if(w[i]<=j){
            dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
         }else{
            dp[i+1][j]=dp[i][j];
         }
      }
   }
   cout<<dp[N][W]<<endl;
   return 0;
}

Measured memory_bytes: 80256
n, y = list(map(int, input().split()))
result = [-1, -1, -1]
for m_10000 in range(n + 1):
    for m_5000 in range(n + 1 - m_10000):
        m_1000 = n - m_10000 - m_5000
        k = 10000 * m_10000 + 5000 * m_5000 + 1000 * m_1000
        if k == y:
            result = [m_10000, m_5000, m_1000]
            break

    else:
        continue
    break
print("{} {} {}".format(result[0], result[1], result[2]))

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

#define ll long long

using namespace std;

//memset(dp, 0, sizeof(dp));

void work(int T) {
	
	ll n, res = 0;
	cin >> n;
	vector<ll> a(n);
	
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.rbegin(), a.rend());
	int l = 0, c = 1;
	for(int i = 0; i < n - 1; i++) {
		res += a[l];
		c++;
		if(c == 2) {
			l++;
			c = 0;
		}
	}
	cout << res << endl;
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
	// int t;
	// for(cin >> t; t > 0; t--) {
		// work(t);
	// }
	work(0);
	return 0;
};

Measured memory_bytes: 4756
N = int(input())
S = str(input())
S = list(S)

if N%2 != 0:
    print('No')
    exit()

S1, S2 = [], []
for i, s in enumerate(S):
    if i < (N/2):
        S1.append(s)
    else:
        S2.append(s)

s1 = ' '
for s in S1:
    s1 += s

s2 = ' '
for s in S2:
    s2 += s

if s1 == s2:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
from collections import defaultdict

n = int(input())
v = list(map(int, input().split()))
v1 = [v[i] for i in range(0, n, 2)]
v2 = [v[i] for i in range(1, n, 2)]

cnt1 = defaultdict(int)
cnt2 = defaultdict(int)
for x in v1:
  cnt1[x] += 1
for x in v2:
  cnt2[x] += 1
vc1 = []
vc2 = []
for k, v in cnt1.items():
  vc1.append((v, k))
for k, v in cnt2.items():
  vc2.append((v, k))
vc1.sort()
vc1.reverse()
vc2.sort()
vc2.reverse()

vc1.append((0, vc1[0][0] + 1))
vc2.append((0, vc2[0][0] + 1))

ans = n
for _, x1 in vc1[:2]:
  for _, x2 in vc2[:2]:
    if x1 == x2: continue
    s = 0
    for x in v1:
      if x != x1: s += 1
    for x in v2:
      if x != x2: s += 1
    ans = min(ans, s)
print(ans)

Measured memory_bytes: 20784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int N;
    cin >> N;
    vector<ll> A(N+2);
    A[0] = A[N+1] = 0;
    for (int i = 1; i <= N; i++) cin >> A[i];

    ll sum = 0;
    for (int i = 1; i <= N+1; i++) {
        sum += abs(A[i] - A[i-1]);
    }

    // とりやめる
    for (int i = 1; i <= N; i++) {
        cout << sum - abs(A[i] - A[i-1]) - abs(A[i+1] - A[i]) + abs(A[i+1] - A[i-1]) << endl;
    }

    return 0;
}


Measured memory_bytes: 2048
#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 TRAV(a, x) for(const auto& a : x)
#define ALL(x) x.begin(), x.end()
#define NEXT_PERM(x) while(next_permutation(ALL(x))) // 순열 알고리즘(오름)
#define PREV_PERM(x) while(prev_permutation(ALL(x))) // 순열 알고리즘(내림)
#define PRINT(x) cout << x
#define PRINT_LN(x) cout << x << endl;
#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("")

typedef long long int ll;
typedef string s;
typedef int i;
typedef char c;
typedef vector<int> vi;
typedef vector
 vs;

int gcd(int a, int b);
int lcm(int a, int b);


void solve() {
  ll n,r;
  cin >> n >> r;
  if (n < 10) r += 100 * (10 - n);
  PRINT(r);
}
 
int main() {
  solve();
  return 0;
}

int gcd(int a, int b){
	while(b!=0){
		int r = a%b;
		a= b;
		b= r;
	}
	return a;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
  int n;
  cin >> n;
  int ans = 1;
  int h[n];
  rep(i,n) cin >> h[i];
  int high = h[0];
  for(int i =1; i<n; i++){
    if(h[i] >= high){
      ans++;
      high = h[i];
    }
  }
  cout << ans << endl;
}
    

Measured memory_bytes: 3640
#include<stdio.h>
int main(){
	int n;
	scanf("%d",&n);
	int a[n],i,j,tmp;
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		}
	for(i=0;i<n;i++){
		for(j=n-1;j>i;j--){
			if(a[j]<a[j-1]){
				tmp=a[j-1];
				a[j-1]=a[j];
				a[j]=tmp;
				}
			}
		}
		printf("%d",a[n-1]-a[0]);
	return 0;
	}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;

const int N = 40;
const int LOG = 21;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLMOD = 998244353;
const ll LLINF = 1e18;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    cout << c - (min(a, b + c) - b) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pl;
typedef queue<ll> ql;
typedef set<ll> sl;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll &b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll &b) {if(b > a) {a = b; return 1;} return 0;}
const ll inf = 1LL << 60;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const ll max = 500010;
ll num, M, N, ans=0, count=0, sum=0;
int main() {
  cin >> N;
  vl A(N), same(N);
  rep(i, N) {cin >> A[i]; A[i]--; same[A[i]]++;}
  rep(i, N) sum += same[i]*(same[i]-1)/2;
  rep(i, N) cout << sum - same[A[i]] + 1 << endl;
  return 0;
}


Measured memory_bytes: 5760
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        n: usize,
        m: usize,
        x: usize,
        a: [usize;m],
    }

    let mut front = 0;
    let mut back = 0;
    for i in 0..m {
        if a[i]<x {
            front += 1;
        } else {
            back += 1;
        }
    }

    println!("{}", min(front, back));

}


Measured memory_bytes: 2168
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.UncheckedIOException;
import java.io.Writer;
import java.nio.charset.Charset;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		LightScanner in = new LightScanner(inputStream);
		LightWriter out = new LightWriter(outputStream);

		int H = in.ints();
		int W = in.ints();
		int A = in.ints();
		int B = in.ints();

	       for (int i = 0; i < H; i++) {
	            for (int j = 0; j < W; j++) {
	                boolean x = (j < A);
	                boolean y = (i < B);
	                if ((x && y) || (!x && !y)) {
	                    out.print('0');
	                } else {
	                    out.print('1');
	                }
	            }
	            out.ln();
	        }

		out.close();
	}

	static class LightScanner {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;

		public LightScanner(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}

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

		public long longs() {
			return Long.parseLong(string());
		}

		public int ints() {
			return Integer.parseInt(string());
		}
	}

	static class LightWriter implements AutoCloseable {
		private final Writer out;
		private boolean autoflush = false;
		private boolean breaked = true;

		public LightWriter(Writer out) {
			this.out = out;
		}

		public LightWriter(OutputStream out) {
			this(new BufferedWriter(new OutputStreamWriter(out, Charset.defaultCharset())));
		}

		public LightWriter print(char c) {
			try {
				out.write(c);
				breaked = false;
			} catch (IOException ex) {
				throw new UncheckedIOException(ex);
			}
			return this;
		}

		public LightWriter print(String s) {
			try {
				out.write(s, 0, s.length());
				breaked = false;
			} catch (IOException ex) {
				throw new UncheckedIOException(ex);
			}
			return this;
		}

		public LightWriter ans(String s) {
			if (!breaked) {
				print(' ');
			}
			return print(s);
		}

		public LightWriter println(char[] array) {
			return print(new String(array)).ln();
		}

		public LightWriter ans(int i) {
			return ans(Integer.toString(i));
		}

		public LightWriter ans(long i) {
			return ans(Long.toString(i));
		}

		public LightWriter ln() {
			print(System.lineSeparator());
			breaked = true;
			if (autoflush) {
				try {
					out.flush();
				} catch (IOException ex) {
					throw new UncheckedIOException(ex);
				}
			}
			return this;
		}

		public void close() {
			try {
				out.close();
			} catch (IOException ex) {
				throw new UncheckedIOException(ex);
			}
		}

	}
}


Measured memory_bytes: 24100
#include<bits/stdc++.h>
using namespace std;
int main(void){

  string input;   cin >> input;
  int length = (int)(input.length());
  if(length % 2 == 0){
    input.pop_back();
    input.pop_back();
  }else{
    input.pop_back();
  }
  while(true){
    int length = (int)(input.length());
    bool flag = true;
    for(int i = 0 ; i < length / 2 ; i++){
      if(input[i] != input[i + length / 2]){
        flag = false;
        break;
      }
    }
    if(flag){
      cout << length << endl;
      break;
    }
    input.pop_back();
    input.pop_back();
  }


  return 0;
}


Measured memory_bytes: 256
H, W, K = map(int, input().split())
C = []
for i in range(H):
  cs = input()
  C.append(cs)
s = set()
for i in range(H):
  for j in range(W):
    if C[i][j] == "#":
      s.add((i, j))
r = 0
for n in range(1<<(H+W)):
  si = set()
  sj = set()
  for i in range(H+W):
    if n&(1<<i) != 0:
      if i < H:
        si.add(i)
      else:
        sj.add(i-H)
  k = 0
  for i, j in s:
    if (i not in si) and (j not in sj):
      k += 1
  if k == K:
    r += 1
print(r)


Measured memory_bytes: 9060
S = input()
S = S.replace('BC', 'D')

cnt_a = 0
ans = 0
for i in range(len(S)):
    if S[i] == 'A':
        cnt_a += 1
    elif S[i] == 'D':
        ans += cnt_a
    else:
        cnt_a = 0

print(ans)


Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
const int N=102;
int n; char s[N];
int main() {
	scanf("%d%s",&n,s+1);
	int x=0;
	for(int i=1;i<=n;i++){
		if(s[i]=='R')x++;
	}
	printf("%s\n", 2*x>n?"Yes":"No");
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);    
        int n = in.nextInt();
        int l = in.nextInt();
        String[] a = new String[n];
        for (int i = 0; i < n; ++i) {
            a[i] = in.next();
        }
        Arrays.sort(a);
        String s = "";
        for (int i = 0; i < n; ++i) {
            s += a[i];
        }
        System.out.println(s);
    }
}


Measured memory_bytes: 24148
import sys
#import time
import copy
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
from decimal import *
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**20
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(str, input().split()))
a,b = rl()
a = Decimal(a)
b = Decimal(b)
print(int(a*b))


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

typedef long long ll;

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

	map<int,int> r, c;
	for (int i = 0; i < M; i++) {
		r[i+1] = N*(i+1);
	}
	for (int i = 0; i < N; i++) {
		c[i+1] = M*(i+1);
	}

	set<int> st;
	for (auto itr = r.begin(); itr != r.end(); itr++) {
		for (auto itc = c.begin(); itc != c.end(); itc++) {
			st.insert(itr->second);
			st.insert(itc->second);
			st.insert(itr->second+itc->second-(2*(itr->first*itc->first)));
		}
	}

	bool ans=false;
	for (auto itr = st.begin(); itr != st.end(); itr++) {
		if(*itr == K) ans=true;
	}

	cout << (ans?"Yes":"No") << endl;
}

Measured memory_bytes: 13184
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
using std::swap;

vector <int> v;
int main()
{
	int N,L,max = 1000;
	int tot = 0;
	cin >> N>>L;
	v.resize(N);
	for (int i = 0; i < N; ++i) { 
		v[i] = L + i;
		tot += L+i;
		if (abs(v[i]) < abs(max)) {
			max = v[i];
		}
	}
	sort(v.begin(), v.end());
	cout << tot - max << "\n";
	return 0;
}

Measured memory_bytes: 256
from operator import mul
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
count = 0

for i in range(n):
    a = list(map(int, input().split()))
    com = map(mul, a, b)
    if sum(com) + c > 0:
        count += 1
    a.clear()

print(count)

Measured memory_bytes: 9164
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int digit(long long  n){
    long long k = 0;
    while (n>=10){
        n /= 10;
        k ++;
    }
    return ++k;
}

int main(){


    long long N;
    cin >> N;
    long long j = 0 ;
    long long temp =0;
    long long temp1 = 1000000;
    for (long long i = 1; i <=sqrt(N) ; ++i) {
        if(N % i == 0) {
            j = N / i;
            temp = max(digit(i), digit(j));
            temp1 = min(temp, temp1);
        }
    }

    cout << temp1;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int gcd(int a,int b)
{
	if(b==0)
	return a;
	
	return gcd(b,a%b);
}
int power(int x,int y,int p)
{
	int res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		res=(res*x)%p;
		
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
struct Matrix{ 
	int a[2][2] = {{0,0},{0,0}};
	Matrix operator *(const Matrix& other){
		Matrix product;
		for(int i=0;i<2;i++){
			for(int j=0;j<2;j++){
				for(int k=0;k<2;k++){
						product.a[i][k] =product.a[i][k] + (ll)a[i][j]*other.a[j][k];
				}
			}
		}
		return product;
	}
};
int modInverse(int n,int p)
{
	return power(n,p-2,p);
}
int main() {
	
	// your code goes here
	 ios_base::sync_with_stdio(0);
	 cin.tie(0);
	 int n,x,t;
	 cin>>n>>x>>t;
	 int ans = ceil(n/(double)x) * t;
	 cout
	 <<ans<<'\n';
	 return 0;
}


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

int main() {
	int x, y;
	while (1) {
		cin >> x >> y;
		if (x == 0 && y == 0) break;
		if (x > y) {
			cout << y << " " << x << endl;
		}
		else {
			cout << x << " " << y << endl;
		}
	}
	
}


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

#define debug(x) cerr << #x << ": " << x << endl;

#define iosbase ios_base::sync_with_stdio(false)
#define tie cin.tie();cout.tie();

#define endl '\n'

typedef pair<int, int> ii;
typedef long long ll;

int n, m;
int main(){
  iosbase;
  tie;

  int t; cin >> t;
  for(int i = 1; i <= 9; i++){
    if(t%i == 0 && t/i >= 1 && t/i <= 9){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


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

int main(){
  long long N;
  cin >> N;
  string S="";
  while(N){
    N--;
    int A=N%26;
    char B='a'+A;
    S.push_back(B);
    N/=26;
  }
  reverse(S.begin(),S.end());
  cout << S << endl;
}
  

Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        int blackH = Integer.parseInt(sc.next());
        int blackW = Integer.parseInt(sc.next());

        int result = h * w - (blackH * w + blackW * h - blackH * blackW);

        System.out.println(result);
    }
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};


//-----------------------------------------------------------------------------

int x,t;

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

	cin>>x>>t;
	cout<<max(0,x-t)<<endl;

	return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
h=list(map(int,input().split()))
edge=[[] for _ in range(n)]
flg=[True]*n
d=dict()
for _ in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    if (a,b) in d or (b,a) in d:
        continue
    else:
        edge[a].append(b)
        edge[b].append(a)
        d[(a,b)]=0
        d[(b,a)]=0
ans=0
#print(edge)
for i in range(n):
    if not flg[i]:
        continue
    if len(edge[i])==0:
        ans+=1
    else:
        ok=True
        for e in edge[i]:
            if h[i]<=h[e]:
                flg[i]=False
                ok=False
            else:
                flg[e]=False
        if ok:
            ans+=1
print(ans)

Measured memory_bytes: 56620
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<endl
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

ll calc(ll k,ll d) {
  return k*(k+1)/2*d;
}

const ll n=26;
ll c[n],q[444];
ll a[444][n];
set<ll> s[n];

ll solve(ll x,ll y) {
  ll ans=0;
  {
    ans-=a[x][q[x]];
    iter(s[q[x]]) it2=s[q[x]].lower_bound(x);
    iter(s[q[x]]) it1=it2,it3=it2;it1--,it3++;
    ans+=calc(*it2-*it1-1,c[q[x]]);
    ans+=calc(*it3-*it2-1,c[q[x]]);
    ans-=calc(*it3-*it1-1,c[q[x]]);
    s[q[x]].erase(it2);
  }
  {
    q[x]=y;
    s[q[x]].in(x);
    ans+=a[x][q[x]];
    iter(s[q[x]]) it2=s[q[x]].lower_bound(x);
    iter(s[q[x]]) it1=it2,it3=it2;it1--,it3++;
    ans-=calc(*it2-*it1-1,c[q[x]]);
    ans-=calc(*it3-*it2-1,c[q[x]]);
    ans+=calc(*it3-*it1-1,c[q[x]]);
  }
  return ans;
}

         
void Main() {
  srand((unsigned)time(NULL));
  int T;
  R T;
  rep(i,n) R c[i];
  rep(i,T)rep(j,n) R a[i][j];
  rep(i,n) s[i].in(-1),s[i].in(T);
  ll ans[T];
  mem(ans);
  rep(k,T) {
    ll M=0,x=0;
    rep(i,n) {
      if(M<a[k][i]) {
        M=a[k][i];
        x=i;
      }
    }
    q[k]=x;
    s[x].in(k);
    ans[k]=x;
  }
  clock_t t2=clock();
  for(int tt=0;;tt++) {
    ll e[2][3],sum=0,m=rand()%2+1;
    rep(i,m) {
      ll x=rand()%T,y=rand()%n;
      e[i][0]=q[x],e[i][1]=x,e[i][2]=y;
      sum+=solve(x,y);
    }
    if(sum<0) {
      rrep(i,m) {
        int x=e[i][1];
        s[q[x]].erase(x);
        q[x]=e[i][0];
        s[q[x]].in(x);
      }
    } else {
      rep(i,m) ans[e[i][1]]=e[i][2];
    }
    clock_t t3=clock();
    double t4=(double)(t3-t2)/CLOCKS_PER_SEC;
    if(tt>=2&&(double)t3/CLOCKS_PER_SEC+t4*2>1.900) break;
    t2=t3;
  }
  rep(i,T) pr(ans[i]+1);
}

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


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

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

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);


int main(){
  int N,K;
  cin >> N >> K;
  vector<int> l(N);
  REP(i,N)cin>>l[i];

  sort(ALL(l), greater<int>());

  int ans=0;
  REP(i,K)ans+=l[i];
  cout << ans << endl;
}



Measured memory_bytes: 256
def merge(cnt, A, left, mid, right):
    L = A[left:mid] + [2147483648]
    R = A[mid:right] + [2147483648]
    i = 0
    j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
            cnt.append(j)
        else:
            A[k] = R[j]
            j += 1
            
def mergeSort(cnt, A, left, right):
    if left+1 < right:
        mid = (left + right) // 2
        mergeSort(cnt, A, left, mid)
        mergeSort(cnt, A, mid, right)
        merge(cnt, A, left, mid, right)
        
        
import sys
def input():
    return sys.stdin.readline()[:-1]
    
n = int(input())
S = list(map(int, input().split()))

from collections import deque
cnt = deque()
mergeSort(cnt,S,0,n)

print(sum(cnt))


Measured memory_bytes: 41140
import numpy as np 
from numba import jit
n,k=map(int,input().split())
a=list(map(int,input().split()))
a=np.array(a,np.int64)

@jit
def imo(a):
    imos=np.zeros(n+1,np.int64)
    for i in range(n):
        imos[max(0,i-a[i])]+=1
        imos[min(n,i+a[i]+1)]-=1
    
    immo=np.zeros(n+1,np.int64)
    immo=np.cumsum(imos)
    return immo[:n]


for _ in range(min(k,41)):
    a=imo(a)
    
print(*a)


Measured memory_bytes: 124928
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {

  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    PrintWriter out = new PrintWriter(System.out);

    int n = in.nextInt();
    int m = in.nextInt();

    HashSet<Integer> food = new HashSet<>();

    int k1 = in.nextInt();
    for (int j = 0; j < k1; j++)
      food.add(in.nextInt());

    for (int i = 1; i < n; i++) {
      int k = in.nextInt();

      HashSet<Integer> food1 = new HashSet<>();

      for (int j = 0; j < k; j++) {
        int a = in.nextInt();
        if (food.contains(a))
          food1.add(a);
      }
      food = food1;
    }

    out.println(food.size());

    out.close();
  }

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

    public long nextLong() {
      return Long.parseLong(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }
  }
}

Measured memory_bytes: 23380
#include <cstdio>
#include <vector>
#include<algorithm>
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

bool myCompare(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first > b.first;
    }
}

int main(){
  int n; auto dmy = scanf("%d", &n);
  vector<pii> task; task.resize(n);
  for(int i=0; i<n; i++) dmy = scanf("%d %d", &task[i].first, &task[i].second);
  sort(all(task), myCompare);
  
  bool flag = true;
  int time = 0;
  for(int i=0; i<n; i++){
    time += task[i].first;
    if(time > task[i].second){flag = false; break;}
  }
  printf((flag ? "Yes\n" : "No\n"));
}

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

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		double x[3], y[3], s[3];
		double l, m, n;
		
		for (int j = 0; j < 3; j++){
			scanf("%lf %lf", &x[j], &y[j]);
			s[j] = x[j] * x[j] + y[j] * y[j];
		}
		
		double __x[2], __y[2], __s[2];
		__x[0] = x[0] - x[1];
		__y[0] = y[0] - y[1];
		__s[0] = s[0] - s[1];
		__x[1] = x[0] - x[2];
		__y[1] = y[0] - y[2];
		__s[1] = s[0] - s[2];
		
		m = - (__s[0] * __x[1] - __s[1] * __x[0]) / 
		    (__y[0] * __x[1] - __y[1] * __x[0]);
		l = - (__s[0] * __y[1] - __s[1] * __y[0]) / 
		    (__x[0] * __y[1] - __x[1] * __y[0]);
		n = - s[0] - x[0] * l - y[0] * m;
		
//		printf("x^2 + y^2 + %lfx + %lfy + %lf = 0\n", l, m, n);
		
		double a, b, r;
		a = l / -2;
		b = m / -2;
		r = sqrt(- n - a * a - b * b - l * a - m * b);
		
//		printf("(x - %lf)^2 * (y - %lf)^2 = %lf^2\n", a, b, r);
		
		printf("%.3lf %.3lf %.3lf\n", a, b, r);
	}
	
	return 0;
}

Measured memory_bytes: 1092
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;



int main() {
  int n;
  scanf("%d",&n);
  vi a(n);
  cin>>a;
  int cnt = 0;
  rep(i,n) {
    if (a[i] < 0) cnt++;
  }
  ll ans = 0;
  rep(i,n) ans += abs(a[i]);
  if (cnt&1) {
    int l = INF;
    rep(i,n) mins(l,abs(a[i]));
    ans -= l*2;
  }
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 640
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=1000002;

void solve(){
	int n;
	cin>>n;
	vector<pair<int,int>>a(n);
	cin>>a;
	int mn=1e9+100,mx=0,mn2=1e9+100,mx2=0;
	for(auto &i:a){
		if(i.F>i.S){
			swap(i.F,i.S);
		}
		mn=min(mn,i.F);
		mx=max(mx,i.F);
		mn2=min(mn2,i.S);
		mx2=max(mx2,i.S);
	}
	ll ans=(mx2-mn2)*1ll*(mx-mn);
	ll len=max(mx2,mx)-min(mn2,mn);
	sort(all(a));
	multiset<int>st;
	for(auto i:a){
		st.insert(i.F);
	}
	for(int i=0;i<=n;i++){
		int x=*st.begin(),y=*st.rbegin();
		ans=min(ans,len*(y-x));
		if(i<n){
			st.erase(st.find(a[i].F));
			st.insert(a[i].S);
		}
	}
	cout<<ans;
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


Measured memory_bytes: 12800
q = int(input())

def is_prime(n):
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    return n != 1

def main(n):
    return 1 if is_prime(n) and is_prime((n + 1) // 2) else 0

MAX = 10 ** 5 + 100
A = [main(i) for i in range(MAX)]
# 累積和
acc = [0] * (MAX + 1)
for i in range(MAX):
    acc[i + 1] = acc[i] + A[i]

for i in range(q):
    l, r = map(int, input().split())
    # [l, r] なので r + 1 にする
    print(acc[r + 1] - acc[l])

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

int main(){
    long long N;
    scanf("%lld", &N);

    long long ans = 0;
    for(long long p = 2; p*p <= N; p ++){
        int cnt = 0;
        while(N%p == 0){
            N /= p;
            cnt ++;
        }

        //printf("%lld %d\n", p, cnt);

        for(int i = 1; i <= 25; i ++){
            if(i*(i+1)/2 > cnt){
                ans += i-1;
                break;
            }
        }
    }

    if(N != 1){
        ans ++;
    }

    printf("%lld", ans);
}


Measured memory_bytes: 3832
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long ll;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    int ans=0;
    for(int i=0; i<N; i++){
        cin >> h[i];
        if(h[i]>=K) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


N = I()
A = LI()

from collections import Counter

c = Counter(A)

a = 0  # 消さねばならない文字数
for i in c.keys():
    a += c[i]-1

print(N-2*((a+1)//2))

Measured memory_bytes: 98124