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

int main()
{
  int i,j,n,a,cnt,m;
  scanf("%d",&n);
  int A[n];

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

  for(i=0;i<n;i++){
    m=i;
      for(j=i+1;j<n;j++){
	if(A[j]<A[m])m=j;
      }
    if(A[i]>A[m]){
      int c=A[i];
      A[i]=A[m];
      A[m]=c;
      cnt++;
    }
  }
  printf("%d",A[0]);
  for(i=1;i<n;i++){
    printf(" %d",A[i]);
  }

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

  
  return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
#define inf 1e9
#define F first
#define S second
#define dbg(x) cout<<#x<<" value : "<<x<<"\n";
#define rep(i,j,k) for(int i = (j); i <= (k); i++)
#define rep__(i,j,k) for(int i = (j); i < (k); i++)
#define per(i,j,k) for(int i = (j); i >= (k); i--)
#define per__(i,j,k) for(int i = (j); i > (k); i--)
#define mst(a,b) memset(a,b,sizeof(a))
#define sf(n) scanf("%d",&n)
#define stf(n,m) scanf("%d%d",&n,&m)
#define pf(n) printf("%d\n",n)
#define slf(n) scanf("%lld",&n)
#define plf(n) printf("%lld\n",n)
priority_queue<int,vector<int>,less<int> > q;
const int N=1e3+10;
const int mod=1e9+7;
int n,a[N];
int main()
{
	double sum=0;
	int x=0;
	sf(n);
	rep(i,1,n){
		sf(x);
		sum+=(1.0/x);
	}
	printf("%.7f",1.0/sum);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>


using namespace std;


int main(){
    int x,y,v;
    ;
    while (scanf("%d%d%d",&x,&y,&v)&&x!=0&&y!=0&&v!=0){
        int possible_max=0;

        for(int z=1;z<=v/2;z++){
            int after_tax=z*(100+x)/100;
            int another=(v-after_tax)*100/(100+x);
            while(another*(100+x)/100+after_tax<v) another++;
            int sum=z*(100+y)/100+another*(100+y)/100;
            if (another*(100+x)/100+after_tax==v) possible_max=max(sum,possible_max);
        }

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



    return 0;  
}


Measured memory_bytes: 2724
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P pair<int,int>
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; }

signed main(){
  int n;
  cin >> n;
  vint time(13);
  vint D(n);
  time[0]++;
  rep(i,0,n){
    cin >> D[i];
    time[D[i]]++;
  }
  if(time[0] >= 2 || time[12] >= 2){
    cout << 0 << endl;
    return 0;
  }
  rep(i,1,12){
    if(time[i] >= 3){
      cout << 0 << endl;
      return 0;
    }
  }
  int ans = 0;
  for(int i = 0;i < (1 << 12);i++){
    vint judge(13);
    rep(j,0,13){
      if(i>>j&1) judge[j] = 1;
    }
    vint V;
    rep(j,0,13){
      if(time[j] == 2){
        V.push_back(j);
        V.push_back(24-j);
      }
      else if(time[j] == 1){
        if(judge[j] == 0){
          V.push_back(j);
        }
        else{
          V.push_back(24-j);
        }
      }
    }
    int tmp = INF;
    // rep(j,0,V.size()) cout << V[j] << " ";
    // cout << endl;
    rep(s,0,V.size()-1){
      rep(j,s+1,V.size()){
        tmp = min(tmp,abs(V[s] - V[j]));
        tmp = min(tmp,24 - abs(V[s]-V[j]));
      }
    }
    ans = max(ans,tmp);
  }
  cout << ans << endl;
}

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

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

ll A[5000],B[5000];
ll ans=0;
ll N,M;
ll calc(ll nb){
	ll na=0;
	ll res=0;
	while(1){
		if(na==N||nb==M){
			break;
		}
		if(A[na]==B[nb]){
			res++;
			nb++;
		}
		na++;
	}
	return res;
}

int main()
{
	cin>>N>>M;
	rep(i,N) cin>>A[i];
	rep(i,M) cin>>B[i];
	rep(i,M) ans=max(ans,calc(i));
	cout<<ans<<endl;
}

Measured memory_bytes: 3164
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 *
 * AND WATCH OUT FOR OFF BY ONE!!!
 */

#include <bits/stdc++.h>
using namespace std;
typedef unsigned int uint;
typedef long long ll;

#define fori(n) for(ll i=0; i<(n); i++)
#define forn(i, n) for(ll (i)=0; (i)<(n); (i)++)

int main() {
ll n;
    cin>>n;
    vector<ll> a(n);
    fori(n)
        cin>>a[i];

    vector<ll> gleft(n);
    gleft[0]=a[0];
    for(int i=1; i<n; i++)
        gleft[i]=__gcd(gleft[i-1], a[i]);

    vector<ll> gright(n);
    gright[n-1]=a[n-1];
    for(ll i=n-2; i>0; i--) 
        gright[i]=__gcd(gright[i+1], a[i]);

    vector<ll> dp(n); // dp[i]= gcd if a[i] is removed
    dp[0]=gright[1];
    dp[n-1]=gleft[n-2];
    for(int i=1; i<n-1; i++)
        dp[i]=__gcd(gleft[i-1], gright[i+1]);

    ll ans=*max_element(dp.begin(), dp.end());
    cout<<ans<<endl;
}



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


int main(){

    int N,M,A;
    cin >> N >> M;
    vector<int> v(N);
    priority_queue<ll> que;
    ll ans =0;
    for(int i=0;i<N;i++) {
         cin >> A;
         que.push(A);
    }
    for(int i = 0;i<M;i++) {
        int m = que.top();
        que.pop();
        que.push(m/2);
    }
    while(!que.empty()){
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
}


Measured memory_bytes: 1784
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        List<Integer[]> values = new ArrayList<Integer[]>();
        for (int i = 0; i < N; i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            values.add(new Integer[]{a, b, c});
        }
        int[] tmp = {0,0,0};
        for(Integer[] v : values){
            if (v[2] != 0){
                int i = 0;
                for(Integer p: v){
                    tmp[i] = p;
                    i++;
                }
                break;
            }
        }

        for (int cx = 0; cx < 101; cx++) {
            for (int cy = 0; cy < 101; cy++) {
                int h = Math.max(0, tmp[2] + Math.abs(tmp[0] - cx) + Math.abs(tmp[1]-cy));
                int f = 0;
                for(Integer[] v : values){
                    if (!(v[2] == Math.max(h-Math.abs(v[0]-cx) - Math.abs(v[1] - cy),0))){
                        f = 1;
                        break;
                    }
                }
                if (f == 0){
                    System.out.print(String.format("%d %d %d", cx, cy, h));
                    return;
                }
            }
        }
    }
}

Measured memory_bytes: 22228
k=int(input())
if k<=9:
    print(k)
    exit()
a=[1,2,3,4,5,6,7,8,9]
cnt=9
while True:
    q=[]
    for i in a:
       for j in range(10):
            if abs(int(str(i)[-1])-j)<=1:
                cnt+=1
                if cnt==k:
                    print(int(str(i)+str(j)))
                    exit()
                q.append(int(str(i)+str(j)))         
    a=list(sorted(set(q)))

Measured memory_bytes: 48184
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int n;
    cin >> n;
    vector<ll> as(n);
    rep(i, n) cin >> as[i];

    ll sum = accumulate(as.begin(), as.end(), 0ll);

    map<ll, ll> m;
    for (ll a : as) m[a]++;

    int q;
    cin >> q;
    rep(_, q) {
        int b, c;
        cin >> b >> c;

        ll from = m[b];
        ll sub = from * b;
        sum -= sub;

        ll add = from * c;
        sum += add;

        m.erase(b);
        m[c] += from;

        cout << sum << endl;


    }

}


Measured memory_bytes: 7964
n,k=map(int, input().split())
a=list(map(int, input().split()))

l=0
r=10**9

while r-l>1:
    mid=(r+l)//2
    cnt=0
    for i in range(n):
        cnt+=(a[i]-1)//mid
    if cnt>k:
        l=mid
    else:
        r=mid
print(r)


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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define ALL(a) a.begin(), a.end()
#define FOR(x,to) for(x=0;x<(to);x++)

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

void solve() {
	int A,B,K;
	cin >> A >> B >> K;
	if (B-A+1 <= 2*K) {
		for (int i = A; i <= B; ++i) {
			cout << i << '\n';
		}
	} else {
		for (int i = A; i <= A+K-1; ++i) {
			cout << i << '\n';
		}
		for (int i = B-K+1; i <= B; ++i) {
			cout << i << '\n';
		} 
	}	

}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

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

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k; cin>>n>>k;
  int d,tmp;
  vector<bool> flag(n,false);
  for(int i=0;i<k;i++){
    cin>>d;
    for(int j=0;j<d;j++){
      cin>>tmp;
      flag[tmp-1]=true;
      //cout<<tmp<<endl;
    }
  }
  int ans=0;
  for(int i=0;i<n;i++){
    //cout<<flag[i]<<endl;
    if(!flag[i]) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <stack>
#include <queue>
using namespace std;
int main(void){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int l=a+b,r=c+d;
    if(l>r)cout<<"Left"<<endl;
    else if(l==r)cout<<"Balanced"<<endl;
    else cout<<"Right"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

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


      Scanner s  = new Scanner(System.in);
      // System.out.print("[??°???????????????????????§2?????\?????????????????????] >");
      String line = s.nextLine();
      String[] array = line.split(" ");
      int a = Integer.parseInt(array[0]);
      int b = Integer.parseInt(array[1]);
      int square = a * b;
      int length = (2*a) + (2*b);
      System.out.println(square + " " + length);



  }
}

Measured memory_bytes: 25852
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_3-A: Stack

#include <cstdio>
#include <cstdlib>

#define NDEBUG
#include <cassert>

template <int N>
class Stack {
  unsigned int top_ = 0u;
  int ds_[N];
public:
  int pop()
  {
    assert(!is_empty());
    return ds_[--top_];
  }
  void push(int i)
  {
    assert(!is_full());
    ds_[top_++] = i;
  }
  bool is_empty() const { return top_ == 0; }
  bool is_full() const { return top_ == N; }
};

template <int N>
class calc {
  Stack<N> stack_;
public:
  void add()
  {
    int b = stack_.pop();
    int a = stack_.pop();
    stack_.push(a+b);
  }

  void sub()
  {
    int b = stack_.pop();
    int a = stack_.pop();
    stack_.push(a-b);
  }

  void mul()
  {
    int b = stack_.pop();
    int a = stack_.pop();
    stack_.push(a*b);
  }    

  int pop() { return stack_.pop(); }
  void push(int i) { stack_.push(i); }
  bool is_empty() { return stack_.is_empty(); }
};

int main()
{
  calc<100> calc; // ns <= 100
  char buf[6+1]; // n <= 10**6 or '+',etc == 1
  
  while (std::scanf("%6s", buf) != EOF) {
    switch (buf[0]) {
    case '+':
      calc.add(); break;
    case '-':
      calc.sub(); break;
    case '*':
      calc.mul(); break;
    default:
      calc.push(std::atoi(buf)); break;
    }
  }

  printf("%d\n", calc.pop());
  assert(calc.is_empty());
}

// eof

Measured memory_bytes: 2744
import java.util.*;
import java.lang.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		if(a+b>d+c)System.out.println("Left");
		else if(a+b<d+c)System.out.println("Right");
		else System.out.println("Balanced");
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60; //intじゃ扱えないことに注意！
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //範囲外参照とループの初期化に注意！


int main() {
  int K;
  string S;
  cin >> K >> S;

  int leng = S.size();

  if(leng <= K){
    cout << S << endl;
  }
  else{
    S = S.substr(0,K);
    cout << S << "..." << endl;
  }
}

Measured memory_bytes: 3628
import java.util.*;

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

		while(true){
			int w=sc.nextInt(), d=sc.nextInt();
			if(w==0 && d==0) break;

			int[] a=new int[w], b=new int[d];
			for(int i=0;i<w;i++) a[i]=sc.nextInt();
			for(int i=0;i<d;i++) b[i]=sc.nextInt();

			Arrays.sort(a);
			Arrays.sort(b);

			int ans = 0;
			int i=0, j=0;
			while(true){
				if(i == w && j == d) break;
				else if(i == w){ans+=b[j++];continue;}
				else if(j == d){ans+=a[i++];continue;}
				else if(a[i] == b[j]){ans+=a[i++];j++;}
				else if(a[i] > b[j]) ans+=b[j++];
				else ans+=a[i++];
			}

			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
using namespace std;

int inf = 2147483647;
int64_t inf64 = 9223372036854775807;
int mod = 1e+7;

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

  string s;
  cin >> s;
  rep(i,s.size()-1) {
    if (s.substr(i,2) == "?D" || s.substr(i,2) == "P?" || s.substr(i,2) == "??") {s[i] = 'P';s[i+1] = 'D';}
  }
  rep(i,s.size()) {
    if(s[i] == '?') s[i] = 'D';
  }
  cout << s << endl;
  return 0;
}

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

using namespace std;

const int N = 5050;
int a[N], f[N][N];

const int MOD = 1e9 + 7;

void Add(int& a, int b) {
    a += b;
    a -= (a >= MOD ? MOD : 0);
    a += (a < 0 ? MOD : 0);
}

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    int p = 2;
    while (p <= n && a[p] > a[p - 1]) {
        Add(f[p][1], 1);
        Add(f[p + 1][1], -1);
        //cerr << p << " " << p - 1 << '\n';
        ++p;
    } 
    if (p <= n) {
        Add(f[p][1], 1);
        Add(f[p + 1][1], -1);
    }
    a[n + 1] = n + 1;
    int ans = 0;
    if (p > n && m == n) Add(ans, 1);
    ++n;
    for (int i = 2; i <= n; ++i) {
        int L = i + 1, R = i;
        while (R < n && a[R + 1] > a[R]) ++R;
        while (L <= R && a[L] <= a[i - 1]) ++L;
        if (R != n && a[R + 1] > a[i - 1]) ++R;
        // cerr << "At " << i << ' ' << L << ' ' << R << '\n';
        for (int j = 1; j < i; ++j) {
            Add(f[i][j], f[i - 1][j]);
            // cerr << "DP " << i << ' ' << j << ' ' << f[i][j] << '\n';
            if (L > R) continue;
            // cerr << "Add " << L << ".." << R << ' ' << i - j + 1 << ' ' << f[i][j] << '\n';
            Add(f[L][i - j + 1], f[i][j]);
            Add(f[R + 1][i - j + 1], -f[i][j]); 
        }
    }
    for (int t = 2; t <= m + 1; ++t) {
        if (n - t <= m) {
            Add(ans, f[n][t]);
        }
    }
    cout << 1ll * ans * 2 % MOD << '\n';
}


Measured memory_bytes: 70148
#include<iostream>
#include<queue>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	if (b == 0) return a;
	return gcd(b, a % b);
	//return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	ll g = gcd(a, b);
	return a / g * b; // Be careful not to overflow
	//return a * b / gcd(a, b);
}

template<typename T>
T binarysearch(vector<T> A, T key) {
	ll left = 0;ll right = 4;ll mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;
		if (key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	return 0;
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)//階乗
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

template<typename T>
T keta(T a) {
	ll kazu = 1;
	while (1) {
		if (a / 10 != 0) { a /= 10;kazu++; }
		else break;
	}
	return kazu;
}//桁数

//素数判定
template<typename T>
bool IsPrime(T num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

template<typename T>
T nCr(ll n, T r) {
	ll ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
//vector<vector<int>> data(3, vector<int>(4));
//vector<vector<Type>> vv(n);

int main() {
	ll K; ll ans = 0;cin >> K;
	string S;cin >> S;
	ll mina = 0;
	vector<ll>sum;
	//vector<ll>C(N);
	//vector<ll>S(N), F(N);
	//for (ll i = 1;i < N;i++)cin >> C[i] >> S[i] >> F[i];
	if (S.size() <= K) {
		cout << S << endl;
	}
	else {
		for (ll i = 0;i < K;i++) cout << S[i];
		cout << "..." << endl;
	}
}


Measured memory_bytes: 3628
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
	int x,y;
	while(cin>>x>>y){
		cout<<x+y/2<<endl;
	} 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
#include <utility>
#include <cstdlib>

#define MOD 1000000007
using namespace std;
typedef  long double ll;




int main(){
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;
    return 0;
}



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

int main() {
    long long int n, a, b;
    cin >> n >> a >> b;
    if(n == 1 && a != b) {
        cout << 0 << '\n';
        return 0;
    }
    if(a > b) {
        cout << 0 << '\n';
        return 0;       
    }
    
    cout << (((n-1)*b + a) - ((n-1)*a+b) + 1) << '\n';
    
    return 0;
}


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

int main() {
  long N;
  cin >> N;
  
  long A[N], B[N];
  for (long i=0; i<N; i++) {
    cin >> A[i];
  }
  
  //人数が投稿順
  for (long i=0; i<N; i++) {
    B[A[i]-1]=i+1;
  }

  for (long i=0; i<N; i++) {
    cout << B[i] << " " ;
  }
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 2432
import java.io.*;
class Main
{
    public static void main(String[] args)throws IOException
    {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String s = in.readLine();
        int n = s.length();
        long[][] DP = new long[2][n];
        DP[0][0] = 1;
        DP[1][0] = 0;
        DP[0][1] = (s.charAt(1) == s.charAt(0))? 0 : 2;
        DP[1][1] = 1;
        for (int i=2;i<n;i++)
        {
            if (DP[0][i - 1] > DP[1][i - 1] && s.charAt(i) != s.charAt(i - 1))  DP[0][i] = DP[0][i - 1] + 1;
            else    DP[0][i] = DP[1][i - 1] + 1;

            if (DP[1][i - 2] > DP[0][i - 2] && !s.substring(i-3,i - 1).equals(s.substring(i - 1, i + 1)))   DP[1][i] = DP[1][i - 2] + 1;
            else    DP[1][i] = DP[0][i - 2] + 1;
        }
        System.out.println(Math.max(DP[0][n - 1], DP[1][n - 1]));
    }
}


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

int main()
{
ll n , x , y ;
cin >> n >> x >> y ;
vector<ll> ans(n-1);
vector<vector<ll>> g(n);
rep(i, n-1)
{
  g[i].push_back(i+1);
  g[i+1].push_back(i); 
}
g[x-1].push_back(y-1); 
g[y-1].push_back(x-1); 

rep(i,n){

vector<bool> see(n);
vector<ll> dist(n);
queue<ll> q;
see[i]=1;
q.push(i);
while(!q.empty()){
  auto p=q.front();
  q.pop();
  for(auto r:g[p]){
    if(see[r]!=0)continue;
    see[r]=1;
    dist[r]=dist[p]+1;
    q.push(r);
  }
}
rep(i,n)if(dist[i]!=0)ans[dist[i]-1]++;
}

for(auto r:ans)cout << r/2 << endl;
return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5+100;
typedef long long LL;
map<LL,int> cnt;
int n;
int main(){
    scanf("%d",&n);
    LL sum =0;
    cnt[0]++;
    LL ans=0;
    for (int i=0;i<n;i++){
        int temp;
        scanf("%d",&temp);
        sum+=temp;
        ans+=cnt[sum];
        cnt[sum]++;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+15+7;
ll n,m,l;
string s,t;
ll d[100],dp[100][100];
ll a,b;
vi vec;

int main(){
  cin >> n;
  int x[500],y[500],z[500],ans;
  rep(i,0,n-1)cin >> x[i] >> y[i] >> z[i];
  rep(i,0,n-1){
    ans = 0;
    rep(j,i,n-1){
      if(ans < y[j]){
        ans = y[j];
      }else{
        if(ans % z[j] != 0)ans += z[j] - (ans % z[j]);
      }
      ans += x[j];
    }
    // print(ans);
    vec.pb(ans);
  }
  vec.pb(0);
  rep(i,0,vec.sz)print(vec[i]);
  return 0;
}

Measured memory_bytes: 256
"use strict";

const main = arg => {
    const A = [1,3,5,7,8,10,12];
    const B = [4,6,9,11];
    
    const x = parseInt(arg.split("\n")[0].split(" ")[0]);
    const y = parseInt(arg.split("\n")[0].split(" ")[1]);
    
    if(x == y) {
        console.log("Yes");
        return;
    }
    
    if(A.indexOf(x) !== -1 && A.indexOf(y) !== -1) {
        console.log("Yes");
        return;
    }
    
    if(B.indexOf(x) !== -1 && B.indexOf(y) !== -1) {
        console.log("Yes");
        return;
    }
    
    console.log("No");
    
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define VIN(x) for(auto&youso_: (x) )cin>>youso_
#define VOUT(x, delim) for(auto&youso_: (x) )cout<<youso_<<delim;cout<<endl

#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) i64 __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    SCIN(S);

    i64 maxl = 0;
    i64 curl = 0;
    char prev = 'S';
    for (char c : S) {
        if (prev == 'S' && c == 'R') curl = 1;
        else if (prev == 'R' && c == 'R') curl++;
        else curl = 0;
        chmax(maxl, curl);
        prev = c;
    }
    COUT(maxl);

    return 0;
}


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

#define range(i, l, r) for (int i = (int)l; i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = ((int)(r) - 1); i >= (int)l; --(i))

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rwhole(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)

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

using int32 = int;
using int64 = long long;

const int mod     = 1e9 + 7;
const int32 inf   = 1001001001;
const int64 infll = 1001001001001001001ll;

const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(16); cerr << fixed << setprecision(16); } } iosetup;

template <typename T = int64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solver() {
  int N = input();

  int ans = 0;
  range(i, 1, N + 1) {
    if (i % 2 == 0) continue;
    int cnt = 0;
    range(j, 1, i + 1) {
      if (i % j == 0) cnt++;
    }

    if (cnt == 8) ans++;
  }

  cout << ans << endl;
}

signed main(int argc, char *argv[]) {
  solver();
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int n, k, ans, max, min=1;
    scanf("%d%d", &n, &k);
    if(k==1) ans=0;
    else{
        max=n-k+1;
        ans=max-min;
    }
    printf("%d\n", ans);
    return 0;
}


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

int main(){
	string s;
	cin >> s;
	if(s == "Sunny") cout << "Cloudy" << endl;
	else if(s == "Cloudy") cout << "Rainy" << endl;
	else cout << "Sunny" << endl;
	return 0;
}

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

using namespace std;

typedef long long llint;

llint n, x;

llint f (llint a, llint b) {
    if (a < b) swap(a, b);
    if (a % b == 0) return (a/b * 2 - 1) * b;
    return a / b * b * 2 + f(a % b, b);
}

int main () {
    cin >> n >> x;
    cout << n + f(n - x, x);
    return 0;
}


Measured memory_bytes: 256
N = int(input())
s = input()

b = [0 if si == 'o' else 1 for si in s]

for i in range(2):
    for j in range(2):
        sw = [i] + [j] + [0] * (N - 2)

        for k in range(2, N):
            sw[k] = b[k - 1] ^ sw[k - 1] ^ sw[k - 2]

        if b[N - 1] != (sw[N - 2] ^ sw[N - 1] ^ sw[0]):
            continue
        if b[0] != (sw[N - 1] ^ sw[0] ^ sw[1]):
            continue

        ans = ['W' if si else 'S' for si in sw]
        print(''.join(ans))
        quit()

print(-1)

Measured memory_bytes: 6364
#include <bits/stdc++.h>
using namespace std;
int n,m,dp[2][200][200][200],sum[200][200],now=1,pre=0;
char ch;
bool check(int x_1,int y_1,int x_2,int y_2){
	int tmp=sum[x_2][y_2]-sum[x_1-1][y_2]-sum[x_2][y_1-1]+sum[x_1-1][y_1-1];
	return tmp==0||tmp==(x_2-x_1+1)*(y_2-y_1+1);
}
int main(){
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++){
		scanf(" %c",&ch);
		sum[i][j]=sum[i][j-1]+(ch=='.');
	}
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) sum[i][j]=sum[i-1][j]+sum[i][j];
	for(int i=1;i<=n;i++){
		for(int l=1;l<=m;l++) for(int r=l;r<=m;r++){
			int lans=i,rans=n,ans=i-1;
			while(lans<=rans){
				int mid=(lans+rans)>>1;
				if(check(i,l,mid,r)) ans=mid,lans=mid+1;
				else rans=mid-1;
			}
			dp[0][i][l][r]=ans;
		}
	}
	if(dp[0][1][1][m]==n) return puts("0"),0;
	for(int ty=1;ty<=20;ty++,now^=1,pre^=1){
		for(int i=1;i<=n;i++){
			for(int l=1;l<=m;l++) for(int r=l;r<=m;r++){
				int tmp=dp[pre][dp[pre][i][l][r]+1][l][r];
				if(dp[pre][i][l][r]==n){
					dp[now][i][l][r]=n;continue;
				}
				int lans=l,rans=r-1;
				while(lans<=rans){
					int mid=(lans+rans)>>1;
					int tmp1=dp[pre][i][l][mid],tmp2=dp[pre][i][mid+1][r];
					tmp=max(tmp,min(tmp1,tmp2));
					if(tmp1>=tmp2) lans=mid+1;
					else rans=mid-1;
				}
				dp[now][i][l][r]=tmp;
			}
		}
		if(dp[now][1][1][m]==n) return printf("%d\n",ty),0;
	}
}

Measured memory_bytes: 61440
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
    int a,b;
    char op;
    while(1){
        cin >> a >> op >> b;
        switch(op){
            case '+':
                cout << a+b << endl;
                break;
            case '-':
                cout << a-b << endl;
                break;
            case '*':
                cout << a*b << endl;
                break;
            case '/':
                cout << a/b << endl;
                break;
            case '?':
                return 0;
    //cout << (int)(a/b) << " " << (int)((int)a%(int)b) << " " << a/b << endl;
    //printf("%.6f %.6f\n",(double)(r*r*3.14159265),(double)(2*r*3.14159265));
        }
    }
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} 



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

string s; cin >> s;
i64 cnt = 0;
if (s.size() < 3){
    cout << "0\n";
    return 0;
}
rep(i, 0, s.size()){
    if (s[i] == 'A'){
        ++i;
        int m = 1;
        for(; i < s.size(); ++i){
            if (s.substr(i, 2) == "BC") {++i; cnt += m;}
            else if (s[i] == 'A') ++m;
            else break;
        }
    }
}


cout << cnt << "\n";
return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 720
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define   sz(s)         s.size()
#define   ll            long long int
#define   ull           unsigned ll
#define   ld            long double
#define   print(v)      for(ll i=0;i<v.size();i++)cout<<v[i]<<" "
#define   printpair(v)  for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<"\n"
#define   bmd           1000000007
#define   bmd1          998244353
#define   umll          unordered_map<ll,ll>
#define   mll           map<ll,ll>
#define   mcl           map<char,ll>
#define   pll           pair<ll,ll>
#define   F             first
#define   S             second
#define   setp(x)       setprecision(x)
#define   pb            push_back
#define   all(v)        v.begin(),v.end()
#define   tr(a)         for(auto it=a.begin();it!=a.end();it++)
#define   trr(a)        for(auto it1=a.begin();it1!=a.end();it1++)
#define   vll           vector<long long int>
#define   sorty(v)      sort(v.begin(),v.end())
#define   rsort(v)      sort(v.rbegin(),v.rend())
#define   unik(v)       v.erase(unique(all(v)),v.end())
#define   PI            3.1415926535897932384626
#define   db()          cout<<"\n"<<"here"<<"\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


//---------------------------------------------------------------------------
const int MOD = bmd;
const int N=2e5+100;
inline  ll sqr(ll x){return x*x;}
inline  void normal(ll &a) { a = (a+MOD)%MOD; }
inline  ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline  ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline  ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline  ll modPow(ll b, ll p) { ll r = 1;b=b%MOD; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline  ll modInv(ll a) { return modPow(a, MOD-2); }
inline  ll modDiv(ll a,ll b) { return modMul(a, modInv(b)); }
//---------------------------------------------------------------------------
void solve()
{
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    if(x == 0){
        if(k%2==0){
            cout <<0<<"\n";
        }
        else cout << x+d <<"\n";
        return;
    }
    else {
        ll p = x/d;
        if(k<=p){
            x-=k*d;
            cout << x <<"\n";
            return;
        }
        else {
            x-=(p*d);
            k-=p;
            if(k%2==0){
                cout << x <<"\n";
            }
            else cout << abs(x-d) <<"\n";
            return;
        }
    }

}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);//first give all input then gives output
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int n;

void dfs(string s,char la){
    if(s.size()==n){
        cout<<s<<endl;
        return;
    }

    for(char c='a';c<=la;c++){
        if(c==la && c!='z') dfs(s+c,char(c+1));
        else dfs(s+c,la);
    }
}

int main() {
    cin>>n;

    dfs("a",'b');
}



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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;

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

    vector<int>P(n),Q(n),a(n);
    rep(i,n){
        cin>>P[i];
    }
    rep(i,n){
        cin>>Q[i];
    }
    rep(i,n){
        a[i]=i+1;
    }

    int p,q,cnt;
    do{
        if(P==a){
            p=cnt;
        }
        if(Q==a){
            q=cnt;
        }
        cnt++;
    }while(next_permutation(a.begin(),a.end()));

    cout<<abs(p-q)<<endl;

}


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

int main() {
  ll N, D;
  cin >> N >> D;
  int ans = 0;
  ll x, y;
  rep(i, N) {
    cin >> x >> y;
    if (x * x + y * y <= D * D) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
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 (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    string s; cin >> s;
    if (s[0]=='R' && s[1]=='R' && s[2]=='R') cout << 3 << endl;
    else if ((s[0]=='R' && s[1]=='R')||(s[1] =='R' && s[2]=='R')) cout << 2 << endl;
    else if (s[0]=='R'||s[1]=='R'||s[2]=='R') cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 3548
// compilation flags
// normal
//      g++ -std=c++17 -O2 -Wall a.cpp -o a
// fast running time
//      g++ -O2 -std=c++17 -Wno-unused-result -Wshadow -Wall -o a a.cpp
// check for mistakes
//      g++ -std=c++17 -Wshadow -Wall -o a a.cpp -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g
#include<bits/stdc++.h>
using namespace std;
#define fastIO(); ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fr(i,a,b) for(lli i=a;i<b;i++)
#define f0(a,b) for(lli i=a;i<b;i++)
#define fn(b,a) for(lli i=b;i>a;i--)
#define dbg(x); cout<<"\n"<<#x<<": "<<x;
#define ret return
#define pb push_back
#define pf push_front
#define mp make_pair
#define E9 1000000007
#define E5 100007
#define INF 1e18+7
#define PI 3.1415926
#define sq(a) (a)*(a)
#define fs first
#define sc second
#define el "\n"
#define all(a) a.begin(),a.end()
typedef long long int lli;  //  e-18 to e18
typedef vector<long long int> vll;
typedef vector<vector<long long int>> vvll;
void solve(){
    string s;
    lli k;
    cin>>k>>s;
    if((lli)s.length()>k){
        f0(0,k) cout<<s[i];
        cout<<"..."<<el;
    }
    else cout<<s<<el; 
}
int main(){
    fastIO();
    lli t(1);
    // cin>>t;
    while(t--) solve();
    ret 0; 
}                                                             

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

int main() {
	int R, G, B, N; cin >> R >> G >> B >> N;
	int ans = 0;
	for (int r = 0; r <= 3000; ++r) {
		for (int g = 0; g <= 3000; ++g) {
			int zan = N - R * r - G * g;
			if (zan >= 0 && zan % B == 0) {
				++ans;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
#define FIO                     ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod                     1000000007
#define eps                     1e-9
#define setbits                 __builtin_popcount
#define gcd                     __gcd
#define rep(i,a,b)              for(int i=a;i<=b;i++)
#define repr(i,b,a)             for(int i=b;i>=a;i--)
#define forn(i,n)               for(int i=0;i<n;i++)
#define all(a)                  a.begin(), a.end()
#define pb                      push_back
#define endl                    "\n"
#define ff                      first
#define ss                      second
#define asort(c)                sort(all(c)) 
#define lbpos(x,v)              (int)(lower_bound(all(v),x)-v.begin())//=v.size()==>No LB 
#define ubpos(x,v)              (int)(upper_bound(all(v),x)-v.begin())//=v.size()==>No UB
#define PI                      3.14159265358979323846
#define int                     long long
typedef  vector<int>                 vi;
typedef  pair<int, int>              ii;
typedef  vector<ii>                 vii;
typedef  long double                 ld;
#define debug(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
  const char* comma = strchr(names + 1, ',');
  std::cerr.write(names, comma - names) << " = " << arg1;
  ZZ(comma, args...);
}
clock_t time_p=clock();
void timer()
{
    time_p=clock()-time_p;
    cerr<<"Execution Time: "<<(double)(time_p)/CLOCKS_PER_SEC<<"\n";
}

int32_t main()
{
  FIO; 
  int n,x,od=0;
  cin>>n;
  forn(i,n)
  {
    cin>>x;
    od+=(x&1);
  }
  cout<<(od==0?"second":"first");
  timer();
  return 0;
}  

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.D_Challenge
{
    class ABC_053
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] array = ReadInts();
            Array.Sort(array);
            var cntList = new List<int>();
            cntList.Add(1);
            bool requirePair = false;
            for(int i = 1; i < n; i++)
            {
                if (array[i] == array[i - 1])
                {
                    cntList[cntList.Count - 1]++;
                }
                else
                {
                    if (cntList[cntList.Count - 1] % 2 == 0)
                    {
                        requirePair = !requirePair;
                    }
                    cntList.Add(1);
                }
            }
            if (cntList[cntList.Count - 1] % 2 == 0)
            {
                requirePair = !requirePair;
            }
            if (requirePair)
            {
                Console.WriteLine(cntList.Count - 1);
            }
            else
            {
                Console.WriteLine(cntList.Count);
            }
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 16992