akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
using namespace std;
char s[111][111];
int dis[111][111];
bool vis[111][111];
int n,m;
int mx[10]={0,1,-1,0,0};
int my[10]={0,0,0,1,-1};
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	  for(int j=1;j<=m;j++)
	    cin>>s[i][j];
	       	 int maxx=0;
   for(int i=1;i<=n;i++)
   for(int j=1;j<=n;j++)
   {
   	if(s[i][j]!='.')continue;
   	memset(dis,0,sizeof(dis));
   	memset(vis,0,sizeof(vis));
   	 queue<pair<int,int> >q;
   	 q.push(make_pair(i,j));
   	 vis[i][j]=1; 
   	 while(!q.empty())
   	 {
   	 	int x=q.front().first;
   	 	int y=q.front().second;
   	 	q.pop();
   	 	for(int k=1;k<=4;k++)
   	 	  {
   	 	  	int xx=x+mx[k];
   	 	  	int yy=y+my[k];
   	 	  	if(xx<1||yy<1||xx>n||yy>m)continue;
   	 	  	if(vis[xx][yy])continue;
   	 	  	if(s[xx][yy]!='.')continue;
   	 	  	vis[xx][yy]=1;
   	 	  	q.push(make_pair(xx,yy));
   	 	  	dis[xx][yy]=dis[x][y]+1;
   	 	  	maxx=max(maxx,dis[xx][yy]);
   	 	  }
   	 }
   }
   cout<<maxx<<endl;
}

Measured memory_bytes: 3692
#include <iostream>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

using pii = pair<int, int>;
struct rwv {
    int left;
    int right;
    int value;
    rwv(int l, int r, int v) : left(l), right(r), value(v) {}
};

int main() {
    string s;
    cin >> s;
    stack<pii> stk;
    vector<rwv> rs; 
    int sum = 0;
    int h = 0;
    int x = 0;
    stk.push(pii(0, 0));
    for(char c : s) {
        x++;
        if(c=='\\') {
            h--;
        } else if(c=='/') {
            h++;
            stk.pop();
            if(!stk.empty()) {
                pii cur = stk.top();
                stk.pop();
                int ds = x - cur.first - 1;
                sum += ds;
                int cs = ds;
                while(!rs.empty() && rs.back().left > cur.first) {
                    rwv pre = rs.back();
                    rs.pop_back();
                    cs += pre.value;
                }
                rs.push_back(rwv(cur.first, x, cs));
            }
        } else {
            stk.pop();
        }
        stk.push(pii(x, h));
    }
    cout << sum << endl;
    cout << rs.size();
    for(auto&& v : rs) {
        cout << " " << v.value;
    }
    cout << endl;
}


Measured memory_bytes: 3252
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std;
int main() {
	int N, x = 0, ans = 0;
	char S;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> S;
		if (S == 'I')x++;
		else x--;
		ans = max(ans, x);
	}
	cout << ans;
}


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

using namespace std;

#define MAX 100000

int main(){

    vector<bool> pr(MAX,true);
    vector<int> prime;
    for(int i = 2; i < MAX; i++)if(pr[i]){
        prime.push_back(i);
        for(int j = 2; i*j < MAX; j++)pr[i*j] = false;
    }
    int n;
    while(cin >> n){
        int ans = lower_bound(prime.begin(),prime.end(),n) - prime.begin()-1;
        if(prime[ans+1] == n)
            cout << prime[ans] << " " << prime[ans+2] << endl;
        else
            cout << prime[ans] << " " << prime[ans+1] << endl;
    }
}



Measured memory_bytes: 3292
#include <stdio.h>

int main(){
	int x,y,z;
	scanf("%d %d %d", &x, &y, &z);
	int tamP = y+z+z;
	int cont = 0;
	while(tamP <= x){
		tamP = tamP + y+z;
		cont++;
	}
	printf("%d\n",cont);
	return 0;
}


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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	string s;

	cin >> s;
	for(int i = 0; i < 8; i++)
		s.pop_back();

	cout << s << endl;

	return 0;
}

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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)

// policy-based
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;	


using namespace std;


typedef long long ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

/*
typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
 
const ll MAX = 2e6+100;
const ll inf = 1e15;


int main(){
	fastio;
	ll a,b,c;
	cin >> a >> b >> c;
	cout << ((a+b-1)/b)*c << endl;
}

Measured memory_bytes: 3608
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
//        sc.useDelimiter(",");
//        DecimalFormat df = new DecimalFormat("0.00000000");

        char[] ch = sc.next().toCharArray();
        boolean ans = false;
        for (int i = 0; i < ch.length; i++)
            if (ch[i] == '7') ans = true;
        out.println(ans ? "Yes" : "No");
        out.flush();
    }
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  long double r; cin >> r;
  cout << setprecision(10) << r*2*M_PI << endl;
  return 0;
}


Measured memory_bytes: 3792
n = int(input())
s = [input(),input()]
tate = []
i = 0
while i < n:
    if s[0][i] != s[1][i]:
        tate.append(0)
        i += 2
    else:
        tate.append(1)
        i += 1
ans = 6 - tate[0]*3
mod = 1000000007
for i in range(len(tate) - 1):
    if tate[i] ^ tate[i+1]:
        if tate[i]:
            ans *= 2
            ans %= mod
    else:
        if tate[i]:
            ans *= 2
        else:
            ans *= 3
        ans %= mod
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define N 200100
#define pii pair<int,int>
#define rep(i,k,n) for(int i=k;i<n;i++)
#define vi vector<int>
#define inf 1e9
void solve(){
	int a,b;
	cin>>a>>b;
	if(a<b){
		for(int i=0;i<b;i++){
			cout<<a;
		}
	}
	else{
		rep(i,0,a){
			cout<<b;
		}
	}
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

const ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    for(ll i=1;i<=n;i++){
        if(i<=k)continue;
        ll m=n/i;
        ll s=n%i;
        ans+=(i-k)*m;
        ans+=max(0LL,s-k+1);
        if(k==0&&m>0)ans--;
    }
    cout<<ans<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    int P = 2;
    ll ans = A[0] - 1;
    repd(i, 1, N) {
        ll cnt = A[i] / P;
        if (A[i] % P == 0) cnt--;
        if (A[i] == P) P++;
        ans += cnt;
    }

    cout << ans << endl;
    return 0;
}

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

#define mod 1000000007

int main() {
    int N, K;
    cin >> N >> K;
    vector<int>a(N-1);
    vector<int>b(N-1);
    for (int i = 0; i < N-1; ++i) {
      cin >> a[i] >> b[i];
    }

    if(N == 1) {
        cout << K;
        return 0;
    }

    vector<int> graph[N+1];
    for (int i = 0; i < N - 1; ++i) {
        graph[a[i]].push_back(b[i]);
        graph[b[i]].push_back(a[i]);
    }

    vector<int>flag(N+1, 0);
    int s;
    for (int i = 1; i <= N; ++i) {
        if(graph[i].size() == 1){
            s = i;
            break;
        }
    }
    ll ans = K;
    flag[s] = 1; // sを塗る
    queue<int> que;
    que.push(graph[s][0]);
    flag[graph[s][0]] = 1;
    ans = ans * (K-1) % mod;
    while (! que.empty()){
        int t = que.front();
        que.pop();
        int count = K-2;
        for (int x : graph[t]) {
            if(flag[x] == 0){
                flag[x] = 1;
                que.push(x);
                ans = ans * count % mod;
                count--;
            }
        }
    }

    cout << ans;
    return 0;
}

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

struct Node {
    int parent = -1;
    vector<int> children = vector<int>();
    int counter = 0;
};

int N, Q;
vector<Node> T;

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

    T.resize(N);

    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--; // to 0 origin

        T[a].children.push_back(b);
        T[b].children.push_back(a);
    }

    rep(i, Q) {
        int p, x;
        cin >> p >> x;
        p--; // to 0 origin
        T[p].counter += x;
    }



    vector<ll> sums(N, 0);
    queue<int> qu;
    qu.push(0);

    while (!qu.empty()) {
        int idx = qu.front();
        sums[idx] += T[idx].counter;
        Node& n = T[idx];
        for (int i = 0; i < n.children.size(); ++i) {
            int cidx = n.children[i];
            if (cidx == T[idx].parent) continue;
            T[cidx].parent = idx;
            qu.push(cidx);
            sums[cidx] = sums[idx];
            
        }

        qu.pop();

    }

    rep(i, N) {
        cout << sums[i];
        if (i < N - 1) cout << ' ';
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 19444
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
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; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  ll n;cin>>n;
  vector<ll> a(n),b(n);
  vector<P> p(n);
  rep(i,n){
    cin>>a[i]>>b[i];
    p[i]=P(a[i]+b[i],i);
  }
  sort(all(p),greater<P>());
  ll d=0LL,e=0LL;
  rep(i,n){
    ll f=p[i].second;
    if(i%2){
      e+=b[f];
    }else{
      d+=a[f];
    }
  }
  cout<<d-e;
}

Measured memory_bytes: 3328
import java.io.*;// 从这行开始复制，这是第一行
import java.util.*;


public class Main {

    /**
     * TODO 提交的时候一定要设置为 true
     */
    private boolean submitFlag = true;

    private void solve() {
        int ans = 0;


        System.out.println(ans);
    }


    private void run() throws IOException {
        setReader();

        //TODO 从这里开始读入题目输入
        int numberOfTestcases = 5;

        for (int t = 0; t < numberOfTestcases; t++) {
            long a = nextLong();
            if (a == 0) {
                System.out.println(t + 1);
                return;
            }
        }

    }


//    main以及输入输出========================================================================

    public static void main(String[] args) throws IOException {
        Main solution = new Main();
        solution.run();
        solution.reader.close();
    }

    /**
     * TODO 存档时，改一下moduleName
     */
    String moduleName = "atcoder-race";

    /**
     * 注意不同题目这里路径要设一下
     *
     * @throws IOException
     */
    private void setReader() throws IOException {
        if (submitFlag) {
            reader = new BufferedReader(new InputStreamReader(System.in));
        } else {
            String projectPath = System.getProperty("user.dir");
            String modulePath = projectPath + "/" + moduleName + "/src/main/java/";
            String className = this.getClass().getPackage().getName().replace(".", "\\");
            reader = new BufferedReader(new FileReader(modulePath + className + "\\input.txt"));
        }
    }

    private BufferedReader reader;
    private StringTokenizer tokenizer;

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

    private long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    private double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    private String next() throws IOException {
        return nextToken();
    }

    private String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}


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

int main(){
  int N,b,c;
  c=0;
  cin>>N;
  b=N;
  for (int i=0;i<8;i++){
    c +=b%10;
    b =b/10;
  }
  if(N%c==0){
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <stdarg.h>
#include <algorithm>
#include <iostream>

#define ll long long

using namespace std;

int
main() {
 
  ll n;
  cin>>n;

  ll best = n-1;
  for (ll i=2; i<=1000000; i++)
    if (n % i == 0) {
      ll right = n / i;
      best = min(best, right + i - 2);
    }

  cout<<best<<endl;
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 100005
#define NIL -1
struct Node_struct{int p, l, r, sib;}; /*p: 親(parent), l: 一番左の子(left chil\
d), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];
int deg[MAX];
int hei[MAX];

void print(int u){
  int i, c;
  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height =\
 %d, ", u, T[u].p, T[u].sib, deg[u], D[u], hei[u]);

  if(T[u].p == -1) printf("root");
  else if(T[u].l == NIL && T[u].r == NIL) printf("leaf");
  else printf("internal node");
  printf("\n");

}
void calcDegree(int n){
  int i;
  for(i=0;i<n;i++){
    deg[i] = 0;
  }
  for(i=0;i<n;i++){
    if(T[i].p != -1) deg[T[i].p]++;
  }
}

void calcDepth(int u, int p){
  D[u] = p;
  if(T[u].r != NIL) calcDepth(T[u].r, p+1);
  if(T[u].l != NIL) calcDepth(T[u].l, p+1);
}


int max(int a ,int b){
  if(a>b) return a;
  else return b;
}

int calcHeight(int n){
  int h1 = 0, h2 = 0;
  if(T[n].l != NIL) h1 = calcHeight(T[n].l) +1;
  if(T[n].r != NIL) h2 = calcHeight(T[n].r) +1;

  return hei[n] = max(h1, h2);
}




int main(){
  int i, j, k;
  int n;
  int id, child1, child2;
  int root = NIL;
  scanf("%d", &n);
  for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = T[i].sib = NIL;

  for(i=0; i<n; i++){
    scanf("%d %d %d", &id, &child1, &child2);
    T[id].l = child1;
    T[id].r = child2;
    if(child1 != NIL) T[child1].p = id;
    if(child2 != NIL) T[child2].p = id;
    T[child1].sib = child2;
    T[child2].sib = child1;
  }




  //根を求める (find the root)                                                  
  for(i=0; i<n; i++){
    if(T[i].p == -1) root = i;
  }

  calcDegree(n);// ノードの子の数を求める                                       

  //それぞれのノードの深さを求める (find depth of each node)                    
  calcDepth(root, 0);

  calcHeight(root);


  //出力 (output)                                                               
  for(i=0; i<n; i++) print(i);

  return 0;
}



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

 using namespace std;
 typedef long long ll;
 #define rep(i, n) for(int i = 0; i < (int)(n); i++)

 int main() {
   int n;
   cin >> n;
   vector<int> a(n), A;
   rep(i, n) cin >> a.at(i);

   rep(i, n) {
     if (i % 2 == 0) A.insert(A.begin(), a.at(i));
     else A.push_back(a.at(i));
   }
   if (n % 2 == 0) reverse(A.begin(), A.end());

   rep(i, n - 1) {
     cout << A.at(i) << " ";
   }
   cout << A.at(n - 1) << endl;
 }


Measured memory_bytes: 3828
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn=1e5+100;
const int mod=1e9+7;
char s[maxn];
LL a[maxn],c[maxn],ql[maxn],qr[maxn];
LL pow3[maxn];

int main()
{
    //freopen("1.txt","r",stdin);
    memset(pow3,0,sizeof(pow3));
    pow3[0]=1;
    for (int i=1;i<maxn;i++)
        pow3[i]=(pow3[i-1]*3)%mod;

    while (scanf("%s",s+1)!=EOF)
    {
        memset(a,0,sizeof(a));
        memset(c,0,sizeof(c));
        memset(ql,0,sizeof(ql));
        memset(qr,0,sizeof(qr));
        int len=strlen(s+1);
        for (int i=1;i<=len;i++)
        {
            if (s[i]=='A') a[i]=a[i-1]+1;
            else a[i]=a[i-1];
            if (s[i]=='?') ql[i]=ql[i-1]+1;
            else ql[i]=ql[i-1];
        }

        for (int i=len;i>=1;i--)
        {
            if (s[i]=='C') c[i]=c[i+1]+1;
            else c[i]=c[i+1];
            if (s[i]=='?') qr[i]=qr[i+1]+1;
            else qr[i]=qr[i+1];
        }

        LL sum=0;
        for (int i=1;i<=len;i++)
        {
            if (s[i]=='?' || s[i]=='B')
            {
                LL o1=(a[i-1]*c[i+1]%mod)*pow3[ql[i-1]+qr[i+1]]%mod;
                LL o2=(a[i-1]*qr[i+1]%mod)*pow3[ql[i-1]+qr[i+1]-1]%mod;
                LL o3=(c[i+1]*ql[i-1]%mod)*pow3[ql[i-1]+qr[i+1]-1]%mod;
                LL o4=(ql[i-1]*qr[i+1]%mod)*pow3[ql[i-1]+qr[i+1]-2]%mod;
                sum=(((((((sum+o1)%mod)+o2)%mod)+o3)%mod)+o4)%mod;
            }
        }
        printf("%lld\n",sum);
    }
    return 0;
}


Measured memory_bytes: 4224
#define DEBUGGING  // Enables DEBUG macro.
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifndef DEBUGGING
#define debug(...)
#define DEBUG(...)
#else
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                     \
  do {                                 \
    cerr << " (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ": ";      \
    debug(__VA_ARGS__);                \
    cerr << endl;                      \
  } while (0)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> adj(N);
  REP(i, M) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  vector<bool> visited[2] = {vector<bool>(N), vector<bool>(N)};
  deque<pair<int, int>> q;
  visited[0][0] = true;
  q.emplace_back(0, 0);
  while (q.size()) {
    int d = q.front().first;
    int j = q.front().second;
    q.pop_front();
    for (auto x : adj[j]) {
      if (visited[(d + 1) % 2][x]) continue;
      visited[(d + 1) % 2][x] = true;
      q.emplace_back(d + 1, x);
    }
  }
  i64 ecnt = 0, ocnt = 0;
  REP(i, N) {
    if (visited[1][i]) {
      ocnt++;
    } else if (visited[0][i]) {
      ecnt++;
    }
  }

  i64 ans = 0;
  REP(i, N) {
    if (visited[0][i]) ecnt--;
    if (visited[1][i]) ocnt--;
    if (visited[0][i]) {
      ans += ocnt;
      for (auto j : adj[i]) {
        if (j > i && visited[1][j]) ans--;
      }
    } else if (visited[1][i]) {
      ans += ecnt;
      for (auto j : adj[i]) {
        if (j > i && visited[0][j]) ans--;
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 5888
import sys
input = sys.stdin.readline


N = int(input())
graph = [[] for _ in range(N)]
for _ in range(N-1):
    a, b, w = map(int, input().split())
    graph[a-1].append((b-1, w))
    graph[b-1].append((a-1, w))

def dfs(s):
    Ind = [0]*N
    stack = [s]
    Color = [0]*N
    while stack:
        p = stack[-1]
        if Ind[p] == len(graph[p]):
            stack.pop()
        elif len(stack) > 1 and stack[-2] == graph[p][Ind[p]][0]:
            Ind[p] += 1
        else:
            ch, w = graph[p][Ind[p]]
            Ind[p] += 1
            stack.append(ch)
            Color[ch] = Color[p]^(w%2)
    return Color

Color = dfs(0)
print(*Color, sep="\n")


Measured memory_bytes: 65808
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
  int n; cin >> n;
  vector<ll> a(n);
  vector<ll> sum(n+1);
  sum[0] = 0;
  // [l, r) = sum(r) - sum(l)
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum[i+1] = sum[i] + a[i];
  }
  ll ans = 0xdeadbeef;
  for (int div = 1; div < n; div++) {
    ans = min(ans, abs(sum[div] - (sum[n] - sum[div])));
  }
  cout << ans << endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    int x1, x2, x3, x4, x5; cin >> x1 >> x2 >> x3 >> x4 >> x5;
    if (x1 == 0) {
        cout << 1 << endl;
    }
    if (x2 == 0) {
        cout << 2 << endl;
    }
    if (x3 == 0) {
        cout << 3 << endl;
    }
    if (x4 == 0) {
        cout << 4 << endl;
    }
    if (x5 == 0) {
        cout << 5 << endl;
    }
}

Measured memory_bytes: 3632
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int a, b, c;
  cin>>a>>b>>c;
  if(b-a==c-b) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 3560
#!/usr/bin/env python3
def main():
    from scipy.special import comb

    N = int(input())
    A = [int(x) for x in input().split()]

    num_lst = [0] * (N + 1)
    for a in A:
        num_lst[a] += 1

    ans = 0
    for num in num_lst:
        ans += comb(num, 2, exact=True)

    for a in A:
        print(ans - (num_lst[a] - 1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 65688
/*g++ main.cpp -o main.out*/
/*./main.out*/

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

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int ishuiwen(int x)
{
    int newed,t,n;

    newed=0;
    n=x;
    do
    {
        newed=newed*10+x%10;
        x/=10;
    }
    while(x>0);
    if(n==newed)
        return 1;
    else
        return 0;

}

int a[100005];

int main()
{
    NO_TLE
    int sum=0;
    for(int i=10000;i<=99999;++i)
    {
        if(ishuiwen(i))sum++;
        a[i]=sum;
    }
    int A,B;
    cin>>A>>B;
    cout<<a[B]-a[A-1]<<endl;
    return 0;
}

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


int main(){
	string s;
	cin >> s;

	rep(i,3){
		cout << s.at(i);
	}
	cout << endl;	
}







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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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



void func(long long A, long long B, long long C, long long X, long long Y){

    lli ans = INF;
    for(lli ab=0;;ab+=2){
        lli leftX = X-ab/2;
        lli leftY = Y-ab/2;
        if(leftX<0 && leftY < 0)break;
        chmin(ans,ab*C + max(0LL,leftX*A)+max(0LL,leftY*B));
    }
    cout<<ans<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    func(A, B, C, X, Y);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
x = input()

original_pop_count = x.count('1')
one_pop_count = original_pop_count - 1
zero_pop_count = original_pop_count + 1

one_mod = 0
zero_mod = 0
for b in x:
    if one_pop_count != 0:
        one_mod = (one_mod *2 + int(b))%one_pop_count
    zero_mod = (zero_mod *2 + int(b))%zero_pop_count

f = [0]*220001
pop_count = [0]*220001
for i in range(1, 220001):
    pop_count[i] = pop_count[i//2] + i%2
    f[i] = f[i%pop_count[i]] + 1

one_pow2 = [1]*220001
zero_pow2 = [1]*220001
for i in range(1, 220001):
    if one_pop_count != 0:
        one_pow2[i] = one_pow2[i-1] *2 % one_pop_count
    zero_pow2[i] = zero_pow2[i-1] *2 % zero_pop_count

for i in range(n-1, -1, -1):
    if x[n-1-i] == '1':
        if one_pop_count != 0:
            nxt = one_mod
            nxt -= one_pow2[i]
            nxt %= one_pop_count
            print(f[nxt]+1)
        else:
            print(0)

    if x[n-1-i] == '0':
        nxt = zero_mod
        nxt += zero_pow2[i]
        nxt %= zero_pop_count
        print(f[nxt]+1)

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

using namespace std;
using ll = long long;

ll gcd(ll a, ll b) {
  if (a < b) return gcd(b, a);
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  ll l = lcm(C, D);
  cout << (B - A) -
              (B / C - (A - 1) / C + B / D - (A - 1) / D -
               (B / l - (A - 1) / l)) +
              1
       << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define NUM 100;
using namespace std;

int main(){
    bool ans = 1;
    long long n,m;
    double sum = 0;
    cin >> n >> m;
    vector<long long> a(n);
    for(int i = 0;i < n;i++){
        cin >> a.at(i);
        sum += a.at(i);
    }
    sum /= 4*m;
    /**/
    sort(a.begin(),a.end());
    if(a.at(n - m) < sum){
        ans = 0;
    }

    if(ans){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
N = input()
TA = input().split()
T = int(TA[0])
A = int(TA[1])

first = True
place = 0
minTmep = 0

H = list(map(int, input().split()))
for i in range(0,len(H)):
    compare = abs(A * 1000 - (T * 1000 - H[i] * 0.006 * 1000))
    if first == True:
        place = i
        minTmep = compare
        first = False
    
    if minTmep > compare:
        place = i
        minTmep = compare

print(place + 1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
*/

ll modpow(__int128_t a, ll n,ll mo) {
	__int128_t r=1;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

ll n,p,dp[200010],a[10010]={},ans=0;
string s;

int main(void){
	cin>>n>>p>>s;
	s="0"+s;
	dp[0]=0;
	a[0]=1;
	reg(i,1,n){
		dp[i]=( dp[i-1]+modpow(10,n-i,p)*(s[i]-'0') ) % p;
		a[dp[i]]++;
	}
	rep(i,p)ans += a[i]*(a[i]-1)/2;
	if(p==2 || p==5){
		// 最終的な桁がOKならOK
		ans=0;
		reg(i,1,n){
			if((s[i]-'0')%p==0){
				ans += i;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int main() {
   int n, a;
   cin >> n >> a;
   n %= 500;
   if (a >= n) {
      puts("Yes");
   } else {
      puts("No");
   }

   return 0;
}

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

int gcd(int a, int b){
    if(a<b) swap(a, b);
    if(b==0) return a;
    return gcd(b, a%b);
}

int n;
int arr[100000];
vector<int> v;
string s;
int main() {
    cin >> s;
    int cnt=0;
    for(int i=0; i<s.size(); ++i){
        if(s[i]=='+') cnt++;
        else cnt--;
    }
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 1000000007
#define h1 7897897897897897
#define h2 7897466719774591
#define b1 98762051
#define b2 98765431
#define inf 1000000000
#define pi 3.1415926535897932384626
#define LMAX 9223372036854775807
#define ll long long
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pii>
#define SET(a, b) memset(a, b, sizeof(a));
#define all(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
int n, m, k, t, T, x, y, sum, cnt, h[200005];
ll a[200005], seg[800005], ans;
void update(int id, int l, int r, int pos, ll val) {
  if (l == pos && r == pos) {
    seg[id] = val;
    return;
  }
  int mid = (l + r) >> 1;
  if (pos <= mid) update(id * 2, l, mid, pos, val);
  else update(id * 2 + 1, mid + 1, r, pos, val);
  seg[id] = max(seg[id*2], seg[id*2+1]);
}
ll query(int id, int l, int r, int ql, int qr) {
  if (ql > r || qr < l) return 0;
  if (ql <= l && r <= qr) return seg[id];
  int mid = (l + r) >> 1;
  return max(query(id * 2, l, mid, ql, qr), query(id * 2 + 1, mid + 1, r, ql, qr));
}
int main () {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  FOR(i, 1, n) {
    cin >> h[i];
  }
  FOR(i, 1, n) {
    cin >> a[i];
  }
  FOR(i, 1, n) {
    if (h[i] == 1) {
      update(1, 1, n, h[i], a[i]);
      ans = max(ans, a[i]);
      continue;
    }
    ll maxx = query(1, 1, n, 1, h[i] - 1);
    update(1, 1, n, h[i], maxx + a[i]);
    cerr << maxx  + a[i] <<endl;
    ans = max(ans, maxx + a[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 10116
H, W = map( int, input().split())
A = [ input() for _ in range(H)]
dp = [[0]*W for _ in range(H)]
dp[0][0] = 1
Q = 10**9+7
for i in range(H):
    for j in range(W):
        if not i == H-1:
            if A[i+1][j] == ".":
                dp[i+1][j] = (dp[i+1][j] + dp[i][j])%Q
        if not j == W-1:
            if A[i][j+1] == ".":
                dp[i][j+1] = (dp[i][j+1] + dp[i][j])%Q
print(dp[H-1][W-1])


Measured memory_bytes: 43700
#include <iostream>
#include <array>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;

//?????¨?????\
double round_four(double value){
    //0??????
    if (value <= 0.00001 && value >= -0.00001){
        return 0;
    }
    //?????????
    value *= 1000;
    value += (value / fabs(value)) * 0.5;
    int nValue = static_cast<int>(value);
    value = static_cast<double>(nValue) / 1000;
    return value;
}

//????¬?????¨?????§£
array<double, 2> comp_linear_equation(int a, int b, int c, int d, int e, int f){
    array<double, 2> result;
    result[0] = static_cast<double>(e * c - (f * b));
    result[1] = static_cast<double>(-(d * c) + a * f);
    double num = 1.0 / ((a * e) - (b * d));
    result[0] *= num;
    result[1] *= num;
    result[0] = round_four(result[0]);
    result[1] = round_four(result[1]);
    return result;
}

//?????????
int main(){
    int a, b, c, d, e, f;
    vector<array<double, 2>> result;
    while (cin >> a >> b >> c >> d >> e >> f){
        result.push_back(comp_linear_equation(a, b, c, d, e, f));
    }
    for (const auto& element : result){
        cout << fixed << setprecision(3) << element[0] << " " << element[1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1276
# encoding: utf-8                                                            

def solve arr
  ans, curr_max = 0, arr[0]
  arr.each do |num|
    if ans + num < 0
      ans = 0
    else
      ans = ans + num
      curr_max = ans if ans > curr_max
    end
  end
  curr_max
end

while n = gets
  n = n.rstrip.to_i
  break if n == 0
  num = []
  (1..n).each { |n| nn = gets.to_i; num << nn}
  puts "#{solve(num)}"
end

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

#define EACH(i, a) for (auto &&i : a)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RFOR(i, a, b) for (int i = (int)b - 1; i >= (int)a; --i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREPS(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(x) (x).begin(), (x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define debug(x) cout << #x << ": " << x << endl

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF (1L << 30)
#define MOD (998244353)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

template <class T>
void pv(T a, T b) {
  for (T i = a; i != b; ++i) cout << *i << " ";
  cout << endl;
}
template <class T>
void pvp(T a, T b) {
  for (T i = a; i != b; ++i)
    cout << "(" << i->first << ", " << i->second << ") ";
  cout << endl;
}
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 in() {
  int x;
  scanf("%d", &x);
  return x;
}

using ll = long long;
#define int ll

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

  int n;
  cin >> n;

  int DD[100010];
  MEMSET(DD, 0);

  int maxd = 0;

  REP(i, n) {
    int d;
    cin >> d;
    DD[d] += 1;
    chmax(maxd, d);

    if (i > 0 && d == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  // debug(maxd);

  int ans = 1;
  REP(i, maxd) {
    REP(j, DD[i + 1]) {
      ans *= DD[i];
      ans %= MOD;
    }
  }

  cout << ans << endl;

  return 0;
};


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(void) {
  int N, X, T, ans;
  cin >> N >> X >> T;
  ans = (N / X);
  ans += (N % X) ? 1 : 0;
  cout << ans * T << endl;
  return 0;
}

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

int main(){
    int n,m;
    cin >> n >> m;
    ve<int> a(m);
    rep(i,m) cin >> a[i];
    sort(a.begin(), a.end());
    ve<int> sa(m-1);
    rep(i,m-1) sa[i] = a[i+1] - a[i];
    sort(sa.rbegin(), sa.rend());
    int ans = a[m-1]-a[0];
    if(n >= m){
        ans = 0;
        cout << ans << endl;
        return 0;
    }
    rep(i,n-1){
        ans -= sa[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4036
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	set<int> st{ a,b,c };
	cout << st.size() << endl;
}

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

using namespace std;

int main()
{
    //cout<<"here-1";
    int k, n;
    cin>>k>>n;
    int a[n];
    //cout<<"here-2";
    for(int i=0; i<n; ++i)
    {
        int x;
        cin>>x;
        a[i]=x;
        //cout<<i<<endl;
        //if(i==n)
            //break;
    }
    //cout<<"here 0";
    int b[n];

    for(int i=0; i<n-1; i++)
    {
        b[i]=a[i+1]-a[i];
    }
    b[n-1]=a[0]+k-a[n-1];
    int max=INT_MIN;
    int ind;
    //cout<<"here 1";
    for(int i=0; i<n; i++)
    {
        if(b[i]>max)
        {
            max=b[i];
            ind=i;
        }
    }
    int ans=0;
    //cout<<"here 1";
    for(int i=0; i<n ; i++)
    {
        if(i==ind) continue;
        else{
            ans+=b[i];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        int N = Reader.Int(), C = Reader.Int(), K = Reader.Int();
        var T = Reader.IntArray(N);
        Array.Sort(T);
        int ans = 0;

        for (int i = 0; i < N; )
        {
            ans++;
            int time = T[i] + K;
            int next = i + 1;
            while (next < N && next - i < C && time >= T[next] && time <= T[next] + K) next++;
            i = next;
        }

        Console.WriteLine(ans);
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { Dispose(); A = new string[0]; }
    public static void Set(TextReader r) { Init(); reader = r; }
    public static void Set(string file) { Init(); reader = new StreamReader(file); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    public static void Dispose() { reader.Dispose(); }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 15448
#include <cstdio>
#include <cstring>

const int MAXN = 2e5 + 10;

char s[MAXN];

int main() {
  int i, j;

  scanf(" %s", s);

  i = 0;
  while (s[i] != 'A') ++i;
  
  j = strlen(s);
  while (s[j] != 'Z') --j;

  printf("%d\n", j - i + 1);
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;

using ll = long long int;
const int maxn = 100000 + 5;
int N;
int A[maxn];
int Left[maxn];
int Right[maxn];

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

int solve()
{
	for(int i = 0; i <= N; i++) Left[i+1] = gcd(Left[i], A[i]);
	for(int i = N-1; i >= 0; i--) Right[i] = gcd(Right[i+1], A[i]);
	/*
	for(int i = 0; i <= N; i++) printf("%d ", Left[i]); 
	cout << endl;
	for(int i = 0; i <= N; i++) printf("%d ", Right[i]); 
	cout << endl;
	*/

	int Max = 0; 
	for(int i = 0; i < N; i++)
	{
		int result = gcd(Left[i], Right[i+1]);
		// printf("%d ", result);
		if(result > Max) Max = result;
	}
	
	//cout << endl;
	return Max;
}

int main()
{
	cin >> N;
	for(int i = 0; i < N; i++) cin >> A[i];
	printf("%d\n", solve());
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<string>
using namespace std;

int H,W;

int main(){
    cin >> H>>W;
    string C[H];
    
    for(int i = 0; i < H; i++){
            cin >> C[i];

    }
   
   
    for(int i = 0; i < H*2; i++){
            cout << C[i/2]<<endl;
    } 
}

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

void solve(){
    string s; cin >> s;
    for( int i = 0; i + 1 < s.size(); ++i )
        if( s[ i ] == s[ i + 1 ] ){
            cout << i + 1 << " " << i + 2 << "\n";
            return;
        }
    for( int i = 0; i + 2 < s.size(); ++i )
        if( s[ i ] == s[ i + 2 ] ){
            cout << i + 1 << " " << i + 3 << "\n";
            return;
        }
    cout << -1 << " " << -1 << "\n";
}

int main(){
    ios::sync_with_stdio( false );
    solve();
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#include <string>

using namespace std;

int main(){
  int A[3];
  vector<int> answer(100, 100000);
  cin >> A[0] >> A[1] >> A[2];
  for(int i = 0; i < 3; i++){
    int result = 0;
    for(int j = 0; j < 3; j++){
      result += abs(A[i] - A[j]);
    }
    answer[i] = result;
  }
  sort(answer.begin(), answer.end());
  cout << answer[0] << endl;
}



Measured memory_bytes: 256
import sys
import heapq
import bisect
import itertools

mod = 10**9+7
dd = ((-1,0),(1,0),(0,-1),(0,1))

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def S(): return(sys.stdin.readline()[:-1])
def IR(n): return([I() for _ in range(n)])

def GCD(a,b):
    while b!=0:
        a,b = b,a%b
    return a

def LCM(a,b):
    return a * b // GCD(a,b)

def Eratosthenes(N):
    r = [True]*(N+1)
    r[0] = False
    r[1] = False
    i = 2
    while i*i<=N:
        if r[i]: 
            j = i
            while i*j<=N:
                prime[i*j]=False
                j+=1
        i+=1
    return(r)

def main():
    N,M,R = LI()
    r = LI()
    node = [[] for _ in range(N)]
    for _ in range(M):
        a,b,c = LI()
        node[a-1].append([b-1,c])
        node[b-1].append([a-1,c])

    dic = {}
    for x in r:
        dic_part = {}
        for y in r:
            dic_part[y-1] = 0
        dic[x-1] = dic_part

    for x in r:
        ques = []
        flag = [True] * len(node)
        heapq.heappush(ques,[0,x-1])
        while ques:
            dist,crt = heapq.heappop(ques)
            if flag[crt]:
                flag[crt] = False
                if (crt+1) in r:
                    dic[x-1][crt] = dist
                    dic[crt][x-1] = dist
                for nxt,nxt_dist in node[crt]:
                    if flag[nxt]:
                        heapq.heappush(ques,[dist+nxt_dist,nxt])
    ans = 10**11
    for tr in itertools.permutations(r):
        tans = 0
        for i in range(len(tr)-1):
            tans += dic[tr[i]-1][tr[i+1]-1]
        ans = min(ans,tans)
    return(ans)

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


Measured memory_bytes: 66908
#include<iostream>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<vector>
using namespace std;

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

  vector<pair<long double, long double>> xy(N);
  for(int i = 0; i < N; i++){
    double x, y;
    cin >> x >> y;
    xy[i] = make_pair(x, y);
  }

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

  long double dist_sum = 0;
  int cnt = 0;
  do{
    for(int i = 0; i + 1 < N; i++){
      dist_sum += sqrt((xy[perm[i]].first - xy[perm[i + 1]].first) * (xy[perm[i]].first - xy[perm[i + 1]].first) +
                       (xy[perm[i]].second - xy[perm[i + 1]].second) * (xy[perm[i]].second - xy[perm[i + 1]].second));
    }
    cnt++;
  }while(next_permutation(perm.begin(), perm.end()));
  dist_sum /= cnt;

  cout << setprecision(20) << dist_sum << endl;
}
  
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const double pi=3.1415926;
int main()
{
    int n,m;
    cin>>n>>m;
    while(m--)
    {
        int t;
        cin>>t;
        n-=t;
    }
    cout<<(n<0?-1:n);
    return 0;
}


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

int main() 
{
    int h1,m1,h2,m2,k ;
    cin >> h1>>m1>>h2>>m2>>k;
    
    int hr = h2-h1;
    int ans=hr*60;
    ans-=m1;
    ans+=m2;
    ans-=k;
    
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3592