akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  string s;
  cin>>s;
  ll n=sz(s);
  vvll dp(n+1,vll(4,0));
  dp[0][0]=1;
  rep(i,n){
    rep(j,4){
      dp[i+1][j]+=dp[i][j];
      dp[i+1][j]%=MOD;
    }
    if(s[i]=='A'){
      dp[i+1][1]+=dp[i][0];
      dp[i+1][1]%=MOD;
    }
    else if(s[i]=='B'){
      dp[i+1][2]+=dp[i][1];
      dp[i+1][2]%=MOD;
    }
    else if(s[i]=='C'){
      dp[i+1][3]+=dp[i][2];
      dp[i+1][3]%=MOD;
    }
    else{
      rep(j,4){
        dp[i+1][j]+=2*dp[i][j];
        dp[i+1][j]%=MOD;
      }
      rep(j,3){
        dp[i+1][j+1]+=dp[i][j];
        dp[i+1][j+1]%=MOD;
      }
    }
  }
  COUT(dp[n][3]);
}

Measured memory_bytes: 10388
#include <iostream>
#include <fstream>
#include <queue>
#include <list>
//#define LOCAL
using namespace std;
typedef long long ll;
const int mx=1e3+10;
priority_queue<ll, vector<ll>, greater<ll> >num1;
priority_queue<ll, vector<ll>, less<ll> >num2;
int main() {
#ifdef LOCAL
ifstream fin("1.txt");
streambuf*p;
p=cin.rdbuf(fin.rdbuf());
#endif // LOCAL
for(int i=1;i<=3;i++){
    ll value;
    cin>>value;
    num1.push(value);
    num2.push(value);
}
printf("%lld %lld\n", num1.top(), num2.top());


#ifdef LOCAL
fin.close();
#endif // LOCAL
}




Measured memory_bytes: 3280
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=1; i<=(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    string s,t;
    cin>>s>>t;
    sort(all(s));
    sort(t.rbegin(),t.rend());
    if(s<t) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define F first
#define S second
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()
//library begin
int gcd(int a,int b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
int log(int a){
    int b=a;
    int cnt=0;
    while(b%2==0){
        b/=2;
        cnt++;
    }
    return cnt;
}
int mypow(int a,int b){
    if(b==0)return 1;
    if(b==1)return a;
    int t=mypow(a,b/2);
    if(b%2==0)return t*t;
    return t*t*a;
}
//library end
string s,t;
int a,b;
string u;
signed main(){
    cin>>s>>t;
    cin>>a>>b;
    cin>>u;
    if(s==u)a--;
    else b--;
    cout<<a<<" "<<b<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <map>
#include <list>
#include <queue>
#include <cstdlib>
#define INF (1000000007)
#define distance(x1,y1,x2,y2) sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
#define rep(i,N) for(ll i=0;i<N;i++)
#define rep2(i,j,k) for(ll i=j; i<k;i++)
typedef long long int ll;
using namespace std;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vs=vector<string>;
using vvs=vector<vector<string>>;

template <typename T>
void print(T v){
    for(size_t i=0;i<v.size();i++){
        cout<<i<<": "<<v[i]<<endl;}
}

template <typename T>
void print2(T v){
    for(size_t i=0;i<v.size();i++){
        cout<<i<<": ";
        for(size_t j=0;j<v[0].size();j++){
            cout<<v[i][j]<<" ";
        }
        cout<<endl;
    }
}

template <typename T>
T slice(T v,ll left,ll right){
    T ret(0);
    copy(v.begin()+left,v.begin()+right,back_inserter(ret));
    return ret;
}

int main(){
    ll N;
    vl acc(5);
    cin>>N;
    rep(i,5){
        cin>>acc[i];
    }
    
    ll m=0;
    ll f=0;
    rep(i,5){
        if(m<N/acc[i]){
            m=N/acc[i];
            if(N%acc[i]==0){
                f=1;
            }
            else{
                f=0;
            }
        }
    }
    
    cout<<5+m-f<<endl;
    
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
import bisect


def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    # divisors.sort()
    return divisors


if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    negA = []
    for i, a in enumerate(A):
        negA.append(i - a)

    cnt_negA = Counter(negA)
    negA_keys = sorted(cnt_negA.keys())
    ans = 0
    for i in range(N):
        if i + A[i] in cnt_negA:
            ans += cnt_negA[i + A[i]]
    print(ans)


Measured memory_bytes: 42604
#include <iostream>
#include <limits>
#include <vector>

using namespace std;

int main() {
  constexpr auto none = numeric_limits<int>::max() / 2;
  int N, M, L;
  cin >> N >> M >> L;
  vector<vector<int>> graph(N + 1, vector<int>(N + 1, none));
  for (int i = 0; i < M; ++i) {
    int A, B, C;
    cin >> A >> B >> C;
    graph[A][B] = graph[B][A] = C;
  }
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N - 1; ++j) {
      for (int k = j + 1; k <= N; ++k) {
        graph[k][j] = graph[j][k] = min(graph[j][k], graph[j][i] + graph[k][i]);
      }
    }
  }
  for (int i = 1; i <= N - 1; ++i) {
    for (int j = i + 1; j <= N; ++j) {
      graph[j][i] = graph[i][j] = graph[i][j] <= L ? 1 : none;
    }
  }
  for (int i = 1; i <= N; ++i) {
    graph[i][i] = 0;
  }
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N - 1; ++j) {
      for (int k = j + 1; k <= N; ++k) {
        graph[k][j] = graph[j][k] = min(graph[j][k], graph[j][i] + graph[k][i]);
      }
    }
  }
  int Q;
  cin >> Q;
  for (int i = 0; i < Q; ++i) {
    int s, t;
    cin >> s >> t;
    cout << (graph[s][t] == none ? -1 : graph[s][t] - 1) << endl;
  }
}

Measured memory_bytes: 896
list_HW = list()
while True:
    base = input("")
    term = base.split(' ')
    if(int(term[0]) == 0 and int(term[0]) == 0):
        break
    else:
        map_HW = {'H': int(term[0]), 'W': int(term[1])}
        list_HW.append(map_HW)

for HW in list_HW:
    h = HW['H']
    w = HW['W']

    for r in range(h):
        for s in range(w):
            print('#',end='')
        print('',end='\n')

    print('',end='\n')



Measured memory_bytes: 7020
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    string T;
    cin >> T;
    int l = T.length();
    REP(i, l) {
        if (T[i] == '?') cout << 'D';
        else cout << T[i];
    }
    cout << endl;
    return 0;
}


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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

int main() {
  ll d, t, s;
  cin >> d >> t >> s;
  cout << (d <= t * s ? "Yes" : "No") << endl;
  return 0;
}


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

int main()
{
  int a, b;
  cin >> a >> b;
  if(a > b)
  {
    cout << a+max(a-1, b) << endl;
  }
  else if(a < b)
  {
    cout << b+max(b-1, a) << endl;
  }
  else{
    cout << 2 * a << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=100000+1;
int main(int argc,char *argv[]){
	int n;int h;scanf("%d%d",&n,&h);
	int maxw=-1;
	int w[maxn],t[maxn];
	for(int i=1;i<=n;++i){
		scanf("%d%d",&w[i],&t[i]);
		if(w[i]>maxw)maxw=w[i];
	}
	sort(t+1,t+1+n);
	int ans=0;
	for(int i=n;i>=1;--i){
		if(t[i]<=maxw)break;
		if(h>0){
			h-=t[i];
			++ans;
		}else break;
	}
	if(h>0){
		ans+=(h-1)/maxw+1;
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] charArray = sc.next().toCharArray();

        char one =charArray[0];
        int oneCount = 1;
        int twoCount = 0;
        int[] secondCharIndexone = new int[3];
        int index = 0;

        for (int i=1; i<4; i++){
            if (charArray[i] == one){
                oneCount++;
            }else {
                secondCharIndexone[index] = i;
                index++;
            }
        }

        if (oneCount ==2 && charArray[secondCharIndexone[0]] == charArray[secondCharIndexone[1]]){
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
use proconio::input;

fn is_palindrome(s: String) -> bool {
  let r: String = s.chars().rev().collect();
  return s == r;
}
fn is_string_palindrome(s: String) -> bool {
  let n = s.len();
  is_palindrome((&s[0..n]).to_string()) && 
  is_palindrome((&s[..(n-1)/2]).to_string()) &&
  is_palindrome((&s[(n+3)/2-1..n]).to_string())
}

fn main() {
  input! {
    s: String,
  }
  if is_string_palindrome(s) {
    println!("Yes");
  } else {
    println!("No");
  }
}


Measured memory_bytes: 2184
#include <stdio.h>
main()
{
 int num;
  int i = 0 ;
 
  while(1)
    {
      ++i;
       
      scanf("%d", &num);
      if( num == 0)
    break;
 
      printf("Case %d: %d\n", i, num);
 
    }
 
 
  return 0;
 
}

Measured memory_bytes: 600
#include <iostream>
#include <queue>
using namespace std;


int main() {
  int n, m;
  cin >> n >> m;
  priority_queue<int> items;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    items.push(a);
  }
  for (int i = 0; i < m; i++) {
    int target = items.top();
    items.pop();
    target = target / 2;
    items.push(target);
  }
  long long  ans = 0;
  for (int i = 0; i < n; i++) {
    ans += items.top();
    items.pop();
  }
  cout << ans << endl;
}


Measured memory_bytes: 892
#include <stdio.h>
int main(void){
	int i, j, t, a[5] = {20000};
	for( i = 0; i < 10; i++ ){
		scanf("%d", &t );
		for( j = 3; t > a[j]; j-- )a[j+1] = a[j];
		a[j+1] = t;
	}
	for( i = 1; i < 4; i++ ){
		printf("%d\n", a[i] );
	}
	return 0;
}

Measured memory_bytes: 0
import fractions

A, B, C, D = (int(i) for i in input().split())


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


one_to_b = B - ((B // C) + (B // D) - (B // lcm(C, D)))
one_to_a = A - 1 - ((((A - 1) // C) +
                     ((A - 1) // D) -
                     (A - 1) // lcm(C, D)))

print(one_to_b - one_to_a)


Measured memory_bytes: 5560
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
	map<int, int> mp;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		++mp[x];
	}
	bool ok = true;
	for (auto i : mp)
		if (i.second >= 2)
			ok = false;
	cout << (ok ? "YES" : "NO") << "\n";
}

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

using namespace std;

int main(){
  string s,s2;

  cin >> s;
  s2 = s;
  reverse(s.begin(), s.end());
  for(int i=0; i<s.size(); ++i){
    if(s[i] == 'b'){
      s[i] = 'd';
    }else if(s[i] == 'd'){
      s[i] = 'b';
    }else if(s[i] == 'p'){
      s[i] = 'q';
    }else if(s[i] == 'q'){
      s[i] = 'p';
    }
  }
  if(s == s2){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(){


  int a,b,i,j,sum,total=0;
  int mat[1000][1000];

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

 for(i=0;i<a;i++){
   for(j=0;j<b;j++){
     scanf("%d",&mat[i][j]);
   }}



 for(i=0;i<a;i++){
   sum=0;
   for(j=0;j<b;j++){
     printf("%d ",mat[i][j]);
     sum +=mat[i][j];
   }
   printf("%d\n",sum);
 }


  for(i=0;i<b;i++){
    sum=0;
   for(j=0;j<a;j++){
     sum += mat[j][i];
     
   }
   total+=sum;
   printf("%d ",sum);
  }

  printf("%d\n",total);


  return 0;
}

Measured memory_bytes: 2984
//https://atcoder.jp/contests/tenka1-2018-beginner/tasks/tenka1_2018_a
//A - Measure
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}
int main() {
    string S; cin>>S;
    if(S.size()>=3){
        reverse(S.begin(),S.end());
    }
    cout<<S<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
  char S[4], T[4];
  int cnt = 0;

  std::cin >> S;
  std::cin >> T;

  for (int i = 0; i < 3; i++)
  {
    if (S[i] == T[i])
    {
      cnt++;
    }
  }

  std::cout << cnt;

  return 0;
}

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

int main(){
    int N , i;
    int odd,even;
    cin>>N;
    
    for(i=1;i<=N;i++){
        
        if(i%2==0){
            even++;
        }
        else{
            odd++;
        }
    
    }
    cout<< even*odd<<endl;
}

Measured memory_bytes: 256
import kotlin.math.sqrt

fun main() {
    val nmk = nextInt()
    val ans = solve(nmk)
    println(ans)
}

fun solve(nmk: Int): Int {
    val a = (1..nmk).filter { it % 2 != 0 }.filter {
        (1..nmk).filter { i -> it % i == 0 }.size == 8
    }

    return a.size

}

fun nextInt(): Int {
    return readLine()!!.toInt()
}

Measured memory_bytes: 34744
//ABC056B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int w, a, b;
	cin >> w >> a >> b;
	int ans = max(abs(a-b)-w,0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; ++i) cin >> p[i];
    int answer = 0;
    for (int i = 1; i < n - 1; ++i) {
        if (p[i - 1] > p[i] && p[i] > p[i + 1]) ++answer;
        if (p[i - 1] < p[i] && p[i] < p[i + 1]) ++answer;
    }
    cout << answer << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	vector<int> v(N);
	for (int i = 0; i < N; i++) cin >> v.at(i);
	sort(v.begin(), v.end());

	int A, B;
	A = 0;
	B = 0;

	for (int i = N - 1; i >= 0; i--) {
		if ((N % 2) != (i % 2)) A += v.at(i);
		else B += v.at(i);
	}

	cout << A - B << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 100005;
int n,ans;
struct Node{
	int v,pos;
	bool operator < (const Node &b)const
	{
		return v<b.v;
	}
}a[MAXN];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",&a[i].v),a[i].pos=i;
	sort(a+1,a+n+1);
	int ans=0;
	for(int i=1;i<=n;++i)
		ans+=(a[i].pos^i)&1;
	cout<<ans/2<<endl;
	return 0;
}


Measured memory_bytes: 1024
N = int(input())
V = list(map(int,input().split()))
O = []
E = []
nums_O = []
nums_E = []

for i in range(0,N,2):
  O.append(V[i])
  E.append(V[i+1])

for j in range(100000):
  nums_O.append([0,j])
  nums_E.append([0,j])

for k in range(N//2):
  nums_O[O[k]-1][0] += 1
  nums_E[E[k]-1][0] += 1
  
nums_O.sort()
nums_E.sort()
##print(O,E,nums_O[-1],nums_E[-1])
if nums_O[-1][1] != nums_E[-1][1]:
  print(N-(nums_O[-1][0] + nums_E[-1][0]))
else:
  print(N-max(nums_E[-2][0]+nums_O[-1][0],nums_O[-2][0]+nums_E[-1][0]))

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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 1LL << 30;
const ll LINF = 1LL << 60;
const double eps = 1e-9;
const ll MOD = 1000000007LL;
template <typename T>
void chmin(T& a, T b) {
    a = min(a, b);
};
template <typename T>
void chmax(T& a, T b) {
    a = max(a, b);
};
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
vector<vector<int>> G;
int u, v, cy;
void dfs(int i, int p) {
    for(auto e : G[i]) {
        if(e == p || e == v) {
            continue;
        }
        if(e == u) {
            cy = 1;
            break;
        } else {
            dfs(e, i);
        }
    }
}
int main() {
    int n, m;
    cin >> n >> m;
    G.resize(n);
    vector<int> co(n);
    for(int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        co[a]++;
        co[b]++;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    bool f = true, ff = false;
    u = -1;
    int c = 0;
    for(int i = 0; i < n; i++) {
        if(co[i] % 2) {
            f = false;
        }
        if(co[i] >= 6) {
            ff = true;
        }
        if(co[i] == 4) {
            c++;
            if(u == -1) {
                u = i;
            } else {
                v = i;
            }
        }
    }
    if(f) {
        if(ff || c > 2) {
            cout << "Yes" << endl;
        } else if(c == 2) {
            dfs(u, -1);
            if(cy) {
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        } else {
            cout << "No" << endl;
        }
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 7296
#include <stdio.h>
# include <stdlib.h>

int menor(const void * x, const void * y){
	int a = *((int *) x), b = *((int *) y);
 
	if (a<b)
		return -1;
	if (a>b)
		return 1;
 
	return 0;
 
}

int main() {
    int most, esp;
    
    scanf("%d %d", &most, &esp);
    int vec[most];
    
    for (int i = 0; i < most; ++i){
        scanf("%d", &vec[i]);
    }
    
    qsort(vec, most, sizeof(vec[0]), menor);
    
    long long att = 0;
    
    for (int i = 0; i < most-esp; ++i){
        att += vec[i];
    }
    
    printf("%lld\n", att);
    
    
    return 0;
}


Measured memory_bytes: 1788
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n,m=gsmi
s=gs.reverse
step=[]

i=0
while i<n do
  can=false
  m.downto(1) do |mm|
    next if i+mm>n
    next if s[i+mm]=='1'
    step<<mm
    i+=mm
    can=true
    break
  end
  if !can
    putsend -1
  end
end

puts step.reverse.join(" ")

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

int N;
int A[110];
int main(){
	cin >> N;
	for(int i=1;i<=N;i++){
		cin >> A[i];
	}
	int flag = 1;
	int count = 0;
	while(flag){
		flag = 0;
		int j = N;
		while(j>=1){
			if(A[j] < A[j-1]){
				count++;
				int tmp = A[j];
				A[j] = A[j-1];
				A[j-1] = tmp;
				flag = 1;
			}
			j--;
		}
	}
	for(int i=1;i<=N;i++){
		if(i!=N) cout << A[i] <<" ";
		else cout << A[i] << endl;
	}
	cout << count << endl;
}


Measured memory_bytes: 3112
/*
 * A.cpp
 *
 *  Created on: 2020/06/06
 *      Author: admin
 */


#include <iostream>
#include <string>


using namespace std;


int main(){
	int i=0, a[10];
	while(i<2){
		cin >> a[i];
		i++;
	}
	cout << a[0] * a[1];
}


Measured memory_bytes: 3596
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt(),b=sc.nextInt();
        int s=(int)Math.min(a/0.08,b/0.1);
        int min=1251;
        for(int i=s;i<1251;i++){
            if((int)(i*0.08)==a&&(int)(i*0.1)==b){
                min=(int)Math.min(i,min);
            }
        }
        if(min==1251)min=-1;
        System.out.println(min);
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
int mod = 1e9 + 7;

signed main() {
    int N;
    cin >> N;
    if (N % 2 == 0) {
        int ans = 0;
        for (int i = 0; i <= 24; i++) {
            ans += N / (10 * (int)pow(5, i));
        }

        cout << ans << endl;
    } else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 640
from collections import Counter
import math

h, w = map(int,input().split())
a = [list(input()) for _ in range(h)]

c=Counter(sum(a,[]))

if h%2==0 and w%2==0:
    g1=0
    g2=0
    g4=(h//2)*(w//2)
elif h%2==1 and w%2==0:
    g1=0
    g2=w//2
    g4=(h//2)*(w//2)
elif h%2==0 and w%2==1:
    g1=0
    g2=h//2
    g4=(h//2)*(w//2)
else:
    g1=1
    g2=(h//2)+(w//2)
    g4=(h//2)*(w//2)

g1_cnt=0
g2_cnt=0
g4_cnt=0

for key in c:
    if c[key]%4==1:
        g1_cnt+=1
        g4_cnt+=c[key]//4
    elif c[key]%4==2:
        g2_cnt+=1
        g4_cnt+=c[key]//4
    elif c[key]%4==2:
        g1_cnt+=1
        g2_cnt+=1
        g4_cnt+=c[key]//4
    else:
        g4_cnt+=c[key]//4

# print(g1,g2,g4)

# print(g1_cnt,g2_cnt,g4_cnt)

flag=False
if g1==g1_cnt:
    if g2==g2_cnt and g4==g4_cnt:
        flag=True
    elif g2_cnt<g4_cnt and g2>g4 and g2*2+g4*4==g2_cnt*2+g4_cnt*4:
        flag=True

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


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
ll digitSum(ll n) {
    ll tmp = n;
    ll ret = 0;
    while (n > 0) {
        ret += n % 10; n /= 10;
    }
    return ret;
}
/* main */
int main(){
    string S;
    cin >> S;
    int m = 2019;
    reverse(S.begin(), S.end());

    vector<int> cnt(2020);
    cnt[0] = 1;
    int p = 1;
    int sum = 0;
    for (char c : S) {
        sum += p * (c - '0');
        sum %= m;
        cnt[sum]++;
        p *= 10;
        p %= m;
    }

    int ans = 0;
    for (int i = 0; i < cnt.size(); i++) ans += cnt[i] * (cnt[i] - 1) / 2;
    cout << ans << '\n';
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int a, b;
    cin >> a >> b;
    if (a + b == 15)
        cout << "+" << endl;
    else if (a * b == 15)
        cout << "*" << endl;
    else
        cout << "x" << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main(){

	int H,W;

	for(;;){
		cin >> H >> W;
		if(H == 0 && W == 0) break;

		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				cout << "#";
			}
			cout << endl;
		}

		cout << endl;

	}

	return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    int a,b;
    cin >> a >> b;
    cout << (a-1)*(b-1) << endl;


    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define vector std::vector
#define string std::string
typedef long long ll;
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int i = 0; i < (n); i++)

template <class T = int>
T in() { T x; std::cin >> x; return x; }
#define output(e) std::cout << e << '\n'

#ifdef LOCAL
#define db std::cout << "L" << __LINE__ <<
#define de << "\n"
#define dv(x) << " " << #x << "->" << x
#else
#define db
#define de
#define dv(x)
#endif

//
// Implementation
//

int main() {
  string s = in<string>();
  bool isa = false;
  int ans = 0;
  int cnt = 0;
  for (auto c : s) {
    if (c == 'A') {
      isa = true;
    }
    if (isa) {
      cnt++;
    }
    if (c == 'Z') {
      ans = std::max(ans, cnt);
    }
  }
  output(ans);
}


Measured memory_bytes: 640
import Debug.Trace
import Data.Array
import Control.Monad
type Prof_Diff = Array Int (Array Int Int)
type Business_Day = Array Int (Array Int Bool)


get_BD::Int -> IO Business_Day
get_BD n = do
  ss<-forM [1..n] (\_ ->  getLine)
  let lss = map (\st ->map (\x -> if x=="1" then True else False) (words st) ) ss
  let f   = listArray (1,n) (map (listArray (1,10)) lss)
  return f

get_Prof_Diff::Int -> IO Prof_Diff
get_Prof_Diff n = do
  ss<-forM [1..n] (\_ -> getLine)
  let lss = map (\st ->map read (words st)) ss
  let p   = listArray (1,n) (map (listArray (0,10)) lss)
  return p


all_pat::Int ->[[Bool]]
all_pat n = (iterate (\ls-> concat [map (b:) ls|b<-[False,True]]) [[]])!!n

value::Business_Day->Prof_Diff->Array Int Bool->Int
value bd pd pat = let (shop_i,shop_f) = bounds bd  in
                  let (day_i ,day_f ) = bounds pat in
                  let doubling        = listArray (shop_i,shop_f) [ (length.(filter (\d ->  (pat!d) && ((bd!j)!d) ) ) ) [day_i..day_f] |j<-[shop_i..shop_f]] in
                  sum [(pd!j)!(doubling!j) |j<-[shop_i..shop_f]]

solver::Business_Day->Prof_Diff->Int->Int
solver bd pd n = let pat = map (listArray (1,n)) (tail (all_pat n)) in
                 maximum (map (value bd pd) pat)
main::IO()
main=do
  nc<-getLine
  let n = read nc::Int
  bd<-get_BD n
  pd<-get_Prof_Diff n
  --print bd
  --print pd
  --print (value bd pd (take 10 (repeat True)))
  print (solver bd pd 10)


Measured memory_bytes: 1916
#include<iostream>
using namespace std;
int main(){
	int n,a;
	long long  sum=0;
	int max=-1000000;
	int min=1000000;
	cin>>n;
    for(int i=1;i<=n;i++){
    	cin>>a;
    	if(a>max){
    		max=a;
    	}
    	if(a<min){
    		min=a;
    	}
        sum+=a;
    }
	cout<<min<<" "<<max<<" "<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll n,i,has;
string s;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	cin>>s;
	for(i=0;i<n;i++)
		if(i==0||(s[i]!=s[i-1]))
			has++;
	cout<<has<<"\n";
}


Measured memory_bytes: 512
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    int n;
    double t, a;
    cin >> n;
    cin >> t >> a;
    vector<int> h(n);
    REP(i, n) cin >> h[i];
    
    double d = 99999;
    REP(i, n){
        double now = t - h[i] * 0.006;
        if(abs(now - a) < d){
            ans = i+1;
            d = abs(now - a);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
a, b = 0, 0
for x in input().split():
    x = int(x)
    if x % 4 == 0: a += 1
    elif x % 2 == 0: b += 1
if a * 2 + b // 2 * 2 + 1 >= n: print('Yes')
else: print('No')


Measured memory_bytes: 11096
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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


fn main () {
    input! {
        x: i32,
        y: i32,
        z: i32,
    }
    let ans = (x - z) / (y + z);
    println!("{:?}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
using namespace std;
int main(void){
    string s,t;
    cin>>s>>t;
    string n;
    for(int i=0;i<s.size();i++){
        n=s.substr(i,s.size())+s.substr(0,i);
        if(n==t){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())
 
if a<b and a<c:
    if b<c :
        print(a, b, c)
    else :
        print(a, c, b)
elif b<a and b<c :
    if a<c :
        print(b, a, c)
    else :
        print(b, c, a)
else :
    if a<b :
        print(c, a, b)
    else :
        print(c, b, a)


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

#define REP(i,n) for(long long i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9



int main(){
  int A, B;
  cin >> A >> B;
  if(0 <= A && A <= 9 && 0 <= B && B <= 9){
    cout << A*B << endl;
  }
  else{
    cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String[] ss = s.split(" ");
        int a = Integer.parseInt(ss[0]);
        int b = Integer.parseInt(ss[1]);
        int c = Integer.parseInt(ss[2]);
        if (a == b && a != c) {
            System.out.println("Yes");
        }
        else if (a == c && a != b) {
            System.out.println("Yes");
        }
        else if (b == c && a != b) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
}

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

int main(){
    using namespace std;
    constexpr unsigned long C = 26;
    unsigned long D;
    cin >> D;
    vector<unsigned long> c(C);
    for(auto&& i : c)cin >> i;
    vector v(D, vector<unsigned long>(C));
    for(auto&& i : v)for(auto&& j : i)cin >> j;

    for(unsigned long i{0}, j{min_element(begin(c), end(c)) - begin(c)}; i < D; ++i)cout << j + 1 << endl;

    return 0;
}

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

int main() {
  #define int long long
  int n, k;
  cin >> n >> k;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a.at(i);
  }
  vector<int> q;
  q.push_back(1);
  int imp;
  vector<int> s(n + 1, 0);
  for (int j = 0; j < n; j++) {
    if (s.at(a.at(q.at(j))) == 0) {
      q.push_back(a.at(q.at(j)));
      s.at(a.at(q.at(j))) = 1;
    }
    else {
      imp = a.at(q.at(j));
      break;
    }
  }
  int qsz = q.size();
  int pnt;
  for (int j = 0; j < qsz; j++) {
    if (q.at(j) == imp) {
      pnt = j;
    }
  }
  int grp;
  grp = qsz - pnt;
  if (k < pnt) {
    cout << q.at(k) << endl;
  }
  else {
    int r = (k - pnt) % grp;
    cout << q.at(pnt + r) << endl;
  }
}




Measured memory_bytes: 8424
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;
const int mod = 1e9 + 7;
int main() {
  int N, M;
  cin >> N >> M;
  vector <bool> broken(N + 1);
  for (int i = 0; i < M; i++) {
	  int a;
	  cin >> a;
	  broken[a] = true;
	}
  int dp[100001] = { };
  dp[0] = 1;
  if (broken[1]) {
	  dp[1] = 0;
	} else {
	  dp[1] = 1;
	}
  for (int i = 2; i <= N; i++) {
	  if (broken[i]) {
		  dp[i] = 0;
		  continue;
		}
	  dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
	}
  cout << dp[N] << endl;
  return 0;
}


Measured memory_bytes: 640
l, n = map(int, input().split())

lis = list(map(int, input().split()))

dist = 0

dist = l - lis[n-1] + lis[0]
for kk in range(n-1):
    	if dist < lis[kk + 1] - lis[kk]:
    			dist = lis[kk + 1] - lis[kk]

print(l-dist)

Measured memory_bytes: 26436
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <tuple>
#include <queue>
#include <string>
const int maxn = 1e5+1;
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    ll ans=0;
    int n=s.size()-1;
    for(int msk=0; msk<(1<<n); ++msk){
        ll cur=0;
        string temp="";
        for(int i=0; i<=n; ++i){
            temp+=s[i];
            if (msk&(1<<i))
                temp+="+";
        }
        ll cur_num=0;
        temp+="+";
        for(int i=0; i<temp.size(); ++i){
            if (temp[i]>='0' && temp[i]<='9')
                cur_num=cur_num*10+temp[i]-'0';
            else{
                cur+=cur_num;
                cur_num=0;
            }
        }

        ans+=cur;
    }
    cout<<ans;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll a,b,d,num=1;
int main()
{
	cin>>a>>b;
	d=gcd(a,b);
	for(int i=2;i<=sqrt(d);i++)
		if(d%i==0){
			num++;
			while(d%i==0)d/=i;
		}
	int pd=1;
	for(int i=2;i<=sqrt(d);i++)
		if(d%i==0)
			pd=0;
	num+=pd&&d>1;
	cout<<num;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define for_(i,a,b) for(int i=(a);i<(b);++i)
template< typename T > using Vec = vector< T >;
typedef long long lint;
template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b) % mod; }
 
struct Edge {
	int v;
	lint d;
	bool operator > (const Edge& e) const { return d > e.d; }
};
 
int N, M, S, T, U[200005], V[200005];
lint D[200005];
Vec< Vec< Edge > > edge;
 
lint dst[2][100005];
lint numpath[2][100010];
const lint MOD = (lint)1e9 + 7;
 
void calcDist(int piv, int start) {
	priority_queue< Edge, Vec< Edge >, greater< Edge > > que;
	que.push(Edge{start, 0});
	dst[piv][start] = 0;
	numpath[piv][start] = 1;
	while (!que.empty()) {
		Edge e = que.top(); que.pop();
		//if (dst[piv][e.v] < e.d) continue;
		for (const Edge& ei : edge[e.v]) {
			if (dst[piv][ei.v] == -1 || dst[piv][ei.v] > e.d + ei.d) {
				dst[piv][ei.v] = e.d + ei.d;
				numpath[piv][ei.v] = numpath[piv][e.v];
				que.push(Edge{ei.v, dst[piv][ei.v]});
			} else if (dst[piv][ei.v] == e.d + ei.d) {
				modAdd(numpath[piv][ei.v], numpath[piv][e.v], MOD);
			}
		}
	}
}
 
void solve() {
	memset(dst, -1, sizeof(dst));
	calcDist(0, S);
	calcDist(1, T);
	
	lint collision = 0;	
	
	for_(v,0,N) {
		if (dst[0][v] == dst[1][v] && dst[0][v] + dst[1][v] == dst[0][T]) {
			lint num = (numpath[0][v] * numpath[1][v]) % MOD;
			modAdd(collision, num * num, MOD);
		}
	}
	
	double thr = (double)dst[0][T] / 2.;
	for_(i,0,M) {
		int u = U[i], v = V[i], d = D[i];
		if (abs(dst[0][v] - dst[0][u]) == d) {
			if (dst[0][v] + d == dst[0][u]) swap(u, v);
			if (dst[0][u] + dst[1][v] + d == dst[0][T] && (double)dst[0][u] < thr && (double)(dst[0][u] + d) > thr) {
				lint num = (numpath[0][u] * numpath[1][v]) % MOD;
				modAdd(collision, num * num, MOD);
			}
		}
	}
	
	cout << ((numpath[0][T] * numpath[1][S] - collision + MOD) % MOD) << endl;
}
 
int main() {
	cin >> N >> M;
	cin >> S >> T;
	--S; --T;
	
	edge.assign(N, Vec< Edge >());
	for_(i,0,M) {
		cin >> U[i] >> V[i] >> D[i];
		--U[i]; --V[i];
		edge[U[i]].push_back(Edge{V[i], D[i]});
		edge[V[i]].push_back(Edge{U[i], D[i]});
	}
	
	solve();
}

Measured memory_bytes: 21844
MOD = 10 ** 9 + 7


def MAP():
    return list(map(int, input().split()))


class BinaryIndexedTree:
    def __init__(self, tree_size):
        self.tree_size = tree_size
        self.tree = [0] * (self.tree_size + 1)

    def add(self, i, x):
        while 0 < i <= self.tree_size:
            self.tree[i] += x
            i += i & -i

    def sum(self, i):
        s = 0
        while 0 < i:
            s += self.tree[i]
            i -= i & -i
        return s


def count_inversion(A, max_num):
    bit = BinaryIndexedTree(max_num)
    x = 0
    for i, a in enumerate(A, start=1):
        bit.add(a, 1)
        x += i - bit.sum(a)
    return x


def main():
    N, K = MAP()
    A = MAP()

    tento_int = count_inversion(A, 2000)  # Aの内部で発生する転倒数
    tento_ext = count_inversion(sorted(A, reverse=True), 2000)  # AiとAjの間で発生する転倒数

    x = tento_int * K
    y = tento_ext * K * (K - 1) // 2
    print((x + y) % MOD)


if __name__ == "__main__":
    main()


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

using namespace std;
using ll = long long;

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

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_V(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_M(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}

int main() {
    int x, a;
    cin >> x >> a;
    if (x < a)cout << 0 << endl;
    else cout << 10 << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from math import ceil, floor

def solve(S: str):
    N = len(S)
    ans = [0] * N

    i = 0
    for i in range(N):
        # 配列をR..Lに分割する
        if((i == 0 and S[i] == 'R') or (S[i-1] == 'L' and S[i] == 'R')):
            try:
                idx = S[i:].index('LR')+i
            except:
                idx = N-1

            # RLのところに集中するのでカウントする
            sidx = S[i:idx+1].index('RL')
            # カウントはRがceil(S[i:idx]), Lがfloor(S[i:idx])
            ans[sidx+i] = ceil(len(S[i:idx+1])/2)
            ans[sidx+i+1] = floor(len(S[i:idx+1])/2)
            if(len(S[i:idx+1])%2 == 1 and S[i:idx+1].count('L')%2 == 1):
                ans[sidx+i], ans[sidx+i+1] = ans[sidx+i+1], ans[sidx+i]

            i = i+idx

    print(' '.join(map(str, ans)))
    # print(ans)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 13828
#include<bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
typedef long long  ll;


int main(){
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int &x : a)
        cin >> x;

    for(int i = 0 ; i < n ; ++i){
        if(i == 0 || a[i] > a[i - 1])a[i]--;

        if(i && a[i] < a[i - 1]){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
}


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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T>
struct edge {
    int src, to;
    T cost;

    // to, costで初期化
    edge (int to, T cost) : src(-1), to(to), cost(cost) {}

    // src, to, costで初期化
    edge (int src, int to, T cost) : src(src), to(to), cost(cost) {}

    // toにxを代入？
    edge &operator=(const int &x) {
        to = x;
        return *this;
    }
    
    // edge()でtoを返す？
    operator int() const {return to;}
};

// templates
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<Edges<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/*
 * Dijkstra
 * input: WeightedGraph<T> &g: グラフ
 *        int s: 始点
 * output: vector<T>: sから各要素への最短経路長
 */
template<typename T>
vector<T> dijkstra(WeightedGraph<T> &g, int s) {
    const auto INF = numeric_limits<T>::max();
    vector<T> dist(g.size(), INF);

    using Pi = pair<T, int>;
    priority_queue<Pi, vector<Pi>, greater<Pi>> que;
    dist[s] = 0;
    que.emplace(dist[s], s);
    while(!que.empty()) {
        T cost;
        int idx;
        tie(cost, idx) = que.top();
        que.pop();
        if(dist[idx] < cost) continue;
        for(auto &e : g[idx]) {
            auto next_cost = cost + e.cost;
            if(dist[e.to] <= next_cost) continue;
            dist[e.to] = next_cost;
            que.emplace(dist[e.to], e.to);
        }
    }
    return dist;
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int n, k; cin >> n >> k;
  WeightedGraph<int> g(n);
  Edges<int> e;
  for(int i=0;i<n-1;++i) {
    int a, b; cin >> a >> b;
    a--; b--;
    g[a].push_back(edge<int>(a, b, 1));
    g[b].push_back(edge<int>(b, a, 1));
    e.push_back(edge<int>(a, b, -1));
  }

  vector<vector<int>> dist(n);

  for(int i=0;i<n;++i) {
    dist[i] = dijkstra(g, i);
  }

  if(k % 2 == 0) {
    int mi = INF;
    for(int i=0;i<n;++i) {
      int cnt = 0;
      for(int j=0;j<n;++j) {
        if(dist[i][j] > k/2) {
          cnt++;
        }
      }
      mi = min(mi, cnt);
    }
    cout << mi << endl;
  } else {
    int sz = e.size();
    int mi = INF;
    for(int i=0;i<sz;++i) {
      int cnt = 0;
      int a = e[i].src;
      int b = e[i].to;
      for(int j=0;j<n;++j) {
        if(min(dist[a][j], dist[b][j]) > k/2) {
          cnt++;
        }
      }
      mi = min(mi, cnt);
    }
    cout << mi << endl;
  }


  
}


Measured memory_bytes: 16128
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 200010;

// aのn乗を求める。計算量はO(logn)
ll modpow(ll a, ll n) {
    if(n == 0) {
        return 1;
    }
    if(n%2 == 1) {
        return (a * modpow(a, n-1))%mod;
    }
    return (modpow(a, n/2) * modpow(a, n/2))%mod;
}

ll inverse(ll a) {
    return modpow(a, mod-2);
}

ll inv[MAX_N];  // inv[i] : iの逆数のmod
ll fact[MAX_N];  // fact[i] : iの階乗のmod
ll invfact[MAX_N];

void init() {
    inv[0] = fact[0] = invfact[0] = 1;
    inv[1] = 1;
    for(ll i = 1; i < MAX_N; i++) {
        if(i >= 2) {
            inv[i] = mod - inv[mod%i]*(mod/i)%mod;
        }
        fact[i] = (i*fact[i-1])%mod;
        invfact[i] = inverse(fact[i]);
    }
}
 
ll Comb(ll n, ll r) {
    if(r < 0 || n < 0 || n < r) {
        return 0;
    }
    ll res = fact[n];
    res = (res * invfact[r])%mod;
    res = (res * invfact[n-r])%mod;
    return res;
}

//--- main関数でinit()を呼び出すのを忘れるな ---//
int main() {
    ll h, w, a, b;
    cin >> h >> w >> a >> b;

    init();

    ll ans = 0;
    exrep(j, b, w-1) {
        ll x = Comb(h-a-1+j, h-a-1);
        ll y = Comb(w+a-2-j, a-1);
        ll z = (x*y)%mod;
        ans += z;
        ans %= mod;
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 4992
# coding: utf-8
# Your code here!
# 幅優先探索（行きがけ）

import sys


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N, K = LI()
    Aarray = LI()

    # start = 1
    # for i in range(K):
    #     start *= Aarray[i]

    # for i in range(K, N):
    #     now = start/Aarray[i-K]*Aarray[i]
    #     if now > start:
    #         print("Yes")
    #     else:
    #         print("No")
    #     start = now

    for i in range(K, N):
        now = Aarray[i-K]
        now2 = Aarray[i]
        if now2 > now:
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    main()


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

int main() {
  int N;
  cin >> N;
  string s;
  int x=0;
  for (int i = 0; i < N; i++) {
  cin >> s;
  if (s == "P" || s == "W" || s == "G") {
    x += 0;
  }
  else if (s == "Y") {
    x += 1;
  }
  }
  if (x == 0) {
    cout << "Three" << endl;
  }
  else if (x >= 1) {
    cout << "Four" << endl;

  }
}

Measured memory_bytes: 256