akhauriyash/Code-Regression huggingface dataset:
from collections import Counter
H,W = map(int,input().split())
src = [input() for i in range(H)]
counter = Counter()
for row in src:
    counter.update(row)

def solve():
    if H%2 == 0 and W%2 == 0:
        for n in counter.values():
            if n%4 != 0: return False
        return True
    elif H%2 == 1 and W%2 == 1:
        odd = pairs = 0
        for n in counter.values():
            if n%4 == 0: continue
            if n%2 == 1:
                if odd > 0: return False
                odd = 1
                if (n-1)%4 == 0: continue
            pairs += 2
            if pairs > H+W-1: return False
        return True
    else:
        even = (H if H%2 == 0 else W)
        pairs = 0
        for n in counter.values():
            if n%4 == 0: continue
            if n%2 == 1: return False
            pairs += 2
            if pairs > even: return False
        return True

print('Yes' if solve() else 'No')


Measured memory_bytes: 3444
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

const int SIZE=18;

const ll MOD=1e9+7;

void add(ll &lhs,ll rhs){
    lhs=(lhs+rhs)%MOD;
}
int main(){
    int n;
    cin>>n;
    int xyz[3];
    for(int i=0;i<3;i++) cin>>xyz[i];

    vector<vector<ll>> dp(n+1,vector<ll>(1<<SIZE));
    dp[0][(1<<SIZE)-1]=1;

    vector<int> isAccept(1<<SIZE);

    for(int bit=0;bit<(1<<SIZE);bit++){
        int st=0;
        int buf=0;
        for(int i=0;i<SIZE;i++){
            buf++;
            if(!((bit>>i)&1) && xyz[st]==buf){
                st++;
                buf=0;
                if(st==3){
                    isAccept[bit]=true;
                    break;
                }
            }
        }
    }

    vector<ll> pow10(n);
    pow10[0]=1;
    for(int i=0;i+1<n;i++) pow10[i+1]=pow10[i]*10%MOD;

    ll res=0;
    int mask=(1<<SIZE)-1;
    for(int i=0;i<n;i++){
        for(int bit=0;bit<(1<<SIZE);bit++){
            for(int v=1;v<=10;v++){
                int nex=(bit<<v)+(1<<(v-1))-1;
                nex&=mask;
                add(dp[i+1][nex],dp[i][bit]);
            }
        }
        for(int bit=0;bit<(1<<SIZE);bit++){
            if(isAccept[bit]){
                ll r=pow10[n-1-i];
                res+=r*dp[i+1][bit];
                res%=MOD;   
                dp[i+1][bit]=0;
            }
        }
    }

    cout<<res<<endl;
    
    
    return 0;
}


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

int main(){
	int i,j,n,l;
	string st;
	vector<string>a;
	cin>>n>>l;
	for(i=0;i<n;i++){
		cin>>st;
		a.push_back(st);
	}
	sort(a.begin(),a.end());
//	for(i=0;i<a.size()-1;i++){
//		for(j=i+1;j<a.size();j++){
//			if(a[i]+a[j]>a[j]+a[i])swap(a[i],a[j]);
//		}
//	}
	for(i=0;i<a.size();i++)cout<<a[i];
	return 0;
}

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

int main(){
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    double dist = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
    cout << fixed << setprecision(15);
    cout << dist << endl;
    return 0;
}


Measured memory_bytes: 3268
#pragma GCC optimize(2)
#pragma GCC optimize(3)   
#include<bits/stdc++.h>
#include<cstdlib>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds; 
//#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
typedef vector < ll > vl;
typedef vector < vl > vvl;
typedef pair < ll, ll > pll;
typedef long double ld;
typedef vector < pair < ll, ll > > vpll;
#define Boost() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define forn(i,n) for (ll i = 0; i < n; i++)
#define fo(i,n) for (ll i = 1; i <= n; i++)
#define fore(i,l,r) for (ll i = l; i <= r; i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define all(c) c.begin(), c.end()
#define go(c,it) for(auto it=(c).begin(); it!=(c).end(); it++)
//#define back(c,it) for(auto it=(c).rbegin(); it!=(c).rend(); it++)
#define fi first
#define se second
#define MOD 998244353
#define MAX 1000000007
#define N 2000009
#define N1 100007
ll power(ll a,ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;}a=(a*a)%MOD;b>>=1;}return res;}
ll fact[500009];
ll fermat_inv(ll y){return power(y,MOD-2);}
ll nCrMod(ll n, ll r){ ll p=fact[n];ll q=(fact[r]*fact[n-r])%MOD;return (p*fermat_inv(q))%MOD;} 
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
const ld PI = acos(-1.0);
vl g[N1];

  int main(){
      #ifndef ONLINE_JUDGE
      freopen("input.cpp","r",stdin);
      freopen("output.cpp","w",stdout);
      #endif
      Boost();
      int t;
      //cin>>t;
      t=1;
      int t1=t;
      while(t--)
      {
        ll n;
        cin>>n;
        ll dp[2*n+1];
        ll i,j,k;
        memset(dp,0,sizeof(dp));
          for(j=1;j*j<=n;j++)
          {
            ll x=n-j*j;
            for(k=1;k*k<=x;k++)
            {
              ll y=n-k*k-j*k;
              for(ll l=1;l*l<=y;l++)
              {
                ll w=j*j+k*k+l*l+j*k+k*l+j*l;
                if(w<=n)
                  dp[w]++;
              }
            }

          }
          fo(i,n)
          cout<<dp[i]<<endl;
        
      }
      
      return 0;
  }

Measured memory_bytes: 6080
//
//  main.cpp
//  minor changes
//
//  Created by Bryan on 27/06/20.
//  Copyright © 2020 mac. All rights reserved.
//

#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
    string s,t;
    cin>>s;
    cin>>t;
    int len = s.length();
    int count = 0;
    for (int f = 0; f<len;f++)
    {
        if (s[f]!=t[f])
            count++;
        
    }
    printf ("%d\n", count);
}


Measured memory_bytes: 3824
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        init();

        int N = nextInt();

        int[] a = new int[N], b = new int[N], c = new int[N];

        for (int i = 0; i < N; i++) {
            a[i] = nextInt();
            b[i] = nextInt();
            c[i] = nextInt();
        }

        int[] chooseA = new int[N];
        int[] chooseB = new int[N];
        int[] chooseC = new int[N];

        for (int i = N - 1; i >= 0; i--) {
            if (i == N - 1) {
                chooseA[i] = a[i];
                chooseB[i] = b[i];
                chooseC[i] = c[i];
            } else {
                chooseA[i] = a[i] + Math.max(chooseB[i + 1], chooseC[i + 1]);
                chooseB[i] = b[i] + Math.max(chooseA[i + 1], chooseC[i + 1]);
                chooseC[i] = c[i] + Math.max(chooseA[i + 1], chooseB[i + 1]);
            }
        }

        System.out.println(Math.max(chooseA[0], Math.max(chooseB[0], chooseC[0])));
    }

    //Input Reader
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    private static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
}

Measured memory_bytes: 43568
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
int main(){
    int a, b;
    cin >> a >> b;
    if(a >= 10){
        cout << b << endl;
    }   
    else{
        cout << b + (100 * (10 - a)) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define     PI                       acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void GO(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
const int N=80+5;
int a[N],n;
int main(){
    GO();
    int T;
   // cin>>T;
    T=1;
    while(T--){

        cin>>n;
        for(int i=0;i<n;i++) cin>>a[i];
        ll bal=1000,cnt=0;
        for(int i=0;i<n;i++){

            if(i+1<n&&a[i+1]>=a[i]){
                cnt+= bal/a[i];
                bal%=a[i];
                bal+= cnt*a[i+1];
                cnt=0;
            }
            else{

                ;

            }

        }
        cout<<bal<<"\n";
    }
}





































































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

int main(){
    long long a, b, c, d;

    cin >> a >> b >> c >> d;

    long long ans = -1000000000000000000;

    long long cnt[4] = {a*c, a*d, b*c, b*d};

    for(long long i = 0; i < 4; i++)
        ans = max(ans, cnt[i]);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#pragma GCC optimize("Ofast","unroll-loops")
#pragma GCC push_options
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
// #include <xmmintrin.h>
// #include <immintrin.h>
using namespace::std;
__attribute__((constructor))void init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// typedef mp::number<mp::cpp_dec_float<0>> cdouble;
// typedef mp::cpp_int cint;
template<typename T>using pbds=__gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T>using pbds_map=__gnu_pbds::tree<T,T,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T,typename E>using hash_map=__gnu_pbds::gp_hash_table<T,E>;
template<typename T>using pqueue =__gnu_pbds::priority_queue<T, less<T>,__gnu_pbds::rc_binomial_heap_tag>;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define MOD 1000000007LL
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
template<typename T>inline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i<INF/2?i:"INF";f=1;}cout<<endl;}
template<typename T>inline void numout2(T t){for(auto i:t)numout(i);}
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void _output(T t){bool f=0;for(lint i=0;i<t.size();i++){cout<<f?"":" "<<t[i];f=1;}cout<<endl;}
template<typename T>inline void _output2(T t){for(lint i=0;i<t.size();i++)output(t[i]);}
#define rep(i,n) for(lint i=0;i<lint(n);++i)
#define repi(i,a,b) for(lint i=lint(a);i<(lint)(b);++i)
#define rrep(i,n) for(lint i=lint(n)-1;i>=0;--i)
#define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)
#define irep(i) for(lint i=0;;++i)
#define all(n) begin(n),end(n)
#define dist(a,b,c,d) sqrt(pow(a-c,2)+pow(b-d,2))
inline lint gcd(lint A,lint B){return B?gcd(B,A%B):A;}
inline lint lcm(lint A,lint B){return A/gcd(A,B)*B;}
// inline cint cgcd(cint A,cint B){return B?cgcd(B,A%B):A;}
// inline cint clcm(cint A,cint B){return A/cgcd(A,B)*B;}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
const vector<lint> dx={1,0,-1,0,1,1,-1,-1};
const vector<lint> dy={0,1,0,-1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
auto call=[&](auto f,auto... args){return f(f,args...);};

int main(){
    lint h,n;
    cin>>h>>n;
    cout<<(lint)ceil(h*1./n)<<endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
ans=[0]*n
pen=[0]*n
res_pen=0
for i in range(m):
  p,s=list(input().split())
  if ans[int(p)-1]!=1:
    if s=="AC":
      ans[int(p)-1]=1
      res_pen+=pen[int(p)-1]
    else:
      pen[int(p)-1]+=1
print(str(sum(ans))+" "+str(res_pen))

Measured memory_bytes: 4596
input()
A=map(int,raw_input().split())
def f():
 s=[(0,-1)];p=A*2
 for i,a in enumerate(A):
  while a<s[-1][0]:s.pop()
  p[a]=i-s[-1][1];s+=[(a,i)]
 return p
l=f()
A.reverse()
r=f()
print sum(a*l[a]*r[a]for a in A)

Measured memory_bytes: 40596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}
int main() {
    ll N, M;string s, t;bool ok = true;
    cin >> N >> M >> s >> t;
    ll g = gcd(M, N),res = N / g * M;N /= g, M /= g;
    for (ll i = 0; i < g; ++i) {
        if (s[i * N] != t[i * M]) ok = false;
    }
    if (ok) cout << res << endl;
    else cout << -1 << endl;
}

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

int main(){
  double l;
  cin >> l;
  l = pow(l,3);
  printf("%.10f\n",l/27);
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
s = input()
l = len(s)-1
ans = 0
ops = []

# +あり/なしのbit全探索(桁数-1の2乗の範囲)
for i in range(1 << l):
    op = [''] * l
    for j in range(l):
        if ((i >> j) & 1) == 1:
            op[l-1-j] = '+'
    ops.append(op)

for op in ops:
    num = [digit for digit in s]
    for k in range(len(op)):
        # 演算子は奇数番目
        num.insert(2*k+1, op[k])
    ans += eval(''.join(num))

print(ans)


Measured memory_bytes: 3064
def solve(s):
    dp = [0] * 2019
    dp[0] = 1
    r = 0
    for i in range(1, len(s) + 1):
        r += int(s[-i]) * pow(10, i - 1, 2019)
        r %= 2019
        dp[r] += 1
    res = 0
    for r in range(2019):
        res += dp[r] * (dp[r] - 1) // 2
    return res


def main():
    s = input()
    res = solve(s)
    print(res)


def test():
    assert solve("1817181712114") == 3
    assert solve("14282668646") == 2
    assert solve("2119") == 0


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 9432
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

bool flag[1000001];

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

    int s;
    cin >> s;
    
    ll a = s;
    flag[s] = true;
    for(int i = 0; i < 1000001; i++){
        if(a%2 == 0){
            a = a / 2;
        }else{
            a = 3*a + 1;
        }
        if(flag[a] == false) flag[a] = true;
        else{
            cout << i+2 << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
using ll = long long int;

const ll MOD = 1e9 + 7;

ll pow_fast(ll n, ll k) {
  if (k == 0) {
    return 1LL;
  }
  if (k == 1) {
    return n;
  }

  if (k % 2 == 0) {
    ll tmp = pow_fast(n, k / 2);
    return tmp * tmp % MOD;
  } else {
    ll tmp = pow_fast(n, (k - 1) / 2);
    tmp *= tmp;
    tmp %= MOD;
    return tmp * n % MOD;
  }
}

template<typename T>
class stack
{
private:
vector<T> _vec;
public:
  stack () {
  };

  void push(T n) {
    _vec.push_back(n);
    return;
  }

  void pop() {
    if (this->empty()) {
      return;
    }
    _vec.erase(_vec.end() - 1);
    _vec.shrink_to_fit();
    return;
  }

  size_t size() {
   return _vec.size(); 
  }

  T top() {
    return _vec[this->size() - 1];
  }
  bool empty() {
    return _vec.empty();
  }
};


int main() {

  ll N, M;
  cin >> N >> M;
  vector<pair<ll, ll>> students(N);
  vector<pair<ll, ll>> check(M);

  for (ll i = 0; i < N; i++)
  {
    ll x, y;
    cin >> x >> y;
    students[i].first = x;
    students[i].second = y;
  }
  
  for (ll i = 0; i < M; i++)
  {
    ll x, y;
    cin >> x >> y;
    check[i].first = x;
    check[i].second = y;
  }
  
  for (ll i = 0; i < N; i++)
  {
    pair<ll, ll> s = students[i];
    ll idx = 0;
    ll mn = INT_MAX;
  
    for (ll j = 0; j < M; j++)
    {
      pair<ll, ll> c = check[j];
      if (abs(c.first - s.first) + abs(c.second - s.second) < mn) {
        idx = j;
        mn = abs(c.first - s.first) + abs(c.second - s.second);
      }
    }
    cout << idx + 1 << endl;
  }
  
}

Measured memory_bytes: 3628
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

int main(){
    int n;
    ll m;
    int v,p;
    cin>>n>>m>>v>>p;

    vector<ll> a(n);
    for(int i=0;i<n;i++) cin>>a[i];

    sort(a.begin(),a.end());
    vector<ll> sum(n+1);
    for(int i=0;i<n;i++) sum[i+1]=sum[i]+a[i];

    
    int lb=-1;
    int ub=n-p;
    while(ub-lb>1){
        int mid=(lb+ub)/2;
        if(a[mid]+m>=a[n-p]) ub=mid;
        else lb=mid;
    }
    int res=p;

    for(int i=ub;i<n-p;i++){
        ll s;
        int rest=v-i-p;
        if(rest<=0){
            res++;
        }
        else{
            int r=n-p+1;
            int l=i+1;
            ll s=sum[r]-sum[l];
            ll lhs=s+m*rest;
            ll rhs=(a[i]+m)*(r-l);
            if(lhs<=rhs){
                res++;
            }
            
        }
    }
    cout<<res<<endl;
    
    return 0;
}


Measured memory_bytes: 1792
n = int(input())
ss=[list(map(str,input().split())) for i in range(n)]
zenhan=[]
kouhan=[]

for i in range(n):
    retu = list(ss[i])[0]
    acnt=0
    bcnt=0
    for j in range(len(retu)):
        if retu[j] == "(":
            acnt+=1
        elif acnt>0:
            acnt-=1
    a=acnt

    acnt=0
    bcnt=0
    for j in reversed(range(len(retu))):
        if retu[j] == ")":
            bcnt+=1
        elif bcnt>0:
            bcnt-=1
    b=bcnt

    if a!=0 or b!=0:
        if a < b:
            kouhan.append([a,b,retu])
        else:
            zenhan.append([a,b,retu])

zenhan.sort(key=lambda x:x[1])
kouhan.sort(reverse=True)
cnt=0
for tmp in zenhan:
    retu=tmp[2]
    for i in range(len(retu)):
        if retu[i] == "(":
            cnt+=1
        else:
            cnt-=1
        if cnt<0:
            print("No")
            exit()

for tmp in kouhan:
    retu=tmp[2]
    for i in range(len(retu)):
        if retu[i] == "(":
            cnt+=1
        else:
            cnt-=1
        if cnt<0:
            print("No")
            exit()
if cnt!=0:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 411340
n,k=map(int,input().split())
a=[list(map(int,input().split()))for i in range(n)]
a.sort()
b=float("inf")
for i in range(n-k+1):
    for j in range(i+k-1,n):
        p=a[j][0]-a[i][0]
        c=sorted([d[1] for d in a[i:j+1]])
        for s in range(j-i-k+2):
            q=c[s+k-1]-c[s]
            b=min(b,p*q)
print(b)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> pii;
typedef std::pair<long long, long long> pll;

using namespace std;

const long long MOD = 1000000007;

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

	string s;
	cin >> s;

	if (s == "SUN") {
		cout << 7 << "\n";
	}
	else if (s == "MON") {
		cout << 6 << "\n";
	}
	else if (s == "TUE") {
		cout << 5 << "\n";
	}
	else if (s == "WED") {
		cout << 4 << "\n";
	}
	else if (s == "THU") {
		cout << 3 << "\n";
	}
	else if (s == "FRI") {
		cout << 2 << "\n";
	}
	else {
		cout << 1 << "\n";
	}

	return 0;
}


Measured memory_bytes: 256
n=int(input())
i=1
facts = []
ans = 0
Number  =n
import math 
def factorize(n): 
    count = 0
    while ((n % 2 > 0) == False):  
        n >>= 1;  
        count += 1
    if (count > 0): 
        facts.append(2)
    for i in range(3, int(math.sqrt(n)) + 1): 
        count = 0
        while (n % i == 0):
            count += 1 
            n = int(n / i)
        if (count > 0): 
            facts.append(i)
        i += 2
    if (n > 2): 
        facts.append(n)
factorize(n)
facts = sorted(facts)
for i in range(len(facts)):
    cnt = 1
    while(n >= facts[i]**cnt):
        if(n%(facts[i]**cnt)==0):
            n//=(facts[i]**cnt)
            ans+=1
        cnt+=1
print(ans)



Measured memory_bytes: 63372
/* 
 * Author: pawanmsr
 */

/*
 * Run in Mac using the following command:
 * g++ -std=c++14 <cpp_filename>
 * A binary will be generated. Then run:
 * ./a.out
 */

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <fstream>
#include <cstring>
#include <unordered_map>

// #include <bits/stdc++.h>

using namespace std;
typedef long long int ll;

// Macro //
#define X first
#define Y second
#define pii pair<int,int>
#define pll pair<ll,ll>

// Global //
int n, m;

// Functions //


// Main //
int main(int argc, char const *argv[])
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // // freopen("output.txt", "w", stdout);
    // #else
    // // online submission
    // #endif
    
    /* code */

    cin >> n >> m;
    if (n==m) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools, random
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right; sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

n, m = wi()
#XYZ
w = mi(m)

class UnionFind2(object):
    def __init__(self, size):
        self.parent = [i for i in range(size)]
        self.rank = [0 for _ in range(size)]


    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            return self.find(self.parent[x])


    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)
u = UnionFind2(n)
for i in range(m):
    u.union(w[i][0] - 1, w[i][1] - 1)

se = set()
for i in range(n):
    se.add(u.find(i))


print(len(se))

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

int main() {
  long N, K;
  cin >> N >> K;
  vector<long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  
  sort(A.begin(), A.end());
  
  long ok = -2e18, ng = 2e18;
  while (ng - ok > 1) {
    long mid = (ok + ng) / 2, sum = 0;
    for (int i = 0; i < N; i++) {
      long double tmp = (long double) mid / A.at(i);
      if (A.at(i) > 0) sum += lower_bound(A.begin(), A.end(), tmp) - A.begin();
      if (A.at(i) < 0) sum += N - (upper_bound(A.begin(), A.end(), tmp) - A.begin());
      if (A.at(i) == 0) sum += (mid > 0) ? N : 0;
      if (A.at(i) * A.at(i) < mid) sum--;
    }
    (sum / 2 < K) ? ok = mid : ng = mid;
  }
  cout << ok << "\n";
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class 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;};

vector<int> dp(200020);

signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	int n;
	string s;
	cin >> n >> s;

	int ans = n + 10;
	vector<int> w(n+10, 0), r(n+10, 0);
	rep(i, n) {
		w[i+1] = w[i];
		r[i+1] = r[i];
		if(s[i] == 'R') r[i+1]++;
		else w[i+1]++;
	}
	//rep(i, n+1) cout << w[i] << " " << r[i] << endl;

	vector<int> dp(n, 0);
	rep(i, n+1) {
		int now = max(w[i], (r[n] - r[i]));
		
		//cout << w[i] << " " << r[n] - r[i] << " " << now << endl;
		chmin(ans, now);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9900
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  map<int, int, greater<int>> red; rep(i, N){ int a,b; cin >> a >> b; red[a]=b; }
  map<int, int> blue; rep(i, N){ int c,d; cin >> c >> d; blue[d]=c; }

  int result = 0;
  for (auto x: red) {
    for (auto y: blue) {
      if (x.first<y.second && x.second<y.first) {
        result++;
        blue.erase(y.first);
        break;
      }
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))
MOD = 10**9+7

ans = 0
for i in range(60):
    cnt = np.count_nonzero((A >> i) & 1)
    ans += (2**i * cnt*(N-cnt)) % MOD
    ans %= MOD
print(ans)


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

int main(){
    int n;
    cin >> n;
    double x = (double)n / 3.0;
    double vol = x * x * x;
    cout << fixed << setprecision(10) << vol << endl;
    
    return 0;
} 

Measured memory_bytes: 256
// c++ -std=c++14 atcoder.cpp
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int x;
    cin >> x;
    int ans = x/500;
    x -= 500*ans;
    ans *= 1000;
    ans += x/5*5;
    cout << ans << endl;
}


Measured memory_bytes: 256
// Problem : K - Stones
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_k
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 200005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
int dp[maxn];
void solve()
{
	int n,k;
	cin >> n >> k;
	vector<int> a(n);
	for(auto &x:a)
		cin >> x;
	dp[0]=0;
	for(int i=1;i<=k;i++)
	{
		for(int j=0;j<n;j++)
			if(a[j] <= i and dp[i-a[j]]==0)
			{
				dp[i]=1;
				break;
			}
	}
	if(dp[k] == 0)
	cout << "Second" <<"\n";
	else cout <<"First" <<"\n";
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 4412
//ALDS1_1_A


#include<iostream>
using namespace std;

int trace(int A[], int N){
        int i;
        for (i=0; i < N; i++){
            if( i > 0 ) printf(" "); //隣接する要素の間に一つの空白を入力
            printf( "%d", A[i]);
        }
        printf("\n");
    }
    
/* Insertion Sort 
1 insertionSort(A, N) // N個の要素を含む0-オリジンの配列A
2   for i が 1 から N-1 まで
3     v = A[i]4     j = i - 1
5     while j >= 0 かつ A[j] > v
6       A[j+1] = A[j]
7       j--
8     A[j+1] = v
*/
int IS(int A[], int N){
    int j, i, v;
    for(i = 1; i < N; i++){
        v = A[i];
        j = i - 1;
        while (j >= 0 and A[j] > v){
            A[j + 1] = A[j];
            j --;
        }
        A[j + 1] = v;
        trace(A, N);
    }
}
    
int main(void){
    int N, i, j;
    int A[100];
    
    scanf("%d", &N);
    for(i = 0; i < N; i++ ) scanf("%d", &A[i]);
    
    trace(A, N);
    IS(A, N);
    
    return 0;
}



Measured memory_bytes: 3212
import std.stdio;
import std.string;
import std.conv;
import std.array;
import std.algorithm;

void main() {
    int num;

    num = readln.chomp.to!int;
    foreach (i; 0..num) {
        char[] input;
        int[] data;
        int max, min;

        input = cast(char[])(readln.chomp);
        foreach (temp; input) data ~= (temp - '0').to!int;

        data.sort;
        min = data.map!(to!string).join.to!int;
        data.reverse;
        max = data.map!(to!string).join.to!int;

        writeln(max-min);
    }
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int n;
  string s;
  cin >> n >> s;

  int r = 0;
  for(int i = 0; i < n; ++i)
  {
    r += s[i] == 'R';
  }

  int ans = 0;
  for(int i = 0; i < r; ++i)
  {
    if (s[i] == 'W') ans++;
  }

  cout << ans;

  /*
  int lr = 0, lw = 0;
  for(int i = 0; i < n / 2; ++i)
  {
    lr += s[i] == 'R';
    lw += s[i] == 'W';
  }

  int rr = 0, rw = 0;
  for(int i = n / 2; i < n; ++i)
  {
    rr += s[i] == 'R';
    rw += s[i] == 'W';
  }
  */


}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
#define req(i, c) for(int i=0; i<(int)c; i++)
const int inf = 1000000000;

int main(){
  int N;
  cin >> N;
  vector<int> X(N);
  for(int i=0; i<N; i++){
    cin >> X[i];
  }
  int Left = X[0];
  int Right = X[0];
  req(i, N){
    Left = min(Left, X[i]);
    Right = max(Right, X[i]);
  }
  int ans = inf;
  for(int i=Left; i<Right+1; i++){
    int cost = 0;
    req(j, N) cost+=(X[j]-i)*(X[j]-i);
    ans = min(ans, cost);
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    double ans;
    if (N % 2 == 0) {
        ans = 0.5;
    } else {
        ans = (N/2 + 1.0)/N;
    }
    printf("%.10lf\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    char s[4];
    scanf("%s", s);

        if(s[0] == 'S'){
            if(s[1] == 'U'){
                printf("7");
            }else{
                printf("1");
            }
        }else if(s[0] == 'M'){
            printf("6");
        }else if(s[0] == 'T'){
            if(s[1] == 'U'){
                printf("5");
            }else{
                printf("3");
            }
        }else if(s[0] == 'W'){
            printf("4");
        }else if(s[0] == 'F'){
            printf("2");
        }

    
    return 0;

}

Measured memory_bytes: 128
n = int(input())
s = input()

lst1 = [0]
c = 0
for i in range(1,len(s)):
    if s[i-1] == "W":
        c += 1
    lst1.append(c)
    
lst2 = [0]
c = 0
for i in range(len(s)-2,-1,-1):
    if s[i+1] == "E":
        c += 1 
    lst2.append(c)
#print(lst1,lst2)

lst = []
for i in range(len(lst1)):
    lst.append(lst1[i] + lst2[n-i-1])

lst.sort()
#print(lst)
print(lst[0])

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

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

  int ans = 1;
  sort(d.begin(),d.end());
  int now=d[n-1];
  for(int i = n-2;i>=0;--i)
    if(d[i]<now){
      now = d[i];
      ans++;
    }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main() {
  int N;
  int d[100];
  int e[100];
  int types = 0;
  int boo;

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

  for(int i = 0; i < N; i++) {
    if(types == 0) {
      e[types] = d[i];
      types++;
    }
    boo = 1;
    for(int j = 0; j < types; j++) {
      if(d[i] == e[j]) {
        boo = 0;
      }
    }
    if(boo == 1) {
      e[types] = d[i];
      types++;
    }
  }
  cout << types << endl;
}


Measured memory_bytes: 256
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  int n;
  bool ans=true;
  string s[110];
  std::cin >> n;
  for(int i=0; i<n; i++) std::cin >> s[i];

  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      if(s[i]==s[j]){
        ans=false;
        break;
      }
    }
  }


  for(int i=0; i<n-1; i++){
    if(s[i][s[i].size()-1]!=s[i+1][0]){
      ans=false;
      break;
    }
  }

  if(ans) std::cout << "Yes" << '\n';
  else std::cout << "No" << '\n';
  return 0;
}


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

using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  vector<pair<int, int> > P[100010];
  string s[100010];
  for(int i=1; i<=M; i++){
    int p, y;
    cin >> p >> y;
    P[p].emplace_back(make_pair(y,i));
  }
  for(int i=1; i<=N; i++) sort(P[i].begin(), P[i].end());
  for(int i=1; i<=N; i++){
    for(int j=0; j<P[i].size(); j++){
      for(int k=0; k<6-to_string(i).size(); k++) s[P[i][j].second]+='0';
      s[P[i][j].second]+=to_string(i);
      for(int k=0; k<6-to_string(j+1).size(); k++) s[P[i][j].second]+='0';
      s[P[i][j].second]+=to_string(j+1);
    }
  }
  for(int i=1; i<=M; i++) cout << s[i] << endl;
  
  return 0;
}

Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
//#define int long long //Strong Power
#ifdef LOCAL
#define lout cout
#else
ostream devnull(0);
#define lout devnull
#endif
#define AMULET \
  cin.tie(0);  \
  ios::sync_with_stdio(false);
// https://github.com/kurokoji/.cpp-Template/blob/master/template/template2.cpp
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...)                                 \
  GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1) \
  (__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, d) for (decltype(n) i = (a); i < (n); i += (d))
#define rrep(...)                                    \
  GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1) \
  (__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, 1)
#define rrep4(i, a, n, d) for (decltype(a) i = (a); i >= (n); i -= (d))
// -----
typedef long long ll;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template <class C>
inline void vcin(C &c);
template <class C, class D>
inline void vcin(C &c, D &d);
template <class C>
inline void vcout(const C &c, const string separate = "\n");
template <class T = int>
inline T in();

lint pow2(lint a)
{
  return a * a;
}

void solve()
{
  int n, d;
  cin >> n >> d;
  int x[10][10];
  rep(i, n) rep(j, d) cin >> x[i][j];

  auto distance_unroot = [&](int i, int j) {
    lint sum = 0;
    rep(k, d)
        sum += pow2(x[i][k] - x[j][k]);
    return sum;
  };

  lint cnt = 0;
  rep(i, n) rep(j, i)
  {
    lout << "i,j:" << i << "," << j << endl;
    lint dis = distance_unroot(i, j);
    lout << dis << endl;
    if (dis == pow2((int)sqrt(dis)))
    {
      cnt++;
    }
  }

  cout << cnt << endl;
}

signed main()
{
  AMULET
  solve();
  return 0;
}

template <class C>
inline void vcin(C &c)
{
  for (auto &a : c)
  {
    cin >> a;
  }
}
template <class C, class D>
inline void vcin(C &c, D &d)
{
  for (auto it1 = c.begin(), it2 = d.begin(); it1 != c.end() && it2 != d.end(); it1++, it2++)
  {
    cin >> *it1 >> *it2;
  }
}
template <class C>
inline void vcout(const C &c, const string separate)
{
  for (auto it = c.begin(); it != c.end(); it++)
  {
    if (it != c.begin())
      cout << separate;
    cout << *it;
  }
}
template <class T = int>
inline T in()
{
  T x;
  cin >> x;
  return (x);
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class a{
    public static void Main(){
        int n = int.Parse(Console.ReadLine());
        int ans = n%1000;
        if(ans != 0){
            ans = 1000-ans;
        }
        Console.WriteLine(ans);
    }
}


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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

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

#define MAX_V 100000

#define MOD 1000000007L
#define INF 2147483647

signed main() {
	int n;
	cin >> n;
	int c = 0;
	int res = 0;
	for (int i = 1; i <= n; ++i) {
		int a;
		cin >> a;
		if (a == i) {
			c ++;
			if (c % 2 == 1) {
				res ++;
			}
		} else {
			c = 0;
		}
	}
	cout << res << endl;
}


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

int main() {
		
	string w; cin >> w;
	const int p = 26;
	vector<int> num(p, 0);
	for (int i = 0; i < w.size(); i++) {
		num[w[i] - 'a']++;
	}
	bool beautiful = true;
	for (int i = 0; i < p; i++) {
		if (num[i] % 2 != 0) {
			beautiful = false;
		}
	}
	if (beautiful) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<int> a(N+1), res(N+1, 0);
    REP(i, N){
        cin >> a[i+1];
    }
    for (int i = N; i > 0; i--) {
        int tmp = i*2;
        int td = 0;
        while(tmp <= N){
            td += res[tmp];
            tmp += i;
        }
        if(a[i] ^ (td&1))res[i] = 1;
    }
    vector<int> ans;
    REP(i, N){
        if(res[i+1]) ans.pb(i+1);
    }
    if(ans.empty()){
        pr(0);
        return 0;
    }
    pr(ans.size());
    for(auto i : ans) pr(i);
}

Measured memory_bytes: 3064
import java.util.Scanner;
import java.util.*;

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

int i=0;  
for(i=0;i<n;i++){
    h[i]=scan.nextLong();
}
  
Arrays.sort(h);
  
long sum=0;

if(n>k){
    for(i=0;i<n-k;i++){
      sum=sum+h[i];
    }
}

System.out.println(sum);
}
}


Measured memory_bytes: 64556
import numpy as np
nk = input()
[n, k] = [int(comp) for comp in nk.split()]
a = np.zeros(n, dtype=int)
for i in range(k):
    d = input()
    temp = input()
    for comp in temp.split():
        a[int(comp)-1] = 1
print(n-np.array(a).sum())

Measured memory_bytes: 27244
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 100100100;

// L[0] = P    size = 1
// L[2] = BLPLB = B P P P B  size = 
// L[3] = BLPLB = B BPPPB P BPPPB B = BBPPPBPBPPPBB
// L[4] = BBBPPPBPBPPPBBPBBPPPBPBPPPBBB

//Get number of P.
//P[i] = 2*P[i-1]+1  P[0] = 1
//
//Get numbe of length l
//l[i] = 2*l[i-1]+3,  l[0] = 1
//

ll rec(int n, ll x){
  if(n == 0) return 1;
  ll len = (1LL<<(n+1)) - 3;
  ll num = (1LL<<n) - 1;
  if(x == 1) return 0;
  else if(x <= len+1) return rec(n-1,x-1);
  else if(x == len+2) return num+1;
  else if(x <  len+2+len) return num+1+rec(n-1,x-(len+2));
  else return num+1+num;
}


int main(){
  ll n,x;
  cin >> n >> x;
  cout << rec(n,x) << endl;
}


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

int n, sum, t[55];
string x, s[55];
int main() {
	int i;
	cin >> n;
	for(i=0; i<n; i++) cin >> s[i] >> t[i], sum += t[i];
	cin >> x;
	for(i=0; s[i]!=x; i++) sum -= t[i];
	cout << sum - t[i];
	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,a,ten=1,o=0;
  cin >> n;
  for(int i=0;i<3;i++){
    if((n/ten)%10==1) a=9;
    else a=1;
    //cout << "a is " << a << endl;
    o+=a*ten;
    ten*=10;
  }
  cout << o <<endl;
}

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

using namespace std;

// segtree code from : https://codeforces.com/blog/entry/18051

const int N = 5e5 + 5;  // limit for array size
const int AL = 26; // alphabet size
int n;  // array size
int t[AL][2 * N];

void build() {  // build the tree
    for (int i = 0; i < AL; i++) {
        for (int j = n - 1; j > 0; --j) t[i][j] = t[i][j << 1] + t[i][j << 1 | 1];
    }
}

void modify(int p, int v) {  // set value at position p
    int o_p = p;
    for (int i = 0; i < AL; i++) {
        p = o_p;
        if (i == v) continue;
        for (t[i][p += n] = 0; p > 1; p >>= 1) t[i][p >> 1] = t[i][p] + t[i][p ^ 1];
    }
    p = o_p;
    for (t[v][p += n] = 1; p > 1; p >>= 1) t[v][p >> 1] = t[v][p] + t[v][p ^ 1];
}

int query(int l, int r) {  // sum on interval [l, r)
    int ans = 0;
    int o_l = l, o_r = r;
    for (int i = 0; i < AL; i++) {
        int res = 0;
        l = o_l; r = o_r;
        for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
            if (l&1) res += t[i][l++];
            if (r&1) res += t[i][--r];
        }
        if (res > 0) ++ans;
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(0); cout.tie(0);
    
    cin >> n;
    string s; cin >> s;
    
    for (int i = 0; i < n; i++) {
        int v = s[i] - 'a';
        t[v][n + i] = 1;
    }
    
    build();
    
    int q; cin >> q;
    while (q--) {
        int x, l, r; cin >> x >> l;
        if (x == 1) {
            char c; cin >> c;
            int v = c - 'a';
            modify(l - 1, v);
        }
        else {
            cin >> r;
            cout << query(l - 1, r) << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 102556
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		long m=2019;
		
		String str=s.next();
		
		int n=str.length();
		
		long ans=0;
		
		HashMap<Long,Long> map=new HashMap<>();
		
		map.put(0l,1l);
		
		long pow=1;
		long v=0;
		
		for(int i=n-1;i>=0;i--)
		{
			if(str.charAt(i)!='0')
			{
				long digit=Long.valueOf(str.charAt(i)+"");
				
				long mod=(v%m+(digit%m*pow%m)%m)%m;
				pow=(pow%m*10)%m;
				v=mod;
				
				if(map.containsKey(mod))
				{
					ans=ans+map.get(mod);
					map.put(mod,map.get(mod)+1);
				}
				else
				{
					map.put(mod,1l);
				}
			}
			else
			{
				pow=(pow%m*10)%m;
			}
		}
		
		System.out.println(ans);
		
	}
	
	
	
}

Measured memory_bytes: 58036