akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define LL long long
#define REP(i, n) for(LL i = 0; i < (LL)(n); i++)
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()

const LL mod = 1e9+7;

LL add(LL x, LL y) {
    return (x + y)%mod;
}
LL sub(LL x, LL y) {
    return (x - y + mod)%mod;
}
LL mul(LL x, LL y) {
    return (x*y)%mod;
}
LL pw(LL x, LL y) {
    LL res = 1;
    while(y != 0) {
        if(y%2) {
            res = mul(x, res);
            y--;
        }else{
            x = mul(x, x);
            y /= 2;
        }
    }
    return res;
}
LL inv(LL x) {
    return pw(x, mod - 2);
}

int main() {
    LL H, W, A, B;
    cin >> H >> W >> A >> B;

    vector<LL> fact(H + W + 1, 1);
    FOR(i, 1, H + W + 1) {
        fact[i] = mul(i, fact[i - 1]);
    }

    LL res = 0;
    REP(i, H - A) {
        LL d1 = mul(mul(fact[i + B - 1], inv(fact[i])), inv(fact[B - 1]));
        LL d2 = mul(mul(fact[H - i - 1 + W - B - 1], inv(fact[H - i - 1])), inv(fact[W - B - 1]));
        res = add(res, mul(d1, d2));
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define pi 3.14159265358979323846264338
using namespace std;

int main() {
	int n;
	cin >> n;
	int j;
	int count = 0;
	for (int i = 0; i < n; i++) {
		cin >> j;
		if (j % 2 == 1) {
			count++;
		}
	}
	if (count % 2 == 1) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
	return 0;
}


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

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define dbg(x) true
#endif

const string YES = "Yes";
const string NO = "No";

void solve(long long X) {
  cout << (X >= 30 ? YES : NO) << endl;
}

int main() {
  long long X;
  scanf("%lld", &X);
  solve(X);
  return 0;
}


Measured memory_bytes: 3764
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define x1 xdddddddddddddddddd
#define y1 ydddddddddddddddddd
#define eps 0.0000000000000000001

vector <ll> v,p,q;
map <ll,ll> m;

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

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    for(int i=1;i<=9;i++){
        v.pb(i);
    }
    for(int i=1;i<=9;i++){
        v.pb(10*i+9);
        p.pb(10*i+9);
    }
    for(int i=2;i<15;i++){
        for(ll j : p){
            ll t=j*10+9;
            if(!m[t]) m[t]=1,v.pb(t),q.pb(t);
            ll f=1,g=t;
            for(int i=1;i<=17;i++){
                if(g%10==9) g/=10,f*=10;
            }
            if(!g) f/=10;
            ll h=t;
            f/=10,g=9;
            while(g%10){
                g--;
                if((h-f)*s(h)<=h*s(h-f)){
                    if(!m[h-f]) m[h-f]=1,v.pb(h-f),q.pb(h-f);
                }
                else break;
                h-=f;
            }
        }
        swap(p,q);
        q.clear();
    }
    sort(v.begin(),v.end());
    //cout << v.sz;
    ll k;
    cin >> k;
    for(int i=0;i<k;i++) cout << v[i] << '\n';
}


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);

char exchange(char c,int cnt){
    if (c=='?')
        return c;
    int chr = c - 'A';
    cnt %= 26;
    if (chr + cnt < 0)
    {
        cnt += chr+1;
        chr = 'Z' - 'A';
        chr += cnt;
    }
    else if (chr + cnt >= 26)
    {
        cnt -= 'Z' - 'A' - chr+1;
        chr = cnt;
    }
    else{
        chr+=cnt;
    }
    return 'A'+chr;
}


int rev(int j, string &r,string &s)
{
    string ans_tmp;
    int cnt=0;
    reps(i,j, s.size())
        {
            string tmp;
            if (s[i] == '[')
            {
                i = rev(i + 1, tmp,s);
                tmp[0]=exchange(tmp[0],cnt);
                cnt=0;
                ans_tmp += tmp;
                continue;
            }
            else if (s[i]==']'){
                reverse(ans_tmp.begin(),ans_tmp.end());
                r=ans_tmp;
                return i;
            }
            else if (s[i] == '+')
            {
                cnt++;
            }
            else if (s[i] == '-')
            {
                cnt--;
            }
            else
            {
                //cout<<s[i]<<" "<<cnt<<endl;
                char k=exchange(s[i],cnt);
                //cout<<k<<endl;
                ans_tmp+=k;
                cnt=0;
            }
        }
return -1;

}

int main()
{
    vector<string> ans;
    cin.sync_with_stdio(false);
    while (1)
    {
        string s;
        cin >> s;
        if (s == ".")
            break;
        string ans_tmp;

        int cnt = 0;
        rep(i, s.size())
        {
            string tmp;
            if (s[i] == '[')
            {
                i = rev(i + 1, tmp,s);
                tmp[0]=exchange(tmp[0],cnt);
                cnt=0;
                ans_tmp += tmp;
            }
            else if (s[i] == '+')
            {
                cnt++;
            }
            else if (s[i] == '-')
            {
                cnt--;
            }
            else
            {
                ans_tmp+=exchange(s[i],cnt);
                cnt=0;
            }
        }
        rep(i,ans_tmp.size())if(ans_tmp[i]=='?')ans_tmp[i]='A';
        ans.push_back(ans_tmp);
    }
    rep(i, ans.size()) cout << ans[i] << endl;
    return 0;
}


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

int main()
{
  int N;
  cin >> N;
  const int M = 0;
  const int A = 1;
  const int R = 2;
  const int C = 3;
  const int H = 4;
  vector<long long> counts(5);
  string name;
  for (int i = 0; i < N; i++)
  {
    cin >> name;
    if (name.at(0) == 'M')
    {
      counts.at(M)++;
    }
    else if (name.at(0) == 'A')
    {
      counts.at(A)++;
    }
    else if (name.at(0) == 'R')
    {
      counts.at(R)++;
    }
    else if (name.at(0) == 'C')
    {
      counts.at(C)++;
    }
    else if (name.at(0) == 'H')
    {
      counts.at(H)++;
    }
  }
  unsigned long long result = 0;
  for (int i = 0; i < 3; i++)
  {
    for (int j = i + 1; j < 4; j++)
    {
      for (int k = j + 1; k < 5; k++)
      {
        result += counts.at(i) * counts.at(j) * counts.at(k);
      }
    }
  }
  cout << result << endl;
}

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

int main(){
    int a,b,c,k;
    cin >>a>>b>>c>>k;
    if(k <= a) cout << k<<endl;
    else if(a<k&k<=a+b) cout << a << endl;
    else if(k>a+b) cout << a - (k - a - b) << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

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

        int ans = 0;
        for(int i = 1;i <= n;i += 2) {
            int count = 0;
            for(int j = 1;j <= i;j++) {
                if(i % j == 0) count++;
            }
            if(count == 8) ans++;
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,count=0,p[25];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>p[i];
    //cout<<p[i]<<endl;
  }
  for(int i=1;i<=n-2;i++){
    if(p[i-1]<p[i]&&p[i]<p[i+1]) count++;
    if(p[i-1]>p[i]&&p[i]>p[i+1]) count++;
  }
  cout<<count<<endl;
}
    

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
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...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n,k;cin>>n>>k;
  vector<ll>h(n);
  rep(i,0,n)cin>>h[i];
  sort(ALL(h));
  rep(i,0,n-k){
    res+=h[i];
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe


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

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;
const int MaxN = 100000,MOD = 1e9+7;
typedef long long LL;
int n,m;
LL f[MaxN+3];
int main() {
	scanf("%d%d",&n,&m);
	if (abs(n-m)>=2) {
		puts("0");
		return 0;
	}
	f[0]=1;
	for (int i=1;i<=100000;++i) f[i]=(f[i-1]*i)%MOD;
	if (n==m) {
		LL ans=((f[n]*f[n])%MOD*2)%MOD;
		printf("%d\n",(int)ans);
	} else {
		LL ans=(f[n]*f[m])%MOD;
		printf("%d\n",(int)ans);
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int N, K;
  string S;
  cin >> N >> K;
  cin >> S;
  REP(i, N) {
    if (i == K-1) {
      cout << (char)tolower(S[i]);
    } else {
      cout << S[i];
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
def result(m,f,r):
	if m==-1 or f==-1:
		return "F"
	if m+f>=80:
		return "A"
	if m+f>=65:
		return "B"
	if m+f>=50:
		return "C"
	if m+f>=30:
		return "C" if r>=50 else "D"
	return "F"

while True:
	m,f,r = map(int, input().split())
	if m==-1 and f==-1 and r==-1:
		break
	print(result(m,f,r))



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e5+7;
const int N=1e5+5;


int main(){
    int n;cin>>n;
    string s;cin>>s;
    int cnt=0,ans=0;
    for(int i=0;i<n;i++){
        if(s[i]=='R')
            cnt++;
    }
    for(int i=cnt;i<n;i++){
        if(s[i]=='R')
            ans++;
    }
    cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3716
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <iterator>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(c) (c).begin(), (c).end()
const int N = 1000000;

template<typename T> inline void chmin(T& t, T f){if(t > f)t = f;}

vector<int> mem1, mem2;

void calc(vector<int>& v, vector<int>& mem){
    mem.assign(N, 0); iota(all(mem), 0);
    rep(i, N)for(int& j: v){
        if(i < j)break;
        chmin(mem[i], mem[i-j] + 1);
    }
}

void init(){
    vector<int> num, odd;
    for(int i=1, x=1; x<N; ++i, x=i*(i+1)*(i+2)/6)num.push_back(x);
    copy_if(all(num), back_inserter(odd), [](int x){return x&1;});
    calc(num, mem1); calc(odd, mem2);
}

int main(){
    init();
    for(int n; cin >> n, n; cout << mem1[n] << " " << mem2[n] << '\n');
    return 0;
}

Measured memory_bytes: 8784
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < (ll) b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= (ll) b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < (ll) b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= (ll) b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
 
const ll MAX= 5e5+6;
const ll inf =1e12;



int main(){
	fastio;
	ll h1,h2,m1,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;
	cout <<max(0LL, h2*60+m2 -k  - h1*60-m1)<<endl;  
}


 

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  int left = 0;
  int right = 1e9;
  while(right-left>1){
    int x = (left+right)/2;
    int num = 0;
    for(int i=0; i<N; i++){
      num += A.at(i)/x - (A.at(i)==x);
    }
    if(num<=K){
      right = x;
    }else{
      left = x;
    }
  }
  cout << right;
  return 0;
}

Measured memory_bytes: 3988
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    map<long,long> zz;
    long i;
    for(i=0; i<3; i++) {
        long a, b;
        scanf("%ld%ld", &a, &b);
        zz[a]++;
        zz[b]++;
    }



    if(zz.size()==4) {
        if(zz[1]>2 || zz[2]>2 || zz[3]>2 || zz[4]>2) {
            printf("NO\n"); return 0;
        }
        printf("YES\n");
    }
    else {
        printf("NO\n");
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k,l[100],ans=0;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>l[i];
    }
    sort(l,l+n,greater<int>());
    for(int i=0;i<k;i++){
        ans+=l[i];
    }
    cout<<ans<<endl;
    return(0);
}

Measured memory_bytes: 3616
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main implements Runnable{
	int[][] table;
	int[] d;
	int ans;
	public int check(int[] d,int len){

		int prev = 0;

		for(int i = 0;i < len;i++){
			prev = table[prev][d[i]];
		}

		return prev;
	}

	public boolean single(int[] d){

		for(int i = 0;i < 5;i++){

			int prev = d[i];

			for(int j = 0;j < 10;j++){

				if(prev == j)continue;
				d[i] = j;
				if(check(d,5) == 0)return false;
				d[i] = prev;
			}
		}
		return true;
	}

	public boolean adjacent(int[] d){

		for(int i = 0;i < 4;i++){
			if(d[i] == d[i+1])continue;
			{
				int tmp = d[i];
				d[i] = d[i+1];
				d[i+1] = tmp;
			}

			if(check(d,5) == 0)return false;

			{
				int tmp = d[i];
				d[i] = d[i+1];
				d[i+1] = tmp;
			}
		}

		return true;

	}

	public void solve() {
		table = new int[10][10];
		for(int i = 0;i < 10;i++){
			for(int j = 0;j < 10;j++){
				table[i][j] = nextInt();
			}
		}

		d = new int[5];
		ans = 0;
		for(int i = 0;i < 10;i++){
			for(int j = 0;j < 10;j++){
				for(int k = 0;k < 10;k++){
					for(int l = 0;l < 10;l++){

						d[0] = i;
						d[1] = j;
						d[2] = k;
						d[3] = l;
						d[4] = check(d,4);

						if(!single(d) || !adjacent(d)){
							ans++;
						}
					}
				}
			}
		}

		out.println(ans);
	}

	public static void main(String[] args) {
		new Thread(null,new Main(),"",32 * 1024 * 1024).start();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

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

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

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

	public int nextInt() {
		return Integer.parseInt(next());
	}

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

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

	@Override
	public void run() {
		out.flush();
		new Main().solve();
		out.close();

	}
}

Measured memory_bytes: 25528
#include<stdio.h>
int main()
{
	char s[3][4];
	for(int i = 0; i < 3; i++)
	{
		scanf("%s", s[i]);
	}
	printf("%c%c%c\n", s[0][0], s[1][1], s[2][2]);
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

vector<pair<int, int>> GetMaxCount(const vector<int> &vec, size_t start)
{
    map<int, int> count;
    for (auto i = start; i < vec.size(); i += 2) {
        count[vec[i]] += 1;
    }

    vector<pair<int, int>> sorted;
    for (const auto &p : count) {
        sorted.push_back({p.second, p.first});
    }

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

    vector<pair<int, int>> max_count{sorted[0]};
    if (sorted.size() > 1) {
        max_count.push_back(sorted[1]);
    } else {
        max_count.push_back({0, 0});
    }
    return max_count;
}

int Solve(const vector<int> &vec)
{
    auto odd = GetMaxCount(vec, 0);
    auto even = GetMaxCount(vec, 1);

    if (odd[0].second != even[0].second) {
        return vec.size() - odd[0].first - even[0].first;
    }

    return vec.size() - max(odd[0].first + even[1].first,
                            odd[1].first + even[0].first);
}

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

    vector<int> vec(n);
    for (auto &num : vec) {
        cin >> num;
    }

    auto res = Solve(vec);
    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 3828
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++)
	ans+=i;
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))


def f(x):
    v = 0
    for i in range(len(A)):
        v += abs(A[i] - (x + i + 1))
    return v


left = -(10**9 + 2 * 10**5)
right = 10**9 + 2 * 10**5
v = 10**18
while left + 1 < right:
    x = (left + right) // 2
    # print('left right x', left, right, x)
    a = f(x)
    v = min(v, a)
    if a <= f(x + 1):
        right = x
    elif f(x - 1) >= a:
        left = x

# ans = f(left)
# print('left ans v', left, ans, v)
print(v)


Measured memory_bytes: 86868
#include <bits/stdc++.h>
using namespace std;
// ----------------------R00TDADA------------------------------
#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define pf push_front
#define prq priority_queue
#define mp make_pair
#define mem(x, val) memset((x), (val), sizeof(x));
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
#define int long long

signed main()
{
    rootdada;

    // #ifndef ONLINE_JUDGE
    //     // for getting input from input.txt
    //     freopen("input.txt", "r", stdin);
    //     // for writing output to output.txt
    //     freopen("output.txt", "w", stdout);
    // #endif
    string s;
    cin >> s;
    int q;
    cin >> q;
    int rev = 0;
    while (q--)
    {
        int t;
        cin >> t;
        if (t == 1)
        {
            rev ^= 1;
        }
        else
        {
            int f;
            char c;
            cin >> f >> c;
            if (f == 1)
            {
                if (rev & 1)
                {
                    s.pb(c);
                }
                else
                {
                    s.insert(s.begin(), c);
                }
            }
            else
            {
                if (rev & 1)
                {
                    s.insert(s.begin(), c);
                }
                else
                {
                    s.pb(c);
                }
            }
        }
    }
    if (rev & 1)
        reverse(all(s));

    cout << s << endl;
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n; cin >> n;
  vector<double> a(n);
  for (auto &i : a) cin >> i;
  sort(all(a));
  double s = a[0];
  for (auto &i : a) (s += i) /= 2;
  cout << s << '\n';
}


Measured memory_bytes: 3812
#include <bits/stdc++.h>
#define endl "\n"
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;
}

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    bool a = false;
    ll ans = 1;
    while(N--) {
        ll b;
        cin >> b;
        if(b == 0) {
            cout << 0 << endl;
            return 0;
        }
        if(INF / b < ans) a = true;
        ans *= b;
    }
    if(a) ans = -1;
    if(ans > INF) ans = -1;
    cout << ans << endl;
    return 0;
}


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

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

using namespace std;


int main()
{
	int N;
	cin>>N;
	
	int c1,c2,c3,c4;
	c1=N%10;
	N=N/10;
	c2=N%10;
	N=N/10;
	c3=N%10;
	N=N/10;
	c4=N%10;
	
	if((c1==c2) and (c2==c3)){
		cout<<"Yes"<<endl;
	}
	else{
		if((c2==c3) and (c3==c4)){
			cout<<"Yes"<<endl;
		}
		else{
			cout<<"No"<<endl;
		}
	}
	
	
	
}

Measured memory_bytes: 256
var i,n,j,d,temp:integer;
    a:array[1..50] of integer;
begin
  readln(n);
  for i:=1 to n do read(a[i]);
  for i:=1 to n do 
    if i <> a[i] then d:=d + 1;
  if (d = 2) or (d = 0) then write('YES') else write('NO')
end.

Measured memory_bytes: 128
//OP MANISH in CHAT
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll MOD=1e9+7;

void solve()
{
	ll k;
	cin>>k;
    ll s=7%k;
    for(ll i=1;i<1e8;i++)
    {
        if(s==0)
        {
            cout<<i;
            return;
        }
        else
            s=(s*10+7)%k;
            
    }
    cout<<"-1";
	return;
}
int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        	solve();
        
        return 0;
}


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

typedef vector<int> vi;

int H, W;
vector<string> S;
vector<vi> U, D, L, R;

void input_init(void) {
	cin >> H >> W;
	S.resize(H);
	for (int i = 0; i < H; ++i)
		cin >> S[i];
	U.resize(H, vi(W, 0));
	D.resize(H, vi(W, 0));
	L.resize(H, vi(W, 0));
	R.resize(H, vi(W, 0));
}

void pre_calcu(void) {
	for (int i = 0; i < W; ++i)
		U[0][i] = (S[0][i] == '.') ? 1 : 0;
	for (int j = 1; j < H; ++j) {
		for (int i = 0; i < W; ++i)
			U[j][i] = (S[j][i] == '.') ? U[j - 1][i] + 1 : 0;
	}
	for (int i = 0; i < W; ++i)
		D[H - 1][i] = (S[H - 1][i] == '.') ? 1 : 0;
	for (int j = H - 2; j >= 0; --j) {
		for (int i = 0; i < W; ++i)
			D[j][i] = (S[j][i] == '.') ? D[j + 1][i] + 1 : 0;
	}
	for (int j = 0; j < H; ++j)
		L[j][0] = (S[j][0] == '.') ? 1 : 0;
	for (int i = 1; i < W; ++i) {
		for (int j = 0; j < H; ++j)
			L[j][i] = (S[j][i] == '.') ? L[j][i - 1] + 1 : 0;
	}
	for (int j = 0; j < H; ++j)
		R[j][W - 1] = (S[j][W - 1] == '.') ? 1 : 0;
	for (int i = W - 2; i >= 0; --i) {
		for (int j = 0; j < H; ++j)
			R[j][i] = (S[j][i] == '.') ? R[j][i + 1] + 1 : 0;
	}
}

int solve(void) {
	int max_cnt = 0;
	for (int j = 0; j < H; ++j) {
		for (int i = 0; i < W; ++i) {
			if (S[j][i] == '#')
				continue;
			int cnt = 1;
			if (j - 1 >= 0)
				cnt += U[j - 1][i];
			if (j + 1 < H)
				cnt += D[j + 1][i];
			if (i - 1 >= 0)
				cnt += L[j][i - 1];
			if (i + 1 < W)
				cnt += R[j][i + 1];
			max_cnt = max(cnt, max_cnt);
		}
	}

	return max_cnt;
}

int main(void) {
	input_init();
	pre_calcu();
	int ans = solve();
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 67200
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    long long L, R, i, j, ans=3000;

    cin >> L >> R;

    if(R-L >= 2019){
        cout << 0 << endl;
    }

    else{
        for(i=L; i<=R-1; i++){
            for(j=i+1; j<=R; j++){
                chmin(ans, (i*j)%2019);
            }
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

long long GCD(long long a, long long b) {
    if(b == 0)
        return a;
    else
        return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}
int main() {
    int N, Q;
    long long K;
    cin >> N >> K >> Q;
    vector<int> point(N, 0);
    rep(i, 0, Q) {
        int a;
        cin >> a;
        point[a - 1]++;
    }
    rep(i, 0, N) {
        // cout << "i:" << i << ",point" << point[i] << endl;
        if(point[i] - Q + K > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	string s;
	cin >> s;
	int r = 0, w = 0;
	rep(i, n) if (s[i] == 'R') r++;
	int ans = r;
	rep(i, n) {
		if (s[i] == 'R') r--;
		else w++;
		chmin(ans, max(r, w));
	}
	cout << ans << '\n';
}

Measured memory_bytes: 3776
#include <iostream>
#include <string>
#include <vector>
#define REP(val,times) for(int val = 0;val < times;val++)
using namespace std;

struct Dice{
    int s[6];
    void roll(char ope){
        int b;
        if(ope == 'E'){
            swap(s[0],s[2]);
            swap(s[0],s[5]);
            swap(s[0],s[3]);
        }
        if(ope == 'W'){
            swap(s[0],s[3]);
            swap(s[0],s[5]);
            swap(s[0],s[2]);
        }
        if(ope == 'S'){
            swap(s[0],s[1]);
            swap(s[0],s[5]);
            swap(s[0],s[4]);
        }
        if(ope == 'N'){
            swap(s[0],s[4]);
            swap(s[0],s[5]);
            swap(s[0],s[1]);
        }
        if(ope == 'R'){
            swap(s[1],s[2]);
            swap(s[1],s[4]);
            swap(s[1],s[3]);
        }
    }
    int top(){
        return s[0];
    }
    int right(){
        return s[2];
    }
    int left(){
        return s[3];
    }
    int front(){
        return s[1];
    }
};

bool same(Dice a,Dice b){
    REP(i,6)
     if(a.s[i] != b.s[i])   
         return false;
    return true;
}

int main(){
    Dice Dice[101];
    int n;
    cin >> n;
    REP(i,n)
        REP(j,6)
            cin >> Dice[i].s[j];
    bool flag2 = true;
    REP(k,n-1)
        for(int l = k + 1;l<n;l++){
            bool flag = false;
            REP(i,4){
                Dice[1].roll('R');
                REP(j,4){
                    Dice[l].roll('N');
                    if(same(Dice[k],Dice[l]))
                        flag = true;
                }
            }
            Dice[l].roll('E');
            REP(i,4){
                Dice[l].roll('N');
                if(same(Dice[k],Dice[l]))
                    flag = true;
            }
            Dice[l].roll('W');
            Dice[l].roll('W');
            REP(i,4){
                Dice[l].roll('N');
                if(same(Dice[k],Dice[l]))
                    flag = true;
            }
            if(flag)
                flag2 = false;
    }
    cout << (flag2 ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3116
N,M = gets.split.map &:to_i
G = Array.new(N){[]}
M.times do
  a,b = gets.split.map &:to_i
  G[a-1] << b-1
  G[b-1] << a-1
end

P = [0] # パリティ
S = [0] # スタック

while S.size > 0
  i = S.pop 
  G[i].each do |j|
    if P[j].nil?
      P[j] = 1 - P[i]
      S << j
    elsif P[i] == P[j]
      puts N * (N - 1) / 2 - M
      exit
    end
  end
end

puts P.count(0) * P.count(1) - M

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n];
    rep(i,0,n) cin >> a[i];
    bool ok = true;
    rep(i,0,n){
        if(a[i] % 2 == 1) continue;
        if(!(a[i] % 3 == 0 || a[i]%5==0)) ok = false;
    }
    if(ok)cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//D
long long gcd(long long x, long long y){
	if(y==0) return x;
	return gcd(y,x%y);
}
int main() {
	// your code goes here
	long long a,b,g,h,ans=1;
	cin >> a >> b;
	g=gcd(a,b);
	h=g;
	for(long long i=2;i*i<=h;i++){
		if(h%i!=0) continue;
		ans++;
		while(h%i==0) h/=i;
	}
	if(h>1) ans++;
	cout << ans << endl;
 	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	vector<int> a(n);
	vector< vector<int> > x(n), y(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		
		x[i].resize(a[i]);
		y[i].resize(a[i]);
		
		for(int j = 0; j < a[i]; ++j) {
			cin >> x[i][j] >> y[i][j];
			x[i][j]--;
		}
	}
	
	int ans = 0;
	for(int bit = 1; bit < (1 << n); ++bit) {
		bool judge = true;
		
		for(int i = 0; i < n; ++i) {
			if( !(bit & (1 << i)) ) continue;
			
			for(int j = 0; j < a[i]; ++j) {
				if( y[i][j] == 1 && !(bit & (1 << x[i][j])) ) judge = false;
				if( y[i][j] == 0 && (bit & (1 << x[i][j])) ) judge = false;
			}
		}
		
		if( judge ) {
			int cnt = 0;
			
			for(int k = 0; k < n; ++k) {
				if( bit & (1 << k) ) cnt++;
			}
			
			ans = max(ans, cnt);
		}
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
icase=0
if icase==0:
    def cd(nn):
        nnn=int(nn**0.5)+1
        cdl=set()
        for i in range(1,nnn):
            if nn%i==0:
                r=nn//i
                if not i in cdl:
                    cdl.add(i)
                if not r in cdl:
                    cdl.add(r)
        return len(cdl)            
            
    n=int(input())
    if n<105:
        print(0)
    elif n==105:
        print(1)
    else:
        icnt=1
        for nn in range(107,n+1,2):
            if cd(nn)==8:
                icnt+=1
#                print(nn)
        print(icnt)


Measured memory_bytes: 3188
s = gets.chomp("").to_i

a= []
s.times do |i|
  a[i] = gets.chomp("").to_i
end

mx = a.max
ind = a.index(mx)

s.times do |i|
  if i == ind
    t = a.clone
    t.delete_at(i)
    puts t.max
  else
    puts mx
  end
end


Measured memory_bytes: 6856
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
    cin>>N>>M;
    //ll mini = 1000;
    int ans=0;
    ll mf = M;
    rep(i,N){
        ans += M;
        if(i != N-1) ++M;
    }
    if(mf<=0&&M>=0){
        cout<<ans<<endl;
        return 0;
    }
    if(mf>0){
        cout<<ans-mf<<endl;
        return 0;
    }
    cout<<ans-M<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    vector<vector<int>> c(3);
    vector<int> a(3);
    vector<int> b(3);
    rep(i,3) {
        c[i].resize(3);
        rep(j,3) cin >> c[i][j];
    }
    a[0] = 0;
    rep(i,3) {
        b[i] = c[0][i]-a[0];
    }
    a[1] = c[1][0]-b[0];
    a[2] = c[2][0]-b[0];
    rep(i,3) {
        rep(j,3) {
            if (c[i][j] != a[i]+b[j]) {
                cout << "No\n";
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

using namespace std;


int main()
{
	string s;
	cin >> s;
	int k = 0;
	string stuck = "";
	for (int i = 0; i < s.length(); i++) {
		if (stuck != s.substr(i, 1)) {
			stuck = s.substr(i, 1);
		}
		else {
			if (i == s.length() - 1) break;
			stuck = s.substr(i, 2);
			i++;
		}
		k++;
	}

	cout << k << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define endl "\n"
const ll mod = 1000000007;

typedef tree<pair<ll, int>, null_type, less<pair<ll, int>>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//Ordered set
//pbds s1
int n, m;
ll k;
ll val[14][14];
int ok;

ll go () {
    ll vv = 1e18;
    for (int i=1; i<(1<<n); i++) {
        ll skill[m+1] = {0};
        ll cost = 0;
        for (int al=0; al<n; al++) {
            ll v = 1<<al;
            if (i&v) {
                cost += val[al][0];
                for (int j=1; j<=m; j++) {
                    skill[j] += val[al][j];
                }
            }
        }
        int flg = 1;
        for (int j=1; j<=m; j++) {
            if (skill[j] < k) {
                flg = 0;
                break;
            }
        }
        if (flg) {
            ok = 1;
            vv = min (vv, cost);
        }
    }
    return vv;
}

void testCase() {
    cin >> n >> m >> k;
    for (int i=0; i<n; i++) {
        for (int j=0; j<=m; j++) {
            cin >> val[i][j];
        }
    }
    ll ans = 0;
    ans = go ();
    if (ok == 0)
        cout << "-1" << endl;
    else
        cout << ans << endl;
}
 
int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    testCase();
    return 0;
}

Measured memory_bytes: 3652
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void)
{
	int a, b;
	double f;

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

	f = (double)a / b;

	printf("%d %d %f\n", a / b, a % b,f);

		return 0;
}


Measured memory_bytes: 2744
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		System.out.println(gcd(a, b));
	}
	
	public static int gcd(int a, int b) {
		if(b == 0)
			return a;
		else
			return gcd(b, a % b);
	}

}



Measured memory_bytes: 26148
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int[] d=new int[N];
        for(int i=0;i<N;i++){
            d[i]=sc.nextInt();
        }
        d=sort(d);
        int temp=d[0];
        int sum=1;
        for(int i=1;i<N;i++){
            if(temp>d[i]){
                sum++;
                temp=d[i];
            }
        }
        System.out.println(sum);
    }

    static int[] sort(int[] num){
        int temp=0;
        for(int i=0;i<num.length-1;i++){
            for(int j=num.length-1;j>i;j--){
                if(num[j] > num[j-1]){
                    temp=num[j];
                    num[j]=num[j-1];
                    num[j-1]=temp;
                }
            }
        }
        return num;
    }
}

Measured memory_bytes: 21204
import java.util.* ; 
import java.math.*;
class Main{
  public static void main(String[] args) {
    Scanner scan = new Scanner (System.in);
	int n = scan.nextInt();
 	int x = scan.nextInt();
    System.out.println((n%x % 2 != 0 ? 1:0));

  }
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int,Int> pii;
typedef pair<Int,double> pid;
typedef pair<double,double> pdd;
typedef pair<Int,pii> pip;
typedef pair<double,Int> pdp;
#define A first
#define B second
#define pb(x) push_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define Itype(a) typeof(a.begin()) 
#define REP(i,a,b) for(int i = (a);i <= (b);i++)
#define FORO(i,n) REP(i,0,(int)n-1)
#define FORI(i,n) REP(i,1,(int)n)
#define FORIT(i,t) for(Itype(t) i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a,_b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
template<typename T>void getMin(T &a,T b) { if(a > b) a = b; }
template<typename T>void getMax(T &a,T b) { if(a < b) a = b; }
template<typename T> vector<T> getVector(const int n) { return vector<T>(n); }
const int MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    cout << 1000 * (!!(N % 1000)) - (N % 1000) << endl;
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    long long ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i);
        ans+=a.at(i)-1;
    }
    cout<<ans<<endl;
}


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

int main(){

  int n;

  cin >> n;

  for(int i = 1;;i++){
    if(pow(2, i) - 1 > n){
      cout << i - 1 << endl;
      return 0;
    }
  }

  return 0;
}



Measured memory_bytes: 3284
import sys

def a(x, n):
    if (int(x/n)):
        return a(int(x/n), n)+str(x%n)
    return str(x%n)

def main():
    tmp = input().replace('\n','').split(' ')
    n = int(tmp[0])
    r = int(tmp[1])
    res = a(n, r)
    print(len(res))
if __name__ == '__main__':
    input = sys.stdin.readline
    main()

Measured memory_bytes: 3064
#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()

struct UnionFind{
    vector<int> par;

    UnionFind(int n) : par(n,-1) { }
    void init(int n) { par.assign(n,-1); }

    int root(int x){
        if(par[x]<0) return x;
        else return par[x]=root(par[x]);
    }

    bool issame(int x,int y){
        return root(x)==root(y);
    }

    bool merge(int x,int y){
        x=root(x);
        y=root(y);
        if(x==y) return false;
        if(par[x]>par[y]) swap(x,y);
        par[x]+=par[y];
        par[y]=x;
        return true;
    }

    int size(int x){
        return -par[root(x)];
    }
};

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> p(n);
    rep(i,n) cin>>p[i];
    UnionFind uf(n);
    rep(i,m){
        int x,y;
        cin>>x>>y;
        x--,y--;
        uf.merge(x,y);
    }

    int ans=0;
    rep(i,n){
        if(uf.issame(p[i]-1,i)) ans++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3984
import java.util.*;
public class Main {
	static int N;
	static int M;
	static int []rank;
	static int[]par;
	static int[]size;

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc= new Scanner(System.in);
		N= sc.nextInt();
		M= sc.nextInt();
		
		rank=new int [N+1];
		par= new int[N+1];
		size= new int[N+1];
		
		for(int i=0;i<=N;i++){
			rank[i]= 0;
			par[i]= i;
			size[i]= 0;
			
		}
		
		for(int i=0;i<M;i++){
			int a= sc.nextInt();
			int b= sc.nextInt();
			
			union(a,b);
		}
		
		sc.close();
		
		int ans=0;
		
		for(int i=1;i<=N;i++){
			int p= find(i);
			size[p]++;
			ans= Math.max(ans, size[p]);
		}
		
		System.out.println(ans);
		
		
	}
	static void union(int x,int y){//rootを繋げて併合
		x= find(x);
		y= find(y);
		if(x== y)return;
		
		if(rank[x] < rank[y]){//高さのバランスを整えるために、rankの大きい方の根に小さい方を繋げる
			par[x]= y;
		}
		else{
			par[y]= x;
			if(rank[x] == rank[y])rank[x]++;
		}
		
	}
	
	static int find(int x){//rootを求める
		if(par[x] == x)return x;
		else{
			par[x]= find(par[x]);
			return  par[x];
		}
		
	}
	
	static boolean same(int x,int y){
		boolean res= false;
		if(find(x) == find(y))res= true;
		
		return res;
	}
}


Measured memory_bytes: 61928
from collections import defaultdict
N=int(input())
A=list(map(int,input().split()))
dict=defaultdict(int)
for i in A:
    dict[i]+=1
ans=0
tmp=0
for i,j in dict.items():
    ans+=1
    if j%2==0:
        tmp+=1
print(ans-(tmp%2))


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

string s;
int black;
ll ans;

void solve() {
    cin >> s;
    black = 0, ans = 0;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == 'B') black++;
        else ans += black;
    }
    cout << ans << "\n";
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    solve();

}

Measured memory_bytes: 3740
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a,b;
        while(true){
            
            a=sc.nextInt();b=sc.nextInt();
            
            if(a==0 && b==0)break;
            
            for(int i=0;i<a;i++){
                
                if(i%2==0){
                    for(int j=0;j<b;j++){
                        if (j%2==0)System.out.print("#");
                        else System.out.print(".");
                    }
                }
                
                else{
                    for(int j=0;j<b;j++){
                        if (j%2==1)System.out.print("#");
                        else System.out.print(".");
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


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

int main(){
    string s;
    cin >> s;
    string str(s);
    sort(str.begin(), str.end());    //昇順ソート
    if(str[0] == str[1] & str[2] == str[3] & str[1] != str[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256