akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
 
int comp( const void *c1, const void *c2 );
 
int main(){
  int n, a[100001]={0}, i, c, m, t;

  scanf("%d", &n);
  for( i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }
  qsort(a, n, sizeof(int), comp);
  c = 0;
  m = a[0];
  t = 1;
  for( i = 1; i <= n; i++){
     if(a[i] == a[i-1]){
       t++;
     }else{ 
        if(t > m){
            c += t - m;
        }else if(t < m){
            c += t;
        }
        t = 1;
        m = a[i];
    }
  }
  printf("%d\n", c);

  return 0;
}

int comp( const void *c1, const void *c2 )
{
  int tmp1 = *(int *)c1;
  int tmp2 = *(int *)c2;
 
  if( tmp1 > tmp2 )  return -1;
  if( tmp1 == tmp2 ) return  0;
  if( tmp1 < tmp2 )  return  1;
}

Measured memory_bytes: 892
#include<stdio.h>
#include <math.h>

main(void)
{
  int N,M,i;
  double counter=0,sum=0;
  int A[1000];
  
  scanf("%d %d",&N,&M);
  for(i=0;i<=N;i++)
  {
    scanf("%d",&A[i]);
    sum+=A[i];
  }
  

  for(i=0;i<=N;i++)
  {
    if(A[i]>=sum/(4*M))
    {
      counter++;
    }
  }
  
  
  if(M<=counter && M<=N)
  {
    printf("Yes");
  }
  
  else
  {
    printf("No");
  }

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1

int main() {
  int A,B,C;
  cin >>A>>B>>C;
  if(A*B<C)
    cout << A*B<<endl;
  else
    cout <<C<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<vector>
#include<cmath>
#define maxn 1000007
using namespace std;
int n,ans;
inline int read()
{
    int x = 0;
    int flag = 1;
    char ch;
    ch = getchar();
    while(!isdigit(ch)) 
    {
        if(ch == '-') flag = -1;
    ch = getchar();
    } 
    while(isdigit(ch))
    {
        x = (x<<1) + (x<<3) + ch - 48;
        ch = getchar();
    }
    return x * flag;
}


int main()
{
	n = read();
	int minn = 1e9;
	for(register int i = 1;i <= n;i++)
	{
		int x = read();
		if(x < minn) 
		{
			ans++;
			minn = x;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define LOL cout<<'\n';
#define MOD 1000000007
#define sz(x) ((int)x.size())
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define deb(x) cout << "[" << #x << "=" << x << "]" << '\n'
#define deb2(x,y) cout << "[" << #x << "=" << x << "] [" << #y << "=" << y << "]" << '\n'
#define deb3(x,y,z) cout << "[" << #x << "=" << x << "] [" << #y << "=" << y << "] [" << #z << "=" << z << "]" << '\n'

void solve(){
	int n; cin>>n;
	string s;
	map<string,int> m;
	for(int i=0 ; i<n ; i++){
		cin>>s;
		m[s]++;
	}
	int ma=0;
	for(auto x:m){
		ma=max(ma,x.s);
	}
	for(auto x:m){
		if(x.s==ma){
			cout<<x.f;LOL
		}
	}
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  //int _;
  //for(cin>>_ ; _ ; --_){
    //cout<<"Case "<<_<<": ";
    solve();
  //}
  return 0;
}

Measured memory_bytes: 19264
//
// Created by Hideaki Imamura on 2020-03-14.
//
# include <bits/stdc++.h>

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

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

int N;
vector<l_l> b_a;

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) {
        ll a, b;
        cin >> a >> b;
        b_a.push_back(make_pair(b, a));
    }
    sort(b_a.begin(), b_a.end());

    ll cur = 0;
    for (int i = 0; i < N; ++i) {
        cur += b_a[i].second;
        if (cur > b_a[i].first) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

  int n, ans = 0;
  cin >> n;

  rep(i, 0, n) {
    int a;
    cin >> a;
    if (i % 2 == 0 && a % 2 == 1) ++ans;
  }

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }


int main() {
    string s; cin >> s;
    int slen = s.length();
    int gcnt = 0; int pcnt = 0;
    int ans = 0;
    for(int i = 0; i < slen; ++i) {
        if(s.at(i) == 'g') {
            if(gcnt > pcnt) {
                ans++;
                pcnt++;
            }else gcnt++;
        }else {
            if(gcnt > pcnt) pcnt++;
            else {
                ans--;
                gcnt++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<iostream>
#include<map>
using namespace std;
#define ll long long
const int maxn = 100005;
int gcd(int x,int y){
	if(y==0)
		return x;
	else return gcd(y,x%y);
}

char s1[maxn],s2[maxn];
int p1[maxn],p2[maxn];
map<ll,char> mp;
int main(){
	ll n,m;
	cin >> n >> m;
	ll t = gcd(max(n,m),min(n,m));
	ll ans = n*m/t;
	scanf("%s %s",s1,s2);
	if(s1[0]!=s2[0]){
		printf("-1\n");
		return 0;
	}
	long long f = ans/n;
	for(int i=1; i<n; i++){
		mp[f] = s1[i];
		f+=(ans/n);
	}
	f = ans/m;
	bool flag = true;
	for(int i=1; i<m; i++){
		if(mp.find(f)!=mp.end()&&s2[i]!=mp[f]){
			flag=false;
			break;
		}
		else {
			mp[f] = s2[i];
			f += (ans/m);
		}
	}
	if(flag)
		printf("%lld\n",ans);
	else printf("-1\n"); 
} 

Measured memory_bytes: 10880
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

template<class T>
void outvo(vector<T> v) {
  cout << v[0];
  for (int i = 1; i < v.size(); i++)
    cout << " " << v[i];
  cout << endl;
}

void solve() {
  int n; cin >> n;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) cin >> a[i];

  int ans = 0;
  for (int i = 1; i < n; i++) {
    if (a[i] == i) {
      swap(a[i], a[i+1]);
      ans++;
    }
  }
  if (a[n] == n) {
    swap(a[n-1], a[n]);
    ans++;
  }

  // outvo(a);

  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int>l(n);
	for(int i=0;i<n;i++)
		cin>>l[i];
	int cnt=0;
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
			for(int k=j+1;k<n;k++){
				int a=l[i],b=l[j],c=l[k];
				if(a==b||a==c||b==c)
					continue;
				if(a+b>c&&a+c>b&&b+c>a)
					cnt++;
			}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 3616
// :)
// "Khodaya, be man "Tagwaye setiz" biamooz ta
//  dar anbuh masuliat nalaghzam ..." -Shariati
#include <bits/stdc++.h>

using namespace std;
typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64,int> pii32;
typedef pair<int64,int64> pii64;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

const int maxn = 1e5+10;
const int64 MO = 1e9+7;
const int64 IN = 1e9;

int a, b;

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> a >> b;
	cout << a - b + 1 << "\n";
}


Measured memory_bytes: 256
#include <stdio.h>
#define TRUE 1
#define FALSE 0
#define n 20
#define q 200

int solve(int, int);

int A_len, A[n];

int main(){
  int M[q], M_len, i;

  scanf("%d",&A_len);
  for(i = 0; i < A_len; i++) scanf("%d",&A[i]);
  scanf("%d",&M_len);
  for(i = 0; i < M_len; i++) scanf("%d",&M[i]);

  for(i = 0; i < M_len; i++){
    if( solve( M[i], 0 ) ) printf("yes\n");
    else printf("no\n");
  }
  
  return 0;
}

int solve(int m, int i){
  if( m == 0 ) return TRUE;
  if( i == A_len ) return FALSE;
  return solve( m, i+1 ) || solve( m-A[i], i+1 );
}



Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	while(true){
		int N,b=0,cun=0; 
		int p[10]={0,0,0,0,0,0,0,0,0,0};
		char c[100];
		cin >> N;
		if(N==0)
			break;
		for(int i=0;i<100;i++){
			cin >> c[i];
			if(c[i] == 'M'){
				p[b] = p[b]+1;
			}
			else if(c[i] == 'L'){
				p[b] = p[b]+cun+1;
				cun=0;
			}
			else{
				cun += p[b]+1;
				p[b] = 0;
			}
			b++;
			if(b==N){
					b=0;
			}
		}
		sort(p,p+N);
		for(int i=0;i<N;i++){
			cout << p[i] << " ";
		}
		cout << cun << endl;
	}
	return 0;
}
		

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

int counter[100100];

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    rep(i, n) {
        int a;
        cin >> a;
        counter[a]++;
        ans += a;
    }

    int q;
    cin >> q;
    while (q--) {
        int b, c;
        cin >> b >> c;
        ans += (c - b) * counter[b];
        counter[c] += counter[b];
        counter[b] = 0;
        cout << ans << endl;
    }
}

Measured memory_bytes: 4020
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  vector<int> a;
  for(int i = 0; i < n; i++){
    int x;
    cin >> x;
    x--;
    a.pb(x);
  }
  ll res = 0;
  for(int i = 0; i < n; i++){
    if(a[a[i]] == i)res++;
  }
  cout << res / 2 << endl;
	return 0;
}


Measured memory_bytes: 892
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    ll S = accumulate(all(A),0LL);

    int win = 0;
    if (N&1) {
        if (S%2==0) win = 1;
        while (true) {
            int cnt = 0;
            int k = -1;
            rep(i,N) {
                if (A[i]&1) {
                    cnt++;
                    k = i;
                }
            }
            if (cnt >= 2 or A[k]==1) break;
            A[k]--;
            ll g = 0;
            rep(i,N) g = gcd(g,A[i]);
            S = 0;
            rep(i,N) {
                A[i] /= g;
                S += A[i];
            }
            if (S&1) win = 1-win;
            else break;
        }
    } else {
        if (S&1) win = 1;
    }

    cout << (win ? "First" : "Second") << ln;
}


Measured memory_bytes: 3992
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

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



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

  ll sn = 0, t = n;
  while(t > 0) {
    sn += (t % 10);
    t /= 10;
  }

  if(n % sn == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var abcd = Console.ReadLine().Split();
        var a = long.Parse(abcd[0]) - 1;
        var b = long.Parse(abcd[1]);
        var c = long.Parse(abcd[2]);
        var d = long.Parse(abcd[3]);
        var e = lcm(c, d);

        var ax = a - a / c;
        var ay = a - a / d;
        var az = a - a / e;

        var bx = b - b / c;
        var by = b - b / d;
        var bz = b - b / e;

        var A = ax + ay - az;
        var B = bx + by - bz;

        var ans = B - A;
        Console.WriteLine(ans);
    }

    static long gcd(long x, long y)
    {
        return x == 0 ? y : gcd(y % x, x);
    }

    static long lcm(long x, long y)
    {
        return x * y / gcd(x, y);
    }
}


Measured memory_bytes: 13140
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	int A, B, C, D;
	cin >> A >> B >> C >> D;

	cout << max(min(B, D) - max(A, C), 0) << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
template <class T> void corner(bool flg, T hoge) {
    if(flg) {
        cout << hoge << endl;
        exit(0);
    }
}
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin >> n;
    ll kazu[10][10];
    rep(i,10){
        rep(j,10){
            kazu[i][j]=0;
        }
    }

    for(ll i=1;i<n+1;i++){
        string s=to_string(i);
        a=s[0]-'0';
        b=s[s.length()-1]-'0';
        kazu[a][b]++;
    }
rep(i,10){
    rep(j,10){
        ans+=kazu[i][j]*kazu[j][i];
    }
}

    cout << ans << endl;
}

Measured memory_bytes: 256
cat<<EOF>Source.cpp
#include <iostream>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;

int max(int a,int b){
	return a>b?a:b;
}
int x[100000],y[100000],x_mod_k[100000],x_div_k[100000];
char s[100000][2];
int n,k;

void add(int*cnt,int x,int t){
	if((x_div_k[x]&1)==0){
		if(t==0){
			cnt[0]++;
			cnt[k-x_mod_k[x]]--;
		}
		else{
			cnt[k-x_mod_k[x]]++;
		}
	}
	else{
		if(t==0){
			cnt[k-x_mod_k[x]]++;
		}
		else{
			cnt[0]++;
			cnt[k-x_mod_k[x]]--;
		}
	}
}
int ans[2000];
int main(){
	scanf("%d%d",&n,&k);
	rep(i,n){
		scanf("%d%d%s",&x[i],&y[i],s[i]);
		x_mod_k[i]=y[i]%k;
		x_div_k[i]=y[i]/k;
	}
	int Max=0;
	#pragma omp parallel for schedule(dynamic, 1) num_threads(20)
	rep(i,k){
		int cnt[max(n,k)];
		rep(j,max(n,k))cnt[j]=0;
		rep(j,n){
			if(s[j][0]=='B'){
				if(((x[j]+i)/k)%2==0){
					add(cnt,j,0);
				}
				else{
					add(cnt,j,1);
				}
			}
			else{
				if(((x[j]+i)/k)%2==0){
					add(cnt,j,1);
				}
				else{
					add(cnt,j,0);
				}
			}
		}
		rep(j,k){
			if(j)cnt[j]+=cnt[j-1];
			ans[i]=max(ans[i],max(cnt[j],n-cnt[j]));
		}
	}
	rep(i,k)Max=max(Max,ans[i]);
	cout<<Max<<endl;
}
EOF
g++ -O3 Source.cpp -o Source -fopenmp -std=c++11
./Source

Measured memory_bytes: 47028
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/
int gcd(int a, int b)
{
	if (a < b)
	{
		return gcd(b,a);
	}

	return gcd(b, a % b);
}

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

	int A, B, K;
	
	cin >> A >> B >> K;
	std::vector<int> v;
	for(int i = 1; i < 101; i++)
	{
		if ((A % i == 0) && (B % i == 0))
		{
			v.pb(i);
		}
	}

	int size = v.size();

	cout << v[size-K] << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct P {
    bool operator<(const P &p) const {
        return c > p.c;
    }
    int b, c;
};

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

    int n, m;
    cin >> n >> m;

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    vector<P> p(m);
    for (int j = 0; j < m; j++) {
        int b, c;
        cin >> b >> c;
        p[j] = { b, c };
    }
    sort(p.begin(), p.end());

    for (int j = 0; j < m; j++) {
        for (int i = 0; i < p[j].b; i++) {
            a.push_back(p[j].c);
            if (a.size() >= n * 2) goto break2;
        }
    }
break2:

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

    ll r = 0;
    for (int i = 0; i < n; i++) {
        r += a[i];
    }

    cout << r << endl;

    return 0;
}

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

void prians(bool answer) {
  if(answer)
    cout << "Cat" << endl;
  else
    cout << "Rabbit" << endl;
}
bool solve(string s);
string t;

int main() {
  cin >> t;
  prians(solve(t));
  return 0;
}

bool solve(string s) {
  if(s.size() == 0) return 1;
  string nexts[2];
  int cnt[3] = {0};
  int i;
  if(s[0] != 'm' || s[s.size() - 1] != 'w') return 0;
  // left side
  for(i = 1; i < s.size() - 1; ++i) {
    if(s[i] == 'm')
      ++cnt[0];
    else if(s[i] == 'e')
      ++cnt[1];
    else if(s[i] == 'w')
      ++cnt[2];
    else
      return 0;
    if(cnt[0] == cnt[2] && cnt[0] + 1 == cnt[1]) break;
    nexts[0] += s[i];
  }
  // right side
  cnt[0] = cnt[1] = cnt[2] = 0;
  while(++i < s.size() - 1) {
    if(s[i] == 'm')
      ++cnt[0];
    else if(s[i] == 'e')
      ++cnt[1];
    else if(s[i] == 'w')
      ++cnt[2];
    else
      return 0;
    nexts[1] += s[i];
  }
  if(cnt[0] == cnt[1] && cnt[1] == cnt[2])
    return solve(nexts[0]) & solve(nexts[1]);
  else
    return 0;
}



Measured memory_bytes: 3296
#include <stdio.h>

typedef struct{ char suit, value;} Card;

void bubble(Card A[], int N){
    int i, j;
    Card t;
    for(i = 0; i<N; i++){
        for(j = N-1; j >= i; j--){
            if(A[j].value < A[j-1].value){
                t = A[j]; A[j] = A[j-1]; A[j-1] = t;
            }
        }
    }
}

void selection(Card A[], int N){
    int i, j, minj;
    Card t;
    for(i=0;i<N;i++){
        minj = i;
        for(j=i;j<N;j++){
            if(A[j].value < A[minj].value) minj = j;
        }
        t = A[i]; A[i] = A[minj]; A[minj] = t;
    }
}

void print(Card A[], int N){
    int i;
    for(i=0;i<N;i++){
        if(i>0)printf(" ");
        printf("%c%d",A[i].suit,A[i].value);
    }
    printf("\n");
}

int isStable(Card C1[], Card C2[], int N){
    int i;
    for(i=0; i<N; i++){
        if(C1 [i].suit != C2[i].suit) return 0;
    }
    return 1;
}

void str2Card(Card *t,char str[]){
    t->suit = str[0];
    t->value = str[1] - '0';
}

int main(void){
    Card C1[100], C2[100];
    int N,i;
    char str[3];
    
    scanf("%d",&N);
    for(i=0;i<N; i++){
        scanf("%s",str);
        str2Card(&C1[i],str);
    }
    
    for(i=0; i<N; i++) C2[i] = C1[i];
    
    bubble(C1,N);
    selection(C2,N);
    
    print(C1,N);
    printf("Stable\n");
    print(C2,N);
    if(isStable(C1,C2,N)){
        printf("Stable\n");
    } else{
        printf("Not stable\n");
    }
    
    return 0;
}
    



Measured memory_bytes: 2100
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
sys.setrecursionlimit(10 ** 7)

mod = 998244353
from collections import Counter

def main():
  n = ni()
  d = na()

  if d[0] != 0:
    print(0)
    return
  
  pre = 0
  for dd in set(d[1:]):
    if dd - pre > 1 or dd == 0:
      print(0)
      return
    pre = dd

  dic = {}
  for dd in d:
    if dd in dic:
      dic[dd] += 1
    else:
      dic[dd] = 1

  ans = 1
  t = sorted(dic.items(), key = lambda x: x[0])
  for i in range(1, len(t) - 1):
    x = (t[i][1] ** t[i+1][1]) % mod
    ans *= x
    ans %= mod
  print(ans % mod)
 

if __name__ == '__main__':
  main()

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/

#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)

// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif


template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

#endif



void solve(){
    string S;
    cin >> S;
    int a=0;
    rep(i,3){
        if(S[i]=='A') a++;
    }
    if(a==1 || a==2) Yes;
    else No;
    
}

signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


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

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g) {
  for (int i = g; i < n; i++) {
    int v = A[i];
    int j = i - g;
    while (j >= 0 && A[j] > v) {
      A[j+g] = A[j];
      j -= g;
      cnt++;
    }
    A[j+g] = v;
  }
}

void shellSort(int A[], int n) {
  for (int h = 1; ;) {
    if (h > n) break;
    G.push_back(h);
    h = 3 * h + 1;
  }

  for (int i = G.size() - 1; i >= 0; i--) {
    insertionSort(A, n, G[i]);
  }
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%d", &A[i]);
  cnt = 0;

  shellSort(A, n);
  cout << G.size() << endl;
  for (int i = G.size() - 1; i >= 0; i--) {
    printf("%d", G[i]);
    if (i) printf(" ");
  }

  printf("\n");
  printf("%lld\n", cnt);
  for (int i = 0; i < n; i++) printf("%d\n", A[i]);

  return 0;
}



Measured memory_bytes: 7192
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = (long)(sc.nextDouble()*100+0.9);
        
        long res = A*B/100;
        
        System.out.println(res);
    }

}



Measured memory_bytes: 37040
#include <iostream>
#include <map>
using namespace std;
int main()
{
	int n, sum = 0;
	cin >> n;
	string s;
	map<string, int> m;
	for (int i = 1; i <= n; i++)
	{
		cin >> s;
		if (m[s] == 0)
			sum++;
		m[s]++;
	}
	cout << sum;
	return 0;
}

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

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int n;
  cin >> n;
  int a[n];
  rep(i, n) cin >> a[i];

  int ans = 0;
  for (int i = 0; i < n; i += 2) {
    if (a[i] & 1) ++ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3644
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	string a, b;
	cin >> a >> b;
	if(a.size() == b.size()){
		bool flag = true;
		for(int i = 0;i < a.size();i++){
			if(a[i] == b[i]) continue;
			if(a[i] < b[i]){
				flag = false;
				cout << "LESS" << endl;
			}
			if(a[i] > b[i]){
				flag = false;
				cout << "GREATER" << endl;
			}
			break;
		}
		if(flag){
			cout << "EQUAL" << endl;
		}
	}else if(a.size() < b.size()){
		cout << "LESS" << endl;
	}else{
		cout << "GREATER" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N, M = list(map(int,input().split()))
H = list(map(int,input().split()))
H = sorted(H,reverse = False) 

if N == 1:
    print(abs(H[M-1] - H[0]))
else:
    A = []
    for i in range(M-1):
        A.append(H[i+1] - H[i])
    A = sorted(A,reverse = False) 
    print(sum(A[:-N+1]))

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

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

#define all(x)          x.begin(), x.end()
#define kill(x)         return cout << x << endl, 0
#define X               first
#define Y               second
#define sep             ' '
#define endl            '\n'

ll pw(ll a, ll b, ll mod) {
    if (!b)    return 1;
    if (b & 1) return a * pw(a * a % mod, b / 2, mod) % mod;
    return pw(a * a % mod, b / 2, mod) % mod;
}

const ll N    = 1e5 + 10;
const ll MOD  = 1e9 + 7;
const ll INF  = 1e18;

int n, A[N], even, odd, one, ind;

bool solve() {
    odd = even = ind = 0;
    for (int i = 0; i < n; i++) {
        if (A[i] & 1) {
            odd++;
            ind = i;
            one = (A[i] == 1);
        }
    }
    even = (n - odd) & 1;
    if (one)
        return even;
    if (even)
        return true;
    if (odd > 1)
        return false;
    if (n == 1)
        return false;
    A[ind]--;
    int g = 0;
    for (int i = 0; i < n; i++) {
        g = __gcd(g, A[i]);
    }
    for (int i = 0; i < n; i++) {
        A[i] /= g;
    }
    return !solve();
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    cout << (solve() ? "First" : "Second") << endl;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  int tmp = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    ans += a;
    tmp = max(tmp, a);
  }
  cout << ans - tmp / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N, K;
ll A[200000];

signed main(){
    cin >> N >> K;
    rep(i, N) cin >> A[i];

    rep(i, N-K){
        if(A[i] < A[K+i]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 5176
#include<iostream>
#include<cstdio>
using namespace std;
int a,b;
string s;
int main(){
	int i,j;
	scanf("%d %d",&a,&b);
	cin>>s;
	if(s[a]!='-'){
		cout<<"No";
		return 0;
	}
	for(i=0;i<=a+b;i++){
		if(i!=a){
			if(s[i]<'0'||s[i]>'9'){
				cout<<"No";
				return 0;
			}
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){
    int n,sum[5]={0},am,pm,i=0,max=-1000,num;
    bool bo=false;
    char ans;
    while(1){
        for(i=0;i<5;i++){
            cin>>am>>pm;
            if(am==0 && pm==0){
                bo=true;
                break;
            }
            sum[i]=am+pm;
        }
        if(bo){
            break;
        }
        for(int i=0;i<5;i++){
            if(sum[i]>max){
                max=sum[i];
                num=i;
            }
        }
        ans='A'+num;
        cout<<ans<<" "<<max<<endl;
        max=-1000;
    }
    return 0;
}

Measured memory_bytes: 3084
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

int main()
{
  string S, T;
  cin >> S;
  int N = S.size();
  string alphabet = "abcdefghijklmnopqrstuvwxyz";
  int check[26]={0};

  for(int i=0; i < N; ++i){
    for(int j=0; j < 26; ++j){
      if(S[i]==alphabet[j]) ++check[j];
    }
  }

  for(int i=0; i < 26; ++i){
    if(check[i]==0) T+=alphabet[i];
  }

  if(T.size()==0) cout << "None" << endl;
  else cout << T[0] << endl;
  
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int a, b, k;
	cin >> a >> b >> k;
	for( int i = 0; i < k; ++i ){
		if( i%2 == 0 ){
			a -= a % 2;
			a /= 2;
			b += a;
		} else {
			b -= b % 2;
			b /= 2;
			a += b;
		}
	}
	cout << a << " " << b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline void chmin (int& a, int b) {
  if (a > b) a = b;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> cst(m, vector<int>(m));
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      cin >> cst[i][j];
    }
  }
  vector<vector<int>> mlt(3, vector<int>(m, 0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int col;
      cin >> col;
      mlt[(i + j) % 3][--col]++;
    }
  }
  int ret = 1e9;
  for (int a = 0; a < m; a++) {
    for (int b = 0; b < m; b++) {
      if (a == b) continue;
      for (int c = 0; c < m; c++) {
        if (a == c || b == c) continue;
        int tmp = 0;
        for (int i = 0; i < 3; i++) {
          int x;
          if (i == 0) x = a;
          if (i == 1) x = b;
          if (i == 2) x = c;
          for (int col = 0; col < m; col++) {
            tmp += mlt[i][col] * cst[col][x];
          }
        }
        chmin(ret, tmp);
      }
    }
  }
  cout << ret << '\n';
  return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
h = list(map(int,input().split()))
x = [[] for _ in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a -= 1; b -= 1
    x[a].append(b)
    x[b].append(a)
    #duble
ans = 0

y = [0 for _ in range(n)]
for i in range(n):
    if y[i] == -1:continue
    flag = 1
    for z in x[i]:
        if h[z] >= h[i]:
            flag = 0
            y[i] = -1
    if flag == 1:
        y[i] = 1
for i in y:
    if i == 1:
        ans += 1
print(ans)


Measured memory_bytes: 30248
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int X = fs.nextInt();

        for (int i = -200; i <= 200; ++i) {
            for (int j = -200; j <= 200; ++j) {
                if (Math.pow(i,5) - Math.pow(j,5) == X) {
                    System.out.println(i + " " + j);
                    System.exit(0);
                }
            }
        }

    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}

    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }

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




Measured memory_bytes: 36608
#include <stdio.h>

int p[20005];
int a[20005];
int b[20005];

int main(){
    int N;
    scanf("%d", &N);
    for(int i=1; i<=N; i++) scanf("%d", &p[i]);
    for(int i=1; i<=N; i++) a[i] = i, b[i] = N-i+1;
    int last=0;
    for(int i=1; i<=N; i++){
        if(a[p[i]]+b[p[i]] > last){ last = a[p[i]]+b[p[i]]; continue; }
        b[p[i]] += last+1-a[p[i]]-b[p[i]];
        //printf("%d", last);
        //printf("%d", a[p[i]]+b[p[i]]);
        int add=0;
        if(p[i] > 1 && b[p[i]] >= b[p[i]-1]) add += b[p[i]]-b[p[i]-1]+1;
        //printf("%d", add);
        if(add) for(int j=1; j<p[i]; j++) b[j] += add, a[j] -= add;
        if(add) for(int j=p[i]+1; j<=N; j++) a[j] += add, b[j] -= add;
        last = a[p[i]]+b[p[i]];
    }
    int plus = 1-a[1];
    for(int i=1; i<=N; i++) a[i] += plus;
    plus = 1-b[N];
    for(int i=1; i<=N; i++) b[i] += plus;
    for(int i=1; i<=N; i++) printf("%d ", a[i]);
    printf("\n");
    for(int i=1; i<=N; i++) printf("%d ", b[i]);
    return 0;
}

Measured memory_bytes: 768
#include <stdio.h>

int main(void)
{
	int a, b, c;
	int n;
	
	scanf("%d", &n);
	
	while (n != 0){
		scanf("%d %d %d", &a, &b, &c);
		
		if (a * a == (b * b) + (c * c) || b * b == (a * a) + (c * c) || c * c == (a * a) + (b * b)){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
		
		n--;
	}
	
	
	return (0);
}

Measured memory_bytes: 1696
a,b,c,d,n,*A=`dd`.split.map &:to_i;e=f=1;a>c&&(a,c,e=c,a,-1);b>d&&(b,d,f=d,b,-1);V=[];A.each_slice(2){|x,y|a<=x&&x<=c&&b<=y&&y<=d&&V<<[x*e,y*f]};D=[F=1e9]*-~V.size;V.sort.map{|x,y|D[D.bsearch_index{|e|e>y}]=y};N=D.index{|e|e>=F};p 1e2*(c-a+d-b)-20*N+5*(N+(N>[c-a,d-b].min ? 1:0))*Math::PI

Measured memory_bytes: 45812
#include <stdio.h>
#include <string.h>

#define maxn 200000 

char s[maxn];

int main( void ) {
	scanf("%s", s);
	
	int n = strlen(s);
	for( int len = 2; len <= 3; len++ ) {
		for( int i = 0; i < n; i++ ) {
			int count[26] = {0};
			for( int j = 0; j < len; j++ ) {
				count[s[j+i]-'a']++;
			}
			
			for( int j = 0; j < 26; j++ ) {
				if( count[j] >= 2 ) {
					printf("%i %i\n", i+1, i + len);
					return 0;
				}
			}
		}
	}
	
	printf("-1 -1\n");
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int M1 = sc.nextInt();
		int D1 = sc.nextInt();
		int M2 = sc.nextInt();
		int D2 = sc.nextInt();
		sc.close();
		
		if(D2==1)System.out.println(1);
		else System.out.println(0);
	}
	
}


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

#define F first 
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 3010, M = 1010;

int n, m;
int v[N], w[N];
int f[N][N], g[N][N];

int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i ++ ) cin >> v[i] >> w[i];
	
	for (int i = 1; i <= n; i ++ )
		for (int j = 0; j <= m; j ++ )
		{
			f[i][j] = f[i - 1][j];
			if (j >= v[i]) f[i][j] = max(f[i][j], f[i - 1][j - v[i]] + w[i]);
		}
		
	for (int i = n; i >= 1; i -- )
		for (int j = 0; j <= m; j ++ )
		{
			g[i][j] = g[i + 1][j];
			if (j >= v[i]) g[i][j] = max(g[i][j], g[i + 1][j - v[i]] + w[i]);
		}
		
	int res = 0;
	for (int i = 1; i <= n; i ++ )
		for (int j = 0; j < m; j ++ )
			res = max(res, w[i] + f[i - 1][j] + g[i + 1][m - j - 1]);
			
	cout << res << endl;
    return 0;
}

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

int main()
{
    int arr[10],k;
    for(int i=0;i<5;i++)
    {
        cin>>arr[i];
    }
    cin>>k;
   sort(arr,arr+4);
   if(arr[4]-arr[0]<=k)
   {
       cout<<"Yay!"<<endl;
   }
   else cout<<":("<<endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
int sum[100233]={};
signed main()
{
	int n,k,q;
	scanf("%d%d%d",&n,&k,&q);
	for(int i=1,a;i<=q;i++)
	{
		scanf("%d",&a);
		sum[a]++;
	}
	for(int i=1;i<=n;i++)
	{
		if(sum[i]+k-q<=0) printf("No\n");
		else printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 1024
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

l=lmp()

print(l.index(0)+1)

Measured memory_bytes: 10364
#include<bits/stdc++.h>
 
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS) 
 
using namespace std;
 
bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }
 
class Point {
public:
  double x,y,z;
  Point(double x=0,double y=0,double z=0):x(x),y(y),z(z){}
 
  Point operator + (const Point &a) {
    return Point(x+a.x,y+a.y,z+a.z); 
  }
 
  Point operator - (const Point &a) {
    return Point(x-a.x,y-a.y,z-a.z); 
  }
 
  Point operator * (const double &d) {
    return Point(x*d,y*d,z*d);
  }
 
  Point operator / (const double &d) {
    return Point(x/d,y/d,z/d);
  }
 
  bool operator < ( const Point &p ) const {
    if( !equals(x,p.x) ) return LT(x,p.x);
    if( !equals(y,p.y) ) return LT(y,p.y);
    return LT(z,p.z);
  }
 
  bool operator == ( const Point &p ) const {
    return equals(x,p.x) && equals(y,p.y) && equals(z,p.z);
  }
 
};
 
struct Segment{
  Point p[2];
  Segment(Point p1=Point(),Point p2=Point()){
    p[0] = p1, p[1] = p2;
  }
};
 
typedef Point Vector;
typedef Segment Line;
 
double dot(Point a,Point b){
  return a.x*b.x + a.y*b.y + a.z*b.z;
}
 
Vector cross(Point a,Point b) {
  return Vector(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x);
}
 
inline double norm(Point p){
  return p.x*p.x + p.y*p.y + p.z*p.z;
}
 
inline double abs(Point p){
  return sqrt(norm(p));
}
 
Point project(Segment seg,Point p){
  Vector base = seg.p[1] - seg.p[0];
  double t = dot(p-seg.p[0],base) / norm(base);
  return seg.p[0] + base * t;
}
 
bool on_line(Line line,Point p){
  return equals(abs(cross(p-line.p[0],line.p[1]-line.p[0])),0);
}
 
bool on_segment(Segment seg,Point p){
  if( !on_line(seg,p) ) return false;
  double dist[3] = { abs(seg.p[1]-seg.p[0]), abs(p-seg.p[0]), abs(p-seg.p[1]) };
  return on_line(seg,p) && equals(dist[0],dist[1]+dist[2]);
}
 
 
double distanceSP(Segment seg,Point p){
  Point r = project(seg,p);
  if( on_segment(seg,r) ) return abs(p-r);
  return min(abs(seg.p[0]-p),abs(seg.p[1]-p));
}
 
typedef long long ll;
 
int N,Q;
Point cp[100];
double r[100];
ll l[100];
Point s,t;
 
void compute(){
  ll answer = 0;
  Segment seg = Segment(s,t);
  rep(i,N){
    double dist = distanceSP(seg,cp[i]);
    if( LTE(dist,r[i]) ) {
      answer += l[i];
    }
  }
  cout << answer << endl;
}
 
int main(){
  cin >> N >> Q;
  rep(i,N){
    cin >> cp[i].x >> cp[i].y >> cp[i].z >> r[i] >> l[i];
  }
  rep(_,Q){
    cin >> s.x >> s.y >> s.z >> t.x >> t.y >> t.z;
    compute();
  }
 
  return 0;
}

Measured memory_bytes: 1240