akhauriyash/Code-Regression huggingface dataset:
import collections as c

n,k = map(int,input().split())
l = list(map(int,input().split()))
count = c.Counter(l)
ans = 0
check = 0
right = len(count)-k
if right <= 0:
    print(0)
    exit()
for i,j in count.most_common()[::-1]:
    ans += j
    check += 1
    if check == right:
        print(ans)
        exit()

Measured memory_bytes: 39344
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll k;
ll a[100];
int main(){
	cin >> k;
	ll n = 50;

	REP(i,n) {
		a[i] = n - 1 + (k / n);
	}

	REP(i,k % n) {
		a[i] += n - (k % n) + 1;
	}
	FOR(i,k % n,n) {
		a[i] -= (k % n);
	}
	cout << n << endl;
	REP(i,n) {
		cout << a[i] << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a, b, c, i, yakusu = 0;

	scanf("%d %d %d", &a, &b, &c);

	for(i=a; i<=b; i++)
	{
		if(c%i == 0)
		{
			yakusu++;
		}
	}

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

	return 0;
}

Measured memory_bytes: 596
d = ["A","G","T","C"]
s = input()
r=[0]
n = 0
bf =0
for t in s:
    if t in d:
        n +=1
        bf = 1
        continue
    if bf == 1:
        r.append(n)
        n=0
    bf = 0
if bf == 1:
        r.append(n)
        
print(max(r))

Measured memory_bytes: 3060
N=int(input())
A = [int(x) for x in input().split()]
A.sort()
score=0
for i in range(N):
  for j in range(i,N):
    for k in range(j,N):
      if A[i]!=A[j] and A[j]!=A[k] and A[i]+A[j]>A[k]:
        score+=1
print(score)

Measured memory_bytes: 9124
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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

__attribute__ ((constructor))
void init() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
}

signed main(){
    int a,b;
    cin >> a >> b;
    if(a >= 13)
      cout << b << endl;
    else if(6 <= a && 12 >= a)
      cout << b / 2 << endl;
    else
    {
      cout << 0 << endl;
    }
    
    return 0;
}

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

int main(void){
   int A,B,C;
   cin>>A>>B>>C;
   int num[11]={0};
   num[A]+=1;
   num[B]+=1;
   num[C]+=1;
   if(num[5]==2&&num[7]==1){
      cout<<"YES"<<endl;
   }else{
      cout<<"NO"<<endl;
   }
   return 0;
}



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

	int main() {
		
		int a,i;
		int data[5];
		for ( i = 0; i < 5; i++) {
			cin >> data[i];
		}

		for ( i = 0; i < 5; i++) {
			if (data[i] != i + 1) {
				cout << i + 1;
			}
		}

		return 0;
	}

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

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

int main()
{
    ll N;
    cin >> N;
    vector<ll> a(N);
    rep(0, i, N)
    {
        cin >> a.at(i);
    }

    ll highest = a.at(0);
    ll ans = 0;
    rep(1, i, N)
    {
        if (a.at(i) < highest)
        {
            ans += highest - a.at(i);
        }
        else
        {
            highest = a.at(i);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
vector<int> x = {1,-1,0,0};
vector<int> y = {0,0,-1,1};
int main(){
    map<ll,ll> data;
    ll n;
    cin >> n;
    vector<ll> input(n);
    rep(i,0,n){
        ll a;
        cin >> a;
        input[i]=a;
        data[a]++;
    }
    ll sum=0;
    rep(i,0,n+1){
        sum += data[i]*(data[i]-1)/2;
    }
    rep(i,0,n){
        if(data[input[i]]>1){
            ll b = sum;
            ll c = data[input[i]]-1;
            cout<<b-c<<endl;
        }else{
            cout<<sum<<endl;
        }
        
    }
  return 0;
}

Measured memory_bytes: 17228
#include <bits/stdc++.h>
using namespace std;
int N, ans=0;

int Sosu(int x){
  switch(x){
    case 1: return 2;
    case 2: return 3;
    case 3: return 5;
    case 4: return 7;
    case 5: return 11;
    case 6: return 13;
    case 7: return 17;
    case 8: return 19;
  }
}

int Loop(int Point, int Bridge[], int Posi){
  Point/=Sosu(Posi);
  if(Point==1){
    ans++;
    return 0;
  }
  for(int i=1 ; i<N+1 ; i++)
    if(Point%Sosu(i)==0 && Bridge[Posi]%Sosu(i)==0){
      //cout << Posi << "->" << i << endl;
      Loop(Point, Bridge, i);
    }
  return 0;
}

int main(){
  int M;
  cin >> N >> M;
  int Point=1, Bridge[N+1];
  for(int i=1 ; i<N+1 ; i++){
    Point*=Sosu(i);
    Bridge[i]=1;
  }
  
  for(int i=0 ; i<M ; i++){
    int A, B;
    cin >> A >> B;
    Bridge[A]*=Sosu(B);
    Bridge[B]*=Sosu(A);
  }
  
  int Posi=1;
  Loop(Point, Bridge, Posi);
  cout << ans << endl;
}

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

int main() {
    constexpr double pi = 3.1415926535;

    cout << fixed << setprecision(9);
    int a, b; cin >> a >> b;
    int h, m; cin >> h >> m;

    double ha = (h * 1800 + m * 30) / 60.0;
    double ma = (m * 360) / 60.0;
    double wa = ha - ma;

    cout << sqrt(pow(a - b * cos(wa / 180 * pi), 2) + pow(b * sin(wa / 180 * pi), 2)) << endl;
}



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

using namespace std;
using ll = long long;

#define rep(i, a) for (int (i) = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int (i) = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int (i) = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int (i) = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
	#define lcout(a) cout << a;
	#define lcoutln(a) cout << a << endl;
	#define lcerr(a) cerr << a;
	#define lcerrln(a) cerr << a << endl;
#else
	#define lcout(a) 
	#define lcoutln(a) 
	#define lcerr(a) 
	#define lcerrln(a) 
#endif

int main()
{
	CIN(string, s);
	PRINT(s[0] == s[2]);
}


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;

  vector<int> Time = { a, b, c, d, e };

  vector<int> NextTime(5);

  for(int i = 0; i < 5; i++){
    if(Time[i] % 10 != 0){ NextTime[i] = Time[i] - Time[i] % 10 + 10; }
    else{ NextTime[i] = Time[i]; }
  }

  int BestTime = 99999999;
  int sum = 0;
  for(int i = 0; i < 5; i++){
    sum += NextTime[i];
  }

  for(int i = 0; i < 5; i++){
    sum -= NextTime[i];
    sum += Time[i];

    if(sum < BestTime) BestTime = sum;
    sum -= Time[i];
    sum += NextTime[i];
  }

  cout << BestTime << endl;

  return 0;

}


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

#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define INF 2000000000000000000
#define endl "\n"
#define _time_ 1.0 * clock() / CLOCKS_PER_SEC
#define popcount(x) __builtin_popcountll(x)
#define pll pair<ll,ll> 
#define ld long double

const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);

ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T, U> &p)
{ 
    return os<<'('<<p.F<< ","<<p.S<<')'; 
}
char c[10][10];
int _runtimeTerror_()
{
    int h,w,k;
    cin>>h>>w>>k;
    for(int i=0;i<h;++i)
        for(int j=0;j<w;++j)
            cin>>c[i][j];
    auto cnt=[&](int m1,int m2)
    {
        int ans=0;
        for(int i=0;i<h;++i)
        {
            for(int j=0;j<w;++j)
            {
                if(m1&(1<<i) || m2&(1<<j))continue;
                ans+=c[i][j]=='#';
            }
        }
        return ans;
    };
    int p=0;
    for(int i=0;i<(1<<h);++i)
    {
        for(int j=0;j<(1<<w);++j)
        {
            int l=cnt(i,j);
            p+=l==k;
        }
    }
    cout<<p;
    return 0;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef runSieve
        sieve();
    #endif
    #ifdef NCR
        initialize();
    #endif
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--)
        _runtimeTerror_();
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>

using namespace std;

template <class T> void write(T x){
    cout << x << " = ";
    for(int i = 4; i >= 0; --i) cout << ((x >> i) & 1);
}

const int N = 41;
const long long mod = 1e9 + 7;

int n,x,y,z;
long long res = 1;
long long f[N][1 << 22];

void solve(){
    int t = x + y + z - 1,m = 1 << t;
    f[0][0] = 1;
    for(int i = 0; i < n; ++i){
        for(int msk = 0; msk < m; ++msk) if(f[i][msk]){ // msk & (1 << k) =>>> there exists a postion v | sum(v -> i) = k + 1
            for(int j = 1; j <= 10; ++j){
                int msk1 = 0;
                if(j <= x) msk1 |= (1 << (j - 1));
                bool ok = 1;
                for(int k = 0; k < t; ++k) if(msk & (1 << k)){
                    if(k + 1 + j >= x + y + z){
                        if(k + 1 + j == x + y + z && j <= z){
                            ok = 0;
                            break;
                        }
                        continue;
                    }
                    if(k + 1 < x && k + 1 + j > x) continue;
                    if(k + 1 < x + y && k + 1 + j > x + y) continue;
                    msk1 |= (1 << (k + j));
                }
                if(ok){
                    f[i + 1][msk1] = (f[i + 1][msk1] + f[i][msk]) % mod;
                }
            }
        }
    }
    long long cnt = 0;
    for(int i = 0; i < m; ++i) cnt = (cnt + f[n][i]) % mod;
    res = ((res - cnt) % mod + mod) % mod;
}

int main(){

    cin >> n >> x >> y >> z;

    for(int i = 1; i <= n; ++i) res = (res * 10) % mod;

    solve();

    cout << res;

    return 0;
}


Measured memory_bytes: 82176
#include<stdio.h>
#include<stdlib.h>
int asc(const void* a, const void* b)
{
	if (*(long long int*)a > * (long long int*)b)return -1;
	if (*(long long int*)a < *(long long int*)b)return 1;
	return 0;
}
int main()
{
	long long int n, m, v, p;
	scanf("%lld %lld %lld %lld", &n, &m, &v, &p);
	long long int i;
	long long int a[100005];
	for (i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	qsort(a, n, sizeof(long long int), asc);
	long long int min, mid, max;
	long long int count;
	min = 0;
	max = n;
	while (max - min > 1)
	{
		mid = (max + min) / 2;
		if (mid < p)
		{
			min = mid;
			continue;
		}
		if (a[mid] + m < a[p - 1])
		{
			max = mid;
			continue;
		}
		count = 0;
		for (i = 0; i < n; i++)
		{
			if (i >= mid)
				count += m;
			else if (i < p - 1)
				count += m;
			else
				count += a[mid] + m - a[i];
		}
		if (count >= m * v)
			min = mid;
		else
			max = mid;
	}
	printf("%lld\n", max);
	return 0;
}

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
//int dx[4] = { 1,0,0,-1 };
//int dy[4] = { 0,1,-1,0 };
#define MOD 1000000007
#define ARRAY_MAX 55

const int INF = 1e9 + 7;


int main() {


	ios::sync_with_stdio(false);
	cin.tie(0);

	ll a, b;
	cin >> a >> b;

	ll ans = 0;

	//bit最大は45くらいで
	vector<ll> bit(ARRAY_MAX, 0);

	if (true) {
		//1桁目
		if ((((b+1) / 2) % 2) == 1) {
			bit[0] ^= 1;
		}
	}


	//bの各桁のビットを求める
	for (ll i = 45; i > 0; i--) {
		//1桁目は別で調べる
		//i桁目を見る
		ll high = 1LL << (i+1);//これで割る
		ll low = 1LL << i;
		if (b%high >= low) {
			if ((b%high) % 2 == 0) {
				//この数字まで1が奇数個ある
				bit[i] ^= 1LL;
			}
		}
	}

	a--;//累積和の感覚

	//1桁目
	if ((((a + 1) / 2) % 2) == 1) {
		bit[0] ^= 1LL;
	}

	for (ll i = 45; i > 0; i--) {
		//1桁目は別で調べる
		//i桁目を見る
		ll high = 1LL << (i + 1);//これで割る
		ll low = 1LL << i;
		if (a%high >= low) {
			if ((a%high) % 2 == 0) {
				//この数字まで1が奇数個ある
				bit[i] ^= 1LL;
			}
		}
	}

	for (int i = 0; i <= 45; i++) {
		if (bit[i] == 1) {
			ans += (1LL << i);
		}
	}
	cout << ans << endl;

	return 0;
}


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

public class Main {

    public static void main(String[] args) {
        try (CustomReader in = new CustomReader()) {
            new Main().execute(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void execute(CustomReader in) throws IOException {
        final int N = in.readLineAsInt();
        String input = in.readLine();
        int rcnt = 0;
        int bcnt = 0;
        for(int i=0; i<N; i++){
            char c = input.charAt(i);
            if (c=='R'){
                rcnt++;
            }else if(c=='B'){
                bcnt++;
            }
        }
        System.out.println((rcnt>bcnt)? "Yes": "No");
    }

    static class CustomReader extends BufferedReader {

        private static final int DEFAULT_BUF_SIZE = 2048;
        // private static final int DEFAULT_BUF_SIZE = 4096;
        // private static final int DEFAULT_BUF_SIZE = 8192;
        //private static final int DEFAULT_BUF_SIZE = 16384;
        // private static final int DEFAULT_BUF_SIZE = 1048576;

        public CustomReader() throws IOException {
            super(new InputStreamReader(System.in), DEFAULT_BUF_SIZE);
        }

        public int readLineAsInt() throws IOException {
            return Integer.parseInt(readLine());
        }

        public int[] readLineAsIntArray() throws IOException {
            String[] strArray = this.readLine().split(" ");
            int[] intArray = new int[strArray.length];
            for (int i = 0, n = strArray.length; i < n; i++) {
                intArray[i] = Integer.parseInt(strArray[i]);
            }
            return intArray;
        }

        public int[][] readLinesAsIntMatrix(int rows, int columns) throws IOException {
            int[][] matrix = new int[rows][columns];
            for (int i = 0; i < rows; i++) {
                String[] r = this.readLine().split(" ");
                for (int j = 0; j < columns; j++) {
                    matrix[i][j] = Integer.parseInt(r[j]);
                }
            }
            return matrix;
        }
    }
}

Measured memory_bytes: 22484
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,b,c,k,sum;
    cin>>a>>b>>c>>k;
    if(k<=a)
    {
        sum=k;
    }
    else if(k<=a+b)
    {
        sum=a;
    }
    else
    {
        sum=a+a+b-k;
    }
    cout<<sum;
    return 0;
}
//Author: master_sam

Measured memory_bytes: 3632
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
  int N = nextInt();
  ArrayList<String> list = nextCharArray();
  int output = 1;
  for(int i = 1; i < N; i++){
    if(!list.get(i).equals(list.get(i - 1))){
      output++;
    }
  }
  myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}


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

int main() {
	int m, k;
	cin >> m >> k;
	int n = 1 << m;
	if (!k) {
		for (int i = 0; i < n; i++)
			cout << i << ' ' << i << ' ';
		cout << endl;
		return 0;
	}
	if (n == 2 || n <= k) {
		cout << -1 << endl;
		return 0;
	}
	cout << "0 " << k << " 0 ";
	for (int i = 1; i < n; i++)
		if (i != k)
			cout << i << ' ';
	cout << k << ' ';
	for (int i = n; --i;)
		if (i != k)
			cout << i << ' ';
	cout << endl;
	return 0;
}


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

#define ll long long
int main() {
  ll N, M;
  cin >> N >> M;
  
  if (M <= 2 * N) {
    cout << M / 2 << endl;
  } else {
    cout << N + (M - 2 * N) / 4 << endl;
  }
  
}

Measured memory_bytes: 3616
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
int main(void){
    int a, b;
    cin >> a >> b;
    auto ans = 0;
    if(a > b){
        ans = 2*a - 1;
    } else if(a == b){
        ans = 2*a;
    } else{
        ans = 2*b - 1;
    }
    cout << ans; 
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_set>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long

int n;
vector<int> a;

int main(void)
{
    cin >> n;
    rep(i, n)
    {
        int temp;
        cin >> temp;
        a.push_back(temp);
    }

    sort(a.begin(), a.end(), greater<int>());

    int pa = 0;
    int pb = 0;

    rep(i, n)
    {
        if (i % 2 == 0)
            pa += a[i];
        else
            pb += a[i];
    }

    cout << (pa - pb) << endl;

    return 0;
}


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

int main() {
  int N, L;
  string S[110];
  cin >> N >> L;
  for(int i=0; i<N; i++) cin>>S[i];

  sort(S, S+N);

  for(int i=0; i<N; i++) cout << S[i];
  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, a[11];
    cin >> n;
    REP(i, n)
    cin >> a[i];

    int res = 0;
    for (int i = 0; i < pow(3, n); i++)
    {
        int b[11];
        bool has = false;

        V v;
        int i_ = i;
        REP(j, n)
        v.push_back(i_ % 3), i_ /= 3;
        REP(j, n)
        {
            b[j] = a[j] - 1 + v[j];
            if (b[j] % 2 == 0)
                has = true;
        }
        res += has;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var NM = Sarray();
            var N = NM[0];// スイッチ
            var M = NM[1];// 電球
            var Sij = new List<long>[M];// 電球につながっているスイッチ
            for (var i = 0; i < M; ++i)
                Sij[i] = Slist();
            var Pi = Sarray();// 電球がONになる条件
            var ans = 0L;
            for (var i = 0; i < 1 << (int)N; ++i) // 全探索
            {
                var ss = new long[N];
                for (long j = 0L, s = i; j < N && s != 0; ++j, s >>= 1)// ONになっているスイッチ
                {
                    if ((s & 1) != 0)
                        ss[j] = 1;
                }
                var num = 0L;
                for (var j = 0; j < M; ++j)// 電球の点灯確認
                {
                    var sum = 0L;
                    for (var k = 1; k <= Sij[j][0]; ++k)
                        sum += ss[Sij[j][k] - 1];
                    if (Pi[j] == (sum % 2))
                        ++num;
                }
                if (num == M)// 全部点灯
                    ++ans;
            }
            WriteLine(ans);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

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

int isPrime(int a) {
    for (int i = 2; i * i <= a; ++i) {
        if (a % i == 0) {
            return 0;
        }
    }
    return 1;
}


ll computeDifs(vector<ll>& x, ll mod) {
    vector<pair<ll, ll>> sumLast;
    sumLast.emplace_back(0, 0);
    for (int i = 1; i < x.size(); ++i) {
        ll l =  sumLast.back().second + i * (+ x[i] - x[i - 1]);
        l = l % mod;
        ll s = (sumLast.back().first + l) % mod;

        sumLast.emplace_back(s, l);
    }


    return sumLast.back().first;
}


void oneCase () {
    int n, m;
    cin >> n >> m;
    vector<ll> x(n);
    vector<ll> y(m);
    for (auto& el : x) {
        cin >> el;
    }
    for (auto& el : y) {
        cin >> el;
    }
    ll mod = 1e9 + 7;

    cout << (computeDifs(x, mod) * computeDifs(y, mod)) % mod;
    cout << "\n";

}





int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

Measured memory_bytes: 5460
n = int(input())

abc = []
for i in range(n):
  a,b,c = list(map(int,input().split()))
  abc.append((a,b,c))

dp = [[0]*3 for i in range(n)]
dp[0][0] = abc[0][0]
dp[0][1] = abc[0][1]
dp[0][2] = abc[0][2]

for i in range(1,n):
  for j in range(3):
    dp[i][j] = max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]) + abc[i][j]
    #print(i,j,(j+1)%3,(j+2)%3)
    
#print(dp)
ans = max(dp[n-1])
print(ans)

Measured memory_bytes: 75096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vl = vector<ll>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using vs = vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.141592653589793

template<class S, class T>ostream&operator<<(ostream&os, pair<S, T>p)
{
	os << "[" << p.first << "," << p.second << "]"; return os;
}
template<class S>auto&operator<<(ostream&os, vector<S>t)
{
	bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; }
	return os;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s1, s2;
	while (cin >> s1, s1!="." ) {
		cin >> s2;
		vector<pair<string, int>> tok1(1);
		vector<pair<string, int>> tok2(1);
		int inner = 0;
		for (auto c : s1) {
			if (c == '"') {
				if (inner == 0) {
					inner = 1;
				}
				else {
					inner = 0;
				}
				tok1.emplace_back("", inner);
			}
			else {
				tok1.back().first += c;
			}
		}
		inner = 0;
		for (auto c : s2) {
			if (c == '"') {
				if (inner == 0) {
					inner = 1;
				}
				else {
					inner = 0;
				}
				tok2.emplace_back("", inner);
			}
			else {
				tok2.back().first += c;
			}
		}
		int ans = 0;
		if (tok1.size() == tok2.size()) {
			int diff = 0;
			rep(i, tok1.size()) {
				if (tok1[i].sc != tok2[i].sc) {
					ans = 2; break;
				}
				else {
					if (tok1[i].sc == 0) {
						if (tok1[i].fs != tok2[i].fs) {
							ans = 2;
							break;
						}
					}
					else {
						if (tok1[i].fs != tok2[i].fs) {
							ans++;
						}
					}
				}
			}
		}
		else {
			ans = 2;
		}
		if (ans == 0)cout << "IDENTICAL" << endl;
		else if (ans == 1)cout << "CLOSE" << endl;
		else cout << "DIFFERENT" << endl;
	}
	return 0;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define N 44
lli F[N]={0};

lli fibonacci(int n){
	if(n==0 || n==1)return F[n] = 1;
	if(F[n]!=0)return F[n];
	return F[n] = fibonacci(n-2) + fibonacci(n-1);

}

int main(){
	int n;
	cin >> n;
	cout << fibonacci(n) << endl;
	return 0;
}

Measured memory_bytes: 3068
#include <stdio.h>

int main()
{
  long long l,r,i,j;
  long long min=2020;

  scanf("%lld%lld",&l,&r);

  for(i=l; i<r; i++)
  {
    for(j=l+1; j<=r; j++)
    {
      if((i*j)%2019 < min)
      {
        min = (i*j)%2019 ;
        if(min == 0){
          puts("0");
          return 0;
        }
      }
    }
  }

  printf("%lld",min );

  return 0;
}


Measured memory_bytes: 1736
import java.util.Scanner;

class Card {
	String mark;
	int num, flag;

	public Card(String str, int n, int f) {
		mark = str;
		num = n;
		flag = f;
	}

	public void Show() {
		System.out.println(mark + " " + num);
	}
}

public class Main {
	static Card[] card = new Card[100001];
	static Card swap;

	public static int partation(int p, int r) {
		int x = card[r].num;
		int i = p - 1;
		for (int j = p; j < r; j++) {
			if (card[j].num <= x) {
				i = i + 1;
				swap = card[i];
				card[i] = card[j];
				card[j] = swap;
			}
		}
		swap = card[i + 1];
		card[i + 1] = card[r];
		card[r] = swap;
		return i + 1;
	}

	public static void quicksort(int p, int r) {
		int q;
		if (p < r) {
			q = partation(p, r);
			quicksort(p, q - 1);
			quicksort(q + 1, r);
		}
	}

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int i, n, f = 0;
		n = scan.nextInt();
		for (i = 0; i < n; i++) {
			card[i] = new Card(scan.next(), scan.nextInt(), i);
		}
		quicksort(0, n - 1);

		for (i = 0; i < n - 1; i++) {
			if (card[i].num == card[i + 1].num && card[i].flag > card[i + 1].flag) {
				f = 1;
				break;
			}
		}
		if (f == 0) {
			System.out.println("Stable");
		} else {
			System.out.println("Not stable");
		}

		for (i = 0; i < n; i++) {
			card[i].Show();
		}

		scan.close();
	}
}


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

int main(){

int N, K;
cin >> N >> K;

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

sort(h.begin(), h.end());

vector<long long>sum(N);
sum.push_back(0);

for(int i = 1; i < N; i++){ 
       sum.at(i) = sum.at(i - 1) + (h.at(i) - h.at(i - 1));
}

// 0 1 2 3 4 
 // 0 1 2 3 4

long long ans =2000000000;
for(int i = K - 1; i < N; i++){ 
       ans = min(ans, sum.at(i) - sum.at(i - (K - 1)));
}


cout << ans << endl; 
}

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

using namespace std;

int main()
{
  int N; cin >> N;
  vector<long long> L(N+1);
  L[0] = 2, L[1] = 1;
  for (int i = 2; i <= N; ++i) {
    L[i] = L[i-1] + L[i-2];
  }

  cout << L[N];
}

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

int main(){
    int n,k; cin >> n >> k;
    string s; cin >> s;
    int cnt = 1;
    rep(i,n-1){
        if(s[i] != s[i+1]) cnt ++;
    }
    cout << n-max(1,cnt-2*k) << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define U [7<<15]={}
#define G )+((c=A[a]+A[P[a]]+C[a])%k?c:0)-M(
typedef long long L;using namespace std;map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L M(L f){return f?B[f]+M(f^f&-f):0;}L S(L a,L i){for(a=M(i++G i);i<2e5;i+=i&-i)B[i]+=a;}L D(L f){L d;Z[f]=1;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)d=I->first,!Z[d]?P[d]=f,E[d]=E[f]+1,C[d]=I->second,D(d),Z[f]+=Z[d],!H[f]|Z[H[f]]<Z[d]?H[f]=d:0:0;}L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}main(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(a=0);n<*Z;a=H[P[++n]]-n?n:0)for(;!O[a];S(a=H[a],O[a]=++b))X[a]=n;for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}

Measured memory_bytes: 38084
# -*- coding: utf-8 -*-
import sys
import os

import math
import random


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

a,b = [int(i) for i in input().split(' ')]

#素因数分解
ap = list(set(prime_factorize(a)))
bp = list(set(prime_factorize(b)))

#print(ap, bp)

al = []
bl = []

al = ap
bl = bp

#for i in ap:
#    al.append(i)
#for i in bp:
#    bl.append(i)

if len(al) == 0 or len(bl) == 0:
    print(1)
else:
    print(len(list(set(al) & set(bl))) + 1)

Measured memory_bytes: 4208
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;

int arr[15][15];
int t[15][15];

int main() {
	int n, m;
	cin >> n >> m;
	for (int i=0; i<n; ++i) {
		for (int j=0; j<n; ++j) {
			cin >> arr[i][j];
		}
	}
	int o;
	for (int i=0; i<m; ++i) {
		cin >> o;
		int r, c, size, angle;
		if (o == 0) {
			cin >> r >> c >> size >> angle;
			--r, --c;
			if (angle == 0 || angle == 360) {
				// pass
			} else if (angle == 90) {
				memcpy(t, arr, sizeof t);
				for (int j=0; j<size; ++j) {
					for (int k=0; k<size; ++k) {
						arr[r+j][c+k] = t[r+size-1-k][c+j];
					}
				}
			} else if (angle == 180) {
				memcpy(t, arr, sizeof t);
				for (int j=0; j<size; ++j) {
					for (int k=0; k<size; ++k) {
						arr[r+j][c+k] = t[r+size-1-j][c+size-1-k];
					}
				}
			} else if (angle == 270) {
				memcpy(t, arr, sizeof t);
				for (int j=0; j<size; ++j) {
					for (int k=0; k<size; ++k) {
						arr[r+j][c+k] = t[r+k][c+size-1-j];
					}
				}
			}
		} else if (o == 1) {
			cin >> r >> c >> size;
			--r, --c;
			for (int j=r; j<r+size; ++j) {
				for (int k=c; k<c+size; ++k) {
					arr[j][k] = 1 - arr[j][k];
				}
			}
		} else if (o == 2) {
			cin >> r;
			--r;
			rotate(arr[r], arr[r]+1, arr[r]+n);
		} else if (o == 3) {
			cin >> r;
			--r;
			rotate(arr[r], arr[r]+n-1, arr[r]+n);
		} else {
			cin >> r >> c;
			--r, --c;
			queue<pair<int,int> > q;
			q.push(make_pair(r, c));
			int v = 1 - arr[r][c];
			while ( ! q.empty()) {
				int nr = q.front().first;
				int nc = q.front().second;
				q.pop();
				if (arr[nr][nc] == v) continue;
				arr[nr][nc] = v;
				if (nr+1 < n) q.push(make_pair(nr+1, nc));
				if (0 <= nr-1) q.push(make_pair(nr-1, nc));
				if (nc+1 < n) q.push(make_pair(nr, nc+1));
				if (0 <= nc-1) q.push(make_pair(nr, nc-1));
			}
		}
	}
	for (int i=0; i<n; ++i) {
		for (int j=0; j<n; ++j) {
			cout << (j == 0 ? "" : " ") << arr[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <limits>
using namespace std;
// 素因数分解
typedef pair<long long, long long> P;
vector<P> prime_factorize(long long n)
{
vector<P> res;
for (long long p = 2; p * p <= n; ++p)
{
if (n % p != 0)
continue;
int num = 0;
while (n % p == 0)
{
++num;
n /= p;
}
res.push_back(make_pair(p, num));
}
if (n != 1)
res.push_back(make_pair(n, 1));
return res;
}
// 因数分解
long long gcd(long long x, long long y)
{
  if (y == 0)
  {
    return x;
  }
  else
  {
    return gcd(y, x % y);
  }
}
const int MOD = 1000000007;
typedef long long int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)

int main()
{
    int a, b;
    cin >> a >> b;
    string A = to_string(a), B = to_string(b);
    rep(i,b-1){
        A += to_string(a);
    }
    rep(i,a-1){
        B += to_string(b);
    }
    cout << min(A, B) << endl;
    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector< int > vi;
typedef vector< ll > vll;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define fi first
#define se second
#define endl '\n'
#define mod 1000000007  //1e9+7
#define pi 3.14159265358979323846
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define inf INT_MAX
const int N = 2e5 + 5;


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

   	int n;
   	cin >> n;

   	vi a(n);
   	rep(i,0,n) cin >> a[i];

   	vll dp(n,LLONG_MAX);
   	dp[0] = 0;

   	rep(i,1,n)
   	{
   		rep(j,i-2,i)
   		{
   			if(j < 0) continue;
   			dp[i] = min(dp[i],dp[j]+abs(a[i]-a[j]));
   		}
   	}

   	cout << dp[n-1];

	return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
int main(void)
{
    int n,a,i,j,count = 0;
    scanf("%d",&n);
    for(i = 1 ;i <= n ; i++)
    {
        scanf("%d",&a);
        if(a % 2 == 0)
        {
            if(a % 3 != 0 && a % 5 != 0)
            {
                printf("DENIED");
                return 0 ;
            }
        }
    }
    printf("APPROVED");
    return 0;

}

Measured memory_bytes: 1736
n, m, q = gets.split.map(&:to_i)

array = (0..n - 1).to_a

index = 0

gets.split.map(&:to_i).each do |val|
  index = val.odd? ? (array.size + index - val) % array.size : (array.size + index + val) % array.size
  array.delete_at(index)
end

gets.split.map(&:to_i).each do |val|
  puts (array.include? val) ? 1 : 0
end

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

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 main(){
    int N;cin>>N;
    vector<long long> a(N);
    for(int i=0;i<N;i++)cin>>a[i];
    int num_minus=0;
    long long mi=1LL<<60;
    long long sum=0;
    for(int i=0;i<N;i++){
        if(a[i]<0)num_minus++;
        chmin(mi,abs(a[i]));
        sum+=abs(a[i]);
    }
    if(num_minus %2==0)cout<<sum<<endl;
    else cout<<sum-mi*2<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  ll a,b,c;cin>>a>>b>>c;
  ll x;cin>>x;
  ll ans=0;
  rep(i,a+1){
    rep(j,b+1){
      rep(k,c+1){
        if(x==(500*i+100*j+50*k)){
          ans++;
        }
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

int main(){
  int a,b,c,area,s;
  cin >> a >> b >> c;
  s = (a+b+c)/2;
  area = sqrt(s*(s-a)*(s-b)*(s-c));
  cout << area;
  
}


Measured memory_bytes: 256
import math
from itertools import accumulate

n = int(input())
a = list(map(int, input().split()))

fromright = list(accumulate(a, math.gcd))
a.reverse()
fromleft = list(accumulate(a, math.gcd))
fromleft.reverse()

gcd = []

gcd.append(fromleft[1])

for i in range(1, n-1):
  gcd.append(math.gcd(fromright[i-1], fromleft[i+1]))

gcd.append(fromright[n-2])

if n == 2:
  print(max(a))
else:
  print(max(gcd))

Measured memory_bytes: 25108
// https://atcoder.jp/contests/abc174/tasks/abc174_b
#include<bits/stdc++.h>
using namespace std;

int main(int argc, char* argv[]) {
	long long n, d;
	cin >> n >> d;
	long long ans = 0;
	while (n--) {
		long long x, y;
		cin >> x >> y;
		long double r = sqrt(x*x + y*y);
		if (r <= d) ++ans;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3616
#include<iostream>
using namespace std;
int main() {

	//A
	int n;
	cin >> n;
	cout << n * (n + 1) / 2 << endl;
	return 0;

	//B
	/*string s;
	int i;
	cin >> s;
	int num = 0;
	char a[10];
	for (i = 0; i < s.length(); i++) {
		if (s[i] == '0' || s[i] == '1') {
			a[num] = s[i];
			num++;
		}
		else {
			if (num > 0)num--;
		}
	}
	for (i = 0; i < num; i++) {
		cout << a[i];
	}
	cout << endl;
	return 0;*/

	//C
	/*int a[100];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int sum;
	int min = 100000000;
	for (int i = -100; i <= 100; i++) {
		sum = 0;
		for (int j = 0; j < n; j++) {
			sum = sum + (i - a[j]) * (i - a[j]);
		}
		if (sum < min)min = sum;
	}
	cout << min << endl;
	return 0;*/


	//D
	/*
	string s;
	cin >> s;
	int i, j, k;
	int ab[26];
	for (i = 0; i < 26; i++) {
		ab[i] = 0;
	}
	for (j = 0; j < s.length() - 1; j++) {
		if (s[j] == s[j + 1]) {
			cout << j + 1 << ' ' << j + 2 << endl;
			return 0;
		}
		else if (j < s.length() - 2) {
			if (s[j] == s[j + 2]) {
				cout << j + 1 << ' ' << j + 3 << endl;
				return 0;
			}
		}
	}
	cout << -1 << ' ' << -1 << endl;
	return 0;*/
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

map<vector<int>,char> dp[101000];
int n,a,b,c;
bool check(int x,int y,int z){
   return (x>=0 and y>=0 and z>=0 and abs(x-a)<=4 and abs(y-b)<=4 and abs(z-c)<=4);
}

int main(){
   cin>>n>>a>>b>>c;
   vector<string> s(n);
   dp[0][{a,b,c}]='X';
   rep(i,0,n){
      cin>>s[i];
      for(auto t:dp[i]){
         vector<int> cur=t.first; int x,y,z;
         if(s[i]=="AB"){
            x=cur[0]+1,y=cur[1]-1,z=cur[2];
            if(check(x,y,z))dp[i+1][{x,y,z}]='A';
            x=cur[0]-1,y=cur[1]+1,z=cur[2];
            if(check(x,y,z))dp[i+1][{x,y,z}]='B';
         }
         if(s[i]=="AC"){
            x=cur[0]+1,y=cur[1],z=cur[2]-1;
            if(check(x,y,z))dp[i+1][{x,y,z}]='A';
            x=cur[0]-1,y=cur[1],z=cur[2]+1;
            if(check(x,y,z))dp[i+1][{x,y,z}]='C';
         }
         if(s[i]=="BC"){
            x=cur[0],y=cur[1]+1,z=cur[2]-1;
            if(check(x,y,z))dp[i+1][{x,y,z}]='B';
            x=cur[0],y=cur[1]-1,z=cur[2]+1;
            if(check(x,y,z))dp[i+1][{x,y,z}]='C';
         }
      }
   }
   if(dp[n].size()){
      puts("Yes"); vector<char> res;
      vector<int> cur; int idx=n-1;
      for(auto p:dp[n]){cur=p.first; break;}
      while(1){
         char c=dp[idx+1][cur];
         if(c=='X' or idx==-1)break;
         res.push_back(c);
         if(s[idx]=="AB"){
            if(c=='A')cur[0]--,cur[1]++;
            if(c=='B')cur[0]++,cur[1]--;
         }
         if(s[idx]=="AC"){
            if(c=='A')cur[0]--,cur[2]++;
            if(c=='C')cur[0]++,cur[2]--;
         }
         if(s[idx]=="BC"){
            if(c=='B')cur[1]--,cur[2]++;
            if(c=='C')cur[1]++,cur[2]--;
         } idx--;
      } reverse(ALL(res));
      for(auto& c:res)cout<<c<<endl; /*
      int x=a,y=b,z=c;
      rep(i,0,n){
         if(s[i]=="AB"){
            if(res[i]=='A')x++,y--;
            if(res[i]=='B')x--,y++;
         }
         if(s[i]=="AC"){
            if(res[i]=='A')x++,z--;
            if(res[i]=='C')x--,z++;
         }
         if(s[i]=="BC"){
            if(res[i]=='B')y++,z--;
            if(res[i]=='C')y--,z++;
         }
         if(!check(x,y,z)){
            puts("-1");
            return 0;
         }
      } */
   }
   else puts("No");
   return 0;
}

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

int main() {
  int N,M,Q; cin >> N >> M >> Q;
  int L[M],R[M]; rep(i,0,M) cin >> L[i] >> R[i];
  
  vector<vector<int>> d(N+1,vector<int>(N+1,0));
  rep(i,0,M) d[L[i]][R[i]]++;
  
  vector<vector<ll>> sum(N+1,vector<ll>(N+1,0));
  rep(i,1,N+1) {
    sum[i][1] = d[i][1];
    rep(j,2,N+1) {
      sum[i][j] = sum[i][j-1] + d[i][j];
    }
  }
    
  rep(i,0,Q) {
    int a,b,ans =0; cin >> a >> b;
    rep(j,a,b+1) ans += sum[j][b];
    cout << ans << endl;
  }
}  

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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;

int main() {
  ll N, K; cin >> N >> K;
  vi x(N); for (ll i = 0; i < N; i++) cin >> x[i];

  ll ans = (1ll << 32ll);

  for (ll i = 0; i < N; i++) {
    if (i + K - 1 > N - 1) {
      break;
    }
    if (x[i + K - 1] <= 0) {
      ans = min(ans, -x[i]);
      continue;
    }
    if (x[i] >= 0) {
      ans = min(ans, x[i + K - 1]);
      continue;
    }
    ans = min(ans, -x[i] * 2 + x[i + K - 1]);
    ans = min(ans, -x[i] + 2 * x[i + K - 1]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(int argc, char const *argv[])
{
  char a;
  scanf("%s",&a);
  switch(a){
    case 'a':printf("b"); break;
    case 'b':printf("c"); break;
    case 'c':printf("d"); break;
    case 'd':printf("e"); break;
    case 'e':printf("f"); break;
    case 'f':printf("g"); break;
    case 'g':printf("h"); break;
    case 'h':printf("i"); break;
    case 'i':printf("j"); break;
    case 'j':printf("k"); break;
    case 'k':printf("l"); break;
    case 'l':printf("m"); break;
    case 'm':printf("n"); break;
    case 'n':printf("o"); break;
    case 'o':printf("p"); break;
    case 'p':printf("q"); break;
    case 'q':printf("r"); break;
    case 'r':printf("s"); break;
    case 's':printf("t"); break;
    case 't':printf("u"); break;
    case 'u':printf("v"); break;
    case 'v':printf("w"); break;
    case 'w':printf("x"); break;
    case 'x':printf("y"); break;
    case 'y':printf("z"); break;
  }
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

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

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

        int[] B = new int[M];
        for(int i=0; i<M; i++){
            B[i] = sc.nextInt();
        }

        int[][] A = new int[N][M];
        for(int i=0; i<N; i++){
            for(int j=0; j<M; j++){
                A[i][j] = sc.nextInt();
            }
        }

        sc.close();

        int count = 0;

        for(int i=0; i<N; i++){
            int sum = C;

            for(int j=0; j<M; j++){
                sum += A[i][j] * B[j];
            }

            if(sum > 0){
                count++;
            }
        }

        System.out.println(count);

    }
}


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    int N,A,B;
    cin >> N >> A >> B;

    cout << min(N*A,B) << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  sort(h.begin(),h.end());
  int min = h[k-1]-h[0]; 
  for(int i=1;i<n-k+1;i++){
    if(min>h[k+i-1]-h[i]){
      min = h[k+i-1]-h[i];
    }
  }
  cout << min << "\n";
  return 0;
}

	 



Measured memory_bytes: 640