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

int main() {
  long a,b,c,d;
  string abcd;
  cin >> abcd;
  a=abcd[0]-'0';
  b=abcd[1]-'0';
  c=abcd[2]-'0';
  d=abcd[3]-'0';
  if(a+b+c+d==7) cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
  else if(a+b+c-d==7) cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
  else if(a+b-c+d==7) cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
  else if(a+b-c-d==7) cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
  else if(a-b+c+d==7) cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
  else if(a-b+c-d==7) cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
  else if(a-b-c+d==7) cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
  else if(a-b-c-d==7) cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
void swap(int *,int *);

int main(){
  int i,j,n,A[100],c=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  for(i=0;i<=n-1;i++){
    for(j=n-1;j>=i+1;j--){
      if(A[j] < A[j-1]){
	swap(&A[j],&A[j-1]);
	c++;
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i<n-1)printf(" ");
  }
  printf("\n%d\n",c);
  return 0;
}

void swap(int *a,int *b){
  int t;
  t=*a;
  *a=*b;
  *b=t;
}

Measured memory_bytes: 604
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    string S,T;
    int a,b;
    string U;
    cin >> S >> T;
    cin >> a >> b;
    cin >> U;
    if(S == U){
        cout << a-1 << " " << b << endl;
    }else{
        cout << a << " " << b-1 << endl;
    }


}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int, int> p;
const int INF = (1 << 28);
const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
#define yes cout << "Yes" << el
#define YES cout << "YES" << el
#define no cout << "No" << el
#define NO cout << "NO" << el
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.e()
int h, w;
string s[2000];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h>>w;
    for(int i=0;i<h;i++) cin>>s[i];
    int t[h][w];
    int y[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            t[i][j]=0;
            y[i][j]=0;
        }
    }
    for(int i=0;i<h;i++){
        int count=0;
        int e=0;
        for(int j=0;j<w;j++){
            if(j==w-1){
                if(s[i][j]=='#'){
                    for(int k=e;k<w-1;k++){
                    y[i][k]=count;
                }
                }
                else{
                    for(int k=e;k<w;k++){
                    y[i][k]=count+1;
                }
                }
            }
            else if(s[i][j]=='#'){
                for(int k=e;k<j;k++){
                    y[i][k]=count;
                }
                count=0;
                e=j+1;
            }
            else count++;
        }
    }
    for(int i=0;i<w;i++){
        int count=0;
        int e=0;
        for(int j=0;j<h;j++){
            if(j==h-1){
                if(s[j][i]=='#'){
                for(int k=e;k<h-1;k++){
                    t[k][i]=count;
                }
                }
                else{
                    for(int k=e;k<h;k++){
                    t[k][i]=count+1;
                }
                }
            }
            else if(s[j][i]=='#'){
                for(int k=e;k<j;k++){
                    t[k][i]=count;
                }
                count=0;
                e=j+1;
            }
            else{
                count++;
            }
        }
    }
    int ans=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            ans=max(t[i][j]+y[i][j],ans);
        }
    }
    cout << ans-1<< "\n";
}

Measured memory_bytes: 35712
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const arr = lines.shift().split(' ').map(Number);
  buildMaxHeap(arr);
  console.log(arr.reduce((s, e) => s += ' ' + e, ''));
})();

function buildMaxHeap(arr) {
  const n = arr.length;
  const maxHeapify = (i) => {
    let left, right, largest, tmp;
    left = 2 * i + 1;
    right = 2 * i + 2;
    if (left < n && arr[left] > arr[i]) largest = left;
    else largest = i;
    if (right < n && arr[right] > arr[largest]) largest = right;
    if (largest != i) {
        tmp = arr[i];
        arr[i] = arr[largest];
        arr[largest] = tmp;
    //   arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
  };

  for (let i = Math.floor(arr.length / 2); i >= 0; i--) maxHeapify(i);
}



Measured memory_bytes: 143552
#include <iostream>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 7;
ll num,x;
ll arr[maxn];
ll quick_mi(ll a, ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b&1)
            ans = ans*a%mod;
        a = a*a%mod;
        b >>= 1;
    }
    return ans;
}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cin>>num;
    for(int i = 0; i < num; ++i)
    {
        cin>>x;
        arr[x]++;
        if(arr[x] > 2)
        {
            std::cout<<0<<'\n';
            return 0;
        }
    }
    if(num&1)
    {
        if(arr[0]>1)
            std::cout<<0<<'\n';
        else
        {
            ll aim = quick_mi(2,num/2);
            std::cout<<aim<<'\n';
        }
    }
    else
    {
       if(arr[0] > 0)
            std::cout<<0<<'\n';
       else
        {
            ll aim = quick_mi(2,num/2);
            std::cout<<aim<<'\n';
        }
    }
    return 0;
}


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

int bit_remove(int bit, int i){// A*B -> AB
    int A = bit >> (i+1);
    int B = bit & ((1<<i) - 1);
    return (A << i) + B;
}

int bit_insert(int bit, int i, int x){// AB -> A*B
    int A = bit >> i;
    int B = bit & ((1<<i) - 1);
    return (A << (i+1)) + (x << i) + B;
}

vector<int> DFS(int a, int b, int n){
    if(n == 1) return {a,b};

    for(int i=0; i<n; i++){
        if((a >> i & 1) ^ (b >> i & 1)){
            int na = bit_remove(a,i);
            int nb = bit_remove(b,i);

            for(int j=0; j<(1<<n); j++){
                int x = bit_remove(j, i);
                
                if(__builtin_popcount(na) % 2 != __builtin_popcount(x) % 2
                && __builtin_popcount(nb) % 2 != __builtin_popcount(x) % 2){
                    vector<int> ans1 = DFS(na, x, n-1);
                    vector<int> ans2 = DFS(x, nb, n-1);

                    for(auto& a1 : ans1) a1 = bit_insert(a1, i, (a >> i) & 1);
                    for(auto& a2 : ans2) a2 = bit_insert(a2, i, (b >> i) & 1);
                    
                    ans1.insert(ans1.end(), ans2.begin(), ans2.end());
                    return ans1;
                }
            }
        }
    }
    //assert(false);
    return {};
}

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    
    if(__builtin_popcount(a) % 2 == __builtin_popcount(b) % 2){
        cout << "NO" << endl;
        return 0;
    }

    cout << "YES" << endl;
    vector<int> ans = DFS(a,b,n);

    for(int i=0; i<(1<<n); i++){
        cout << ans[i];
        if(i == (1<<n)-1) cout << endl;
        else cout << " ";
    }
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long
const int INF = 1e9 + 7;

using namespace std;

#define MAX_V 100000
typedef pair<int,int> P;
struct edge{
    int to,cost;
};
int V;
vector<edge> G[MAX_V];
bool used[MAX_V];

//priority_queue使用版，0(ElogV)
int prim(){
    ll res=0,s=0;
  //greater<P>でfisrtが小さい順に取り出せるように
    priority_queue<P,vector<P>,greater<P>> que;
    REP(i,V) used[i] = false;
    que.push(P(0,s));

    while(!que.empty()){
        P p = que.top(); que.pop();
        int v = p.second;
        if(used[v]) continue;
        used[v] = true;
        res += p.first;
        REP(i,G[v].size()) que.push(P(G[v][i].cost, G[v][i].to));
    }
    return res;
}

int main(){
    cin.tie(0), ios::sync_with_stdio(false);
    cin >> V;
    vector<pair<int,int>> vx(V),vy(V);
    REP(i,V){
        cin >> vx[i].first >> vy[i].first;
        vx[i].second = vy[i].second = i;
    }
    sort(vx.begin(),vx.end());
    REP(i,V-1){
        G[vx[i].second].push_back(edge{vx[i+1].second,vx[i+1].first-vx[i].first});
        G[vx[i+1].second].push_back(edge{vx[i].second,vx[i+1].first-vx[i].first});
    }
    sort(vy.begin(),vy.end());
    REP(i,V-1){
        G[vy[i].second].push_back(edge{vy[i+1].second,vy[i+1].first-vy[i].first});
        G[vy[i+1].second].push_back(edge{vy[i].second,vy[i+1].first-vy[i].first});
    }

    /*
    REP(i,V){
        REP(j,G[i].size()){
            cout << "G[" << i << "][" << G[i][j].to << "]:" << G[i][j].cost << "\n";
        }
    }
    */

    cout << prim() << "\n";
    return 0;
}


Measured memory_bytes: 12024
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c,x,y,z;
double d,e,f;
string s,t;
//

signed main() {
  RAPID;
  IN3(a,b,c);
  if(a*c<=b) OUT(c);
  else OUT(b/a);
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
H, W = read_int()

range_W = range(W)
range_H = range(H)
# nomal
L = [[0 for _ in range_W] for _ in range_H]
R = [[0 for _ in range_W] for _ in range_H]
U = [[0 for _ in range_W] for _ in range_H]
D = [[0 for _ in range_W] for _ in range_H]
res = [[0 for _ in range_W] for _ in range_H]
grid = []

append = grid.append
for i in range_H:
    row = list(" ".join(input()).split())
    append(row)

def solve():
    ans = 0
    for i in range_H:
        for j in range_W:
            if grid[i][j] == ".":
                L[i][j] = 1 if j == 0 else L[i][j - 1] + 1
                U[i][j] = 1 if i == 0 else U[i - 1][j] + 1
                res[i][j] += L[i][j] + U[i][j]
                ans = max(res[i][j], ans)

            if grid[H - i - 1][W - j - 1] == ".":
                R[H - i - 1][W - j - 1] = 1 if j == 0 else R[H - i - 1][W - j] + 1
                D[H - i - 1][W - j - 1] = 1 if i == 0 else D[H - i][W - j - 1] + 1
                res[H - i - 1][W - j - 1] += R[H - i - 1][W - j - 1] + D[H - i - 1][W - j - 1]
                ans = max(res[H - i - 1][W - j - 1], ans)
    return ans - 3

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


Measured memory_bytes: 346632
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char* argv[])
{
	int A[3][3],C[3][3];
	int i,j;
	for (i=0;i<3;i++){
		for (j=0;j<3;j++){
			cin>>A[i][j];
			C[i][j]=0;
		}
	}
	int N;
	cin>>N;
	int b;
	for (int k=0;k<N;k++){
		cin>>b;
		for (i=0;i<3;i++){
			for (j=0;j<3;j++){
				if (A[i][j]==b){
					C[i][j]=1;
				}
			}
		}		
	}
	int OK=0;
	for (i=0;i<3;i++){
		OK=0;
		for (j=0;j<3;j++){
			OK+=C[i][j];
		}
		if (OK==3){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	for (j=0;j<3;j++){
		OK=0;
		for (i=0;i<3;i++){
			OK+=C[i][j];
		}
		if (OK==3){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	OK=0;
	for (i=0;i<3;i++){
		OK+=C[i][i];
	}
	if (OK==3){
		cout<<"Yes"<<endl;
		return 0;
	}
	OK=C[2][0]+C[1][1]+C[0][2];
	if (OK==3){
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC142C_2
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var d = ReadInt();

            d = d.OrderBy(x => x).ToArray();

            int ans = 0;
            int a = d[N / 2 - 1];
            int b = d[N / 2];
            if (a == b) ans = 0;
            else ans = b - a;

            Console.WriteLine(ans);
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


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

class Main {

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		int[] P = new int[N];
		for (int i = 0; i < N; i++) {
			P[i] = sc.nextInt();
		}

		int[] Q = new int[N];
		for (int i = 0; i < N; i++) {
			Q[i] = sc.nextInt();
		}

		int[] a = new int[N];
		for (int i = 0; i < N; i++) {
			a[i] = i + 1;
		}

		int cp = 0;
		while (true) {
			boolean ok = true;
			for (int i = 0; i < a.length; i++) {
				if (P[i] != a[i]) {
					ok = false;
					break;
				}
			}
			if (ok) break;
			cp++;
			if (!nextPermutation(a)) break;
		}

		for (int i = 0; i < N; i++) {
			a[i] = i + 1;
		}

		int cq = 0;
		while (true) {
			boolean ok = true;
			for (int i = 0; i < a.length; i++) {
				if (Q[i] != a[i]) {
					ok = false;
					break;
				}
			}
			if (ok) break;
			cq++;
			if (!nextPermutation(a)) break;
		}

		System.out.println(Math.abs(cp - cq));
	}

	private static boolean nextPermutation(int[] a) {
		int n = a.length, k = n - 2, l = n - 1;
		while (k >= 0 && a[k] > a[k + 1]) k--;
		if (k < 0) return false;
		while (a[l] <= a[k]) l--;
		swap(a, k, l);
		k++;
		n--;
		while (k < n) swap(a, k++, n--);
		return true;
	}

	private static void swap(int[] a, int i, int j) {
		int t = a[i];
		a[i] = a[j];
		a[j] = t;
	}


}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
int l,r;
int main(){
	scanf("%d%d",&l,&r);
	int q=l+2019-l%2019;
	if(r>=q)puts("0");
	else{
		int mi=2020,Q=l%2019,W=r%2019;
//		cout<<Q<<" "<<W<<endl;
		for(int i=Q;i<=W;i++)
			for(int j=i+1;j<=W;j++)mi=min(mi,i*j%2019);
		printf("%d\n",mi);
	}
	return 0;
}

Measured memory_bytes: 256
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char **argv)
{
    int a, b, c, x;
    scanf("%d %d %d %d", &a, &b, &c, &x);
    int ans = 0;
    for (int i = 0; i <= a; i++) {
        int s = 500 * i;
        for (int j = 0; j <= b; j++) {
            int t = s + 100 * j;
            for (int k = 0; k <= c; k++) {
                int u = t + 50 * k;
                if (u == x) ans++;
            }
        }
    }
    printf("%d\n", ans);
    return EXIT_SUCCESS;
}


Measured memory_bytes: 128
#include<iostream>
#include<queue>
#include<iomanip>
#include<vector>
#include<string>

using namespace std;

#define MAX 1024
#define N 10
#define SIZE 22

#define NONE 0
#define START 1
#define DIRTY_TILE 2
#define FURNITURE 3

#define INFTY 1<<16

void bfs(int sti, int stj, int map[SIZE][SIZE], int cost_map[SIZE][SIZE]){
	const int di[] = {-1,0,1,0};
	const int dj[] = {0,1,0,-1};
	bool vis[SIZE][SIZE]={{false,},};
	queue< pair<int,int> > q;

	for(int i = 0; i < SIZE; ++i){
		for(int j = 0; j < SIZE; ++j){
			cost_map[i][j] = INFTY;
		}
	}

	q.push( make_pair(sti,stj) );
	cost_map[sti][stj]=0;
	vis[sti][stj]=true;
	while(!q.empty()){
		pair<int,int> t = q.front();
		q.pop();

		for(int k = 0; k < sizeof(di)/sizeof(*di); ++k){
			int ti = t.first + di[k];
			int tj = t.second + dj[k];
			if( map[ti][tj] != FURNITURE && !vis[ti][tj] ){
				cost_map[ti][tj] = cost_map[t.first][t.second] + 1;
				vis[ti][tj]=true;
				q.push( make_pair(ti,tj) );
			}
		}
	}
}

int dp(int n, int ini_cost[N], int cost[N][N] ){
	int ret=INFTY;
	int w[MAX][N];

	for(int state=0;state<(1<<n);++state){
		for(int i=0;i<n;++i){
			w[state][i]=INFTY;
		}
	}

	for(int i=0;i<n;++i){
		w[0][i]=ini_cost[i];
	}

	for(int state=1;state<(1<<n);++state){
		for(int i=0;i<n;++i){
			if(!(state&(1<<i))){
				for(int j=0;j<n;++j){
					if(state&(1<<j)){
						int pre_state=state^(1<<j);
						w[state][i]=min(w[state][i],w[pre_state][j]+cost[j][i]);
					}
				}
				//cout<<w[state][i]<<endl;
			}
		}
	}

	for(int i=0;i<n;++i){
		ret=min(ret,w[((1<<n)-1)^(1<<i)][i]);
	}

	return ret;
}

int CleaningRobot(int h, int w, int map[SIZE][SIZE]){
	int cost[N][N];
	int ini_cost[N];
	int cost_map[SIZE][SIZE];
	vector< pair<int, int> > vtiles;

	for(int i = 1; i <= h; ++i){
		for(int j = 1; j <= w; ++j){
			if( map[i][j] == DIRTY_TILE ){
				vtiles.push_back( make_pair( i, j ) );
			}
			if( map[i][j] == START ){
				bfs(i,j,map,cost_map);
			}
		}
	}

	for(unsigned int i = 0; i < vtiles.size(); ++i){
		ini_cost[i]=cost_map[vtiles[i].first][vtiles[i].second];
	}

	for(unsigned int i = 0; i < vtiles.size(); ++i){
		bfs(vtiles[i].first,vtiles[i].second,map,cost_map);
		
		/*for(int k = 1; k <= h; ++k){
			for(int l = 1; l <= w; ++l){
				cout << setw(4) << cost_map[k][l];
			}
			cout << endl;
		}
		cout << endl;
		*/

		for(unsigned int j = 0; j < vtiles.size(); ++j){
			cost[i][j] = cost[j][i] = cost_map[vtiles[j].first][vtiles[j].second];
			if(cost[i][j]>=INFTY)return -1;
		}
	}

	int ret = dp(vtiles.size(),ini_cost,cost);
	return ret>=INFTY?-1:ret;
}

int main(){
	while(true){
		int h,w;
		int map[SIZE][SIZE];
		cin>>w>>h;
		if(h==0&&w==0)break;
		for(int i=0;i<SIZE;++i){
			for(int j=0;j<SIZE;++j){
				map[i][j]=FURNITURE;
			}
		}
		for(int i=1;i<=h;++i){
			string s;
			cin>>s;
			for(unsigned int j=0;j<s.length();++j){
				switch(s[j]){
					case '.':
						map[i][j+1]=NONE;
						break;
					case 'x':
						break;
					case 'o':
						map[i][j+1]=START;
						break;
					case '*':
						map[i][j+1]=DIRTY_TILE;
						break;
				}
			}
		}

		cout << CleaningRobot(h,w,map) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
int cmp(const int *a,const int *b){
  return *a-*b;
}
int main(){
  int i,n,x,a[100];
  scanf("%d%d",&n,&x);
  for(i=0;i<n;i++)scanf("%d",&a[i]);
  qsort(a,n,sizeof(int),cmp);
  for(i=0;i<n;i++){
    if(a[i]>x)break;
    x-=a[i];
  }
  if(i==n&&x!=0)i--;
  printf("%d",i);
  return 0;
}

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

const int MAXN = 2e5 + 10;


int main(){
	int a , b , c , d;
	scanf("%d%d%d%d" , &a , &b , &c , &d);
	while(1){
		c -= b;
		if(c <= 0){
			printf("Yes\n");
			return 0;
		}

		a -= d;

		if(a <= 0){
			printf("No\n");
			return 0;
		}
	}	
}


Measured memory_bytes: 3676
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var plans = new List<List<int>>();
        for (int i = 0; i < n; i++)
        {
            plans.Add(Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToList());
        }

        var x = 0;
        var y = 0;
        var dt = 0;
        for (int i = 0; i < plans.Count; i++)
        {
            dt = plans[i][0] - dt;
            var dist = Math.Abs(plans[i][1] - x) + Math.Abs(plans[i][2] - y);
            if (dist <= dt && dist % 2 == dt % 2)
            {
                x = plans[i][1];
                y = plans[i][2];
                dt = plans[i][0];
            }
            else
            {
                Console.WriteLine("No");
                return;
            }
        }

        Console.WriteLine("Yes");
    }
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

const ll MOD = 1000000007;
const ll INF = 1e18; //1*10^18
const double PI = 3.14159265;

int ctoi(char c)
{
  if (c >= '0' && c <= '9')
  {
    return c - '0';
  }
  return 0;
}

ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
//最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//最小公倍数

ll powll(ll a, ll n)
{ //O(log n)
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a;
    }
    a = a * a;
    n >>= 1; //(n & 1)=(n % 2 !=0)
  }
  return res;
}

ll modpow(ll a, ll n, ll mod) //O(log n)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a % mod;
    }
    a = a * a % mod;
    n >>= 1; //(n>>=1)=(n/2)
  }
  return res;
}

int ReturnDigit(ll num)
{
  string number = to_string(num);
  return number.length();
}

const ll MAX = 1e4;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind
{
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N)
  { //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++)
      par[i] = i;
  }

  int root(int x)
  { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y)
  {                   // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry)
      return;     //xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y)
  { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main()
{
  // srand((unsigned int)time(NULL));//--> rand()
  ll i, j, k, l, ans = 1;
  ll n, m;
  cin >> n >> m;
  for (i = 1; i * i <= m; i++)
  {
    if (m % i == 0)
    {
      // cout << i << ' ' << m / i << endl;
      if (i >= n)
      {
        ans = max(ans, m / i);
      }
      if (m / i >= n)
      {
        // cout << m / i << endl;
        ans = max(ans, i);
      }
    }
  }
  cout << ans << endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
clock_t startTime;
long double getTime(){
	return (long double)(clock()-startTime)/CLOCKS_PER_SEC;
}

int main(){
	startTime=clock();
	int h,w;
	cin >> h >> w;
	int a[h][w];
	std::vector<tuple<int,int,int,int>> v;
	int n=0;
	FOR(i,h){
		int count=0;
		FOR(j,w){
			cin >> a[i][j];
			a[i][j]+=count;	
			count=0;
			if(j!= w-1 && a[i][j]%2==1){
				v.PB(MT(i+1,j+1,i+1,j+2));
				count++;
				n++;
				a[i][j]--;
			}

		}
	}
	
	

	cout <<"\n";

	FOR(i,h-1){
		if(a[i][w-1]%2){
			a[i][w-1]--;
			v.PB(MT(i+1,w,i+2,w));
			a[i+1][w-1]++;
			n++;
		}
	}

	

	cout << n <<"\n";
	for(auto x : v){
		cout << get<0>(x) << " "<< get<1>(x)<<" " ;
		cout << get<2>(x) << " " <<get<3>(x)<<"\n";
	}

	


	return 0;
}

Measured memory_bytes: 6432
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
using ii=long long;
const int inf = 1e9;
const ii iinf = 1e18;
int main()
{
    int n;
    cin >> n;
    vector<vector<int>> v(n, vector<int>(n));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> v[i][j];
        }
    }
    vector<ii> dp(1 << n), res(1 << n);
    for (int i = 0; i < (1 << n); ++i) {
        for (int j = 0; j < n; ++j) {
            if (!((1 << j) & i)) continue;
            for (int h = 0; h < j; ++h) {
                if (!((1 << h) & i)) continue;
                dp[i] += v[j][h];
            }
            
        }
    }
    for (int i = 0; i < (1 << n); ++i) {
        for (int j = i; j; j = (j - 1) & i) {
            res[i] = max(res[i], dp[j] + res[i ^ j]);
        }
    }
    cout << res[(1 << n) - 1] << "\n";
}


Measured memory_bytes: 1280
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;



int main(void){
	ll x,y,z,a[100010],b[100010],c[100010],sum[100010]={},sp,ans=0;
	mp p[100010];
	priority_queue<ll> Q1,Q2;
	cin>>x>>y>>z;
	reg(i,1,x+y+z){
		cin>>a[i]>>b[i]>>c[i];
		p[i] = make_pair(b[i]-a[i],i);
	}
	sort(p+1,p+x+y+z+1);
	// reg(i,1,x+y+z)cout<<p[i].first<<endl;
	//左側
	sp=0;
	reg(i,1,x){
		ll s=p[i].second;
		Q1.push(c[s]-a[s]);//これが大きいものから銅に変えていく
		sp+=a[s];
	}
	sum[x]+=sp;
	reg(k,x+1,x+z){//左側
		ll s=p[k].second;
		Q1.push(c[s]-a[s]);
		ll t=Q1.top();
		Q1.pop();
		sp+=a[s]+t;
		sum[k]+=sp;
	}
	//右側（k番目の要素を抜くみたいなことができないため，左側と同時にはできない）
	sp=0;
	reg(i,x+z+1,x+z+y){
		ll s=p[i].second;
		Q2.push(c[s]-b[s]);//これが大きいものから銅に変えていく
		sp+=b[s];
	}
	sum[x+z]+=sp;
	ireg(k,x+1,x+z){//左側
		ll s=p[k].second;
		Q2.push(c[s]-b[s]);
		ll t=Q2.top();
		Q2.pop();
		sp+=b[s]+t;
		sum[k-1]+=sp;
	}
	//左右の合計値が最大の物を選ぶ
	reg(k,x,x+z){
		ans=max(ans,sum[k]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6172
#151_D
import queue
h, w = map(int, input().split())
c = [input() for _ in range(h)]
inf = 10 ** 4
 
def bfs(sx,sy):
    d = [[-inf]*w for _ in range(h)]
    que = queue.Queue()
    que.put([sx,sy])
    d[sx][sy] = 0
    res = 0
    while not que.empty():
        qx, qy = que.get()
        for dx,dy in [[1,0],[-1,0],[0,1],[0,-1]]:
            px, py = qx+dx, qy+dy
            if 0<=px<h and 0<=py<w and c[px][py]=='.' and d[px][py]== -inf:
                que.put([px,py])
                d[px][py] = d[qx][qy]+1
                res = max(d[px][py], res)
    return res            

ans = 0
for i in range(h):
    for j in range(w):
        if c[i][j] == '.':
            ans = max(ans, bfs(i, j))
            
print(ans)

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define CEIL(n, m) ceil(n/pow(10.0, m))*pow(10.0, m)
#define FLOOR(n, m) floor(n/pow(10.0, m))*pow(10.0, m)
#define ROUND(n, m) round(n/pow(10.0, m))*pow(10.0, m)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define llong long long
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

void solve()
{
  llong n, m;
  cin >> n >> m;

  if (n > m/2) {
    cout << m/2 << endl;
    return;
  }

  llong d = m - (n*2);
  cout << n+(d/4) << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<string>
using namespace std;
#define reps(i,j,n) for(int i = j ; i < n ; ++i)
#define rep(i,n) reps(i,0,n)
#define fr first
#define sc second
#define INF (1 << 30)
typedef pair< int , int > Pt;

int main(){
  string str;
  int cnt = 0;
  cin >> str;
  for(int i = 0 , j = str.size() - 1 ; i <= j ; i++ , j-- ){
    if( (str[i]=='('&&str[j]==')') || (str[i]==')'&&str[j]=='(') ||
        (str[i]=='i'&&str[j]=='i') || (str[i]=='w'&&str[j]=='w') )
      continue;
    cnt++;
  }
  cout << cnt << endl;
}

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a>=b&&a>=c){
    cout << (10*a)+b+c;
  }
  else if(b>=a&&b>=c){
    cout << (10*b)+a+c;
  }
  else{
    cout << (10*c)+a+b;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <LL,LL>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,a[100010],b[100010],ans=0,now=0;
multiset <pii> sa,sb,svsa,svsb;//sa:左节点最大;sb:右节点最小 

LL solve(int whi)
{
	now=0;
	LL ret=0;
	pii to;
	int fw=whi;
	while(sa.size()>0)
	{
		if(whi==0)
		{
			to=*sa.begin();
			//if(fw==0)cout<<to.fi<<' '<<to.se<<' '<<now<<endl;
			if(-to.fi<=now&&now<=-to.se) break;
			sa.erase(sa.begin());
			sb.erase(sb.find({-to.se,-to.fi}));
		}
		else
		{
			to=*sb.begin();
			if(to.se<=now&&now<=to.fi) break;
			sb.erase(sb.begin());
			sa.erase(sa.find({-to.se,-to.fi}));
		}
		if(whi==0)
		{
			to.fi=-to.fi;
			to.se=-to.se;
		}
		if(abs(now-to.fi)<abs(now-to.se))
		{
			ret+=abs(now-to.fi);
			now=to.fi;
		}
		else
		{
			ret+=abs(now-to.se);
			now=to.se;
		}
		//if(fw==0) cout<<now<<' '<<ret<<' '<<whi<<' '<<to.fi<<' '<<to.se<<endl;
		whi^=1;
	}
	return ret+abs(now);
}

int main()
{
	cin>>n;
	rep(i,n)
	{
		scanf("%lld%lld",&a[i],&b[i]);
		sa.insert({-a[i],-b[i]});
		sb.insert({b[i],a[i]});
	}
	svsa=sa;
	svsb=sb;
	ans=solve(0);//先取sa中的 
	sa=svsa;
	sb=svsb;
	ans=max(ans,solve(1));//先取sb中的 
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 26752
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		while (!str.equals("0 0")) {
			Set<List<String>> coordinate = new HashSet<>();
			String[] data1 = str.split(" ");
			int a = Integer.parseInt(data1[0]);
			int b = Integer.parseInt(data1[1]);
			int[][] route = new int[a][b];
			for (int i = 0; i < a; i++)
				for (int j = 0; j < b; j++)
					route[i][j] = 0;
			route[0][0] = 1;
			str = br.readLine();
			int n = Integer.parseInt(str);
			for (int i = 0; i < n; i++) {
				str = br.readLine();
				String[] data2 = str.split(" ");
				coordinate.add(Arrays.asList(data2));
			}
			for (int i = 0; i < a; i++) {
				for (int j = 0; j < b; j++) {
					String[] ij = { i + 1 + "", j + 1 + "" };
					if (coordinate.contains(Arrays.asList(ij))) {
						route[i][j] = 0;
						continue;
					}
					if (i != a - 1)
						route[i + 1][j] += route[i][j];
					if (j != b - 1)
						route[i][j + 1] += route[i][j];
				}
			}
			System.out.println(route[a - 1][b - 1]);
			str = br.readLine();
		}
	}
}

Measured memory_bytes: 24580
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
// define
#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()
// typedef
typedef long long lint;
typedef double Double;
typedef pair<int, int> pii;
//
typedef vector< int > Array;
typedef vector< Array > Matrix;
typedef vector< Double > DArray;
typedef vector< DArray > DMatrix;
typedef vector< string > SArray;
typedef vector< pii > PArray;
// popcount
inline int POPCNT(int _x) { return __builtin_popcount(_x); }
inline int POPCNT(lint _x) { return __builtin_popcountll(_x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
Double EPS = 1e-9;
// in range
inline bool in_range(int _v, int _mx, int _mi) { return _mi <= _v && _v < _mx; }
inline bool in_range(Double _v, Double _mi, Double _mx) { return -EPS < _v - _mi && _v - _mx < EPS; }
inline bool in_range(int _x, int _y, int _W, int _H) { return 0 <= _x && _x < _W && 0 <= _y && _y < _H; }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};
// variable update
inline void modAdd(int& _a, int _b, int _m) { _a = (_a + _b) % _m; }
inline void modAdd(lint& _a, lint _b, lint _m) { _a = (_a + _b) % _m; }
inline void minUpdate(int& _a, int _b) { _a = min(_a, _b); }
inline void minUpdate(lint& _a, lint _b) { _a = min(_a, _b); }
inline void maxUpdate(int& _a, int _b) { _a = max(_a, _b); }
inline void maxUpdate(lint& _a, lint _b) { _a = max(_a, _b); }

int n;
PArray vp;

void solve() {
	sort(allof(vp));
	
	int ans = 0;
	
	for_(i,0,n) for_(j,i+1,n) {
		pii pi = vp[i], pj = vp[j];
		int dx = abs(pi.first - pj.first), dy = abs(pi.second - pj.second);
		
		pii p1(pi.first - dy, pi.second + dx), p2(pj.first - dy, pj.second + dx);
		pii pp1(pi.first + dy, pi.second - dx), pp2(pj.first + dy, pj.second - dx);
		
		if ( (binary_search(allof(vp), p1) && binary_search(allof(vp), p2))
			|| (binary_search(allof(vp), pp1) && binary_search(allof(vp), pp2)) ) {			
			int tmp = dx * dx + dy * dy;
			maxUpdate(ans, tmp);
		}
	}
	
	cout << ans << endl;
}

int main() {
	while (cin >> n, n) {
		vp.clear();
		for_(i,0,n) {
			int x, y; cin >> x >> y;
			vp.push_back(pii(x, y));
		}
		solve();
	}
	return 0;
}

Measured memory_bytes: 1256
// 参考
// https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

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

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

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

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

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

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

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

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

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

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r"4 3 6
" => r"safe",

r"6 5 1
" => r"delicious",

r"3 7 12
" => r"dangerous"
}

use std::cmp;
use std::cmp::{max, min};
use std::collections::HashSet;
use std::f32::MAX;

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        x: i32,
        a: i32,
        b: i32,
    }
    if a - b < x * -1 {
        "dangerous".to_string()
    } else if a - b < 0 {
        "safe".to_string()
    } else {
        "delicious".to_string()
    }
}


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

int32_t main() {
    int n,k;
    cin>>n>>k;
    int A[n];
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    for(int i=k;i<n;i++){
        if(A[i]>A[i-k])
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
}

Measured memory_bytes: 5192
using System;
namespace ABC149B
{
    public class MainClass
    {
        public static void Main(string[] args)
        {
            long[] inp = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            string result;
            if (inp[0] + inp[1] <= inp[2])
            {
                result = "0 0";
            }
            else
            {
                if (inp[0] >= inp[2])
                {
                    inp[0] -= inp[2];
                }
                else
                {
                    inp[1] -= inp[2] - inp[0];
                    inp[0] = 0;
                }
                result = inp[0].ToString() + ' ' + inp[1].ToString();
            }

            Console.WriteLine(result);
        }

    }
}


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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, a[212345], ans;
int main() {
	cin >> n;
	for (ll i = 0; i < n; ++i)cin >> a[i];
	ll mx = a[0];
	for (ll i = 1; i < n; ++i) {
		if (a[i] < a[i - 1]) {
			ans += a[i - 1] - a[i];
			a[i] = a[i - 1];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5192
r, c = map(int, input().split())
a = [[0 for i in range(c+1)] for j in range(r+1)] 


for i in range(r):
    ai = list(map(int,input().split()))
    for j in range(c):
        a[i] [j] = ai[j]
#rint(a)


for i in range(r+1):
    for j in range(c):
        a[i][c] += a[i][j]
        
for j in range(c+1):
    for i in range(r):
        a[r][j] += a[i][j]


for a in a:
    print(*a)


Measured memory_bytes: 6216
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int N;
    string ip;

    cin >> N;

    int count[4] = {0, 0, 0, 0};

    for (int i = 0; i < N; i++) {
        cin >> ip;

        if (ip == "AC") {
            count[0]++;
        } else if (ip == "WA") {
            count[1]++;
        } else if (ip == "TLE") {
            count[2]++;
        } else if (ip == "RE") {
            count[3]++;
        }
    }

    cout << "AC x " << count[0] << endl;
    cout << "WA x " << count[1] << endl;
    cout << "TLE x " << count[2] << endl;
    cout << "RE x " << count[3];

    return 0;

}

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

int main(){
  string N;
  cin >> N;
  
  int d=N.size();
  long long sum=0;
  for(int bit=0; bit <(1<<(d-1)); bit++){
    string fml;
    fml.push_back(N[0]);
    for(int i=0; i<d-1; i++){
      if(bit & (1<<i)){
        fml.push_back('+');
        fml.push_back(N[i+1]);
      }else{
        fml.push_back('-');
        fml.push_back(N[i+1]);
      }
    }
    int temp=fml[0]-'0';
    for(int i=1; i+1<fml.size(); i++){
      if(fml[i]=='+'){
        temp+=fml[i+1]-'0';
      }else if(fml[i]=='-'){
        temp-=fml[i+1]-'0';
      }
    }
    if(temp==7){
      cout << fml << "=7"<<endl;
      return 0;
    }
  }
}

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

using namespace std;

int main()
{
  int N;  cin >> N;
  vector<vector<int>> abc(N, vector<int>(3));
  int a, b, c;

  for (auto& i: abc)
    cin >> i[0] >> i[1] >> i[2];

  a = abc[0][0];
  b = abc[0][1];
  c = abc[0][2];

  for (int i = 1; i < N; i++)
  {
    int x = max(b, c) + abc[i][0];
    int y = max(a, c) + abc[i][1];
    int z = max(a, b) + abc[i][2];

    a = x;  b = y;  c = z;
  }

  cout << max(a, max(b, c)) << '\n';
}


Measured memory_bytes: 5760
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define int long long
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int n, m, a[1234];
vector<int>v;
void solve() {
	for1(i, n) { scanf("%d", &a[i]); }
	v.clear();
	for0(i, n + 1)for (int j = i; j <= n; j++) {
		if (a[i] + a[j] <= m) v.push_back(a[i] + a[j]);
	}
	sort(v.begin(), v.end());
	unique(v.begin(), v.end());
	int ans = 0;
	for (int p : v) {
		if (p + v.back() <= m) {
			ans = max(ans, p + v.back());
		}
		else {
			int r = 0, l = v.size() - 1;
			while (l - r > 1) {
				int mid = (l + r) / 2;
				if (p + v[mid] <= m)r = mid;
				else l = mid;
			}
			ans = max(ans, p + v[r]);
		}
	}
	printf("%d\n", ans);
}
signed main() {
	while (cin >> n >> m, n, m)solve();
}


Measured memory_bytes: 7112
//====== begin of bisma c++ template===========
#include<bits/stdc++.h>
#include <assert.h>
using namespace std;
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define ll long long 
#define sum(a,b) a=a+b
#define mem(a, b) memset(a, (b), sizeof(a))

//=======binarysearch===========
int bs(vector<int>&a,int que){
 auto it=lower_bound(a.begin(),a.end(),que);
 if(*it==que){
    return it-a.begin();
 }
 return -1;
}
//========binarysearch=========



//=======SUBSET WITH BRUTEFORCE=============
void subsets(int S[], int n) {
     int nSub = 1<<n; 
     for(int i=0; i<nSub; i++){
          cout<<"{ ";//optional
          for(int k=0; k<n; k++){
               //if the k-th bit is set
               if( (1<<k) & i){
                    cout<<S[k]<<" ";
               } 
          }
          cout<<"}\n"; //optional
     }
}
//======SUBSET WITH BRUTE FORCE================


//======permuatate all ==================
void permutate(){
int n,x;
cin>>n;

vector<int> permutation;
for (int i = 0; i < n; i++) {
    cin>>x;
permutation.push_back(x);
}
do {
 rep(i,0,n-1) cout<<permutation[i];
 cout<<endl;
} while (next_permutation(permutation.begin(),permutation.end()));

}
//====permuatate all======================





//=====check prime========================
bool isprime(int x)
{
  if ( x == 2 ) return true;
  if ( x  < 2 ) return false;
  for ( int i = 2; i * i <= x; i++ )
    if ( x % i == 0 ) return false;
  return true;
}
//======check prime=====================



//======= the end of bisma c++ template ============



int main(){



ll a,b;


cin>>a>>b;


if((a>=0&&b<=0) || (a<=0&&b>=0)){
  cout<<"Zero";
}else if(a>0 && b>0){
  cout<<"Positive";
}else if(a<0 && b<0){

if( (b-a+1)%2==0 ){
   cout<<"Positive";
}else{
  cout<<"Negative";
}

}

    return 0;
}















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

int n, m;

int sign[][3] = {
  {1, 1, 1},
  {1, 1, -1},
  {1, -1, 1},
  {1, -1, -1},
  {-1, 1, 1},
  {-1, 1, -1},
  {-1, -1, 1},
  {-1, -1, -1}
};

int main(){
  cin >> n >> m;
  vector<long long> x(n), y(n), z(n);
  vector<long long> sum(n, 0);
  long long ans = 0LL;
  for(int i = 0; i < n; i++){
    cin >> x[i] >> y[i] >> z[i];
  }
  
  for(int i = 0; i < 8; i++){
    for(int j = 0; j < n; j++){
      sum[j] = sign[i][0] * x[j] + sign[i][1] * y[j] + sign[i][2] * z[j];
    }
    sort(sum.begin(), sum.end(), greater<long long>());
    ans = max(ans, accumulate(sum.begin(), sum.begin() + m, 0LL));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
    int n,m;cin>>n>>m;
    int ans = 0;
    vector<vector<int>> l(101010,vector<int>());
    rep(i,0,n-1){
        int a,b;cin>>a>>b;
        l[a].push_back(b);
    }
    priority_queue<int> q;
    rep(i,1,m){
        int x = l[i].size()-1;
        for(int x : l[i]){
            q.push(x);
        }
        if(!q.empty()){
            ans += q.top();
        q.pop();
        }

    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5632
N, K = map(int, input().split())

data = [list(map(int, input().split())) for _ in range(int(2 * K))]

Sunuke = [0] * N

for i in range(K):
    for j in range(data[int(2 * i)][0]):
        Sunuke[data[int(2 * i + 1)][j] - 1] += 1


count = 0
for i in range(N):
    if(Sunuke[i] == 0):
        count += 1

print(count)


Measured memory_bytes: 9192
using System;
using System.Collections.Generic;
using System.Runtime.ExceptionServices;

class Program
{
    static void Main(string[] args)
    {

        
        string[] words = Console.ReadLine().Split(' ');
        int A = int.Parse(words[0]);
        int B = int.Parse(words[1]);
        int K = int.Parse(words[2]);
       

        for(int i = 1;i <= K; i++)
        {
            if (i == 1 || i % 2 == 1)
            {
                if (A % 2 == 1)
                {
                    A--;
                }

                A /= 2;
                B += A;
            }
            else if (i % 2 == 0)
            {
                if (B % 2 == 1)
                {
                    B--;
                }

                B /= 2;
                A += B;
            }
        }
        Console.WriteLine(A + " " + B);




    }
}

Measured memory_bytes: 17596
def findProductSum(A, n): 
    array_sum = 0
    for i in range(0, n, 1): 
        array_sum = array_sum + A[i] 
    array_sum_square = array_sum * array_sum 
    individual_square_sum = 0
    for i in range(0, n, 1): 
        individual_square_sum += A[i] * A[i] 
  
    return (array_sum_square - 
            individual_square_sum) // 2

n = int(input())
arr = list(map(int,input().split()))
mod = (10**9)+7
print(findProductSum(arr,n)%mod)


Measured memory_bytes: 31440
implicit none
integer n,counts,i
character(100) s

read(5,*)n
read(5,*)s 

do i=1,n
if(s(i:i)=="R") then
counts=counts+1;
endif
enddo

if(counts .gt.(n-counts)) then
write(6,*) "Yes"
else 
write(6,*) "No"
endif

end

Measured memory_bytes: 256