akhauriyash/Code-Regression huggingface dataset:
n, q = map(int, input().split())
s = input()

t = [0] * (n + 1)

for i in range(n):
    t[i + 1] = t[i] + (1 if s[i : i + 2] == 'AC' else 0)

for _ in range(q):
    l, r = map(int, input().split())
    print(t[r - 1] - t[l - 1])


Measured memory_bytes: 7748
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());



int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>n;
		// n=s.length();
		ll a[10][10];
		memset(a,0,sizeof a);
		string cx,cy,cp,cq,cr;ll x,y;
		repe(i,1,n+1)
		{
			j=1ll*(to_string(i).size());
			ll y=i%10,x=i/(1ll*pow(1ll*10,j-1));
			if(x==0 || y==0) continue; 
			a[x][y]++;
			// cx=to_string(x),cy=to_string(y);
			// if(x==y) c++;
			// if(10*y+x<=n) c++;
			// cs=0;
			// rep(p,10)
			// {
			// 	cp=to_string(p);
			// 	if(stoll(cy+cp+cx)<=n) c++;//{debug2(i,stoll(cy+cp+cx));}
			// 	else cs=1;
			// 	// debug2(i,cp);
			// 	// debug3(i,cy,cx)
			// }
			// if(cs==1) continue;
			// rep(p,10) rep(q,10)
			// {
			// 	cp=to_string(p),cq=to_string(q);
			// 	if(stoll(cy+cp+cq+cx)<=n) c++;//{debug2(i,stoll(cy+cp+cq+cx));}
			// 	else cs=1;
			// }
			// if(cs==1) continue;

			// rep(p,10) rep(q,10) rep(r,10)
			// {
			// 	cp=to_string(p),cq=to_string(q),cr=to_string(r);
			// 	if(stoll(cy+cp+cq+cr+cx)<=n) c++;//debug2(i,stoll(cy+cp+cq+cr+cx));
			// }
			
			// debug3(i,x,y);
		}
		repe(i,1,10) repe(j,1,10)
			c+=(a[i][j]*a[j][i]);
		cout<<c;

		
		cout<<"\n";
	}
	return 0;
}

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

int N,M;
vector<bool> ava;

const int INF = 1LL << 60;

int dist[2510];

struct edge{int from,to,cost;};

edge E[5010];

void Bellmanford(const int &str){
  
  for(int i = 0; i < N; i++){ 
    dist[i] = -INF;
  }
  
  dist[str] = 0;
  
  for(int k = 0; k < N; k++){
    
    for(int i = 0; i < M; i++){ 
      int r1 = dist[E[i].from];
      int &r2= dist[E[i].to];
      int w = E[i].cost;
      
      if( r2 < r1+w ){ 
        r2 = r1+w;
        if( k == N-1 ){ //ループあり
          if(!ava[E[i].to]){continue;} //このループは関係ないので無視
          
          cout << "-1" << endl; exit(0);
          
        }//if
      }//if
    }//for-i
    
  }//for-k
  
  cout << max(0LL,dist[N-1]) << endl;
  
  return ;
}

signed main(void){
 
  int P;
  cin >> N >> M >> P;
  vector<vector<int>> to(N),to2(N);
  for(int i = 0; i < M; i++){ 
   int a,b,c; cin >> a >> b >> c;
    a--; b--;
    to[b].push_back(a);
    to2[a].push_back(b);
    c -= P;
    E[i].from = a; E[i].to = b;
    E[i].cost = c;
  }
  
  ava = vector<bool>(N,false);
  
  vector<bool> visited(N,false),visited2(N,false);
  
  visited[N-1] = true;
  
  queue<int> Q; Q.push(N-1);
  while(!Q.empty()){ 
    int p = Q.front(); Q.pop();
    for(auto q : to[p]){
      if(visited[q]){ continue;}
      
      visited[q] = true;
      Q.push(q);
    }
  }
  
  Q.push(0);
  visited2[0] = true;
  
  while(!Q.empty()){
    int p = Q.front(); Q.pop();
    for(auto q : to2[p]){
      if(visited2[q]){ continue;}
      
      visited2[q] = true;
      Q.push(q);
    }
  }
  
  for(int i = 0; i < N; i++){ 
    if( visited[i] && visited2[i] ){ ava[i] = true;}
  } //始点からも終点からも到達可能な点
  
  
  Bellmanford(0);
  
  return 0;
}
    
  
  

Measured memory_bytes: 640
n, t = map(int, input().split())
ct = []
for _ in range(n):
    ct.append(list(map(int, input().split())))
ans = 1001
for i in range(n):
    if ct[i][1] <= t:
        ans = min(ans, ct[i][0])
if ans == 1001:
    print("TLE")
else:
    print(ans)

Measured memory_bytes: 38384
void main()
{
    long n, m, s, t;
    rdVals(n, m, s, t);
    --s, --t;
    Edge[][] yen = new Edge[][](n), snk = new Edge[][](n);
    foreach (i; 0 .. m)
    {
        long u, v, a, b;
        rdVals(u, v, a, b);
        --u, --v;
        yen[u] ~= Edge(v, a), yen[v] ~= Edge(u, a);
        snk[u] ~= Edge(v, b), snk[v] ~= Edge(u, b);
    }

    long[] Dijkstra(long x, Edge[][] edge)
    {
        long[] result = new long[n];
        result[] = inf;
        result[x] = 0;
        auto que = new BinaryHeap!(Array!Edge, "a.cost > b.cost");
        que.insert(Edge(x, 0));
        while (!que.empty)
        {
            Edge f = que.front;
            que.popFront;
            foreach (e; edge[f.to])
            {
                if (result[e.to] <= result[f.to] + e.cost) continue;
                result[e.to] = result[f.to] + e.cost;
                que.insert(Edge(e.to, result[e.to]));
            }
        }
        return result;
    }

    long money = 10L ^^ 15;
    long[] dyen = Dijkstra(s, yen), dsnk = Dijkstra(t, snk);
    long[] result = new long[n];
    result[n-1] = money - dyen[n-1] - dsnk[n-1];
    foreach_reverse (i; 0 .. n-1)
    {
        result[i] = max(result[i+1], money-dyen[i]-dsnk[i]);
    }

    foreach (r; result)
    {
        r.writeln;
    }
}

struct Edge
{
    long to, cost;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 39292
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define endl "\n"
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
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; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int V,E;
Graph G;
int d[100050]; //MAX_V
const int INF = 1001001001;

void dijkstra(int s){
  priority_queue<Edge, vector<Edge>, greater<Edge>> que;
  fill(d, d+V, INF);
  d[s] = 0;
  que.push(Edge(0,s));

  while(!que.empty()){
    Edge p = que.top(); que.pop();
    int v = p.second;
    if(d[v]<p.first) continue;
    for(auto x: G[v]){
      if(d[x.first]>d[v]+x.second){
        d[x.first] = d[v]+x.second;
        que.push(Edge(d[x.first],x.first));
      }
    }
  }
}

int main(void){
  int r;
  cin >> V >> E >> r;
  G.assign(V,vector<Edge>());
  FOR(i,0,E-1){
    int s,t,d; cin >> s >> t >> d;
    G[s].PB(MP(t,d));
    // G[t].PB(MP(s,d));
  }
  dijkstra(r);
  FOR(i,0,V-1){
    if(d[i]==INF) cout << "INF" << endl;
    else cout << d[i] << endl;
  }
}





Measured memory_bytes: 12972
/*
  AtCoder Beginner Contest 090
  C - Flip, Flip, and Flip......
*/

#include<iostream>
using namespace std;

long long N, M;

int main() {
  scanf("%lld%lld", &N, &M);

  if (N == 1 && M == 1) {
    printf("1\n");
  }
  else if (N == 1) {
    printf("%lld\n", M - 2);
  }
  else if (M == 1) {
    printf("%lld\n", N - 2);
  }
  else {
    printf("%lld\n", (N - 2) * (M - 2));
  }

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
		try{
			Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			long[] list = new long[N];
			long F = 0;
			long B = 0;
			for(int i = 0; i < N; i++){
				list[i] = sc.nextLong();
				B += list[i];
			}
			F = list[0];
			B -= F;
			long result = Math.abs(B - F);
			for(int i = 1; i < N-1; i++){
				F += list[i];
				B -= list[i];
				long temp = Math.abs(B - F);
				result = (temp < result)? temp : result;
			}
			System.out.println(result);
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 65724
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define rep(i,n) for(int i=0;i<((int)n);i++)
#define rep1(i,n) for(int i=1;i<=((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef long long ll;

const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;

		b>>=1;
	}
	return res;
}
void exgcd(int a,int b,int &x,int &y,int &d)
{
    if (b==0) x=0,y=1,d=a;
    else exgcd(b,a%b,y,x,d),y-=(a/b)*x;
}
int n;
int a[25],b[25];
int main()
{
    //IOS;
    while(cin>>n)
    {
        rep(i,n) cin>>a[i];
        rep(i,n) cin>>b[i];
        int sum=0;
        rep(i,n)
        {
            if(a[i]>b[i]) sum+=a[i]-b[i];
        }
        cout<<sum<<"\n";
    }
	return 0;
}

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

int main(){
	int n;
	cin>>n;
	vector<int>a(n),dp(n,1e9+7);
	for(auto &i:a)cin>>i;
	dp[0] = 0;
	for(int i=1;i<n;i++){
		if(i-1>=0)dp[i]=min(dp[i],dp[i-1]+abs(a[i]-a[i-1]));
		if(i-2>=0)dp[i]=min(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//ll dx[4] = {1, 0, -1, 0};
//ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	string s;
	cin >> s;
	ll cnt = 15 - s.size();
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'o') cnt++;
	}
	dump(cnt >= 8 ? "YES" : "NO");
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	public static void main(String args[]) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder builder = new StringBuilder();
		while(true){
			String data[] = reader.readLine().split(" ");
			int a= Integer.parseInt(data[0]);
			int b= Integer.parseInt(data[1]);
			if(a==0 && b==0)
				break;
			
			builder.append(Integer.toString(a<b?a:b)).append(" ").append(Integer.toString(a<b?b:a)).append("\n");
		}
		System.out.print(builder);
	}
}

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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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


vector<ll> a;
vector<ll> l;


int main(void)
{
  ll n;
  ll s = 0;
  ll a1, d;
  cin >> n;
  a.push_back(0);
  REP1(i, n) {
    cin >> a1;
    a.push_back(a1);
    d = abs(a[i]-a[i-1]);
    l.push_back(d);
    s += d;
  }
  d = abs(a1);
  l.push_back(d);
  s += d;
  REP(i, n) {
    cout << (s-l[i+1]-l[i]+abs(a[i+2]-a[i])) << endl;
  }

  

}


Measured memory_bytes: 3052
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>

using namespace std;

int tt;
int n[100000];
int k[100000];
int t[100000];
long long int dst[100000];
int y[100000];

int distance(int a, int b){
  return abs(b-a);
}

int add(int a,int b){
  return a + b;
}

int main()
{
  cin >> tt;
  
  for (int i = 0; i < tt; ++i)
  {
    cin >> n[i] >> k[i];
    for (int j = 0; j < n[i]; ++j)
    {
      cin >> t[j];
    }
    for (int j = 0; j < n[i] - 1; ++j)
    {
      y[j] = distance(t[j] , t[j + 1]);
    }
    sort(y, y + (n[i]-1));
    for(int j = 0; j < n[i] - k[i]; ++j){
      dst[i] +=  y[j];
      //dst[i] = add(dst[i], y[i]);
    }
    cout << dst[i] << endl;
  }
}


Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  int a=n/2;
  double b;
  if(n%2==0){
    b=((double)a)/n;
  }
  else{
    b=(((double)a)+1)/n;
  }
  cout << b << endl; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define big 998244353
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589
int power(int x,int y){
    int r=1,z=x;
    while(y){
        if(y & 1)r*=z;
        z*=z;y=y>>1;}
    return r;}
int powerm(int x,int y,int p){
    int r=1;
    while(y){
        if(y & 1)r=(r*x)%p;
        y=y>>1;
        x=(x*x)%p;}
    return r%p;}
int modinv(int x,int m){
    return powerm(x,m-2,m);}
int logarithm(int a,int b){
    int x=0;
    while(a>1){
        x++;
        a/=b;}
    return x;}
vector<vector<int> > mat(3000,vector<int>(3000,0));
int dp[4][3000][3000];
int32_t main(){
    fast;
    int r,c;
    cin>>r>>c;
    int k;
    cin>>k;
    for(int i=0;i<k;i++){
        int x,y,z;
        cin>>x>>y>>z;
        mat[x-1][y-1]=z;
    }
    // dp[0][0][0]=0
    // for(int i=0;i<r;i++){
    //     for(int j=0;j<c;j++)
    //         cout<<mat[i][j]<<" ";
    //     cout<<endl;
    // }
    for(int i=0;i<r;i++)
    {
        for(int j=0;j<c;j++){
            int up,zero,one,two,three;
            if(i==0)
                up=0;
            else
                up=max(dp[0][i-1][j],max(dp[1][i-1][j],max(dp[2][i-1][j],dp[3][i-1][j])));
            if(j==0)
                zero=one=two=three=0;
            else{
                one=dp[1][i][j-1];
                two=dp[2][i][j-1];
                three=dp[3][i][j-1];
                zero=dp[0][i][j-1];
            }
            if(!mat[i][j]){
                dp[0][i][j]=max(dp[0][i][j],max(up,zero));
                dp[1][i][j]=max(dp[1][i][j],one);
                dp[2][i][j]=max(two,dp[2][i][j]);
                dp[3][i][j]=max(three,dp[3][i][j]);
                continue;
            }
            dp[0][i][j]=max(dp[0][i][j],max(up,zero));
            dp[1][i][j]=max(dp[1][i][j],max(up+mat[i][j],max(zero+mat[i][j],one)));
            dp[2][i][j]=max(dp[2][i][j],max(two,one+mat[i][j]));
            dp[3][i][j]=max(dp[3][i][j],max(three,two+mat[i][j]));
        }
    }
    // for(int i=0;i<r;i++)
    //     for(int j=0;j<c;j++){
    //         for(int k=0;k<4;k++)
    //             cout<<dp[k][i][j]<<" ";
    //         cout<<endl;
    //     }
    cout<<max(dp[0][r-1][c-1],max(dp[1][r-1][c-1],max(dp[2][r-1][c-1],dp[3][r-1][c-1])));
    return 0;
}

Measured memory_bytes: 355232
def makelist(n,m,p):
    return [[[0 for k in range(p)]for i in range(m)]for j in range(n)]

n,a = map(int,input().split())
x = list(map(int,input().split()))
X = max(x)
X = max(X,a)

dp = makelist(n+1,n+1,n*X+1)
dp[0][0][0] = 1
for j in range(n+1):
    for k in range(n+1):
        for s in range(n*X+1):
            if j*k > 0 and s >= x[j-1]:
                dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j-1]]
            elif j >= 1 and s < x[j-1]:
                dp[j][k][s] = dp[j-1][k][s]
ans = 0
for k in range(1,n+1):
    ans += dp[n][k][k*a]
print(ans)

Measured memory_bytes: 96348
#include <bits/stdc++.h>
using namespace std;
int main(){
    int K;
    cin >> K;
    vector<int> md(K);
    md.at(0) = 7%K;
    for(int i=1;i<K;i++){
        
        md.at(i) = (md.at(i-1)*10+7)%K;
    }
    auto result = find(md.begin(),md.end(),0);
    if(result == md.end()) cout << -1 << endl;
    else cout << distance(md.begin(),result)+1 << endl;
}

Measured memory_bytes: 7168
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int main(void){
    int N, K;
    cin >> N >> K;
    vector<int> D(K);
    for(int i = 0; i < K; i++){
        cin >> D[i];
    }
    
    for(int money = N; money <= 10000000; ++money){
        int temp = money;
        vector<int> digit;
        while(temp > 0){
            digit.push_back(temp % 10);
            temp /= 10;
        }
        bool flag = true;
        for(int i = 0; i < digit.size(); ++i){
            for(int j = 0; j < K; ++j){
                if(digit[i] == D[j]){
                    flag = false;
                    break;
                }
            }
            if(!flag)       break;
        }
        if(flag){
            cout << money << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int MAX=100000;
class Edge{
public:
    int source,target,cost;
    Edge(){}
    Edge(int source,int target,int cost):source(source),target(target),cost(cost){}
    bool operator < (const Edge &e) const{
        return cost<e.cost;
    }
};
class DisjointSet{
public:
    vector<int>rank,p;
    DisjointSet(){}
    DisjointSet(int size){
        rank.resize(size,0);
        p.resize(size,0);
        for(int i=0;i<size;i++)
            makesets(i);
    }
    void makesets(int x){
        rank[x]=0;
        p[x]=x;
    }
    bool same(int x,int y){
        return findset(x)==findset(y);
    }
    void unite(int x,int y){
        if(findset(x)==findset(y))return;
        linked(findset(x),findset(y));
    }
    void linked(int x,int y){
        if(rank[x]>rank[y])
            p[y]=x;
        else{
            p[x]=y;
            if(rank[x]==rank[y])
                rank[y]++;
        }
    }
    int findset(int x){
        if(p[x]!=x){
            p[x]=findset(p[x]);
        }
        return p[x];
    }
};
Edge G[MAX];
int N;
long long sum;
void kruskal(int Elen)
{
    sort(G,G+Elen);
    //vector<int>k;
    DisjointSet D=DisjointSet(N);
    for(int i=0;i<Elen;i++)
    {
        if(D.findset(G[i].source)!=D.findset(G[i].target)){
            //k.push_back(G[i].cost);
            sum+=G[i].cost;
            D.unite(G[i].source,G[i].target);
        }
    }
}
int main()
{
    int E,s,t,w;
    cin>>N>>E;
    for(int i=0;i<E;i++)
    {
        cin>>s>>t>>w;
        G[i]=Edge(s,t,w);
    }
    sum=0;
    kruskal(E);
    cout<<sum<<endl;
}


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

int main(){
    int a, b;
    char op;
    
    while(1){
        cin >> a >> op >> b;
        if(op == '?') break;
        else if (op == '+') cout << a + b << endl;
        else if (op == '-') cout << a - b << endl;
        else if (op == '*') cout << a * b << endl;
        else if (op == '/') cout << a / b << endl;
        }
        return 0;

}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  vll a(4);
  rep(i,4) a[i]=s[i]-'0';
  
  for(ll bit=0; bit<(1<<3); bit++){
    ll sum=a[0];
    rep(i,3){
      if(bit>>i&1){
        sum+=a[i+1];
      }else{
        sum-=a[i+1];
      }
    }
    if(sum==7){
      cout<<a[0];
      rep(i,3){
        if(bit>>i&1){
          cout<<'+';
        }else{
          cout<<'-';
        }
        cout<<a[i+1];
      }
      cout<<"=7"<<endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	ll mx = a * c;
	mx = max(a*d, mx);
	mx = max(b*c, mx);
	mx = max(b*d, mx);
	cout << mx << endl;
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &&i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(a) ((int)a.size())
#define pow2(n) (n * n)
#define int ll
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-8;
ll mod = static_cast<ll>(1e9 + 7);
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class F>
class FixPoint : private F {
public:
    explicit constexpr FixPoint(F &&f) : F(std::forward<F>(f)) {}
    template <class... Args>
    constexpr decltype(auto) operator()(Args &&... args) const { return F::operator()(*this, std::forward<Args>(args)...); }
};
template <class F>
constexpr decltype(auto) funcs(F &&f) { return FixPoint<F>{std::forward<F>(f)}; }
template <class T>
std::vector<T> vecs(int n, T &&val) { return std::vector<T>(std::forward<int>(n), std::forward<T>(val)); }
template <class... Args>
decltype(auto) vecs(int n, Args &&... args) { return std::vector<decltype(vecs(std::forward<Args>(args)...))>(std::forward<int>(n), vecs(std::forward<Args>(args)...)); }
template <class V, class T>
void fill(V &x, const T &val) { x = val; }
template <class V, class T>
void fill(vector<V> &vec, const T &val) {
    for (auto &&v : vec)
        fill(v, val);
}

void solve() {
    string s;
    cin >> s;
    int sum = 0;
    each(x, s) {
        sum += x - '0';
    }
    cout << (sum % 9 == 0 ? "Yes" : "No") << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3740
a, b, c, d = input()

import sys
ops = '+-'
for op1 in ops:
    for op2 in ops:
        for op3 in ops:
            s = '{}{}{}{}{}{}{}'.format(a, op1, b, op2, c, op3, d)
            if eval(s) == 7:
                print('{}=7'.format(s))
                sys.exit(0)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl a(n), b(n);
  bool ok = false;
  rep(i, n) {
    cin >> a[i] >> b[i];
    if(a[i] != b[i]) ok = true;
  }
  if(!ok) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = accumulate(all(a), 0LL);
  ll mn = 1e18;
  rep(i, n) {
    if(a[i] > b[i]) mn = min(mn, b[i]);
  }
  ans -= mn;
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int h1,h2,a1,a2;
void solve(){

    while(true){
        h2-=a1;
        if(h2<=0){
            cout<<"Yes"<<endl;
            break;
        }
        h1-=a2;
        if(h1<=0){
            cout<<"No"<<endl;
            break;
        }
    }
}

int main(){
    cin>>h1>>a1>>h2>>a2;

    solve();
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main(int argc, const char *argv[]) {
  long long int H, W, res;
  cin >> H >> W;

  if(H == 1 || W == 1) {
    cout << 1 << endl;
    return 0;
  }
  cout << (H * W + 1) / 2 << endl;
  return 0;
}



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

int cal(int x, int y, char z){
    if (z == '+'){
        return x + y;
    }
    else{
        return x - y;
    }
}

int main(){
    int K, S;
    cin >> K >> S;
    int count = 0;
    for (int x = 0; x <= K; x++){
        for (int y = 0; y <= K; y++){
            if ((x+y)<=S && S<=K+(x+y)){
                count++;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  string S;
  cin >> S;

  string T = "ATGC";

  int ans = 0;

  int now = 0;
  rep(i, S.size()){
    bool isATGC = false;
    rep(j, T.size()){
      if (S[i] == T[j]) isATGC = true;
    }

    if (!isATGC) now = 0;
    else{
      now ++;
      ans = max(now, ans);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3620
#include <stdio.h>
int main(void){
char s[100000];
  int i=1,ans=0;
  scanf("%s",s);
  while(s[i]){
  if(s[i]==s[i-1]){
    ans++;
    if(s[i]=='0'){
      s[i]='1';
    }else{
      s[i]='0';
  }
  }
    i++;
  
  }
    printf("%d",ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
void dice(){
  int d1,d2,d3,d4,d5,d6;
  cin>>d1>>d2>>d3>>d4>>d5>>d6;

  char dir;
  int tmp;
  while(true){
      cin>>dir;
      if(cin.eof()) break;
      if(dir=='E'){
          tmp=d1;d1=d4;d4=d6;d6=d3;d3=tmp;
      }else if(dir=='N'){
          tmp=d1;d1=d2;d2=d6;d6=d5;d5=tmp;
      }else if(dir=='S'){
          tmp=d1;d1=d5;d5=d6;d6=d2;d2=tmp;
      }else if(dir=='W'){
          tmp=d1;d1=d3;d3=d6;d6=d4;d4=tmp;
      }
  }
  cout<<d1<<endl;
}
int main(){
  dice();
  return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, nod, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 1; ll z = 0, o = 1;
vl flag, color, D; vll path;
int main() {
	string S;
	cin >> S;
	cin >> K;
	ll one = 0;
	ll key = -1;
	for (i = 0; i < S.length(); i++) {
		if (S[i] == '1') one++;
		else { key = ctoi(S[i]); break; }
	}
	if (K <= one) cout << '1';
	else cout << key;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define FORD(i, a, b) for (int i=(a); i>(b); i--)
#define PPC(x) __builtin_popcountll(x)
#define MSB(x) (31 - __builtin_clz(x))
#define SZ(x) ((int)(x).size())
#define BACK(x) prev((x).end())
#define HASK(x, y) ((x).find(y) != (x).end())
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;
 
const int maxN = 1 << 19, INF = 1000000000;

pair <long long, long long> T[maxN];
long long fin[maxN];

void solve()
{
	int n, d, a;
	scanf ("%d%d%d", &n, &d, &a);
	d *= 2;
	FOR(i, 0, n)
		scanf ("%lld%lld", &T[i].ft, &T[i].sd);
	sort(T, T+n);
	long long res = 0, bom = 0;
	
	FOR(i, 0, n)
	{
		long long x, hp; tie(x, hp) = T[i];
		bom -= fin[i];
		hp -= bom;
		if (hp <= 0)	continue;
		
		int ile = (hp + a-1) / a;
		res += ile;
		bom += a * ile;
		int j = upper_bound(T, T+n, make_pair(x+d, 1ll*INF)) - T;
		fin[j] += a * ile;	
	}
	
	printf("%lld\n", res);
}
 
int main()
{
	int t = 1;
	//scanf ("%d", &t);
	FOR(tid, 1, t+1)
	{
		//printf("Case #%d: ", tid);
		solve();
	}
	return 0;
}





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

using pii = pair<int,int>;
using ll = long long;
using vi = vector<int>;
#define f(i,a,b) for (int i = a; i < b; i++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
#define pb push_back

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	int n;	
	cin >> n;
	vi adj[n];
	f(i,0,n-1) {
		int a,b; cin>>a>>b;
		adj[--a].pb(--b); adj[b].pb(a);
	}
	vi pq;
	int deg[n];
	f(i,0,n) deg[i] = adj[i].size();
	f(i,0,n) if (deg[i] == 1)
		pq.pb(i);
	int h = 0;
	int m = 0;
	while (n-m>2) {
		vi nxt;	
		for (int v : pq) 
			for (int w : adj[v])
				if (--deg[w]==1) nxt.pb(w);	
		m += pq.size();
		pq = nxt;
		h++; 
	}
	map<int,int> freq;
	function<void(int,int,int)> dfs = [&](int v, int p, int d) {
		if (adj[v].size()-(p!=-1))
			Max(freq[d+1],int(adj[v].size()-(p!=-1)));
		for (int w : adj[v]) if (w != p)
			dfs(w,v,d+1);
	};
	ll ans = 1e18;
	if (pq.size() == 1) {
		{
			freq = map<int,int>();
			freq[0] = 1;
			dfs(pq[0],-1,0);				
			ll k = 1;
			for (pii pp : freq)
				k *= pp.second;
			Min(ans,k);
		}
		for (int w : adj[pq[0]]) {
			freq = map<int,int>();
			freq[0] = 1;
			dfs(pq[0],w,0); dfs(w,pq[0],0);
			ll k = 1;
			for (pii pp : freq)
				k *= pp.second;
			Min(ans,2*k);
		}
	} else {
		freq = map<int,int>();
		freq[0] = 1;
		dfs(pq[0],pq[1],0); dfs(pq[1],pq[0],0);
		ll k = 1;
		for (pii pp : freq)
			k *= pp.second;
		Min(ans,2*k);
	} 
	cout << h+1 << " " << ans << endl;


#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}



Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner stdIn = new Scanner(System.in);
		int mod = 998244353;
		int N = stdIn.nextInt();
		int K = stdIn.nextInt();
		ArrayList<Integer> L = new ArrayList<Integer>();
		ArrayList<Integer> R = new ArrayList<Integer>();
		for(int i = 0; i < K; i ++) {
			L.add(stdIn.nextInt());
			R.add(stdIn.nextInt());
		}
		
		ArrayList<Long> A = new ArrayList<Long>();
		A.add((long) 0);
		A.add((long) 1);
		ArrayList<Long> Sum = new ArrayList<Long>();
		Sum.add((long) 0);
		Sum.add((long) 1);
		
		for(int i = 2; i <= N; i ++) {
			long addNum = 0;
			for(int j = 0; j < K; j ++) {
				int idxL = i - R.get(j) - 1;
				int idxR = i - L.get(j);
				if(idxR <= 0) {
					continue;
				}else if(idxL < 0 && 0 <idxR) {
					addNum += (Sum.get(idxR) - Sum.get(0)) % mod;
				}else {
					addNum += (Sum.get(idxR) - Sum.get(idxL)) % mod;
				}
			}
			A.add(addNum);
			Sum.add(Sum.get(Sum.size() - 1) + addNum);
		}
      
		System.out.println(A.get(A.size() - 1) % mod);
	}
}

Measured memory_bytes: 65988
N = int(input())
A = [int(i) for i in input().split()]
k = [0] * N
j = (N-1) % 2
for a in A:
    if a % 2 != j:
        print(0)
        break
    elif a == 0 and k[0] == 1:
        print(0)
        break
    elif k[a] == 2:
        print(0)
        break
    else:
        k[a] += 1
else:
    ans = 1
    i = 0
    while(i<(N-1)//2+j):
        ans *= 2
        ans %= 10**9+7
        i += 1
    print(ans)


Measured memory_bytes: 13880
#include <stdio.h>
#include <ctype.h>

int main(){
    int count[26]={0};
    char ch;
    int i, num;

    while(scanf("%c", &ch)!=EOF){
        if(islower(ch)){
            num=ch-'a';
        }else if(isupper(ch)){
            num=ch-'A';
        }else{
            continue;
        }
        count[num]++;
    }
    for(i=0;i<26;i++){
        printf("%c : %d\n", 'a'+i, count[i]);
    }

    return 0;
}

Measured memory_bytes: 544
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to,cap,rev; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
//typedef vector<edge> edges;
//vector<edges> G;

vector<edge> edges;
int graph[60][60];

bool vis[60];
int n, m;

void dfs(int v) {
	if (vis[v])return;
	vis[v] = 1;
	FORI(0, n) {
		if (graph[v][i]) {

			dfs(i);
		}
	}
}
int main(){
	cin >> n >> m;
	FORI(0, m) {
		int x, y;
		cin >> x >> y; x--; y--;
		edges.push_back(edge(x , y ));
		graph[x][y] = 1; graph[y][x] = 1;

	}
	int cnt = 0;
	FORI(0, m) {
		edge e = edges[i];
		graph[e.from][e.to] = graph[e.to][e.from] = 0;
		memset(vis, 0, sizeof(vis));
		dfs(0);
		bool connected=true;
		FORJ(0, n) {
			if (!vis[j])connected = false;
		}
		if (!connected)cnt++;
		graph[e.from][e.to] = graph[e.to][e.from] =  1;



	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


int main() {
    ios_base::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    ll ans=0;
    rep(i,n-k) ans+=a[i];
    cout << ans << endl;


    return 0;   
}


Measured memory_bytes: 1024
#include <cstdio>

int main() {
    int x, a, b;
    while (~scanf("%d%d%d", &x, &a, &b)) {
        a -= x, b -= x;
        if (a < 0) a = -a;
        if (b < 0) b = -b;
        if (a < b) puts("A");
        else puts("B");
    }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define fh(i,be,e) for(int i=head[be];~i;i=e[i].next)
#define fa(i,V) for(auto i:V)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define P pair<int,int>
#define SET set<int>
#define mp map<int,int>
#define mk make_tuple
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m
#define bffs(i) __builtin_ffs(i)
#define bcount(i) __builtin_popcount(i)
#define bone(i) ((1<<i)-1)
using namespace std;
const int INF=LLONG_MAX-1e10;
const int dx[]={0,0,-1,1},dy[]={-1,1,0,0};//up down left right
const int maxn=1e6+1e5;
const int mo_num=1e9+7;
int n,m,t,a[maxn],b[maxn],ans;
int f[15][15];
main() {
    IOS
    int k;
    cin >> n >> m >> k;
    ans = INF;
    fun(i)
    {
        cin>>b[i];
        fum(j)cin>>f[i][j];
    }
    fu(i,0,(1<<n)-1)
    {
        int num=0,key=1;
        fum(ll)a[ll]=0;
        fu(j,1,n)
        {
            if(i&(1<<(j-1)))
            {
                num+=b[j];
                fum(l)
                {
                    a[l]+=f[j][l];
                }
            }
        }
        fum(l)if(a[l]<k){key=0;break;}
        if(!key)continue;
        ans=min(ans,num);
    }
    out(ans==INF?-1:ans)
    return 0;
}

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

int main()
{
    int H, N;
    cin >> H >> N;
    uint64_t s=0;
    for(int n=0; n<N; n++){
        int A;
        cin >> A;
        s += A;
    }
    if(s >= H){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
	return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());
  if(s < t) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int l = a+b;
  int r = c+d;
  if(l==r){
    cout << "Balanced" << endl;
  }else if(l>r){
    cout << "Left" << endl;
  }else{
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
//??????????¨????????????????????¬¬??????????¢?
//BFS
#include <iostream>
#include <queue>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#define MAX_H 1001
#define MAX_W 1001
#define MAX_N 10

using namespace std;

typedef pair<int,int> P;
int H,W,N;
int sx,sy;
int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
char Loc[MAX_H][MAX_W];
int FoodX[MAX_N];
int FoodY[MAX_N];

int BFS(int sa,int sb,int ea,int eb)
{
    int D[H][W];
    for(int i=0;i<H;i++)
        for(int j=0;j<W;j++) D[i][j]=INT_MAX;
    queue<P> que;
    que.push(P(sa,sb));
    D[sa][sb]=0;
    while(que.size())
    {
        P p=que.front();
        for(int i=0;i<4;i++)
        {
            int nx=p.first+dx[i],ny=p.second+dy[i];
            if(nx>=0&&nx<H&&ny>=0&&ny<W&&Loc[nx][ny]!='X'&&D[nx][ny]==INT_MAX)
            {
                que.push(P(nx,ny));
                D[nx][ny]=D[p.first][p.second]+1;
            }
            if(nx==ea&&ny==eb) return D[nx][ny];
        }
        que.pop();
    }
}

int main()
{
    cin>>H>>W>>N;
    int k=0,step=0;
    for(int i=0;i<H;i++)
    {
        getchar();
        for(int j=0;j<W;j++)
        {
            scanf("%c",&Loc[i][j]);
            if(Loc[i][j]=='S') {sx=i;sy=j;}
            if(Loc[i][j]>='1'&&Loc[i][j]<='9') {FoodX[Loc[i][j]-'0']=i;FoodY[Loc[i][j]-'0']=j;}
        }
    }
    FoodX[0]=sx;
    FoodY[0]=sy;
    for(int i=0;i<N;i++)
    {
        step+=BFS(FoodX[i],FoodY[i],FoodX[i+1],FoodY[i+1]);
    }
    cout<<step<<endl;
    return 0;
}

Measured memory_bytes: 8040
/***************************************************
 * Problem Name : B - Common Raccoon vs Monster.cpp
 * Problem Link :
 * OJ           :
 * Verdict      : Trying
 * Date         : 2020-02-03
 * Problem Type :
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <bitset>
#include <cassert>
#include <map>
#include <set>
#include <cassert>
#include <iomanip>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;

#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define __FileRead freopen ("input.txt", "r", stdin)
#define __FileWrite freopen ("output.txt", "w", stdout)
#define SET(a,v) memset(a,v,sizeof(a))
#define SZ(v) (int)v.size()
#define pii pair<int,int>
#define pil pair <int, ll>
#define pli pair <ll, int>
#define pll pair <ll, ll>
#define debug cout <<"######\n"
#define debug1(x) cout <<"### " << x << " ###\n"
#define debug2(x,y) cout <<"# " << x <<" : "<< y <<" #\n"
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define rall(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define r_srt(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.begin(), v.end())
#define Sqr(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define MAX 100005
#define INF 1000000009
#define MOD 1000000007

template<class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;
template<typename T>
using ordered_set  = tree<T, null_type, less<T>, rb_tree_tag,
      tree_order_statistics_node_update>;

template <typename T> string toString ( T Number ) {
    stringstream ss;
    ss << Number;
    return ss.str();
}
template<typename T> int toInt (T str) {
    stringstream ss;
    ss << str;
    int num;
    ss >> num;
    return num;
}
ll lcm (ll a, ll b) {
    return a * b / __gcd (a, b);
}
/************************************ Code Start Here ******************************************************/
int main () {
    //~ __FastIO;
    //~ cout << setprecision (10);
    //~ cout << fixed;
    int n, k, sum = 0;
    cin >> n >> k;
    for(int i = 0; i<k; i++){
		int x;
		cin >> x;
		sum+=x;
	}
	if(sum>=n)cout << "Yes\n";
	else cout << "No\n";
    return 0;
}


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

int soat3(int& a,int& b,int& c){
  if(a<b)swap(a,b);
  if(a<c)swap(a,c);
  if(b<c)swap(b,c);
}

int main(){
  int a,b,c;
  cin >> a >> b >> c;

  soat3(a,b,c);

  if(a == 7 && b == 5 && c == 5){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b

signed main(){
	int k,n; cin>>n>>k;
	if((n+2-1)/2>=k)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 3616