akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX;
const ll MOD = 1e9+7;


long long mergecount(vector<long long> &a) {
    long long count = 0;
    int n = a.size();
    if (n > 1) {
        vector<long long> b(a.begin(), a.begin() + n/2);
        vector<long long> c(a.begin() + n/2, a.end());
        count += mergecount(b);
        count += mergecount(c);
        for (int i = 0, j = 0, k = 0; i < n; ++i)
            if (k == c.size())       a[i] = b[j++];
            else if (j == b.size())  a[i] = c[k++];
            else if (b[j] <= c[k])   a[i] = b[j++];
            else                   { a[i] = c[k++]; count += n/2 - j; }
    }
    return count;
}


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;cin>>S;
  int N=S.length();
  vector<deque<int> > cha(26);
  repeat(i,N){
    cha[S[i]-'a'].push_back(i);
  }
  vll T(N);
  int idx=0;
  bool odd=false;
  repeat(i,N){
    int c=S[i]-'a';
    if(cha[c].size()==1){
      if(!(N&1)||odd){
        cout << -1 << endl;
        return 0;
      }
      odd=true;
    }
    if(cha[c].empty())continue;
    if(cha[c].size()==1){
      T[i]=N/2;
      cha[c].pop_front();
    }else{
      T[i]=idx;
      T[cha[c].back()]=N-1-idx;
      idx++;
      cha[c].pop_front();
      cha[c].pop_back();
    }
  }
  //debugArray(T,N);
  cout << mergecount(T) << endl;
  return 0;
}


Measured memory_bytes: 5456
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <utility>
#include <set>
#include <numeric>
#include <queue>
#include <sstream>
#include <map>
#include <unordered_map>
#include <cmath>
using namespace std;
using LLI = long long int;

#define Rep(i, N) for (int i = 0; i < N; i++)


int main(int argc, char* argv[])
{
    LLI H;
    cin >> H;

    std::map<LLI, LLI> m;
    std::vector<LLI> nums;
    LLI h = H;
    while (h > 0) {
        nums.push_back(h);
        h /= 2;
    }

    sort(nums.begin(), nums.end(), less<LLI>());

    m[LLI(1)] = LLI(1);
    for (int i = 1; i < nums.size(); i++) {
        m[nums[i]] = m[(nums[i]) / 2] * 2 + 1;
    }

    cout << m[H] << endl;
}

Measured memory_bytes: 256
#python3
import numpy as np
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
sum=np.sum(b)
for i in reversed(range(n)):
  k = a[i+1]
  l = a[i]
  m = b[i]

  a[i+1] = max(k-m, 0)
  b[i] = max(m-k, 0)

  a[i] = max(l-b[i], 0)
  b[i] = max(b[i]-l, 0)
postsum=np.sum(b)
print(sum-postsum)



Measured memory_bytes: 27280
#include<stdio.h>
#include<algorithm>
#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)

using namespace std;

int main(){
	int a[10],b[10];
	rep(i,10)scanf("%d",a+i);
	rep(i,10)scanf("%d",b+i);
	sort(a,a+10);
	sort(b,b+10);
	int c=0,d=0;
	reps(i,7,9)c+=a[i];
	reps(i,7,9)d+=b[i];
	printf("%d %d\n",c,d);
	return 0;
}

Measured memory_bytes: 1040
#include <bits/stdc++.h>
using namespace std;
//Author: Ezio Sam
/* Shorthands */
#define ll long long
#define pb push_back
#define em emplace_back
#define mp make_pair
#define sp " "
#define cs "Case "
#define fi first
#define sn second

/* STL */
#define mem(a,n) memset(a, n, sizeof(a));
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define sz(x)  (int)x.size()
#define mx(v)  *max_element(v.begin(),v.end())
#define mxi(v) distance(v.begin(),max_element(v.begin(),v.end()))
#define mxa(a) *max_element(a, a.size())
#define r(a)   reverse(a.begin(),a.end())
/* loops */
#define fa(i, a, b) for (auto (i) = (a); (i) < (b); ++(i))
#define fr(i,n)   for(__typeof(n) i=0;i<(n);i++)
#define fn(i,n)   for(__typeof(n) i=1;i<=(n);i++)
/*Special*/
#define Ezio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(something)  cerr<<#something<<" - "<<something<<"\n";

int main()
{

   Ezio
   ll t,m(0),n,x,a,b;
   string s;

   cin>>a>>b>>n;

   if(n>=b-1)
   m= max(m,(a*(b-1))/b-a*((b-1)/b));
   else m=max(m,(a*n)/b- a*(n/b));

   cout<<m<<endl;
   return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

using namespace std;

#define con(i, j) ((i < j) ? g[i][j] : g[j][i])

void visited_reset(pair<bool, bool> g[50][50])
{
    REP(i, 50)
    {
        REP(j, 50)
        {
            con(i, j).second = false;
        }
    }
}

void _DFS(pair<bool, bool> g[50][50], int start)
{
    REP(i, 50)
    {
        if( con(start, i).first != con(start, i).second )
        {
            con(start, i).second = true;
            _DFS(g, i);
        }
    }
}

bool isAllConnected(pair<bool, bool> g[50][50], int N)
{
    _DFS(g, 0);

    REP(i, 50)
    {
        REP(j, 50)
        {
            if( con(i, j).first != con(i, j).second ) return false;
        }
    }

    REP(i, N)
    {
        bool ok = false;
        REP(j, N)
        {
            ok |= con(i, j).first;
        }

        if( !ok ) return false;
    }

    return true;
}

int main(void)
{
    pair<bool, bool> g[50][50];
    // first: connected? second: visited?

    REP(i, 50)
    {
        REP(j, 50)
        {
            g[i][j] = make_pair(false, false);
        }
    }

    int N, M;

    cin >> N >> M;

    // read graph
    REP(i, M)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        con(a, b).first = true;
    }

    int count = 0;

    // erase 1
    REP(i, 50)
    {
        REP(j, 50)
        {
            if( con(i, j).first )
            {
                con(i, j).first = false;

                bool connected = isAllConnected(g, N);
                visited_reset(g);
                count += connected ? 0 : 1;
                con(i, j).first = true;
            }
        }
    }

    cout << count / 2;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001001;
const int NMAX=8;
const int MOD=1000000007;
const int dbase=80*160;


int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll cnt=0;
	vector<ll> v(3);
	rep(i,n){
		if (s[i]=='R') v[0]++;
		if (s[i]=='G') v[1]++;
		if (s[i]=='B') v[2]++;
	}
	cnt=v[0]*v[1]*v[2];
	//cout<<v[0]<<' '<<v[1]<<' '<<v[2]<<endl;
	//int mi;
	rep(i,n-1){
		for(int j=1;i+2*j<n;j++){
		//	cout<<i<<' '<<j<<endl;
			if (s[i]!=s[i+j] and s[i]!=s[i+2*j] and s[i+j]!=s[i+2*j]) cnt--;
		}
	}
	cout<<cnt;


}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fill( x, y ) memset( x, y, sizeof x )
#define copy( x, y ) memcpy( x, y, sizeof x )
using namespace std;

typedef long long LL;
typedef pair < int, int > pa;

const int MAXN = 200020;

vector < int > G[MAXN];
int st1[MAXN], tp1, st2[MAXN], tp2, n, m;
bool vis[MAXN];

inline void dfs(int *st, int &top, int x)
{
	for( auto y : G[ x ] ) if( !vis[ y ] )
	{
		vis[ y ] = 1;
		st[ ++top ] = y;
		dfs( st, top, y );
		return ;
	}
}

int main()
{
#ifdef wxh010910
	freopen( "data.in", "r", stdin );
#endif
	scanf( "%d%d", &n, &m );
	for( int i = 1 ; i <= m ; i++ )
	{
		int x, y;
		scanf( "%d%d", &x, &y );
		G[ x ].pb( y ); G[ y ].pb( x );
	}
	st1[ ++tp1 ] = 1; vis[ 1 ] = 1;
	dfs( st1, tp1, 1 );
	dfs( st2, tp2, 1 );
	printf( "%d\n", tp1 + tp2 );
	for( int i = tp1 ; i ; i-- ) printf( "%d ", st1[ i ] );
	for( int i = 1 ; i <= tp2; i++ ) printf( "%d ", st2[ i ] );
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
 
int main() {
   string n;
   string ans= "No";
  
  cin >> n;
  for(int i = 0; i < 3;i++){
    if(n.at(i) == '7'){
      ans = "Yes";
      break;
    }
  }
  cout << ans;
      

    }
   


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int A,B;
  cin >> A >> B;
  
  if(A < 0 && B > 0){
  cout << "Zero" << endl;
  }
  
  if(A < 0 && B < 0 && (B - A) % 2 == 0){
    cout << "Negative" << endl;
  }
  
  if(A < 0 && B < 0 && (B - A) % 2 != 0){
    cout << "Positive" << endl;
  }
  
  if(A > 0 && B > 0){
    cout << "Positive" << endl;
  }  
}


Measured memory_bytes: 256
import scala.io.StdIn

/**
  * AOJ
  */
object Main {

  def main(args: Array[String]): Unit = {

    var i = 1
    while(true){
      val in = StdIn.readLine().split(" ").map(s => s.toInt)

      for(i <- in(0) to in(1)){

      }

      if(in(0) == 0 && in(1) == 0){
        return
      } else {
        val answer = in.toSeq.sorted
        println(answer.mkString(" "))}
      i += 1
    }
 }
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
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;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    int n;
    cin >> n;
    ll ans = 0;

    for(int i=1;i<=n;i++){
        if(i%3!=0&&i%5!=0){
            ans+=i;
        }
    }

    cout << ans << endl;
}

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

typedef long long int ll;
string s;

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

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

    return 0;
}

Measured memory_bytes: 3656
// no proof is included. may have unused libraries. may have unused variables. possibly dirty code - contest mode

#include <iostream> // std::cin, std::cout
#include <cstring> // std::memset()
#include <algorithm> // std::max_element(), std::min_element(), std::reverse(), std::sort(), std::__gcd()

using namespace std;

bool debug = false;

unsigned long long int fact(int n) {
    unsigned long long int res = 1;
    for (n; n > 0; n--) {
        res *= n;
        // if (debug) cout << "n:" << n << endl;
    }
    return res;
}

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

    int n;
    cin >> n;
    int p[n], q[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> q[i];
    }

    /*long long int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += (p[i] - q[i]) * fact(n - i - 1);

        // if (debug) cout << p[i] - q[i] << "*" << fact(i) << endl; // debug ro baraye chizi ke be ans ezafe mishe bayad avaz koni khob.
    }*/
    /*int ordp = 0, ordq = 0;
    for (int i = 0; i < n; i++) {
        //ordp += (p[i] - 1) * fact(n - i - 1);
        //ordq += (q[i] - 1) * fact(n - i - 1);
        ordp += (p[i] - i - 1) * fact(n - i - 1);
        ordq += (q[i] - i - 1) * fact(n - i - 1);
    }*/

    //n<= 8:|||

    int ordp = 0, ordq = 0,
        dl;
    bool markp[n + 1], markq[n + 1];
    memset(markp, false, sizeof(markp));
    memset(markq, false, sizeof(markq));
    for (int i = 0; i < n; i++) {// n - 1 ? n ? ; i++) {
        dl = 0;
        for (int j = 1; j < p[i]; j++) {
            dl += markp[j];
        }
        ordp += (p[i] - 1 - dl) * fact(n - (i + 1));
        if (debug) cout << (p[i] - 1 - dl) << "*"<< fact(n - (i + 1)) << endl;
        // oops! :|
        markp[p[i]] = true;

        dl = 0;
        for (int j = 1; j <q[i]; j++) {
            dl += markq[j];
        }
        ordq += (q[i] - 1 - dl) * fact(n - (i + 1));
        //if (debug) cout << (q[i] - 1 - dl) * fact(n - (i + 1)) << endl;
        markq[q[i]] = true;
    }
    ordp++; ordq++;

    //cout << abs(ans) << endl;
    if (debug) cout << ordp << " " << ordq << endl;
    cout << abs(ordp - ordq) << endl;

    return 0;
}


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

void GCD(int& sum,int a,int b,int c){
    int X=0;
    int i=min({a,b,c});
    for(;i>0;i--){
        if(a%i==0&&b%i==0&&c%i==0)break;
    }
    X=i;
    
    sum+=X;
}

int main(void){
    int in;
    cin >> in;
    int sum=0;
    
    for(int i=1;i<=in;i++){
        for(int j=1;j<=in;j++){
            for(int k=1;k<=in;k++){
                GCD(sum,i,j,k);
            }
        }
    }
    
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){

 ll int N,K;
 ll int kaisu;
 kaisu = 0;
 cin >> N >> K;
 vector<ll int> H;
 ll int x;

 for(int i =0; i<N;i++){
  cin >> x;
  H.push_back(x);
  kaisu += x;
 }

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

 for(int i=0;i<K && i<N;i++){
	 kaisu -= H[i];
 }
 cout << kaisu;








	return 0;

}



Measured memory_bytes: 2420
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define prints(x, y) cout<<(x)<<" "<<(y)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define r_rep(i, n) for(int i = n; i >= 0; i--)
#define ll long long int
#define pb push_back

const long long INF = 1LL << 60;

int main() {
  int N, M;
  cin >> N;
  vector<int> a(N);
  int sum = 0;
  rep(i, N){
    cin >> a[i];
    sum += a[i];
  }

  cin >> M;
  int t, x;
  rep(i, M){
    cin >> t >> x;
    print(sum-a[t-1] + x);
  }
}


Measured memory_bytes: 256
mark_list=[1,2,3,'∞']
n=int(input())
element_x=[int(i) for i in input().split()]
element_y=[int(l) for l in input().split()]
for p in mark_list:
    if p==1:
        m_distance=0
        for o in range(n):
            x=element_x[o]
            y=element_y[o]
            m_distance+=abs(x-y)
        print(m_distance)
    if p==2:
        y_distance=0
        y_distance2=0
        for m in range(n):
            x=element_x[m]
            y=element_y[m]
            y_distance2+=pow(abs(x-y),2)
        y_distance=pow(y_distance2,0.5)
        print(y_distance)
    if p==3:
        third_distance=0
        third_distance2=0
        for q in range(n):
            x=element_x[q]
            y=element_y[q]
            third_distance2+=pow(abs(x-y),3)
        third_distance=pow(third_distance2,1/3)
        print(third_distance)
    if p=='∞':
        c_distance=0
        difference=0
        for r in range(n):
            x=element_x[r]
            y=element_y[r]
            difference=abs(x-y)
            if difference>c_distance:
                c_distance=difference
        print(c_distance)


Measured memory_bytes: 5664
#include <iostream>
#include <queue>
#include <climits>
#include <set>

using namespace std;

typedef long long ll;

int main() {
    ll n, m, s;
    pair<ll, ll> node[51][51];
    ll min_length[51][51];
    pair<ll, ll> city[51];
    cin >> n >> m >> s;
    pair<ll, ll> zero = make_pair(0, 0);
    for (ll i=1; i<=n; i++) {
        for (ll j=1; j<=n; j++) {
            node[i][j] = zero;
        }
    }
    for (ll i=0; i<m; i++) {
        ll u, v, a, b;
        cin >> u >> v >> a >> b;
        // (ginka, minute)
        node[u][v] = make_pair(a, b);
        node[v][u] = make_pair(a, b);
    }
    for (int i=1; i<=n; i++) {
        ll c, d;
        cin >> c >> d;
        city[i] = make_pair(c, d);
    }
    for (ll i=1; i<=n; i++) {
        for (ll j=1; j<=n; j++) {
            if (node[i][j] != zero) {
                min_length[i][j] = node[i][j].second;
            } else if (i == j) {
                min_length[i][j] = 0;
            } else {
                min_length[i][j] = INT32_MAX;
            }
        }
    }
    for (int k=1; k<=n; k++) {
        for (int i=1; i<=n; i++) {
            for (int j=1; j<=n; j++) {
                if (min_length[i][j] > min_length[i][k] + min_length[k][j]) {
                    min_length[i][j] = min_length[i][k] + min_length[k][j];
                }
            }
        }
    }
    for (int i=2; i<=n; i++) {
        priority_queue<pair<ll, pair<ll, ll>>, vector<pair<ll, pair<ll, ll>>>, greater<>> q;
        set<pair<ll, ll>> ss;
        // (kitaiti, ginka, position)
        q.push(make_pair(min_length[1][i], make_pair(s, 1)));
        while ( !q.empty() ) {
            auto current = q.top();
            q.pop();
            ll possession = current.second.first;
            ll position = current.second.second;
            ll expected_time = current.first - min_length[position][i];
            if (ss.find(current.second) != ss.end()) {
                continue;
            }
            ss.insert(current.second);
            if (position == i) {
                cout << expected_time << endl;
                break;
            }
            for (int j=1; j<=n; j++) {
                if (node[position][j] != zero && possession >= node[position][j].first) {
                    auto state = make_pair(possession - node[position][j].first, j);
                    if (ss.find(state) == ss.end()) {
                        auto pp = make_pair(expected_time + node[position][j].second + min_length[j][i], state);
                        q.push(pp);
                    }
                }
            }
            auto state = make_pair(possession + city[position].first, position);
            if (ss.find(state) == ss.end()) {
                auto pp = make_pair(expected_time + city[position].second + min_length[position][i], state);
                q.push(pp);
            }

        }
    }
}


Measured memory_bytes: 7568
#include <stdio.h>

int main(void) {
    int H, W;

    while (1) {
        scanf("%d %d", &H, &W);

        if (H == 0 && W == 0) break;

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                printf("#");
                if (j == W - 1) printf("\n");
            }
        }
        printf("\n");
    }
    
    return 0;
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()


void solve(){
 ll h,w,m;
  cin >> h >> w >> m;
  vp p(m);
  vll x(h,0),y(w,0);
  rep(i,0,m){
    ll a,b;
    cin >>a >> b;
    --a;
    --b;
    x[a]++;
    y[b]++;
    p[i]=P(a,b);
  }
    
  ll mx=*max_element(all(x));
  ll my=*max_element(all(y));
  rep(i,0,h) x[i]=(x[i]==mx?1:0);
  rep(i,0,w) y[i]=(y[i]==my?1:0);
 
  ll ans=mx+my;
 
  ll num=sum(x)*sum(y);
  rep(i,0,m) if(x[p[i].fi]&&y[p[i].se]) num--;
    
  if(num==0) ans--;
 
  cout << ans << endl;
   
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

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

int main() {
	long long a,b,x;
	cin >> a>> b>>x;
	
	if(a==0){
		b/=x;
		cout << b+1 << endl;
		return 0;
	}
	long long left,right;
	
	left=(a-1)/x+1;
	right=b/x;
	

	if(right<left){
		cout << 0 << endl;
	}else{
		cout << right - left +1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

#define fs first
#define sc second

int main(void){
	int N;
	int A[114514];
	cin >> N;
	REP(i, N)
		cin >> A[i];
	A[N] = 0;
	ll res = 0;
	REP(i, N){
		res += A[i]/2;
		A[i] %= 2;
		if(A[i] && A[i+1]){
			A[i+1]--;
			A[i]--;
			res++;
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 640
#include <stdio.h>
#define N 101

int a[N];
int count=0;

void swap(int *x,int *y){
  int t=*x;
  *x=*y;
  *y=t;
}

void selectionsort(int n){
  int i,j;
  for(i=0;i<n-1;i++){ // ??????????????¨???????????????????´???????
    int minj=i;
    for(j=i+1;j<n;j++){
      if(a[j]<a[minj]) minj=j;
    }
    if(i!=minj){
    swap(&a[i],&a[minj]);
    count++;
    }
  }
}

int main()
{
  int n;
  scanf("%d",&n);
  int i;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  
  selectionsort(n);
  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i<n-1) printf(" ");
  }
  printf("\n%d\n",count);
  
  return 0;
}

Measured memory_bytes: 604
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	string s;
	cin >> s;
	if(s[0] != 'A' || isupper(s[1]) || isupper(s[s.size() - 1])) return cout << "WA\n", 0;
	bool alreadyFound = false;
	for(int i = 2; i < s.size() - 1; ++i)
	{
		if(isupper(s[i]))
		{
			if(alreadyFound || s[i] != 'C') return cout << "WA\n", 0;
			alreadyFound = true;
		}
	}
	cout << (alreadyFound ? "AC" : "WA") << '\n';
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n+1,0);

  for(int x = 1; x <= n; ++x) {
    for(int y = 1; y <= n; ++y) {
      for(int z = 1; z <= n; ++z) {
        if(x * x + y * y + z * z + x * y + y * z + z * x <= n) {
          a[x * x + y * y + z * z + x * y + y * z + z * x]++;
        } else {
          break;
        }
      }
    }
  }

  for(int i = 1; i <= n; i++) cout << a[i] << endl;

  return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

const ll mod = 1000000007;

ll n;
ll d[1000010], cum[1000010];
ll ans;

signed main() {
	cin >> n;
	d[1] = 1;
	cum[1] = 1;
	ans = (n - 1)*(n - 1) % mod;
	for (int i = 2; i <= n; i++) {
		d[i] = (cum[i - 1] - d[i - 2] + mod) % mod;
		cum[i] = (cum[i - 1] + d[i]) % mod;
		if (i == n)break;
		ans = (ans + d[i] * (n - 1) % mod*(n - 1) % mod) % mod;
		ans = (ans + d[i] * min(n - 1, i + 1LL) % mod) % mod;
	}
	ans = (ans + d[n] * n) % mod;
	if (n == 2)ans++;
	else if (3 <= n)ans = (ans + 2) % mod;
	cout << ans << endl;
}

Measured memory_bytes: 15872
UP = int(1e9)
s = set()


def dfs(n, f3, f5, f7):
    if n > UP:
        return
    if f3 and f5 and f7:
        s.add(n)
    dfs(n * 10 + 3, True, f5, f7)
    dfs(n * 10 + 5, f3, True, f7)
    dfs(n * 10 + 7, f3, f5, True)


dfs(0, False, False, False)
l = list(s)
l.sort()
n = int(input())
ans = 0
for i in l:
    if i <= n:
        ans += 1
    else:
        break
print(ans)


Measured memory_bytes: 6384
#include <iostream>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
int main(void) {
  int n;
  cin >> n;
  vector<int> cnt(n, 0);
  ll ans = 1LL;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    cnt[a]++;
  }
  if (n % 2 == 0) {
    for (int i = 1; i < n; i += 2) {
      if (cnt[i] == 2) {
        ans = ans * 2 % MOD;
      } else {
        ans = 0;
      }
    }
  } else {
    if (cnt[0] != 1) {
      ans = 0;
    }
    for (int i = 2; i < n; i += 2) {
      if (cnt[i] == 2) {
        ans = ans * 2 % MOD;
      } else {
        ans = 0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-22 22:15:34
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int n, m; cin >> n >> m;
  cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		if (N < 2) {
			System.out.println(0);
			in.close();
			return;
		}
		int[] a = new int[N];
		for (int i = 0; i < N; i++) {
			a[i] = in.nextInt();
		}
		Arrays.sort(a);
		int ans = Integer.MAX_VALUE;
		for (int i = a[0]; i <= a[a.length - 1]; i++) {
			int count = 0;
			for (int j = 0; j < a.length; j++) {
				count += (a[j] - i) * (a[j] - i);
			}
			ans = Math.min(ans, count);
		}
		System.out.println(ans);
		in.close();
	}
}

Measured memory_bytes: 22100
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <iostream>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("%s = %d\n", #x, x)
#define debug2(x, y) printf("%s = %d, %s = %d\n", #x, x, #y, y)
#define debug3(x, y, z) printf("%s = %d, %s = %d, %s = %d\n", #x, x, #y, y, #z, z)
#define debug4(x, y, z, t) printf("%s = %d, %s = %d, %s = %d, %s = %d\n", #x, x, #y, y, #z, z, #t, t)
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

ll l, r, a, b, best = LINF;

int main() {
    scanf("%lld%lld", &l, &r);

    if (r - l + 1 >= 2019) {
        a = 0;
        b = 2018;
    } else if (l % 2019 < r % 2019) {
        a = l % 2019;
        b = r % 2019;
    } else {
        a = r % 2019;
        b = 2018;
    }

    for (int i = a; i < b; i++) {
        for (int j = i + 1; j <= b; j++) {
            best = min(best, (i * j) % 2019ll);
        }
    }

    printf("%lld\n", best);

    return 0;
}

Measured memory_bytes: 256
from sys import stdin

def main():
	N,M = [int(x) for x in stdin.readline().strip().split()]
	cantidad = [ 1 for x in range(N)]
	tenencia = [ 0 for x in range(N)]
	tenencia[0] = 1
	for i in range(M):
		x,y = [int(x) for x in stdin.readline().strip().split()]
		cantidad[y-1]+=1
		cantidad[x-1]-=1
		if tenencia[x-1] == 1:
			tenencia[y-1] = 1
		if cantidad[x-1] == 0:
			tenencia[x-1] = 0
	ans,i = 0,0
	while i < N:
		if cantidad[i] >= 1 and tenencia[i] == 1:
			ans+=1
		i+=1
	print(ans)
main()

Measured memory_bytes: 4784
unittest
{
	assert( [ "5 2 4" ].parse.expand.solve == "5\n4\n1\n0" );
	assert( [ "3 1 3" ].parse.expand.solve == "3\n0" );
	assert( [ "7 3 7" ].parse.expand.solve == "7\n8\n4\n2\n0\n0" );
	assert( [ "10 4 8" ].parse.expand.solve == "10\n12\n10\n8\n4\n1\n0\n0\n0" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nxy = input.front.split.to!( long[] );
	nxy[ 1 .. $ ] -= 1;
	return tuple( nxy[ 0 ], nxy[ 1 ], nxy[ 2 ] );
}

auto solve( long n, long x, long y )
{
	auto nss = new long[][ n ];
	foreach( i; 1L .. nss.length.signed )
	{
		nss[ i - 1 ] ~= i;
		nss[ i ] ~= i - 1;
	}
	nss[ x ] ~= y;
	nss[ y ] ~= x;
	
	auto anss = new long[ n - 1 ];
	foreach( i; 0L .. n )
	{
		auto ds = bfs( nss, i );
		foreach( d; ds[ i + 1 .. $ ] )
		{
			anss[ d - 1 ]++;
		}
	}
	return anss.to!( string[] ).join( "\n" );
}

// グラフの始点指定最短経路探索（幅優先探索）
auto bfs( long[][] nss, long s )
{
	import std.container.dlist;
	
	auto ds = new long[ nss.length ];
	ds[] = long.max;
	ds[ s ] = 0;
	
	auto queue = make!DList( s );
	while( !queue.empty )
	{
		auto f = queue.front;
		queue.removeFront();
		
		foreach( t; nss[ f ] )
		{
			if( ds[ t ] < long.max ) continue;
			
			ds[ t ] = ds[ f ] + 1;
			queue.insertBack( t );
		}
	}
	return ds;
}


Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	string s;
	cin>>s;
	if(s.at(0) == s.at(1) || s.at(1) == s.at(2)|| s.at(2) == s.at(3))
	{ cout<<"Bad"<<"\n"; }
	else	{ cout<<"Good"<<"\n"; }

	return 0;
}

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

lint n;
vector<lint> a, b, c;

int main() {
    cin >> n;
    a.resize(n);  for(auto& e : a)  cin >> e, e--;;
    b.resize(n);  for(auto& e : b)  cin >> e;;
    c.resize(n-1);  for(auto& e : c)  cin >> e;

    lint res = 0;
    lint prev = -100;
    for(auto& e : a) {
        res += b[e];
        if(prev + 1 == e)  res += c[prev];
        prev = e;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long ll;
const int N=2e5+10;
const int mo=1e9+7;
int n,c[N],nex[N],loc[N];
ll ksm(ll x,ll y){
	ll ret=1;for(;y;y>>=1){
		if(y&1)ret=ret*x%mo;
		x=x*x%mo;
	}
	return ret;
}
ll f[N];
int main(){ 
	cin>>n;for(int i=1;i<=n;i++)scanf("%d",&c[i]);
	for(int i=n;i;i--){
		nex[i]=loc[c[i]];
		loc[c[i]]=i;
	}
	f[1]=1;
	for(int i=1;i<n;i++){
		if(nex[i]!=i+1){
			f[nex[i]]=(f[nex[i]]+f[i])%mo;
		}
		f[i+1]=(f[i+1]+f[i])%mo;
	}
	cout<<f[n]<<endl;
}

Measured memory_bytes: 4096
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int p = in.nextInt();
            boolean haveOdd = false;
            for (int i = 0; i < n; ++i) {
                if (in.nextInt() % 2 != 0) haveOdd = true;
            }
            if (haveOdd) {
                out.println(1L << (n - 1));
            } else if (p == 0) {
                out.println(1L << n);
            } else {
                out.println(0);
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 21460
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] n = sc.next().split("",0);
        int judge = Integer.parseInt(n[n.length-1]);
        String ans = "";
        if(judge == 3){
            ans = "bon";
        }else if(judge == 0 || judge == 1 || judge == 6 || judge == 8){
            ans = "pon";
        }else{
            ans = "hon";
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35604
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

static void exec()
{
	int N;
	get(N);

	std::vector<std::pair<LLONG, LLONG>> plate(N);
	for (int i = 0; i < N; i++) {
		get(plate[i].first, plate[i].second);
	}

	auto psum = [](const std::pair<LLONG, LLONG>& a, const std::pair<LLONG, LLONG>& b) {
		return (a.first + a.second) > (b.first + b.second);
	};
	std::sort(plate.begin(), plate.end(), psum);

	LLONG tak = 0, aok = 0;
	for (int i = 0; i < N; i++) {
		if (i % 2) {
			aok += plate[i].second;
		}
		else {
			tak += plate[i].first;
		}
	}
	printf("%lld\n", tak - aok);
}


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

typedef long long LL;
typedef pair<int, int> II;

const int N = (int) 2e2 + 10;
int n, a[N];

int main() {
    #ifdef LOCAL
        freopen("Data.inp", "r", stdin);
        freopen("Data.out", "w", stdout);
    #endif

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

    int ans = 0; sort(a + 1, a + 1 + n);
    for (int i = 1; i <= n; i += 2) ans += a[i];
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
n, *a = map(int, open(0).read().split())
if a[0]!=0:
    print(0)
    exit()

b = [0]*n
for i in a: b[i]+=1

if b[0]!=1:
    print(0)
    exit()

ans = 1
i = 0
while i<n-1:
    if b[i]==0:
        if sum(b[i:])>0:
            print(0)
            exit()
        else:
            break
    ans *= b[i]**b[i+1]
    i += 1

print(ans%998244353)

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

using ll = long long;

#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define len(x) int((x).size())

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

	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	int n,k;
	cin>>n>>k;

	vector<int> A;

	for(int i=0; i<n; i++)
	{
		int a;
		cin>>a;
		A.push_back(a);
	}

	while(k--)
	{
		vector<int> new_A(n);
		priority_queue<int> PQ;
		int cur=0;

		for(int i=0; i<n; i++)
		{
			cur++;
			PQ.push(-i-A[i]);

			while(!PQ.empty() && -PQ.top()<i)
			{
				cur--;
				PQ.pop();
			}

			new_A[i]+=cur;
			//cout << i << " " << cur << endl;
		}

		while(!PQ.empty()) PQ.pop();
		cur=0;
		bool fin=1;

		//cout << endl;

		for(int i=n-1; i>=0; i--)
		{
			cur++;
			PQ.push(i-A[i]);

			while(!PQ.empty() && i<PQ.top())
			{
				cur--;
				PQ.pop();
			}

			new_A[i]+=cur-1;
			if(new_A[i]!=n) fin=0;
		
			//cout << i << " " << cur << endl;
		}

		//cout << endl;

		A=new_A;
		if(fin) break;
	}

	for(auto a:A) cout << a << " ";
	cout << "\n";
}

Measured memory_bytes: 6580
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if((a == b && a == c) || (a != b && a != c && b != c)) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
S=gets.chomp
s_arr=S.split("")
odd = s_arr.each_slice(2).map(&:first)
isOdd=1
odd.each do |ch|
  if(ch!="R"&&ch!="U"&&ch!="D") then
    isOdd=0
    break
  end
end
even = s_arr.each_slice(2).map(&:last)
isEven=1

for i in 0..(even.length-1) do
  if(even[i]!="L"&&even[i]!="U"&&even[i]!="D") then
    if(i!=even.length-1) then
      isEven=0
      break
    end
  end
end
if(isOdd==1&&isEven==1) then
  puts("Yes")
else
  puts("No")
end

Measured memory_bytes: 1788
def ketanowa(p):
    ans = 0
    p = str(p)
    for i in p:
        ans += int(i)
    return ans


def main():
    temp1 = input()
    temp1=temp1.split(" ")
    n1 = int(temp1[0])
    n2 = int(temp1[1])
    if n1 <= 8 and n2 <= 8:
        print("Yay!")
    else:
        print(":(")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<cstdio>
#include<queue>

#define gec     getchar
#define FILE(F) freopen(F".in","r",stdin),freopen(F".out","w",stdout)
#define DEBUG   fprintf(stderr,"Passing [%s] in Line (%d)\n",__FUNCTION__,__LINE__)

typedef long long ll;
template<typename T>
inline void read(T &x)
{
	x=0;bool f=0; char c=gec();
	for(;c<'0'||c>'9';c=gec())f=(c=='-');
	for(;c>='0'&&c<='9';c=gec())x=x*10+c-'0';
	x=f?-x:x;
}

const int MAXN(200010);
std::deque<int>que;
int n,a[MAXN],Now,_n;
int main()
{
	read(n);
	for(int i=1;i<=n;i++)read(a[i]);
	Now=0;
	for(int i=1;i<=n;i++)
	{	
		Now^=1;
		if(Now)que.push_back(a[i]);
		else  que.push_front(a[i]);
	}
	while(!que.empty())a[++_n]=que.front(),que.pop_front();
	if(!Now)for(int i=1;i<=n;i++)printf("%d ",a[i]);
	else for(int i=1;i<=n;i++)printf("%d ",a[n-i+1]);
	printf("\n");
	return 0;
}	

Measured memory_bytes: 3712
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    char c;
    char[] ap = new char[] {'A','B','C','D','E','F','G','H','I','J','K',
                              'L','M','N','O','P','Q','R','S','T','U',
                              'V','W','X','Y','Z'};
    int[] count = new int[26];
    while(sc.hasNextLine()){
      String s = sc.nextLine();
      for(int i= 0;i < s.length();i++){
        c = s.charAt(i);
        if(c >= 'A' && c <= 'Z'){
          count[c-'A']++;
        }else if(c >= 'a' && c <= 'z'){
          count[c-'a']++;
        }
      }
    }
    for(int i = 0;i < 26;i++){
      ap[i] += 'a' - 'A';
      System.out.println(ap[i] + " : " + count[i]);
    }
    sc.close();
  }
}



Measured memory_bytes: 26080
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
const int N = 2e5 + 5;
LL a[N], sum[N], f[N];
int main(){
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++ i){
        cin >> a[i];
        sum[i] = (i > 1 ? sum[i - 2] : 0) + a[i];
    }
    for (int i = 2; i <= n; ++ i){
        if (i & 1) f[i] = max(f[i - 2] + a[i], f[i - 1]);
        else f[i] = max(f[i - 2] + a[i], sum[i - 1]);
    }
    cout << f[n] << endl;
    return 0;
}


Measured memory_bytes: 8264
//集計処理・バケット法

#define MAX 50
#include<iostream>

using namespace std;

int main()
{
    int N,M;
    int  city[MAX];

    cin>>N>>M;
    for(int i=0;i<N;++i)
    {
        city[i]=0;
    }

    int a,b;
    for(int i=0;i<M;i++)
    {
        scanf("%d %d",&a,&b);
        city[a-1]++;
        city[b-1]++;
    }

    for(int i=0;i<N;i++)
    {
        printf("%d \n",city[i]);
    }
    return 0;

}

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

int main() {
  int N, K; cin >> N >> K;

  int Ans = 0;
  while ( N>0 ) {
    N /= K;
    Ans++;
  }
  cout << Ans << endl;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include<iomanip>

using namespace std;

const int N = 1e5 + 5;
vector<int> graph[N];
bool mark[N];
bool dp[N][2];
int deg[N];
int n;

void dfs(int v, int par)
{
	mark[v] = true;
	for (int i = 0; i < graph[v].size(); i++)
	{
		int u = graph[v][i];
		if (!mark[u])
		{
			dfs(u, v);
		}
	}
	if (deg[v] == 1)
	{
		dp[v][0] = true;
		dp[v][1] = false;
		return;
	}
	dp[v][0] = true;
	vector<int> vec;
	for (int i = 0; i < graph[v].size(); i++)
	{	
		int u = graph[v][i];
		if (u != par)
		{
			dp[v][0] = dp[v][0] & dp[u][1];
		}
		if (dp[u][1] == false && u != par)
		{
			vec.push_back(u);
		}
	}
	if (vec.size() > 1)
	{
		dp[v][1] = false;
		return;
	}
	if (vec.size() == 1)
	{
		if (dp[vec[0]][0])
		{
			dp[v][1] = true;
		}
		else
		{
			dp[v][1] = false;
		}
		return;
	}
	dp[v][1] = false;
	if (!vec.size())
	{
		for (int i = 0; i < graph[v].size(); i++)
		{
			int u = graph[v][i];
			if (dp[u][0])
			{
				dp[v][1] = true;
			}
		}
	}
}

int main()
{
	cin >> n;
	for (int i = 0; i < n - 1; i++)
	{
		int u, v;
		cin >> u >> v;
		graph[u - 1].push_back(v - 1);
		graph[v - 1].push_back(u - 1);
		deg[u - 1]++;
		deg[v - 1]++;
	}
	int root = 0;
	for (int i = 0; i < n; i++)
	{
		if (deg[i] > 1)
		{
			root = i;
		}
	}
	dfs(root, -1);
	/*
	for (int i = 0; i < n; i++)
	{
		cout << dp[i][0] << " " << dp[i][1] << endl;
	}
	*/
	if (n == 2)
	{
		cout << "Second";
		exit(0);
	}
	if (dp[root][1])
	{
		cout << "Second";
	}
	else
	{
		cout << "First";
	}
}


 

Measured memory_bytes: 6528
function main(input) {
  const A = input.split(" ").map(i => parseInt(i))[0];
  const B = input.split(" ").map(i => parseInt(i))[1];
  var max = 0;
  if (max < A + A - 1) {
    max = A + A - 1;
  }
  if (max < A + B) {
    max = A + B;
  }
  if (max < B + B - 1) {
    max = B + B - 1;
  }
  console.log(max);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372