akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"OK":"NG")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int k,a,b;
	int ans=0;
	cin >>k>>a>>b;
	if((a/k !=b/k) or a%k==0){
		ans=1;
	}
	cout<<solve(ans)<<endl;
}

Measured memory_bytes: 3684
<?php

fscanf(STDIN, "%d", $x);

for ($i = -1000; $i <= 1000; ++$i) {
    for ($j = -1000; $j <= 1000; ++$j) {
        if ($x == pow($i, 5) - pow($j, 5)) {
            break 2;
        }
    }
}

echo "$i $j";


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

using namespace std;

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

#define ll long long int

int ctoi(char c) {return c-'0';}
int ord(char c) {return c-'a';}
int len(string s) {return s.length();}
int itoc(int i) {return i+'a';}

int main() {
int N;
cin>>N;
printf("%.12f",(double)N*N*N/27);
return 0;
}


Measured memory_bytes: 256
class SegTree():
    def __init__(self,data,unit,f):
        self.size=n=len(data)
        self.data=[unit for _ in range(n)]+data
        for i in range(n-1,0,-1):self.data[i]=f(self.data[i+i],self.data[i-~i])
        self.unit=unit
        self.f=f
    def update(self,i,x):
        c,f=self.data,self.f
        i+=self.size
        c[i]=x
        while i>1:
            i>>=1
            c[i]=f(c[i+i],c[i-~i])
    def add(self,i,x):
        c,f=self.data,self.f
        i+=self.size
        c[i]=f(c[i],x)
        while i>1:
            i>>=1
            c[i]=f(c[i+i],c[i-~i])
    def query(self,l,r):
        c,f=self.data,self.f
        x,y=self.unit,self.unit
        l+=self.size
        r+=self.size
        while l<r:
            if l&1:
                x=f(x,c[l])
                l+=1
            if r&1:
                r-=1
                y=f(c[r],y)
            l>>=1
            r>>=1
        return f(x,y)
def main():
    from fractions import gcd
    n,*a=map(int,open(0).read().split())
    f=SegTree(a,0,gcd).query
    m=max(f(1,n),f(0,n-1))
    for i in range(n-2):
        m=max(m,gcd(f(0,i+1),f(i+2,n)))
    print(m)
main()

Measured memory_bytes: 96952
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

int main()
{
   int n, v, num[2][N] = {};
   cin >> n;
   FOR(i, 0, n)
   {
      cin >> v;
      num[i % 2][v]++;
   }

   int even1 = 0, even2 = 0, odd1 = 0, odd2 = 0;
   FOR(i, 1, N)
   {
      if (num[0][i] > num[0][even1])
      {
         even2 = even1;
         even1 = i;
      }
      else if (num[0][i] > num[0][even2])
      {
         even2 = i;
      }

      if (num[1][i] > num[1][odd1])
      {
         odd2 = odd1;
         odd1 = i;
      }
      else if (num[1][i] > num[1][odd2])
      {
         odd2 = i;
      }
   }

   if (even1 != odd1)
   {
      cout << n - num[0][even1] - num[1][odd1] << endl;
   }
   else
   {
      if (num[0][even1] + num[1][odd2] > num[0][even2] + num[1][odd1])
      {
         cout << n - num[0][even1] - num[1][odd2] << endl;
      }
      else
      {
         cout << n - num[0][even2] - num[1][odd1] << endl;
      }
   }

   return 0;
}


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

const int MAX_N=2e5+20;
const int MOD = 1e9+7;
ll fact[MAX_N]; 
int H,W,A,B;

ll powmod(ll x, ll n)
{
	ll res=1;
	while(n){
		if(n&1) res = (res*x)%MOD;
		x = (x*x)%MOD;
		n >>=1;
	}
	return res;
}

ll C(ll n, ll m)
{
	ll a=fact[n];
	ll b=(fact[m]*fact[n-m])%MOD;
	return (a*powmod(b,MOD-2))%MOD;
}

void solve()
{
	fact[0]=1LL;
	for(ll i=1;i<MAX_N;++i) fact[i]=(fact[i-1]*i)%MOD;
	ll res = 0;
	for(ll i=B+1;i<=W;++i){
		ll cur=(C(i-1+H-A-1,H-A-1)*C(W-i+A-1, W-i))%MOD;
		res = (res + cur)%MOD;
	}
	cout << res << endl;
}

int main()
{
	cin >> H >> W >> A >> B;
	solve();
	return 0;
}

Measured memory_bytes: 1792
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;


int main(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  printf("%s", s.substr(0,k-1).c_str());
  if(s[k-1] == 'A') printf("a");
  else if(s[k-1] == 'B') printf("b");
  else printf("c");
  printf("%s\n", s.substr(k,n-k).c_str());
  return 0;
}


Measured memory_bytes: 256
/*
https://atcoder.jp/contests/abc044/submissions/4183707?lang=ja
勉強させていただいた提出
*/

#include <bits/stdc++.h>

using namespace std;

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


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

ll N,A;
ll x[60];

//DP問題だった

int main(){
    cin>>N>>A;
    ll ANS=0;
    int X=A;
    rep(i,N){
        cin>>x[i];
        if(X<x[i])X=x[i];
    }

	vector< vector < vector<ll> > > dp(N+1, vector<vector<ll> >(N+1, vector<ll>(X*N+1)));

    rep(i,N+1){
        rep(j,N+1){
            rep(k,X*N+1){
                if(i==0&&j==0&&k==0)dp[i][j][k]=1;
                else if(i>=1&&k<x[i-1])dp[i][j][k]=dp[i-1][j][k];
                else if(i>=1&&j>=1&&k>=x[i-1])dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-x[i-1]];
                else dp[i][j][k]=0;
            }
        }
    }
    REP(i,1,N+1){
        ANS+=dp[N][i][i*A];
    }
    cout<<ANS<<endl;

    return 0;
}


Measured memory_bytes: 52224
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
    int n,c,ans=100;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    rep(i,n){
        c=0;
        while(a[i]%2==0){
            a[i]/=2;
            c++;
        }
        ans=min(c,ans);
        
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int num[28];
  int ans[30]={0};
  int i;

  for(i=0;i<28;i++){
    scanf("%d", &num[i]);
    ans[num[i]-1]=1;
  }
  for(i=0;i<30;i++){
    if(ans[i]==0) printf("%d\n", i+1);
  }

  return 0;
}


Measured memory_bytes: 596
/**
 * Created by hiramekun at 20:47 on 2019-11-24.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */
struct edge {
    ll from, to, idx;

    edge() {};

    edge(ll from, ll to, ll idx) : from(from), to(to), idx(idx) {};
};

typedef vector<edge> ve;
typedef vector<ve> vve;


void solve() {
    ll n;
    cin >> n;

    vve g(n);
    rep(i, n - 1) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        g[a].eb(edge(a, b, i));
        g[b].eb(edge(b, a, i));
    }

    vb seen(n);
    vl ans(n - 1);
    auto dfs = [&](auto &&f, ll now, ll col) -> void {
        seen[now] = true;
        ll tmp = col;
        bool plus = false;
        each(e, g[now]) {
            if (seen[e.to]) continue;
            if (plus) tmp++;
            else if (tmp > 1) tmp--;
            else if (tmp <= 1) tmp = col + 1, plus = true;

            ans[e.idx] = tmp;
            f(f, e.to, tmp);
        }
    };
    dfs(dfs, 0, 0);
    cout << *max_element(all(ans)) << '\n';
    rep(i, n - 1) {
        cout << ans[i] << '\n';
    }
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 10112
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;


/* define */
#define Yes(X) puts ( (X) ? "Yes" : "No")
#define YES(X) puts ( (X) ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = (a); i < (b) ; i++)
#define REP(i, n) for ( int i = 0; i < (n) ; i++)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = 1000000007;

/* alias */
typedef long long ll;
typedef unsigned  u;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0) return Lgcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / Lgcd(a, b) * b;
}

/* main */


int main(){
	int n, a, b, c = 0, mem;
	cin >> n;
	REP(i, n) {
		cin >> a >> b;
		if (a > c) {
			c = a;
			mem = b;
		}
	}
	cout << c + mem << endl;
}

Measured memory_bytes: 384
use proconio::{input, marker::Usize1};

fn chmax(a: &mut Option<i32>, b: i32) {
    *a = Some(if let Some(v) = *a {
        v.max(b)
    } else {
        b
    });
}

fn rotate(x: &mut usize, y: &mut usize, z: &mut usize) {
    let w = *x;
    *x = *y;
    *y = *z;
    *z = w;
}

fn get_v(m: i32, l: Option<i32>) -> i32 {
    if let Some(l) = l {
        m.max(l + 1)
    } else {
        m
    }
}

struct DP {
    l12: Vec<Vec<Option<i32>>>,
    max: Vec<Option<i32>>,
    n: usize,
}

impl DP {
    fn new(n: usize) -> DP {
        DP {
            l12: vec![vec![None; n + 1]; n + 1],
            max: vec![None; n + 1],
            n: n,
        }
    }
    fn set(&mut self, l1: usize, l2: usize, v: i32) {
        if l2 != self.n {
            chmax(&mut self.l12[l1][l2], v);
            chmax(&mut self.l12[l2][l1], v);
            chmax(&mut self.max[l2], v);
        }
        chmax(&mut self.max[l1], v);
        chmax(&mut self.max[self.n], v);
    }
}

fn main() {
    input! {
        n: usize,
        a: [Usize1; n * 3],
    }

    let mut dp = DP::new(n);
    dp.set(a[0], a[1], 0);
    let mut c = 0; // counter, number of cuts 3 to 5 from the left.
    for i in 1..n {
        let (mut x, mut y, mut z) = (a[i * 3 - 1], a[i * 3], a[i * 3 + 1]);
        if x == y && x == z {
            c += 1;
        } else {
            let m = dp.max[dp.n].unwrap();
            let mut q = vec![];
            for _ in 0..3 {
                for l in 0..n {
                    if let Some(m) = dp.max[l] {
                        let v = if y == z { get_v(m, dp.l12[l][y]) } else { m };
                        q.push((l, x, v));
                    }
                }
                let v = if y == z { get_v(m, dp.max[y]) } else { m };
                q.push((x, n, v));

                let v = get_v(m, dp.l12[z][z]);
                q.push((x, y, v));

                rotate(&mut x, &mut y, &mut z);
            }

            for (x, y, v) in q {
                dp.set(x, y, v);
            }
        }
    }

    let l = a[3 * n - 1];
    let v = get_v(dp.max[dp.n].unwrap(), dp.l12[l][l]);
    println!("{}", v + c);
}


Measured memory_bytes: 33600
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

#define INF 100000000

int main() {
	int n;
	cin >> n;
	int h[30];
	int cnt = 0;
	int target = 0;
	rep(i, n) cin >> h[i];
	rep(i, n) {
		if (h[i] >= target) {
			cnt++;
			target = h[i];
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
string s;
int main()
{
    cin >> s;
    if (s == "SUN")
    {
        cout << 7 << endl;
    }
    else if (s == "MON")
    {
        cout << 6 << endl;
    }
    else if (s == "TUE")
    {
        cout << 5 << endl;
    }
    else if (s == "WED")
    {
        cout << 4 << endl;
    }
    else if (s == "THU")
    {
        cout << 3 << endl;
    }
    else if (s == "FRI")
    {
        cout << 2 << endl;
    }
    else if (s == "SAT")
    {
        cout << 1 << endl;
    }
    
    
}

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

using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;

int main() {
	int n, m; scanf("%d %d", &n, &m);
	vector<bool> working(n + 1, true);
	for (int i = 0; i < m; ++i) {
		int x; scanf("%d", &x);
		working[x] = false;
	}
	vector<ll> waysto(n + 1);
	waysto[0] = 1;
	for (int i = 1; i <= n; ++i) {
		if (working[i]) waysto[i] = (waysto[i-1] + (i >= 2 ? waysto[i-2] : 0)) % MOD;
	}
	printf("%lld\n", waysto[n]);
	return 0;
}

Measured memory_bytes: 1024
import sys
input = lambda: sys.stdin.readline().rstrip()

# SegmentTree
class SegmentTree:
  def __init__(self,n,p,unit,f):
    self.num=2**((n-1).bit_length())
    self.seg=[unit]*(2*self.num)
    for i in range(n):self.seg[i+self.num]=p[i]
    for i in range(self.num-1,0,-1):
      self.seg[i]=f(self.seg[i<<1],self.seg[(i<<1)+1])
    self.f=f
    self.unit=unit
  def update(self,i,x):
    i+=self.num
    self.seg[i]=x
    while i:
      i>>=1
      self.seg[i]=f(self.seg[i<<1],self.seg[(i<<1)+1])
  def query(self,l,r):
    ansl=ansr=self.unit
    l+=self.num
    r+=self.num-1
    if l==r:
      return self.seg[l]
    while l<r:
      if l&1:
        ansl=self.f(ansl,self.seg[l])
        l+=1
      if ~r&1:
        ansr=self.f(self.seg[r],ansr)
        r-=1
      l>>=1
      r>>=1
    if l==r:
      ansl=self.f(ansl,self.seg[l])
    return self.f(ansl,ansr)


n,q=map(int,input().split())
a=list(map(int,input().split()))
f=lambda x,y: max(x,y)
seg=SegmentTree(n,a,0,f)
for _ in range(q):
  t,a,b=map(int,input().split())
  if t==1:
    seg.update(a-1,b)
  if t==2:
    print(seg.query(a-1,b))
  if t==3:
    ng=a-1
    ok=n+1
    while ng+1!=ok:
      mid=(ng+ok)//2
      if seg.query(ng,mid)>=b:ok=mid
      else:ng=mid
    print(ok)

Measured memory_bytes: 98028
#include<bits/stdc++.h>
using namespace std;
char c[5][5];
int main(){
 cin>>c[0]>>c[1];
  bool o=c[0][0]==c[1][2]&&c[0][1]==c[1][1]&&c[0][2]==c[1][0];
  if (o)cout<<"YES"<<endl;else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
using ii=long long;
int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            swap(v[i], v[j]);
            int ok = 1;
            for (int it = 1; it < n; ++it) {
                if (v[it - 1] > v[it]) ok = 0;
            }
            if (ok) {
                cout << "YES\n";
                return 0;
            }
            swap(v[i], v[j]);
        }
    }
    int ok = 1;
    for (int i = 1; i < n; ++i) if (v[i - 1] > v[i]) ok = 0;
    if (ok) cout << "YES\n";
    else cout << "NO\n";
}


Measured memory_bytes: 256
n = int(input())
w = list(map(int,input().split()))
s1,s2 = 0,0
to = sum(w)

for i in range(n):
  if s1 < to//2:
    s1 += w[i]
  else:
    s2 = to - s1
    break
ans1 = abs(s1 - s2)

ss1,ss2 = 0,0
for i in range(n-1,0,-1):
  if ss1 < to//2:
    ss1 += w[i]
  else:
    ss2 = to - ss1
    break
ans2 = abs(ss2 - ss1)

print(min(ans1,ans2))
    
    


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

using namespace std;

typedef long long LL;

const int N = 110;

int n;

int main()
{
    cin >> n;
    if(n <= 111) puts("111");
    else if(n <= 222) puts("222");
    else if(n <= 333) puts("333");
    else if(n <= 444) puts("444");
    else if(n <= 555) puts("555");
    else if(n <= 666) puts("666");
    else if(n <= 777) puts("777");
    else if(n <= 888) puts("888");
    else if(n <= 999) puts("999");

    return 0;
}


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

int main(void){

    int a = 16;
    int b = 18;

    int d;
    int r;
    double f;
    
    std::cin >> a >> b;
    
    d = a / b;
    r = a % b;
    f = (double)a / (double)b;
    
    printf("%d %d %.5lf", d, r, f);

    return 0;
}

Measured memory_bytes: 3224
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int W, H;
char grid[70][70];
vector<char> dp[70][70];

vector<char> max_str(vector<char> str1, vector<char> str2)
{
	if (str1.size() > str2.size()) {
		return str1;
	}
	else if (str1.size() < str2.size()) {
		return str2;
	}
	else {
		bool ret1flag = false;

		rep(i, str1.size()) {
			if (str1[i] > str2[i]) {
				ret1flag = true;
				break;
			}
			else if (str2[i] > str1[i]) {
				break;
			}
		}

		if (ret1flag == true) {
			return str1;
		}
		else {
			return str2;
		}
	}
}

bool isranged(int y, int x)
{
	if (y >= 0 && y < H&&x >= 0 && x < W) {
		return true;
	}
	else {
		return false;
	}
}

int main()
{
	while (true) {		
		cin >> W >> H;

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

		rep(i, 70) {
			rep(j, 70) {
				dp[i][j].clear();
			}
		}

		rep(y, H) {
			rep(x, W) {
				cin >> grid[y][x];
			}
		}

		rep(y, H) {
			rep(x, W) {
				if (grid[y][x] >= 'A'&&grid[y][x] <= 'Z') {
					continue;
				}

				if (grid[y][x] >= '0'&&grid[y][x] <= '9') {
					if (isranged(y - 1, x) == true && isranged(y, x - 1) == true) {
						dp[y][x] = max_str(dp[y - 1][x], dp[y][x - 1]);
						if (grid[y][x] != '0' || dp[y][x].empty() != true) {
							dp[y][x].push_back(grid[y][x]);
						}
					}
					else if (isranged(y - 1, x) == true && isranged(y, x - 1) == false) {
						dp[y][x] = dp[y - 1][x];
						if (grid[y][x] != '0' || dp[y][x].empty() != true) {
							dp[y][x].push_back(grid[y][x]);
						}
					}
					else if (isranged(y - 1, x) == false && isranged(y, x - 1) == true) {
						dp[y][x] = dp[y][x - 1];
						if (grid[y][x] != '0' || dp[y][x].empty() != true) {
							dp[y][x].push_back(grid[y][x]);
						}
					}
					else {
						if (grid[y][x] != '0' || dp[y][x].empty() != true) {
							dp[y][x].push_back(grid[y][x]);
						}
					}
				}
			}
		}

		vector<char> answer;

		rep(y, H) {
			rep(x, W) {
				answer = max_str(dp[y][x], answer);
			}
		}

		rep(i, answer.size()) {
			cout << answer[i];
		}

		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3340
A = list(map(int,input().rstrip().split(" ")))
A.sort()
if A[0] == A[1]:
    if A[1] == A[2]:
        print(1)
    else:
        print(2)
else:
    if A[1] == A[2]:
        print(2)
    else:
        print(3)


Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
long long n,ans,a[100010];
int main()
{
	cin>>n;
	for(int  i=1;i<=n;i++ ) scanf("%lld",&a[i]);
    for(int i=1;i<=n;i++)
    {
    	ans+=a[i]/2;
		a[i]%=2;
		if(i<n&&a[i]&&a[i+1])
		{
			a[i]--;
			a[i+1]--;
			ans++;
		 } 
	}
	cout<<ans<<"\n";
	return 0;
 } 

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
int mod(ll a){return a%1000000007;};
typedef pair<int,int> i_i;

ll abss(ll a){
    if(a>0)return a;
    else return a*(-1);
}

int main(){
    int n;cin>>n;
    ll sum[n];for(int i=0;i<=n-1;i++)sum[i]=0;
    ll su=0;
    for(int i=0;i<=n-1;i++){
        int x;cin>>x;
        su+=x;
        sum[i]=su;
    }
    ll min=(ll)200000*1000000000;
    for(int i=0;i<=n-2;i++){
        if(abs(sum[i]*2-su)<min)min=abs(sum[i]*2-su);
    }
    cout<<min<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = (a) ;i < (b) ;i++)
#define repr(i, a, b) for (int i = (b) - 1 ;i >= a ;i--) 
int main(){
	string S ;
	int K, tmp ;
	cin>>S>>K ;
	rep(i, 0, S.size()){
		tmp = ('z' + 1 - S[i]) % 26 ;
		if (tmp <= K){
			K -= tmp ;
			S[i] = 'a' ;
		}
	//	cout<<i<<' '<<tmp<<' '<<K<<' '<<S<<endl;
	}
	K %= 26 ;
	S[S.size() - 1] = ((S[S.size() - 1] + K - 'a') % 26) + 'a' ;
	cout<<S<<endl ;
	return 0 ;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<queue>
#define For(i,j,k)	for(ll i=j;i<=k;++i)
#define Dow(i,j,k)	for(ll i=k;i>=j;--i)
#define ll long long
using namespace std;
inline ll read()
{
    ll t=0,f=1;char c=getchar();
    while(c<'0'||c>'9')	{if(c=='-')	f=-1;	c=getchar();}
    while(c>='0'&&c<='9')	t=t*10+c-'0',c=getchar();
    return t*f;
}
inline void write(ll x){if(x>=10)	write(x/10);putchar(x%10+'0');}
inline void writeln(ll x){write(x);puts("");}
inline void write_p(ll x){write(x);putchar(' ');}
string s;
int cnt [4],mx,mn;
int main()
{
	cin>>s;
	int len=s.length();
	For(i,0,len)	cnt[s[i]-'a']++;
	mx=max(cnt[0],max(cnt[1],cnt[2]));
	mn=min(cnt[0],min(cnt[1],cnt[2]));
	if(mx-mn>1)	puts("NO");else puts("YES");
}

Measured memory_bytes: 512
n = int(input())
s = input()
l = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']

ans = []
for i in s:
  ans.append(l[l.index(i)+n])

  
for i in range(len(ans)):
  print(ans[i], end = '')

Measured memory_bytes: 4596
n = int(input())
a = [0]*n
b = [0]*n

for i in range(n):
    a[i],b[i] = map(int,input().split())

a.sort(reverse=True)
b.sort()
aa,bb = a[0],b[0]
count = b[0]

for i in range(1,n):
    count += min(aa-a[i],b[i]-bb)
    aa = a[i]
    bb = b[i]

print(count+aa)


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

const int N = 200 + 10;
bool adj[N][N];
int h[N], n;

int bfs(int root) {
	fill(h, h + n, -1);
  	queue<int> q;
  	q.push(root);
  	h[root] = 1;
  	while (q.size()) {
      	int v = q.front();
      	q.pop();
      	for (int i = 0; i < n; i++) {
          	if (h[i] == -1 && adj[v][i]) {
				q.push(i);
              	h[i] = h[v] + 1;
            }
        }
    }
  	int res = 0;
  	for (int i = 0; i < n; i++)
      	res = max(res, h[i]);
  	for (int i = 0; i < n; i++)
      	for (int j = 0; j < n; j++)
          	if (adj[i][j] && abs(h[i] - h[j]) != 1)
              	res = -1;
	return res;
}

int main() {
  	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  	cin >> n;
  	string s;
  	for (int i = 0; i < n; i++) {
      	cin >> s;
    	for (int j = 0; j < n; j++)
          	adj[i][j] = s[j] - '0';
    }
  	int ans = -1;
  	for (int i = 0; i < n; i++)
      	ans = max(ans, bfs(i));
	cout << ans << "\n";
  	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}
 
int main(){
  string S;
  cin>>S;
  bool ok=false;
  if(S[0]==S[1]&&S[2]==S[3]&&S[0]!=S[2]) ok=true;
  if(S[0]==S[3]&&S[1]==S[2]&&S[0]!=S[2]) ok=true;
  if(S[0]==S[2]&&S[1]==S[3]&&S[0]!=S[1]) ok=true;
  if(ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
  

Measured memory_bytes: 256
#coding:utf-8
def Graph(n,A):
    ans=[]
    for i in range(n):
        line=[]
        for j in range(n):
            line.append(0)
        ans.append(line)
    for i in range(n):
        if A[i][1]!=0:
            for j in range(A[i][1]):
                ans[i][A[i][2+j]-1]=1
    for i in range(n):
        for j in range(n):
            ans[i][j]=str(ans[i][j])
        print(" ".join(ans[i]))
 
 
if __name__=="__main__":
    n=int(input())
    A=[]
    for i in range(n):
        A.append(list(map(int,input().split(" "))))
    Graph(n,A)

Measured memory_bytes: 8140
fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    val AArr = readInputLine().split(" ").map { it.toLong() }.reversed().toLongArray()

    if (AArr[0] != 2L) {
        println(-1)
        return
    }

    var min = 2L
    var max = 2L

    for (i in 0 until N) {
        if (max / AArr[i] == min / AArr[i] && min % AArr[i] != 0L) {
            println(-1)
            return
        }

        min = AArr[i] * (min / AArr[i] + if (min % AArr[i] == 0L) 0L else 1L)
        max = AArr[i] * (max / AArr[i]) + AArr[i] - 1L
    }

    println("$min $max")
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 74552
A, B, M =  map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

xyc = [list(map(int,input().split())) for _ in range(M)]

min_a = min(a)
min_b = min(b)

min_cost = min_a + min_b

for i in range(M):
    kari = a[xyc[i][0]-1] + b[xyc[i][1]-1] -xyc[i][2]
    if kari < min_cost:
        min_cost = kari
        
print(min_cost)

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

using namespace std;
using LL = long long;
const int N = 1024;
const int INF = INT32_MAX - 1;
const double EPS = 1E-9;

int a[N];
int n, m;

int main() {
    ios_base::sync_with_stdio(false);

#ifdef CF_DEBUG
    freopen("../cf/input.txt", "r", stdin);
#endif
    int a, b;
    cin >> a >> b;
    int ok = -1;
    for (int i = 1; i <= 2000; ++i) {
        if (floor(i * 0.08) == a && floor(i * 0.1) == b) {
            ok = i;
            break;
        }
    }
    cout << ok;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = INT32_MAX;
const long long int Mod = 1000000007;
const long long int mod = 100000;//10^5
using ll = long long int; //long long int は64bit
using ci = const int; using vi = vector<int>; using Vi = vector<long long int>; using pii = pair<int,int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
//       cin.tie(0);ios::sync_with_stdio(false);
void cinit(){cin.tie(0);ios::sync_with_stdio(false);}
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
constexpr int MAXN = 1e5 + 5;
#define pii pair<int, int>
typedef long long LL;
typedef unsigned long long uLL;
using namespace std;
inline int read(){
    int x = 0, f = 1;
    char ch = getchar();
    while(!isdigit(ch)) f = (ch == '-') ? -1 : 1, ch = getchar();
    while(isdigit(ch)) x = (x << 3) + (x << 1) + ch -48, ch = getchar();
    return x * f;
}
int n, k, cnt;
int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n >> k;
	while (n) {
		n /= k;
		cnt ++;
	}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int n = 0;
    int m = 0;
    n = N*(N-1)/2;
    m = M*(M-1)/2;
    System.out.println(n+m);   
    return;
  }
}

Measured memory_bytes: 23636
(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());

  let i, j, X, Y, xlen, ylen, maxlen;
  let c;
  let str = '';
  while ((X = lines.shift()) && (Y = lines.shift())) {
    xlen = X.length;
    ylen = Y.length;
    c = Array.from(Array(xlen + 1), () => []);

    for (i = 1; i <= xlen; i++) {
      for (j = 1; j <= ylen; j++) {
        if (X[i-1] === Y[j-1]) c[i][j] = c[i - 1][j - 1] + 1||1;
        else c[i][j] = Math.max(c[i - 1][j]||0, c[i][j - 1]||0);
      }
    }
    str += `${c[xlen][ylen]}\n`;
  }
  process.stdout.write(str);
})();



Measured memory_bytes: 148644
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
#define pb push_back
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;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, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

int bin_pow(int a, int b) {
    int ret = 1;
    while (b > 0) {
        if (b & 1) ret = (ret * a);
        a = (a * a);
        b >>= 1;
    }
    return ret;
}

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

    if (N == 0) {
        cout << "0" << endl;
        return 0;
    }

    string S;
    int p = 2;
    int idx = 0;
    REP(i, 40) {
        if (N % p == 0) {
            S = "0" + S;
        } else {
            S = "1" + S;
            N += (p / 2) * (idx % 2 == 0 ? -1 : 1);
        }
        p <<= 1;
        idx++;
    }
    
    idx = 0;
    while (S[idx] == '0') idx++;
    for(; idx < SZ(S); idx++) putchar(S[idx]);
    putchar('\n');
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int A = 0, B = 0, C = 0, K = 0;
		int a = 0, b = 0, c = 0;
		Scanner sc = new Scanner(System.in);
		A = Integer.parseInt(sc.next());
		B = Integer.parseInt(sc.next());
		C = Integer.parseInt(sc.next());
		K = Integer.parseInt(sc.next());
		if (K - A >= 0) {
			a = A;
			K = K - A;
		} else {
			a = K;
			K = 0;
		}
		if (K - B >= 0) {
			b = B;
			K = K - B;
		} else {
			b = K;
			K = 0;
		}
		if (K - C >= 0) {
			c = C;
			K = K - C;
		} else {
			c = K;
			K = 0;
		}
		System.out.println(a + c * (-1));
	}

}


Measured memory_bytes: 26968
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

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

  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << min(a, b) + min(c, d) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long ll;

int main(void){
    int x,y;
    cin>>x>>y;
    int c=0;
    rep(i,x+1){
        if(2*i+(x-i)*4==y)c=1;
    }
    if(c){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

}

Measured memory_bytes: 3604
# -*- coding: utf-8 -*-
import sys, re, copy, math, itertools
from copy import *
from collections import deque, defaultdict
from heapq import *
from bisect import *
#import numpy as np
#import scipy as sp

# 読み込み
N = int( input() )
K = int( input() )

min_x = 2147483647 // 2

for A in range(N):
    x = 1
    for a in range(A):
        x *= 2
    for b in range(N-A):
        x += K
    
    if x < min_x:
        min_x = x

for B in range(N):
    x = 1
    for b in range(B):
        x += K
    for a in range(N-B):
        x *= 2
    
    if x < min_x:
        min_x = x

print(min_x)

Measured memory_bytes: 3692
S = input()

n = len(S)

medalist = [0] * 2019
medalist[0] = 1
num = 0
mods = 1

for i in range(n):
    fig = int(S[n - i - 1])
    num = (num + fig * mods) % 2019
    medalist[num] = medalist[num] + 1
    mods = (mods * 10) % 2019

result = 0

for i in range(2019):
    m = medalist[i]
    if m != 0:
        result += m * (m - 1) / 2

print(int(result))

Measured memory_bytes: 9292
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>

#include <stdio.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, k, n) for (int i = (k); i < (n); i++)
#define rrep(i, k, n) for (int i = (k); i >= (n); i++)
#define pb push_back
#define eb emplace_back
#define vec vector

typedef long long ll;

template<class T> bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template<class T> bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<class T> T gcd(T m, T n) {
  if (n == 0) return m;
  return gcd(n, m % n);
}

template<class T> T lcm(T m, T n) {
  return m * n / gcd(m, n);
}

const ll inf = 1LL << 60;
const ll mod = 1e9 + 7;

using namespace std;

/* Input variables. */
int n, m;
vec<bool> a;
vec<int> dp;

/* Solve! */
void solve() {
  dp = vec<int>(n + 1, 0);
  dp[0] = 1;
  irep(i, 1, n + 1) {
    if (a[i]) {
      dp[i] += dp[i - 1];
      dp[i] %= mod;
      if (i >= 2) {
        dp[i] += dp[i - 2];
        dp[i] %= mod;
      }
    }
  }
  cout << dp[n] << endl;
}

int main() {
  /* Input handling. */
  cin >> n >> m;
  a = vec<bool>(n + 1, true);
  rep(i, m) {
    int t; cin >> t;
    a[t] = false;
  }

  solve();
  return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define pb push_back
#define mkp make_pair
#define maxx 10000005
#define MOD 1000003
#define sf(n) scanf("%lld", &n);
#define sff(n,m) scanf("%lld %lld", &n, &m)
#define pf(n) printf("%lld\n", n)
#define pff(n,m) printf("%lld %lld\n", n, m)
#define mem(a) memset(a, 0, sizeof(a))
#define fr(i,n) for(ll i=0; i<n; i++)
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type))
#define pi 2*acos(0.0)
#define F first
#define S second
#define EPS 1e-9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll n,m;
    cin>>n>>m;
    ll arr[n+5];
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    reverse(arr,arr+n);
    for(int i=0;i<n;i++)
    {
        sum+=arr[i];
        //cout<<arr[i]<<" ";
    }
    //cout<<sum<<endl;
    if(m>n)
        cout<<0<<endl;
    else
    {
        ll sm=0;
        for(int i=0;i<m;i++)
        {
            sm+=arr[i];
        }
        cout<<sum-sm<<endl;
    }


}



Measured memory_bytes: 1792
import sys
from collections import defaultdict as dd
input = sys.stdin.readline
N = int(input())
e = dd(list)
mod = 10 ** 9 + 7
for _ in range(N - 1):
  u, v = map(int, input().split())
  e[u].append(v)
  e[v].append(u)

class Factorial:
  def __init__(self, n, mod):
    self.f = [1]
    for i in range(1, n + 1):
      self.f.append(self.f[-1] * i % mod)
    self.i = [pow(self.f[-1], mod - 2, mod)]
    for i in range(1, n + 1)[: : -1]:
      self.i.append(self.i[-1] * i % mod)
    self.i.reverse()
  def factorial(self, i):
    return self.f[i]
  def ifactorial(self, i):
    return self.i[i]
  def combi(self, n, k):
    return self.f[n] * self.i[n - k] % mod * self.i[k] % mod

f = Factorial(N, mod)

class ReRooting:
  def ReRfunc(self, x):
    y = self.parent[x]
    return self.res[y] * self.size[x] % mod * pow(self.n - self.size[x], mod - 2, mod) % mod

  def __init__(self, n, e):
    self.n = n
    self.e = e
    self.vis = [0] * (n + 1)
    self.order = []
    self.parent = [-1] * (n + 1)
    self.ddp = [0] * (n + 1)
    self.udp = [0] * (n + 1)
    self._dfs()
    self.size = [1] * (n + 1)
    self.order.reverse()
    for x in self.order[: -1]: self.size[self.parent[x]] += self.size[x]
    self.res = [0] * (n + 1)
    #初期化の値
    self.res[1] = f.factorial(N)
    for x in range(1, N + 1): self.res[1] = self.res[1] * pow(self.size[x], mod - 2, mod) % mod

    self.order.reverse()
    for x in self.order[1: ]: self.res[x] = self.ReRfunc(x)

  def _dfs(self):
    s = [1]
    while len(s):
      x = s.pop()
      self.vis[x] = 1
      self.order.append(x)
      for y in self.e[x]:
        if self.vis[y]: continue
        s.append(y)
        self.parent[y] = x

  def Size(self, x):
    return self.size[x]

  def Query(self, x):
    return self.res[x]

rer = ReRooting(N, e)
for x in range(1, N + 1): print(rer.Query(x) % mod)

Measured memory_bytes: 121820
#include <bits/stdc++.h>
#define ll long long 
#define rep(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define endl "\n"
#define dd double
#define mp make_pair
#define fi first
#define se second
#define ull unsigned int long long
const int INF = INT_MAX;
#define INFL LLONG_MAX
#define f_scan  ios_base::sync_with_stdio(!cin.tie(0))
#define all(x) x.begin(),x.end()
#define mod 1000000007
#define deci(n) fixed << setprecision(n)
using namespace std;
int main()
{
    f_scan;
    string s;
    cin>>s;
    if(s=="ABC")
    {
        cout<<"ARC"<<endl;
    }
    else
    {
        cout<<"ABC"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3640
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re


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():
    S1 = S()
    T = S()

    cnt = 0

    for i, s in enumerate(S1):
        if T[i] != s:
            cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10280
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;


int main()
{
	ll N;
	cin >> N;
	cout << N * (N - 1) / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include "stdio.h"
#include "iostream"
using namespace std;


int main()
{
	int a, b;
	cin >> a >> b;
	int i, j, k;
	int c = 0,t;
	for (i = 1;i <= 9;i++)for (j = 0;j <= 9;j++)for (k = 0;k <= 9;k++) {
		t = 10001 * i + 1010 * j + 100 * k;
		if (a <= t && t <= b)c++;
	}
	printf("%d", c);
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var t=sc.S;
		Console.WriteLine("{0}",t[0]==t[1]||t[1]==t[2]||t[2]==t[3]?"Bad":"Good");
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <stdio.h>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long

signed main(){
  int n,k;
  cin >> n >> k;
  int ans = 0;
  int mot = 0;
  LOOP1(i,n){
    int j = i;
    int cnt = 1;
    while(j<k){
      cnt*=2;
      j*=2;
    }
    if(i==1)mot = cnt;
    ans += mot/cnt;
  }
  double ansans = (double)ans / (mot * n);
  printf("%.10f\n", ansans);

}


Measured memory_bytes: 256