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

#define loop(i,a,b) for(ll i=a; i<b; i++)
#define rloop(i,a,b) for(ll i=a; i>b; i--)
#define all(var) var.begin(), var.end()
#define eloop(var) for(auto elem : var)
#define debug(x) cerr<<#x<<" ----> "<<x<<endl;
#define TC ll tt; cin>>tt; while(tt--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ size()
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define INF 0x7fffffff
#define LINF 2000000000000000007
#define MOD 1000000007
#define MAX 100005
typedef long long ll;
typedef long double ld;
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpl vector< pll >

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

    // TC
    {
        ll n;
        cin>>n;
        vll v(n);
        loop(i,0,n) cin>>v[i];

        sort(all(v));
        ll cnt=0;
        map<ll, ll>m;
        loop(i,0,n)
            m[v[i]]++;
        if(m[1]==1) {
            cout<<1<<'\n';
            return 0;
        }
        else if(m[1]>1) {
            cout<<0<<'\n';
            return 0;
        }
        else {
        loop(i,0,n) {
            ll t= sqrt(v[i])+1, j=2;
            bool fg=true;
            if(m[v[i]]>1)
                continue;
            while(j<=t) {
                if(v[i]%j==0) {
                    if(binary_search(all(v), j)!=false || binary_search(all(v), v[i]/j)!=false) {
                        fg = false;
                        break;
                    }
                }
                j++;
            }
            if(fg || v[i]==2){
                cnt++;
                // cout<<v[i]<<'\n';
            }
        }
        }
        cout<<cnt<<'\n';
    }
    return 0;
}

Measured memory_bytes: 17092
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
#define SZ(x) (int)((x).size())
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

const int N = 1e5 + 10;
int f[N];

int find(int x) {
  if (f[x] != f[f[x]]) f[x] = find(f[x]);
  return f[x];
}

int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) f[i] = i;
  int cnt = n;
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    int rx = find(x), ry = find(y);
    if (rx != ry) {
      f[ry] = rx;
      cnt--;
    }
  }
  cout << cnt - 1 << endl;
  return 0;
}


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

int main(){
	char a,tmp;
	cin>>a;
	if(a=='A'||a=='T')
    {
        tmp=(a=='A')?'T':'A';
        cout<<tmp;
    }
    else {
            tmp=(a=='G')?'C':'G';
            cout<<tmp;
    }


}


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

int main(int argc, char *argv[])
{
	int a, b, c;
	vector<int> array;

	cin >> a >> b >> c;
	array.push_back(a);
	array.push_back(b);
	array.push_back(c);

	sort(array.begin(), array.end());
	cout << array[0] + array[1] << endl;

	return 0;
}


Measured memory_bytes: 256
/**akshaykumar99**/
 
#include<bits/stdc++.h>
using namespace std;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define pu push_back           
#define pp pop_back
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const int MOD=1e9+7 ;
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e5+11;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> ivc;
typedef pair<ll,ll> ipr;
 
int main()
{
    IOS();
   
    int n,i,ans=0,p=INF;
    cin>>n;
    int a[n],b[n];
    f(i,0,n)
      cin>>a[i];
    ans=a[0];
    for(i=n-2;i>=0;i--)
    {
      ans+=min(a[i],p);
      p=a[i];
    }
    cout<<ans;


    return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
const int N = -1;

int main()
{
    int a, b;
    cin >> a >> b;
    if (b % a == 0)
        cout << a + b << endl;
    else
        cout << b - a << endl;
    return 0;
}


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

int main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;cin>>s;
    if(s.back()=='s')
    s+="es";
    else
    s+="s";
    cout<<s;
}


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


ans = 0
for i in range(len(A)-1):
    if A[i] + A[i+1] > x:
        if A[i] >= x:
            ans += A[i] - x
            ans += A[i+1]
            A[i+1] = 0
        else:
            tmp = A[i] + A[i+1] - x
            ans += tmp
            A[i+1] -= tmp
print(ans)

Measured memory_bytes: 63856
//master
import java.io.*;
import java.util.*;
public class Main {
    static int[][] memo;
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        long n = sc.nextLong();
        long x = 101;
        long cnt = 1;
        while(x<n) {
            x *= 1.01;
            cnt++;
        }
        p(cnt);
}

    public static <T> void p(T message) {
        System.out.println(message);
    }

    public static <T> void pe(T message) {
        System.err.println(message);
    }

    public static <T> void pp(T message) {
        System.out.print(message);
    }
    
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
 
    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }
 
    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
 
    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
 
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

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

int main ()
{
    fastio

    lli num ;
    cin >> num ;

    if (num < 1200)
        cout << "ABC" ;
    else if (num < 2800)
        cout << "ARC" ;
    else
        cout << "AGC" ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    let a: String;
    let b: String;
    input! {a: String, b: String};

    if a.len() > b.len() {
        println!("GREATER")
    } else if a.len() < b.len() {
        println!("LESS")
    } else {
        let mut t = 'e';

        for i in 0..a.len() {
            if &a[i..i + 1] > &b[i..i + 1] {
                println!("GREATER");
                t = 'a';
                break;
            } else if &a[i..i + 1] < &b[i..i + 1] {
                println!("LESS");
                t = 'a';
                break;
            }
        }

        if t == 'e' {
            println!("EQUAL");
        }
    }
}


Measured memory_bytes: 2136
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>
#include<map>
#include<deque>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=1000000007;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}


int main(void){
    ll X;
    cin>>X;
    ll FH=X/500;
    ll FY=(X-500*FH)/5;
    cout<<1000*FH+5*FY<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cassert>
#include <cstring>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

typedef long long ll;

const int MOD = 998244353;

int x[200], y[200];

int modpow(ll x, int n) {
    int ret = 1;
    while (n) {
        if (n % 2) ret = ret * x % MOD;
        x = x * x % MOD;
        n /= 2;
    }
    return ret;
}

int main(void) {
    int i, j, k, n;
    cin >> n;
    REP (i,n) cin >> x[i] >> y[i];

    int ans = modpow(2,n) - n - 1;
    REP (i,n) REP (j,i) {
        int cnt = 2;
        REP (k,n) if (k != i && k != j && (x[k] - x[i]) * (y[j] - y[i]) == (y[k] - y[i]) * (x[j] - x[i])) {
            if (k < i) {
                cnt = 0;
                break;
            }
            cnt++;
        }
        ans = (ans - (modpow(2,cnt) - cnt - 1) + MOD) % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
#define NUM ((long long)1000000007)
#define int long long
 
using namespace std;
 
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    int n;
 
    cin >> n;
 
    map<int, int> m;
 
    int in, sum = 0;
 
    int ans = 0;
    m[0] = 1;
    for (int i = 0; i < n; ++i)
    {
        cin >> in;
        sum += in;
        ans += m[sum]++;
    }
 
    cout << ans << endl;
}

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

int main(){
    ll n;
    cin >> n;
    vector<ll> h(n, 0);
    for(ll i = 0; i < n; i++){
        cin >> h[i];
    }
    
    ll cnt = 0;
    ll ans = 0;
    for(ll i = 0; i < n-1; i++){
        if(h[i] >= h[i+1]){
            cnt++;
        }else{
            cnt = 0;
        }
        ans = max(cnt, ans);
    }


    cout << ans << endl;

    return 0;

}

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

#define INF 100100100
#define mod 1000000007

using namespace std;

int main(int argc, char const* argv[])
{
   int a,b;
   cin >> a >> b;
   int nega = 0;
   bool zero = false;
   for(int i=a;i<=b;i++){
      if(i < 0)nega++;
      if(i == 0)zero = true;
   }
   if(zero)cout << "Zero" << endl;
   else if(nega % 2 == 1)cout << "Negative" << endl;
   else cout << "Positive" << endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(a) cout << #a ": " << a << endl
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;

int main(void){
    IOS;
    int n; cin >> n;
    string s; cin >> s;
    int l = 0, r = s.size()-1, cnt = 0;
    while (l <= r){
        while (l <= r && s[l] == 'R') l++;
        while (l <= r && s[r] == 'W') r--;
        if (l <= r) cnt++, swap(s[l], s[r]);
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3724
#include <iostream>
//#include <bits/stdc++.h>
#include <atcoder/all>
//#include "ac-library/atcoder/dsu.hpp"

using namespace std;
using namespace atcoder;

int main() {
    int n, m;
    cin >> n >> m;
    dsu d(n);
    for(int i = 0;i < m;i++) {
        int a, b;
        cin >> a >> b;
        d.merge(a-1, b-1);
    }
    cout << d.groups().size() - 1 << endl;

    return 0;
}


Measured memory_bytes: 8348
#include <iostream>

using namespace std;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
   string s;
   cin>>s;
   int h[26],i;
  for(i=0;i<26;++i)
      h[i]=0;
  
  for(i=0;i<s.length();++i)
      h[s[i]-65]++;
  
  for(i=0;i<26;++i)
  {
    if(h[i]==0)
        continue;
    
    else
    {
      if(h[i]==2)
          continue;
      
      else
         break;
    }
  }
  if(i==26)
     printf("Yes");
  
  else
     printf("No");
   
}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


s = input()
if "RRR" in s:
    ans = 3
elif "RR" in s:
    ans = 2
elif "R" in s:
    ans = 1
else:
    ans = 0
print(ans)

Measured memory_bytes: 61780
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
using ll = long long;
int main(void){
    string s;
    cin>>s;
    int n= s.size();
    vector <vector<ll>> dp(100010 ,vector <ll>(2 ));
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        if(s[i]=='0'){
            dp[i+1][0] += dp[i][0]%mod;
            dp[i+1][1] += (dp[i][1]*3)%mod;
           /* dp[i+1][0] = dp[i][0];
        dp[i+1][1] = dp[i][1];
            (dp[i+1][1] += dp[i][1]*2 % mod) %= mod;*/
        }
        if(s[i]=='1'){
            dp[i+1][0] += (dp[i][0]*2) % mod;
            dp[i+1][1] += (dp[i][0])%mod;
            dp[i+1][1] += (dp[i][1]*3)%mod;
            /*dp[i+1][1] = (dp[i][0] + dp[i][1]) % mod;
            (dp[i+1][0] += dp[i][0]*2 % mod) %= mod;
        (dp[i+1][1] += dp[i][1]*2 % mod) %= mod;*/
        }
        dp[i+1][0] %= 1000000007;
        dp[i+1][1] %= 1000000007;
    }
    cout<<(dp[n][0]+dp[n][1])%1000000007<<endl;
}


Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
    int n, m, x, i, j=0;
    cin>>n>>m>>x;
    int ryokin[n+1];
    int min = 100;
    int k;
    for(i=0; i<n+1; i++){
        ryokin[i] = 0;
    }
    for(i=1; i<=m; i++){
        cin>>k;
        ryokin[k]++;
    }

    for(i=0; i<x; i++){
        if(ryokin[i]!=0){
            j++;
        }
    }
    if(j<min){
        min = j;
    }
    j=0;

    for(i=x; i<=n; i++){
        if(ryokin[i]!=0){
            j++;
        }
    }
    if(j<min){
        min = j;
    }

    cout<<min<<endl;
    return 0;
}


Measured memory_bytes: 256
function Main(input){
  input = input.split("\n");
  inputStr = input[0].split(" ");
  var S = inputStr[0];
  //引数に応じた結果を出力
  var ans = ""
  switch(S){
    case "Sunny":
      ans = "Cloudy";
      break;
    case "Cloudy":
      ans = "Rainy"; 
      break;
    default:
      ans = "Sunny";
      break;
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	s, t := scanString(), scanString()
	ans := 1 << 60
	for i := 0; i < len(s); i++ {
		c := 0
		if len(t) > len(s[i:]) {
			break
		}
		for j := 0; j < len(t); j++ {
			if t[j] != s[i:][j] {
				c++
			}
		}
		ans = min(ans, c)
	}
	fmt.Fprintln(wr, ans)
}


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

using namespace std;

//#define FILE_IO

const int VMAX = (1 << 20) + 5;
const int NMAX = 5e5 + 5;
const int mod = 1e9 + 7;

int N;
int v[NMAX], sum[NMAX], dp[NMAX], cnt0[NMAX];
int sumdp[VMAX], sumdpcnt[VMAX];
vector<int> pos[VMAX];

int power(int x, int y)
{
    if(x == 0)  return 0;
    if(y <= 0)  return 1;
    int ans = power( (1LL * x * x) % mod, y >> 1 );
    if(y & 1)   ans = (1LL * ans * x) % mod;
    return ans;
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    cin >> N;
    for(int i = 1; i <= N; i++)
    {
        cin >> v[i];
        sum[i] = sum[i - 1] ^ v[i];
    }

    int sumall = sum[N];
    if(sumall != 0)
    {
        sumdp[0] = 1;
        dp[0] = 1;
        for(int i = 1; i <= N; i++)
        {
            int needval = sum[i] ^ sumall;
            dp[i] = sumdp[needval];
            sumdp[ sum[i] ] = (sumdp[ sum[i] ] + dp[i]) % mod;
        }
        printf("%d\n", dp[N]);
        exit(0);
    }

    cnt0[0] = 1;
    for(int i = 1; i <= N; i++)
    {
        cnt0[i] = cnt0[i - 1] + (sum[i] == 0);
        pos[ sum[i] ].push_back(i);
    }

    for(int i = 1; i <= N; i++)
    {
        if(sum[i] == 0) continue;
        int s = sum[i];
        dp[i] = ((1LL * cnt0[i] * sumdp[s]) % mod - sumdpcnt[s] + mod + 1) % mod;
        sumdp[s] = (sumdp[s] + dp[i]) % mod;
        sumdpcnt[s] = (sumdpcnt[s] + (1LL * dp[i] * cnt0[i]) % mod) % mod;
    }

    int ans = power(2, (int)pos[0].size() - 1);
    for(int i = 1; i <= N; i++)
        if(sum[i] != 0)
            ans = (ans + dp[i]) % mod;
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 50420
{
  const run = (input: string) => {
    let split = input.trim().split("\n")
    const n = parseInt(split[0])
    const tmpList = split[1].split(" ").map(v => parseInt(v))

    let tmpSum = 0
    const list = {}
    for (let i = 0; i < n; i++) {
      const v = tmpList[i]
      list[v] = list[v] ? list[v] + 1 : 1
      tmpSum += v
    }

    const q = parseInt(split[2])

    const result = []
    const max = 3 + q
    for (let i = 3; i < max; i++) {
      const [from, to] = split[i].split(" ").map(v => parseInt(v))
      if (list[from]) {
        tmpSum = tmpSum - (from * list[from]) + (to * list[from])
        list[to] = list[from] + (list[to] || 0)
        list[from] = 0
      }

      result.push(tmpSum)
    }

    return result.join("\n")
  }

  const Main = (input: string) => {
    console.log(run(input))
  };

  Main(require("fs").readFileSync("/dev/stdin", "utf8"));
}


Measured memory_bytes: 68672
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)
#define MAX_N 200000
#define MAX_V 10
#define MAX_M 101
#define yn(f) (f?"Yes":"No")
#define YN(f) (f?"YES":"NO")
#define pro "はいプロ　世界一○○が上手　○○界のtourist　○○時代の終焉を告げる者　実質○○　○○するために生まれてきた男"


int a[MAX_N] = {}, b[MAX_N] = {}, c[MAX_N] = {}, n ,t[MAX_N] = {}, tt[MAX_N] = {},sum, ans;
signed main(){

	
	cin>>n;
	
	for(int i = 0; i < n; i++){
		cin>>a[i];
	}
	for(int i = 0; i < n; i++){
		cin>>b[i];
	}
	for(int i = 0; i < n; i++){
		cin>>c[i];
	}
	sort(a,a+n);
	sort(b,b+n);
	sort(c,c+n);
	
	for(int i = 0; i < n; i++){
		t[i] = c+n-upper_bound(c,c+n,b[i]);
		 //cout<<"b "<<t[i]<<" "<<b[i]<<endl;
	}
	
	for(int i = 0; i < n; i++){
		// tt[0]++;
		// tt[b+n-upper_bound(b,b+n,a[i])]--;
		tt[n-(b+n-upper_bound(b,b+n,a[i]))]++;
		tt[n]--;
		//cout<<"a "<<tt[i]<<" "<<b+n-upper_bound(b,b+n,a[i])<<" "<<a[i]<<endl;
		//cout<<"a "<<tt[i]<<" "<<b+n-upper_bound(b,b+n,a[i])<<" "<<a[i]<<endl;
	}
	
	for(int i = 0; i < n; i++){
		tt[i+1] += tt[i];
		sum += t[i]*tt[i];
		//cout<<t[i]<<" "<<tt[i]<<endl;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 6400
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x:x[1])
time = 0
for i in range(N):
    if time+AB[i][0] > AB[i][1]:
        print ("No")
        break
    else:
        time += AB[i][0]
else:
    print ("Yes")

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

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589

using namespace std;

int gcd(int a, int b){return (a % b)? gcd(b, a % b) : b;}
int lcm(int a, int b){return a * b / gcd(a, b);}

void solve_A(){
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes";
    else cout << "No";
}

void solve_B(){
    int x;
    cin >> x;
    int ctr_500 = 0, ctr_5 = 0;
    
    while(x >= 500){
        x -= 500;
        ctr_500 ++;
    }

    while(x >= 5){
        x -= 5;
        ctr_5 ++;
    }
    
    cout << ctr_500 * 1000 + ctr_5 * 5;
}

int main(void){
    solve_B();
    
    return 0;
}

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

const int N = 100000 + 5;
const int MOD = 1e9 + 7;

int n, m;
int f[N];
bool vis[N];

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= m; i++) {
        int x;
        scanf("%d", &x);
        vis[x] = true;
    }
    f[0] = 1;
    if (!vis[1]) f[1] = 1;
    for (int i = 2; i <= n; i++) {
        if (vis[i]) continue;
        f[i] = (f[i - 1] + f[i - 2]) % MOD;
    }
    printf("%d\n", f[n]);
    return 0;
}

Measured memory_bytes: 640
import bisect
import math
from collections import deque

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29


class Node:
    def __init__(self, val, idx=0):
        self.val = val
        self.idx = idx

    def __str__(self):
        return 'val : ' + str(self.val) + ' idx : ' + str(self.idx)

# 0-idxed SegmentTree
class SegmentTree:
    def __init__(self, N, vals, default_value=INF):
        self.N0 = pow(2, (N-1).bit_length())
        self.nodes = [Node(default_value, i+1-self.N0)
                      for i in range(2*self.N0-1)]
        for i in reversed(range(2*self.N0-1)):
            ind = i+1-self.N0
            if ind >= N:
                self.nodes[i].val = default_value
            elif ind >=0 and N > ind:
                self.nodes[i].val = vals[ind]
            else:
                self.nodes[i] = self.process(
                    self.nodes[i*2+1], self.nodes[i*2+2])

    def __getitem__(self, key):  # getiten : ST[i]
        return self.nodes[key+self.N0-1].val

    def __setitem__(self, i, x):  # update : ST[i] = x
        i += self.N0 - 1
        self.nodes[i].val = x
        while i > 0:
            i = (i-1)//2
            self.nodes[i] = self.process(self.nodes[i*2+1], self.nodes[i*2+2])

    def __str__(self):
        return '['+', '.join(map(str, [self.nodes[i+self.N0-1].val for i in range(self.N0)]))+']'

    def query(self, L, R):  # [L,R)の値
        retnode = Node(0, 0)
        L += self.N0
        R += self.N0
        while L < R:
            if R & 1:
                R -= 1
                retnode = self.process(retnode, self.nodes[R-1])
            if L & 1:
                retnode = self.process(retnode, self.nodes[L-1])
                L += 1
            L >>= 1
            R >>= 1
        return retnode

    def process(self, node_x, node_y):  # x,yが子の時，親に返る値
        return Node(node_x.val | node_y.val)


def main():
    N = iRaw()
    S = sRaw()
    sgt = SegmentTree(N, [1 << (ord(s)-ord('a')) for s in S])
    Q = iRaw()
    ans =[]
    for _ in range(Q):
        t,l,r = ssRaw()
        if t=="1":
            sgt[int(l)-1] = 1 << (ord(r)-ord("a"))
        else:
            ret = sgt.query(int(l)-1, int(r))
            ans.append(str(bin(ret.val)).count("1"))
    return "\n".join(map(str, ans))

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


Measured memory_bytes: 179060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
#define INF 1000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
	int n;
    cin>>n;
    priority_queue<double> q;
    REP(i,n){
        int a;
        cin>>a;
        a=a*(-1);
        q.push(a);
    }
    REP(i,n-1){
        double x=q.top();
        q.pop();
        double y=q.top();
        q.pop();
        q.push((double)(x+y)/2);
    }
    double ans=(double)(-1)*q.top();
    printf("%.8lf\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <deque>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
#define mod 1000000007
#define M 2005
#define LL long long
#define ni 500000004

int n, k;

int a[M], Max[M], Min[M];

LL ans, to, toto;

int main(){
    scanf("%d%d", &n, &k);
    for(int i = 1; i <= n; i ++){
        scanf("%d", &a[i]);
    }
    for(int i = 1; i <= n; i ++){
        for(int j = i+1; j <= n; j ++){
            if( a[i] > a[j] ){
                Max[j]++;
            }
            else if( a[i] < a[j] )
                Min[j]++;
        }
    }
    to = 1ll*(k+1)%mod*k%mod*ni%mod;
    toto = 1ll*(k-1)%mod*k%mod*ni%mod;
    for(int i = 1; i <= n; i ++){
        ans = (ans+1ll*Min[i]*toto%mod)%mod;
        ans = (ans+1ll*Max[i]*to%mod)%mod;
    }
    printf("%lld\n", ans%mod);
    return 0;
}


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

using namespace std;

string divide[4] = {"dream","dreamer","erase","eraser"};



int main() {

  string s;
  cin >> s;

  reverse(s.begin(),s.end());
  for(int i=0 ; i<4 ; i++)
    reverse(divide[i].begin(),divide[i].end());
  
  for(int i=0 ; i<s.size();){

    bool canDivide = false;
    for(int j=0 ; j<4 ; j++){
      if(s.substr(i,divide[j].size()) == divide[j]){
	i += divide[j].size();
	canDivide = true;
	break;
      }
    }
    
    if(!canDivide){
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;
  
  return 0;
}



Measured memory_bytes: 512
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

void solve(long long N, std::vector<std::string> S){
    vll A(4, 0);
    REP(i, N){
        if(S[i] == "AC") A[0]++;
        if(S[i] == "WA") A[1]++;
        if(S[i] == "TLE") A[2]++;
        if(S[i] == "RE")  A[3]++;
    }

    cout<<"AC x "<<A[0]<<endl;
    cout<<"WA x "<<A[1]<<endl;
    cout<<"TLE x "<<A[2]<<endl;
    cout<<"RE x "<<A[3]<<endl;
}
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


Measured memory_bytes: 5252
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n;

int main(){
  ll ans=0;
  string s;cin>>s;
  string t;cin>>t;
  n=s.length();
  for(ll i=0;i<n;i++){
    if (s[i]!=t[i])ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3912
#include<stdio.h>
#define N 501
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
int n,M[N][N];
int color[N],d[N],f[N],tt;

void dfs_visit(int u){
  int v;
  color[u]=GRAY;
  tt++;
  d[u]=tt;
  for(v=0;v<n;v++){
    if(M[u][v] == 0) continue;
    if(color[v] == WHITE)
      dfs_visit(v);
  }
  color[u]=BLACK;
  f[u]=++tt;
}

void dfs(){
  int i,u;
  for(i=0;i<n;i++){
    color[i]=WHITE;
  }
  tt=0;
  for(u=0;u<n;u++){
    if(color[u] == WHITE)
      dfs_visit(u);
  }
  for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
}

int main(){
  int u, k,v;
  int i,j,a=0;
  if(a == 0){
  scanf("%d",&n);
  for(i=0;i<n;i++){
     for(j=0;j<n;j++)
      M[i][j]=0;
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }
  dfs();
  return 0;
}
}


Measured memory_bytes: 2048
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<cstdio>
#include<sstream>
#include<cmath>
#include<set>
#include<algorithm>
#include<map>
#include<ctime>
#define mp make_pair
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define mst(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const double eps = 1e-8;
const int maxn = 200009;
const int inf = 100000009;
const ll mod = 1e9 + 7;
ll op[300009][69];
ll pq[69];
int main()
{
	int n;
	cin >> n;
	mst(op, 0);
	pq[0] = 1;
	for (int i = 1; i <= 60; ++i) pq[i] = (pq[i-1] * 2) % mod;
	for (int i = 0; i < n; ++i) {
		ll tmp;
		scanf("%lld", &tmp);
		int cnt = 0;
		while (tmp) {
			op[i][cnt++] = tmp & 1;
			tmp >>= 1;
		}
	}
	ll sum = 0;
	for (int i = 0; i < 60; ++i) {
		int p0 = 0;
		int p1 = 0;
		if (op[0][i]) ++p1;
		else ++p0;
		for (int j = 1; j < n; ++j) {
			if (op[j][i]) {
				sum = (sum + pq[i] * p0%mod) % mod;
				++p1;
			}
			else {
				sum = (sum + pq[i] * p1%mod) % mod;
				++p0;
			}
		}
	}
	cout << sum;
	//system("pause");
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 3005;
const int INF = 1001001001;
const int MOD = 998244353;

struct mint {
    long long x;
    mint(long long x=0):x(x % MOD + (0 <= x ? 0 : MOD)) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint& a) { if ((x += a.x) >= MOD) x -= MOD; return *this; }
    mint& operator-=(const mint& a) { if ((x -= a.x) < 0) x += MOD; return *this; }
    mint& operator*=(const mint& a) { (x *= a.x) %= MOD; return *this; }
    mint operator+(const mint& a) const { return mint(x) += a; }
    mint operator-(const mint& a) const { return mint(x) -= a; }
    mint operator*(const mint& a) const { return mint(x) *= a; }

    // for prime mod
    mint inv() const {
        long long a = x, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        return mint(u);
    }
    mint& operator/=(const mint& a) { return *this *= a.inv(); }
    mint operator/(const mint& a) const { return mint(x) /= a; }
};
istream& operator>>(istream& is, const mint& a){ return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a){ return os << a.x; }

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

    vector<int> A(N);
    for (int &i : A) cin >> i;

    vector<vector<mint>> dp(N+1, vector<mint>(S+1));
    dp[0][0] = 1;
    rep(i, N) {
        rep(j, S+1) {
            dp[i+1][j] += dp[i][j] * 2;
            if (S < j + A[i]) continue;
            dp[i+1][j+A[i]] += dp[i][j];
        }
    }

    mint ans = dp[N][S];
    cout << ans << endl;
}

Measured memory_bytes: 73696
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// solution 
use std::cmp;
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input!{
        N: usize,
        K: usize,
        A: [usize1; N],
    }
    let mut counts = vec![0; N];
    let mut K_max = 0;
    for &a in A.iter() {
        if counts[a] == 0 {
            K_max += 1;
        }
        counts[a] += 1;
    }
    counts.sort();
    let mut start_ind = 0;
    while counts[start_ind] == 0 {
        start_ind += 1;
    }
    let mut sum = 0;
    for ind in start_ind..start_ind+K_max-K {
        sum += counts[ind]; 
    }
    println!("{}", sum);

}


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

int main(){
  long long w,h,x,y;
  cin >> w >> h >> x >> y;
  double res;
  int i=0;

  if(x+x==w && y+y==h){
    i=1;
  }
  res=(double)w*(double)h/2;
  printf("%.10f %d\n",res,i);
  return 0;
}


Measured memory_bytes: 256
module maze
integer,allocatable,dimension(:,:)::mazemap
integer::dirx(4)=[1,0,-1,0]
integer::diry(4)=[0,1,0,-1]

contains

subroutine getmap(mazemap,R,C)
  integer,allocatable,dimension(:,:)::mazemap
  integer R,C
  character(50) linereader
  allocate(mazemap(0:R+1,0:C+1))
  mazemap=0
  do i=1,R
    read*,linereader
    do j=1,C
      if(linereader(j:j)=="#")mazemap(i,j)=1
    end do
  end do
end subroutine
end module maze
use maze
integer H,W
logical check,precheck
read*,H,W
check=.true.
call getmap(mazemap,H,W)
do i=1,H
  do j=1,W
    if(mazemap(i,j)==1)then
      precheck=.false.
      do k=1,4
        if(mazemap(i+dirx(k),j+diry(k))==1)precheck=.true.
      end do
      check=check .and. precheck
    endif
  end do
end do

print"(A)",trim(merge("Yes","No ",check))
end

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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

signed main()
{   
    gearup;
    int n; cin >> n;
    vl a(n);
    rep(i,n)cin>>a[i];
    auto b = a;
    sort(all(b)); //昇順
    ll odd = 0;
    rep(i,n){
        int idx = lower_bound(all(b),a[i]) - b.begin();
        int dif = abs(i-idx);
        //out(dif);
        if(dif & 1)odd++;
    }
    out(odd/2);
}

Measured memory_bytes: 4784
from functools import reduce
from math import gcd
n = int(input())
aa = list(map(int, input().split()))
ma = max(aa)
cnt = [0] * (ma+1)

for a in aa:
    cnt[a] += 1

if reduce(gcd, aa) != 1:
    print('not coprime')
elif all([sum(cnt[i::i]) <= 1 for i in range(2, ma)]):
    print('pairwise coprime')
else:
    print('setwise coprime')

Measured memory_bytes: 227356
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;
    int ans = 0;
    int tmp = 0;
    for(int i = 0; i < N; i++){
        if(s[i] == 'I'){
            tmp++;
            ans = max(ans, tmp);
        }else{
            tmp--;
        }
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    int N;
    string c1[36], c2[36];
    cin >> N;
    for(int i=0;i<N;i++) cin >> c1[i];
    for(int i=0;i<N;i++) c2[i]=c1[i];

    for(int i=0;i<N;i++){
        for(int j=N-1;j>i;j--){
            if(c1[j][1]<c1[j-1][1]){
                string tmp=c1[j];
                c1[j]=c1[j-1];
                c1[j-1]=tmp;
            }
        }
    }
    for(int i=0;i<N;i++){
        int minj = i;
        for(int j=i;j<N;j++){
            if(c2[j][1]<c2[minj][1]) minj=j;
        }
        string tmp=c2[i];
        c2[i]=c2[minj];
        c2[minj]=tmp;
    }

    cout << c1[0];
    for(int i=1;i<N;i++) cout << ' ' << c1[i];
    cout << endl << "Stable" << endl;
    cout << c2[0];
    for(int i=1;i<N;i++) cout << ' ' << c2[i];
    cout << endl;

    bool isStable=true;
    for(int i=0;i<N;i++){
        if(c1[i]!=c2[i]) isStable=false;
    }
    cout << (isStable?"Stable":"Not stable") << endl;

    return 0;
}


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

num = [0]*2000001

for i in range(N):
    num[A[i]] +=1

V = 2000001 - num.count(0)

if V <=K:
    print(0)
else:
    num.sort()
    num.reverse()
    print(sum(num[K:]))

Measured memory_bytes: 45332
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  ll n, x, m;
  cin >> n >> x >> m;
  set<ll> st;
  vector<ll> a;

  st.insert(x);
  a.push_back(x);
  rep(i, 100010){
    x = (x*x) % m;
    if(st.count(x)) break;
    st.insert(x);
    a.push_back(x);
  }

  vector<ll> b;
  bool IN = false;
  rep(i, a.size()){
    if(!IN) if(a[i] == x) IN = true;
    if(IN) b.push_back(a[i]);
  }
  ll k = a.size() - b.size();
  ll l = b.size();
  ll d = (n-k) / l;
  ll r = (n-k) % l;
  ll pre = 0;
  ll sum = 0;
  ll rest = 0;
  rep(i, k) pre += a[i];
  rep(i, l) sum += b[i];
  rep(i, r) rest += b[i];
   
  cout << pre + sum * d + rest << endl;

  return 0;
}



Measured memory_bytes: 6704
#include <stdio.h>

void	ft_sort(int *a, int n)
{
	int i = 0;
	int j;
	int tmp;
	while (i < n - 1)
	{
		j = i + 1;
		while (j < n)
		{
			if (a[i] < a[j])
			{
				tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
			j++;
		}
		i++;
	}
}

int main(void)
{
	int N;
	scanf("%d", &N);
	int a[N + 1];
	int i = 0;
	int suma = 0;
	int sumb = 0;
	while (i < N)
	{
		scanf("%d", &a[i]);
		i++;
	}
	ft_sort(a, N);
	i = 0;
	while (i < N)
	{
		if (i % 2 == 0)
			suma += a[i];
		else
			sumb += a[i];
		i++;
	}
	printf("%d", suma - sumb);
	return 0;
}

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

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

    if(n >= 10){
        cout << r << endl;
    }
    else{
        r = r + 100*(10 - n);
        cout << r << endl;
    }

    // cout << "" << endl;
}

Measured memory_bytes: 256