akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
#include<string>
#include<map>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<bitset>
#include<stack>
#include<algorithm>
#include<climits>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long int
#define vll vector<ll>
#define mii map<ll, ll>
#define debug(x) cerr << #x << " is " << x << "\n";
#define debug1(x, y) cerr << #x << " is " << x << "\n" << #y << " is " << y << "\n";
#define w(x) ll x; cin >> x; while(x--)
#define endl "\n"
#define f first 
#define s second 
#define fo(n) for(ll i = 0LL; i < n; ++i) 
#define setbits(n) __builtin_popcount(n)
#define all(x) x.begin(), x.end()
#define sortAll(x) sort(x.begin(), x.end())
#define pb push_back
#define mk make_pair
#define PERMUTE next_permutation
#define RESET(a, b) memset(a, b, sizeof(a))
#define MOD 1000000007
using namespace std;
 
int main(){
    fast
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll sum = 0;
    if(k <= a) {
        cout << k << endl;
        return 0;
    }
    k -= a;
    sum += a;
    if(k <= b) {
        cout << sum << endl;
        return 0;
    }
    k -= b;
    if(k <= c) {
        cout << sum - k << endl;
        return 0;
    }
    cout << sum - k << endl;
    
    return 0;
}

Measured memory_bytes: 3636
using System;


namespace ConsoleApplication38
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] input = Console.ReadLine().Split(' ');
            long n = long.Parse(input[0]);
            long m = long.Parse(input[1]);
            long l = long.Parse(input[2]);
            long[,] A = new long[n, m];
            long[,] B = new long[m, l];
            long[,] C = new long[n, l];
            //A?????????
            for (long x = 0; x < n; x++ )
            {
                String[] input2 = Console.ReadLine().Split(' ');  
                for (long y = 0; y < m; y++)
                {
                    long a = long.Parse(input2[y]);
                    A[x , y] =  a;
                }
            }
            //??¢?????????
            for (long x = 0; x < m; x++ )
            {
                String[] input3 = Console.ReadLine().Split(' ');
                for (long y = 0; y < l; y++)
                {
                    long a = long.Parse(input3[y]);
                    B[x, y] = a;
                }
            } 
            //C?????????
            for (long x = 0; x < n; x++)
            {
                for (long y = 0; y < l; y++)
                {
                    long z = 0;
                    for ( z = 0; z < m; z++)
                    {
                        C[x , y] += A[x , z] * B[z , y]; 
                    }
                }
            }
            for (long x = 0; x < n; x++)
            {
                for (long y = 0; y < l; y++)
                {
                    Console.Write(C[x, y]);
                    if(y != l - 1)
                    {
                        Console.Write(" ");
                    }
                }
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 9612
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    int s[3];
    memset(s, -1, sizeof s);
    for (int i = 0; i < m; ++i)
    {
        int a, b;
        cin >> a >> b;
        a--;
        if (s[a] != -1 && s[a] != b)
            return cout << -1, 0;
        s[a] = b;
    }
    if (s[0] == -1)
        s[0] = n == 1 ? 0 : 1;
    if (s[1] == -1)
        s[1] = 0;
    if (s[2] == -1)
        s[2] = 0;
    if (n > 1 && s[0] == 0)
        return cout << -1, 0;
    for (int i = 0; i < n; ++i)
        cout << s[i];
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

int main() {
  uint32_t N = 0;
  std::cin >> N;
  std::vector<uint32_t> F(N+1, 0);

  for (size_t x = 1; x*x < N; x++)
  {
    for (size_t y = 1; y*y < N; y++)
    {
      for (size_t z = 1; z*z < N; z++)
      {
        uint32_t val = x*x + y*y + z*z + x*y + y*z + z*x;
        if(val <= N) F[val]++;
      }
    }
  }
  
  for (size_t i = 1; i <= N; i++) std::cout << F[i] << std::endl;

  return 0;
}

Measured memory_bytes: 3632
#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");}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if (u == s) a--;
    if (u == t) b--;
    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 256
import math

s = input().split()

short_s = int(s[0])
long_s = int(s[1])
hours = int(s[2])
minutes = int(s[3])

d_short = 360 * hours/12 + 360 * (minutes/60) *(1/12)
d_long = 360 * minutes / 60

degree = d_short - d_long


length_2 = short_s * short_s + long_s * long_s  - 2 * short_s * long_s * math.cos(math.radians(degree))
print(math.sqrt(length_2))

Measured memory_bytes: 9372
#include<bits/stdc++.h>
using namespace std;
int main(){
  int w, h, x, y, r; cin >> w >> h >> x >> y >> r;
  if (x - r >= 0 && x + r <= w && y - r >= 0 && y + r <= h) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3116
/* Maximum Heap */
#include <stdio.h>

int A[500005], i, n;

void maxHeapify(int p)
{
    int left = p * 2 + 1, right = p * 2 + 2, large = p; 
    
    if(left <= n && A[left] > A[large]){
        large = left;
    }
    if(right <= n && A[right] > A[large]){
        large = right;
    }
    if(large != p){
        right = A[p];
        A[p] = A[large];
        A[large] = right;
        maxHeapify(large);
    }
}

int main()
{
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", A+i);
    }
    for(i=n/2; i>=0; i--){
        maxHeapify(i);
    }
    for(i=0; i<n; i++){
        printf(" %d", A[i]);
    }
    puts("");
    return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>

int main(void)
{
    int i, j, count, data[100], v;

    scanf("%d", &count);

    for (i = 0; i < count; i++) {
        scanf("%d", &data[i]);
    }

    for (j = 0; j < count; j++) {
        printf("%d", data[j]);
        if (j < count - 1) {
            printf(" ");
        }
    }
    putchar('\n');

    for (i = 1; i < count; i++) {
        v = data[i];
        j = i - 1;
        while (j >= 0 && data[j] > v) {
            data[j + 1] = data[j];
            j--;
        }
        data[j + 1] = v;

        for (j = 0; j < count; j++) {
            printf("%d", data[j]);
            if (j < count - 1) {
                printf(" ");
            }
        }
        putchar('\n');
    }

    return 0;
}



Measured memory_bytes: 2148
import itertools

n=int(input())
# x1,y1,h1
test_data = []
for _ in range(n):
     check=[int(i) for i in input().split()]
     test_data.append(check)
     if check[2]!=0:
         a,b,c=check

for cx, cy in itertools.product(range(100 + 1), range(100+1)):
    blnCorrect=True
    H=c + abs(a - cx) + abs(b - cy)
    for coord in test_data:
        if  coord[2]!=max(H-abs(coord[0] - cx) - abs(coord[1] - cy),0):
            blnCorrect = False
            break
    if blnCorrect:
        print(cx,cy,H)
        break


Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>

int cmp(const void *a,const void *b){
  return *(int*)a - *(int*)b;
}

int main(){
  int n = 0;
  int d[100000] = {};
  int i = 0;
  int diff;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&d[i]);
  }
  qsort(d,n,sizeof(int),cmp);
  diff = d[n/2] - d[n/2-1] ;
  printf("%d",diff);
  return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;
int p[60];

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

    std::cin >> N;

    for(int i=0;i<N;++i){
        std::cin >> p[i];
    }

    bool can = std::is_sorted(p, p + N);

    for(int i=0;i<N;++i){
        for(int j=i+1;j<N;++j){
            std::swap(p[i], p[j]);
            can = can || std::is_sorted(p, p + N);
            std::swap(p[i], p[j]);
        }
    }

    if(can){
        std::cout << "YES" << std::endl;
    }else{
        std::cout << "NO" << std::endl;
    }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;


int main() {
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		int n;
		cin >> n;
		vector<ll> a(n);
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		string s;
		cin >> s;

		vector<ll> b;
		bool canConsist = true;
		for (int i = n - 1; i >= 0; i--) {
			for (auto x : b) {
				a[i] = min(a[i], a[i]^x);
			}

			if (a[i] > 0) {
				if (s[i] == '1') {
					cout << 1 << endl;
					canConsist = false;
					break;
				}

				b.emplace_back(a[i]);
			}

			
			
		}
		if (!canConsist) {
			continue;
		}
		

		
		cout << 0 << endl;
		
		
	}
}

Measured memory_bytes: 3600
#include <stdio.h>

int main(void)
{
	int n, i;
	int count = 0;
	int p[20];

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%d", &p[i]);
	}
	for (i = 1; i < n - 1; i++) {
		if ((p[i] > p[i - 1]) && (p[i] < p[i + 1])) {
			count++;
		}
		else if ((p[i - 1] > p[i]) && (p[i] > p[i + 1])) {
			count++;
		}
	}

	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<vector>
using namespace std;
#define ll long long
const long long M = 10e9+7;
int main()
{
	int n;cin>>n;
	string s;cin>>s;
	int cnt = 0;
	for(int i=0;i<n-2;++i)
	{
		if(s.substr(i,3)=="ABC") cnt++;	
	}
	cout<<cnt<<"\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
    import java.io.*;
    public class Main{
    /// functions
    static long gcd(long a,long b){if(b==0){return a;}return gcd(b,a%b);}
    static long Modpow(long a,long p,long m){if(p==1){return a;}long x=Modpow(a,p/2,m);x=(x*x)%m;return (p&1l)!=0? (x*a)%m:x;}
    static long Modmul(long a,long b,long m){return ((a%m)*(b%m))%m;}
    static long ModInv(long a,long m){return Modpow(a,m-2,m);}
    static long nck(int n,int r,long m){if(r>n){return 0l;}return Modmul(f[n],ModInv(Modmul(f[n-r],f[r],m),m),m);}
    // end
    static long[] f;
     
    public static void main(String[] args) throws FileNotFoundException, IOException{
           Scanner s=new Scanner(System.in);
           StringBuilder sb=new StringBuilder();
           BufferedWriter out=new BufferedWriter(new OutputStreamWriter(System.out));
           int h=s.nextInt(),n=s.nextInt();
           int[][] arr=new int[n+1][2];
           for(int i=1;i<=n;i++){
           	arr[i][0]=s.nextInt();arr[i][1]=s.nextInt();
           }
           int[][] dp=new int[h+1][n+1];
           for(int i=1;i<=h;i++){dp[i][0]=Integer.MAX_VALUE;}
           
           for(int i=1;i<=h;i++){
           	for(int j=1;j<=n;j++){
           		if(i<arr[j][0]){dp[i][j]=Math.min(arr[j][1],dp[i][j-1]);}
           		else{
           			dp[i][j]=Math.min(dp[i][j-1],dp[i-arr[j][0]][j]+arr[j][1]);
           		}
           	}
           }
            out.write(dp[h][n]+"");
            out.flush();
      }
    }

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

int main(){
  long long A, B, K;
  cin >> A >> B >> K;
 
  if(K <= A){
    cout << A - K << " " << B <<endl;
  }
  else if(K <= A+B){
    cout << 0 << " " << B - (K-A) <<endl;
  }
  else{
  cout << 0 << " " << 0 <<endl;
  }
}

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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    string s;
    cin>>s;
    if(s.size()==6&&s[2]==s[3]&&s[4]==s[5])
        cout<<"Yes\n";
    else
        cout<<"No\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n,i,tmp;
    int sright, sall;
    int minimum, idx;
    int res;
    vector<int> w;

    cin >> n;
    sall = 0;
    for(i=0;i<n;i++){
        cin >> tmp;
        sall+=tmp;
        w.push_back(tmp);
    }

    //cout << "sall = " << sall << endl;
    minimum = 101;
    sright = 0;
    for(i=0;i<n;i++){
        sright+=w[i];
        //cout << "sright = " << sright << " : ";
        //cout << "w[" << i << "]=" << w[i];
        if((tmp = abs(2*sright-sall)) < minimum){
            minimum = tmp;
            idx = i +1;
            //cout << " tmp = " << tmp;
        }
        //cout << endl;
    }

    cout << minimum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> vec;
int main()
{
	int n,v_max=0,v_i=0,s=0;
	cin>>n;
	vec.resize(n);
	for(int i=0;i<n;i++)
	{
		cin>>vec[i];
		s+=vec[i];
		if(vec[i]>v_max)
		{
			v_max=vec[i];
			v_i=i;
		}
	}
	vec[v_i]/=2;
	s-=vec[v_i];
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N, M, Q = map(int, input().split())
cum = [[0]*(N+1) for _ in range(N+1)]
for _ in range(M):
    l, r = map(int, input().split())
    cum[l][r] += 1
for i in range(1, N+1):
    for j in range(i+1, N+1):
        cum[i][j] += cum[i][j-1]
ans = []
for _ in range(Q):
    p, q = map(int, input().split())
    tot = 0
    for i in range(p, q+1):
        tot += cum[i][q]
    ans.append(tot)
print(*ans, sep="\n")


Measured memory_bytes: 82692
#include <stdio.h>
#include <stdlib.h>
#define N 100  

int main(void){
  int i;
  int num[N];
  char enzan[N];
  
  int head=0;
  
  for(i = 0; i < N; i++){
    enzan[i]=0;
  }
  
  while (scanf("%s",enzan) != EOF){
    if ( enzan[0] == '+'){
      num[head-2] = num[head-2] + num[head-1];
      head--;
    }   
    else if(enzan[0] == '*'){
      num[head-2] = num[head-2] * num[head-1];
      head--;
    }
    else if(enzan[0] == '-'){
      num[head-2] = num[head-2] - num[head-1];
      head--;
    }
    else {
      num[head] = atoi(enzan);
      head++;
    }
  }
  printf("%d\n",num[head-1]);
  return 0;
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=1;(i)<=(n);(i)++)
using namespace std;
vector<pair<int,int>> tasks;
int main() {
    int n;cin>>n;
    for(int i=0;i<n;i++) {
        int a,b;cin>>a>>b;
        tasks.emplace_back(b,a);
    }
    sort(tasks.begin(),tasks.end());
    int sum=0;
    for(auto v : tasks) {
        sum += v.second;
        if(sum>v.first){
            cout << "No" << endl;
            return 0;
        }

    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

map<int64_t, int> PrimeFactorization(int64_t n) {
	assert(n > 0);
	map<int64_t, int> mp;
	if(n == 1) {
		mp[1] = 1;
		return mp;
	}
	int64_t i = 2;
	while(n > 1) {
		if(n < i * i) {
			mp[n]++;
			return mp;
		}
		if(n % i == 0) {
			n /= i;
			mp[i]++;
		} else {
			i++;
		}
	}
	return mp;
}

int main() {
	int64_t n; cin >> n;
	if(n == 1) {
		cout << 0 << '\n';
		return 0;
	}
	auto mp = PrimeFactorization(n);
	int64_t ans = 0;
	for(auto& e : mp) {
		for(int64_t i = 1; e.second > 0; ++i) {
			e.second -= i;
			if(e.second >= 0) {
				ans++;
			}
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3644
import java.util.*;
class Main {
  static Scanner sc = new Scanner(System.in);
  static int n = Integer.parseInt(sc.next());
  static int l = Integer.parseInt(sc.next());
  
  public static int appleToEat(int n, int l){
    int sum = 0;
    
    for (int i = 0; i < n; i++) {
        sum += (l + i);
    }
    
    if (l >= 0) {
      return sum - l;
    } else if (l*-1 >= n) {
      return sum - (l+n-1);
    } else {
      return sum;
    }
    
  }
  
  public static void main(String args[]) {
    int result = appleToEat(n, l);
    System.out.println(result);
    
  }
  
}

Measured memory_bytes: 23508
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;

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

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

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	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 operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return 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;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////



int main() {

	ll N,K;
	cin >> N >> K;

	vector<ll> A(N + 1), B(N + 1);
	repn(i, N) cin >> A[i] >> B[i];

	ll ans = 0;

	repn(i, N) {
		if ((A[i] | K) == K) { ans += B[i]; }
	}
	
	rep(i, 30) {
		if ((K >> i) % 2 == 0) { continue; }

		ll x = K ^ (1 << i);
		rep(j, i) { x = x | (1 << j); }

		//cout << i << x << endl;

		ll t = 0;
		repn(j, N) {
			if ((x | A[j]) == x) { t += B[j]; }
		}
		//cout << t << endl;

		ans = max(t, ans);
	}

	cout << ans;
	

	system("PAUSE");
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
const ll mod = 1e9 + 7;

bool compare_by_b(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, m;
    cin >> n >> m;
    vector<int> a(n);
    vector<pair<int, int>> p;
    rep(i, n) cin >> a[i];
    rep(i, m)
    {
        int b, c;
        cin >> b >> c;
        p.push_back(make_pair(b, c));
    }
    sort(a.begin(), a.end());
    sort(p.begin(), p.end(), compare_by_b);
    int itr = 0;
    rep(i, n)
    {
        if (a[i] < p[itr].second)
        {
            rep(j, p[itr].first)
            {
                if (a[i] < p[itr].second)
                {
                    a[i] = p[itr].second;
                    i++;
                }
            }
            i--;
            itr++;
        }
        else
            ;
    }
    ll sum = 0;
    rep(i, n) sum += a[i];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1784
#include <iostream>
#define ll long long
#define MOD 1000000007LL
using namespace std;
ll sum[200005];

int main()
{
    ll n, k;
    cin >> n >> k;

    ll l = 0, r = n;
    for (int i = 1; i <= n + 1; i++)
    {
        sum[i] = r - l + 1;
        l += i;
        r += n - i;
    }

    ll ans = 0;
    for (int i = k; i <= n + 1; i++) ans = (ans + sum[i]) % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 5144
import static java.lang.System.out;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int m = (a>=b?a:b);
        int n = (a==m?b:a);
        for(int i=0;i<m;i++){
            out.print(n);
        }
        out.println();
        scan.close();
    } 
}

Measured memory_bytes: 35740
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#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>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// 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>

#if __cplusplus >= 201103L
#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>
#endif

using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
const long long MOD = 1000000007;

int main(void){
    ll n;
    ll k;
    vector<ll> fruits;
    cin >> n >> k;
    REP(i,n){
        ll tmp;
        cin >> tmp;
        fruits.push_back(tmp);
    }
    sort(ALL(fruits));
    ll ans =0;
    REP(i,k){
        ans += fruits[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3220
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

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

fn f(s: &[char]) -> bool {
    let m = s.len();
    for i in 0..m {
        if s[i] != s[m - 1 - i] {
            return false;
        }
    }
    true
}

use std::iter::Iterator;

fn main() {
    input! {
        a: i64,
        b: i64,
        k: i64
    }


    let mut taka = 0;
    let mut ao = 0;

    if a >= k {
        taka = a-k;
        ao = b;
    }else if a < k {
        taka = 0;
        ao = b - (k - a);
    }

    if ao < 0 {
        ao = 0;
    }

    println!("{} {}", taka, ao);

   
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ii pair <long long, long long>
using namespace std;
 
const int N = 3010;
const long long md = 998244353;
const int inf = 123456789;
 
int n, s;
int a[N];
long long dp[N][N][3];
 
long long f(int idx, int cur, int tx) {
  if (cur < 0) return 0;
  if (tx == 2) return cur == 0;
  if (idx == n) return 0;  
  if (dp[idx][cur][tx] != -1) {
    return dp[idx][cur][tx];
  }
  if (tx == 0) {
    return dp[idx][cur][tx] = (f(idx + 1, cur, tx) + f(idx, cur, tx + 1)) % md;
  }
  if (tx == 1) {
    return dp[idx][cur][tx] = (f(idx + 1, cur, tx) + f(idx + 1, cur - a[idx], tx) + f(idx + 1, cur, tx + 1) + f(idx + 1, cur - a[idx], tx + 1)) % md;
  }
}
 
int main() {
  scanf("%d %d", &n, &s);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  long long ans = 0;
  memset(dp, -1, sizeof dp);
  //cout << f(0, s, 0) << endl;
  printf("%lld\n", f(0, s, 0));
  return 0;
}

Measured memory_bytes: 212864
#include <stdio.h>

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

int main(void)
{
    long long int a[100];
    long long int b[100];
    long long int c[100];
    int N;
    scanf("%lld", &N);
    for( int i = 0; i < N; i++){
        scanf("%lld", &a[i]);
    }
    if( N == 1 ){
        printf("%lld",a[0]);
        return 0;
    }
    b[0] = 0;
    b[0] = gcd(a[0], a[1]);
    c[0] = a[0] / b[0] * a[1];
    for( int i = 1; i < N-1; i++){
        b[i] = gcd(c[i-1], a[i+1]);
        c[i] = c[i-1] / b[i] * a[i+1];
    }

    printf("%lld",c[N-2]);

    return 0;
}

long long int gcd(long long int a, long long int b)
{
    if( a < b ){
        return gcd(b , a);
    }
    else if( b == 0 ){
        return a;
    }
    else{
        return gcd(b, a%b);
    }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod=1000000007;
const double PI = 3.14159265359;
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define INF 1000000000000
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define FOR(i,n) for(int i=0;i<(n);i++)
#define FORA(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define count_1(n)  __builtin_popcountll(n)
#define parity(n)   __builtin_parityll(n)   //Even parity 0 as output
void show    (int a[], int arraysize) { for (int i = 0; i < arraysize; ++i)  {cout << a[i] << " ";}	cout<<endl;}
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b);}
void sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}
int main()
{FAST
int n;
cin>>n;
if(n%1000==0)
{
	cout<<"0\n";
}
else
cout<<1000-n%1000<<endl;
return  0;
}






Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
void get_unique(vector<T>& x) {
    x.erase(unique(x.begin(), x.end()), x.end());
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({a * c, a * d, b * c, b * d}) << endl;
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int main() {
	char a[3];
	char b[] = "1";
    int sum = 0;
	cin >> a;
    if (a[0] == b[0]) sum++;
    if (a[1] == b[0]) sum++;
    if (a[2] == b[0]) sum++;
	cout << sum << endl;
}

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

int main()
{
  int N1, N2, N3, N4;
  cin >> N1 >> N2 >> N3 >> N4;

  int a[10] = {0};
  a[N1] = a[N2] = a[N3] = a[N4] = 1;

  if(a[1] == 1 && a[9] == 1 && a[7] == 1 && a[4] == 1) cout << "YES\n";
  else cout << "NO\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <algorithm>
using namespace std;
int main() {
    long long n, m, a[1000][3];
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> a[i][j];
        }
    }
    long long max = -(1LL << 60);
    for (int i = 0; i < 8; ++i) {
        vector<long long> vec;
        for (int j = 0; j < n; ++j) {
            long long S = 0;
            for (int k = 0; k < 3; ++k) {
                if (i & 1 << k) {
                    S += a[j][k];
                } else {
                    S -= a[j][k];
                }
            }
            vec.push_back(S);
        }
        sort(vec.begin(), vec.end(), greater<long long>());
        long long _max = 0;
        for (int j = 0; j < m; ++j) {
            _max += vec[j];
        }
        if (_max > max) {
            max = _max;
        }
    }
    cout << max << endl;
    return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << x << "\n"
using namespace std;
using point = pair< int,int >;
using ll = long long;

int main() {
    int n;
    cin >> n;

    int d[n];

    REP (i, n) {
        scanf("%d", &d[i]);
    }

    sort(d, d + n);

    OUT(d[n / 2] - d[n / 2 - 1]);
    return 0;
}



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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T;
	cin >> T;
	int arr[T];
	int prefix[T];
	int suffix[T];
	for(int i = 0; i<T;i++)
	{
		cin >>arr[i];
		prefix[i] = arr[i];
		suffix[i] = arr[i];
	}
	for(int i = 1; i<T;i++)
	{
		prefix[i] = prefix[i] ^ prefix[i-1];
	}
	for(int i = T-2; i>=0;i--)
	{
		suffix[i] = suffix[i] ^ suffix[i+1];
	}
	cout << suffix[1]<<" ";
	for(int i = 1; i<T-1;i++)
	{
		cout << (prefix[i-1]^suffix[i+1])<<" ";
	}
	cout<<prefix[T-2];
}


Measured memory_bytes: 5952
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int n,m;
 	cin >> n>>m;
 	cout << n*n-m << endl;
 }


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  string s; cin >> s;
  if(s[0] == s[s.length()-1]) {
    if(s.length() % 2 == 1) puts("Second");
    else puts("First");
  } else {
    if(s.length() % 2 == 0) puts("Second");
    else puts("First");
  }
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(void){
    vector<int>L(3,0);
    for (int i=0; i<3; i++){
        cin >> L[i];
    }
    sort(L.begin(), L.end());
    if (L[0]+L[1]==L[2]){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

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

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<vector<int>> A(2, vector<int>(N));
	int i, j;
	for(i = 0; i < 2; i++) {
		for(j = 0; j < N; j++) {
			cin >> A[i][j];
		}
	}
	pair<int, int> location(0, 0);
	int result = 0, max = 0;
	for(i = 0; i < N; i++) {
		for(j = 0; j < i; j++) {
			result += A[location.first][location.second];
			location.second++;
		}
		result += A[location.first][location.second];
		location.first++;
		while(location.second < N) {
			result += A[location.first][location.second];
			location.second++;
		}
		if(max < result) max = result;
		result = 0;
		location.first = 0;
		location.second = 0;
	}
	cout << max << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef vector< pii > vii;

#define ll          long long
#define ff          first
#define ss          second
#define pb          push_back
#define mkp         make_pair
#define sz          size()

#define forf(a,b,c)    for(int i=a;i<=b;i+=c)
#define forr(a,b,c)    for(int i=a;i>=b;i-=c)
#define all(a)      a.begin(),a.end()
#define mem(a,b)    memset(a,b,sizeof(a))
#define pi          2*acos(0.0)
#define End         return 0;
#define nl endl

#define scan1(a)    scanf("%d",&a)
#define scan2(a,b)  scanf("%d %d",&a,&b)
#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scanl(a)    scanf("%lld",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define print1(a)    printf("%d",a)
#define print2(a,b)  printf("%d %d",a,b)
#define print3(a,b,c)  printf("%d %d %d",a,b,c)
#define printl(a)    printf("%lld",a)
#define printll(a,b) printf("%lld %lld",a,b)
#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)

#define MAXN        100000007
#define INF 0x3f3f3f3f
bool mark[100005];vi prime;
void seive(ll N){for(int i=2;i<=N;i++){if(mark[i]==false){prime.pb(i);for(int j=i+i;j<N;j+=i)mark[j]=true;}}}
//freopen("input.txt", "r", stdin);

int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   ll n,f=0;
   cin>>n;
   vector<ll>v(n);
   for(int i=0;i<n;i++) cin>>v[i];
   long long mx=v[0];
   for(int i=1;i<n;i++){
    if(mx-v[i]>1) f=1;
    mx=max(mx,v[i]);
   }
   if(f) cout<<"No"<<endl;
   else cout<<"Yes"<<endl;
   return 0;
}


Measured memory_bytes: 1024
def main():
    import sys
    input = sys.stdin.readline
    n,m = map(int,input().split())
    A = list(map(int,input().split()))
    BC = [list(map(int,input().split())) for _ in range(m)]

    BC = sorted(BC,key=lambda x:(x[1]),reverse=True)
    append_list = []
    for b,c in BC:
        if len(append_list)>=n:
            break
        append_list+=[c]*b
    A+=append_list
    A.sort(reverse=True)
    print(sum(A[:n]))

if __name__=='__main__':
    main()

Measured memory_bytes: 35176
#include <iostream>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <vector>
#include <queue>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;

  int ans = -1;
  for (int i = 1; i <= 1000; i++) {
    int tax_a = floor((double)i*0.08);
    int tax_b = floor((double)i*0.1);
    if (tax_a == a && tax_b == b) {
      ans = i;
      break;
    }
  }

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

Measured memory_bytes: 256
sx,sy,tx,ty = map(int,input().split())
dx = tx-sx
dy = ty-sy
ans = 'R'*dx + 'U'*dy + 'L'*dx + 'D'*dy + 'D' + 'R'*(dx+1) + 'U'*(dy+1) + 'LU' + 'L'*(dx+1) + 'D'*(dy+1) + 'R'
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h> 
using namespace std; 
typedef long long ll;
int n,m,q,a[55],b[55],c[55],d[55],ans,aa[55];
void Calc(){
	int s=0;
	for(int i=1;i<=q;i++)if(aa[b[i]]-aa[a[i]]==c[i])s+=d[i];
	ans=max(ans,s);
}
void DFS(int x){
	if(x>n){
		Calc();
		return ;
	}
	for(int i=max(aa[x-1],1);i<=m;i++)aa[x]=i,DFS(x+1);
}
int main(){
	cin>>n>>m>>q;
	for(int i=1;i<=q;i++)cin>>a[i]>>b[i]>>c[i]>>d[i];
	DFS(1);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3596
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};
    static long mod=1000000007;
    
    public static void main(String[] args) {        
        new Thread(null, new Main(), "", 200 * 1024 * 1024).start();        
    }

    public void run() {
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        
        int n=sc.nextInt();
        int a[]=sc.nextIntArray(n);
        ArrayList<Integer> d[]=new ArrayList[n];
        for (int i = 0; i < d.length; i++) {
			d[i]=new ArrayList<>();
		}
        for (int i = 0,l,r; i < d.length; i++) {
        	l=i-a[i];
        	r=i+a[i];
        	if(0<=l)d[l].add(i);
        	if(r<n)d[r].add(i);
		}
        long ans=0;
        for (int i = 1; i < d.length; i++) {
        	long l=0,r=0; 
			for (int j = 0; j < d[i].size(); j++) {
				if(d[i].get(j)<i)l++;
				else r++;
			}
			ans+=l*r;
		}
   
        out.println(ans);
     	out.flush();
    }
    
    
    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }

    static void ret(long ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//class P {
//	int x,c;long s;
//	P(int  x, int c, long s) {
//	  this.x=x;
//	  this.c=c;
//	  this.s=s;
//	}
//}


class P implements Comparable<P>{
	int x,c;long s;
	P(int  x, int c, long s) {
	  this.x=x;
	  this.c=c;
	  this.s=s;
	}

    public int compareTo(P p){
        return Long.signum(s-p.s);
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString()
    {
        while( st==null || !st.hasMoreTokens() )
			try {
				st = new StringTokenizer(x.readLine());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        return st.nextToken();
    }
    public int nextInt()
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) {
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) {
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() {
        return this.nextString().toCharArray();
    }    
    public long nextLong()
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 74024
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def find_gcd(list_l):
    x = reduce(gcd, list_l)
    return x


def main():
    n,k = map(int,input().strip().split())
    a = list(map(int, input().strip().split()))
    x_min=min(a)
    m=n
    for i in range(n):
        if a[i]==x_min:
            m-=1
    print(-(-m//(k-1)))


if __name__ == '__main__':
    main()

Measured memory_bytes: 74472
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;
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; }

//入力
int n;
long long w,a[110][2];

//DPテーブル
long long dp[110][100010];


int main() {
  cin >> n >> w;
  for(int i=0;i<n;i++){
    cin >> a[i][0] >> a[i][1];
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<w+1;j++){
      
      if(j>=a[i][0]){
        chmax(dp[i+1][j],dp[i][j-a[i][0]]+a[i][1]);
      }
      chmax(dp[i+1][j],dp[i][j]);
    }
  }
  cout << dp[n][w] << endl;
}


Measured memory_bytes: 79360
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,k;
    cin>>k>>n;
    long long int i,a[n],b[n],d,m,count=0;
    for(i=0;i<n;i++)
    cin>>a[i];
    for(i=0;i<n-1;i++)
    {
        d=a[i+1]-a[i];
        m=abs(d);
        if(m>k/2)
        m=k-m;
        b[i]=m;
    }
    d=a[n-1]-a[0];
    m=abs(d);
    if(m>k/2)
    m=k-m;
    b[n-1]=m;
    sort(b,b+n);
    for(i=0;i<n-1;i++)
    count=count+b[i];
    cout<<count;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define INF 1050000000

int main()
{
  int n,wmax;cin>>n>>wmax;
  vector<int> w(n);
  vector<int> v(n);
  int i,j;
  for(i=0;i<n;i++)cin>>w.at(i)>>v.at(i);
  vector<vector<long long>> val(n+1,vector<long long>(wmax+1,0));
  for(i=1;i<=n;i++)
  {
    for(j=0;j<=wmax;j++)
    {
      val.at(i).at(j)=val.at(i-1).at(j);
      if(j-w.at(i-1)>=0)val.at(i).at(j)=max(val.at(i).at(j),val.at(i-1).at(j-w.at(i-1))+v.at(i-1));
      if(j-1>=0)val.at(i).at(j)=max(val.at(i).at(j),val.at(i).at(j-1));
    }
  }
  cout<<val.at(n).at(wmax)<<endl;
}

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

int main(){
    string s;
    cin >> s;
    map<char,int> ans;
    bool out = true;
    for (int i = 0;i < s.size();i++){
        if (ans[s[i]] == 1){
            out = false;
            break;
        }
        else {
            ans[s[i]] = 1;
        }
    }
    if (out){
        cout << "yes" << endl;
    }
    else {
        cout << "no" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdio> 
using namespace std;
int main()
{
	int n,k,x,y,money;
	cin>>n>>k>>x>>y;
	if(n>k)
	money=k*x+(n-k)*y;
	else
	money=n*x;
	cout<<money; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    int main(){
        int a, b, c, d, e, f;
            cin >> a >> b >> c;
                d = a + b;
                e = b + c;
                f = c + a;
                    if(d <= e && d <= f){
                        cout << d;
                            return 0;
                    }else if(e <= d && e <= f){
                        cout << e;
                            return 0;
                    }else if(f <= d && f <= e){
                        cout << f;
                            return 0;
                    }
    return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  ll k;
  cin >> k;
  int km = k % 50;
  k /= 50;
  vector<ll> ans(50, k + 49);
  cout << 50 << endl;
  rep(i, km){
    rep(j, 50){
      if(j == i) ans.at(j) += 50;
      else ans.at(j)--;
    }
  }
  rep(i, 50){
    if(i != 0) cout << " ";
    cout << ans.at(i);
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256