akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		
		Scanner sc=new Scanner(System.in);
		
		int N=sc.nextInt();
		int ans;
		
		if(N%2==0)
			ans=N/2;
		
		else
			ans=(N/2)+1;
		
		System.out.println(ans);
		
		sc.close();
	}
}

Measured memory_bytes: 21332
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
 
struct Node{
  int key;
 struct Node *right, *left, *parent;
};
 
struct Node *root, *Nil;
 
void insert(int);
void inorder(struct Node *);
void preorder(struct Node *);
 
int main(){
  int n, i, x;
  char s[20];
 
  scanf("%d", &n);
 
  for(i=0; i<n; i++){
    scanf("%s", s);

    if(strcmp(s, "insert")==0){
      scanf("%d", &x);
      insert(x);
    }
    else if(strcmp(s, "print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
 
  return 0;
}
 
void insert(int k){
  struct Node *y = Nil, *x = root,*z;
 
  z = malloc(sizeof(struct Node));
  z->key = k;
  z->left = Nil;
  z->right = Nil;
 
  while(x != Nil){
    y = x;
    if(z->key < x->key)  x = x->left;
    else x = x->right;
  }
 
  z->parent = y;
  if(y == Nil)root = z;
  else {
    if(z->key < y->key)y->left = z;
    else y->right = z;
  }
}
 
void inorder(struct Node *u){
 
  if(u == Nil) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
 
void preorder(struct Node *u){
 
  if(u == Nil) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}
 

Measured memory_bytes: 24040
#include<bits/stdc++.h>
using namespace std;
#define MAX 100001
#define MOD 1000000007
#define ll long long
#define ld long double
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
int main() {
	fast;
	int t = 1;
	// cin >> t;
    while(t--) {
		string s;
		cin >> s;
		ll n = s.size();
		ll ans = 0;
		for(ll i=0;i<n;i++) {
			ans += s[i] - '0';
			ans %= MOD;
		}
		if(ans % 9 == 0) cout << "Yes" << endl;
		else cout << "No" << endl;
    }
}


Measured memory_bytes: 3704
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	int ret=0; 
	for (int i=1; i<=n; i++) {
		int x; cin>>x;
		if (x!=i) ret++;
	}
	cout<<(ret==0||ret==2?"YES":"NO")<<endl;
	return 0;
}


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

bool dist_is_int(vector<int> &a, vector<int> &b, int n) {
  double d = 0;
  for (int i = 0; i < n; i++) {
    d += (a[i] - b[i]) * (a[i] - b[i]);
  }
  d = sqrt(d);
  return d == floor(d);
}

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

  int n, d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < d; j++) {
      cin >> x[i][j];
    }
  }
  int cnt = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      cnt += dist_is_int(x[i], x[j], d);
    }
  }
  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void solve() {
        Int M, D;
        cin >> M >> D;

        Int ans = 0;
        for (int i = 1; i <= M; ++i) {
            for (int j = 10; j <= D; ++j) {
                Int a = j % 10;
                Int b = j / 10;
                if (a > 1 && b > 1 && a * b == i) {
                    ans++;
                }
            }
        }
        cout << ans << endl;

    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


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

#define f(i, q) for(int i = 0; i < q; i++)  

typedef long long ll;

int main() {
    int n, suma, sumb;
    vector<int> w(100);

    cin >> n;
    f(i, n) cin >> w.at(i);

    suma = w.at(0);
    sumb = 0;
    for(int i = 1; i < n; i++) sumb += w.at(i);

    int min = 10001;
    for(int i = 1; i < n; i++) {
        if(min > abs(suma - sumb)) {
            min = abs(suma - sumb);
        }

        suma += w.at(i);
        sumb -= w.at(i);
    }

    cout << min << endl;
 
    return 0;
}

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

/* Following function is needed for library function 
qsort(). Refer 
http://www.cplusplus.com/reference/clibrary/cstdlib/qsort/ */
int comp(const void* a, const void* b) 
{ return *(ll*)a > *(ll*)b ; } 

// Function to count all possible triangles with arr[] 
// elements 
int findNumberOfTriangles(ll arr[], ll n) 
{ 
	// Sort the array elements in non-decreasing order 
	qsort(arr, n, sizeof( arr[0] ), comp); 

	// Initialize count of triangles 
	int count = 0; 

	// Fix the first element. We need to run till n-3 
	// as the other two elements are selected from 
	// arr[i+1...n-1] 
	for (ll i = 0; i < n - 2; ++i) 
	{ 
		// Initialize index of the rightmost third 
		// element 
		ll k = i + 2; 

		// Fix the second element 
		for (ll j = i + 1; j < n; ++j) 
		{ 
			// Find the rightmost element which is 
			// smaller than the sum of two fixed elements 
			// The important thing to note here is, we 
			// use the previous value of k. If value of 
			// arr[i] + arr[j-1] was greater than arr[k], 
			// then arr[i] + arr[j] must be greater than k, 
			// because the array is sorted. 
			while (k < n && arr[i] + arr[j] > arr[k]) 
			++k; 

			// Total number of possible triangles that can 
			// be formed with the two fixed elements is 
			// k - j - 1. The two fixed elements are arr[i] 
			// and arr[j]. All elements between arr[j+1]/ to 
			// arr[k-1] can form a triangle with arr[i] and arr[j]. 
			// One is subtracted from k because k is incremented 
			// one extra in above while loop. 
			// k will always be greater than j. If j becomes equal 
			// to k, then above loop will increment k, because arr[k] 
			// + arr[i] is always greater than arr[k] 
			if(k > j) 
			count += k - j - 1; 
		} 
	} 

	return count; 
} 

// Driver code 
int main() 
{ 
	ll n;
	cin>>n;
	ll arr[n];
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];
	}

	cout<<findNumberOfTriangles( arr, n ); 

	return 0; 
} 

// This code is contributed by rathbhupendra 


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

using namespace std;

#define int long long

const int INF = 1e18;
const int DIM = 1e5 + 7;

int v[DIM];
int pre[DIM];


int check(int x, int n, int m)
{
	int sum = 0;
	
	for(int i = n; i >= 1 && m; i--)
	{
		int l = 1;
		int r = n;
		
		int pos = 0;
		
		while(l <= r)
		{
			int mid = (l + r) / 2;
			
			if(v[i] + v[mid] >= x)
			{
				r = mid - 1;
				pos = mid;
			}
			else
			{
				l = mid + 1;
			}
		}
		
		if(pos == 0)
			break;
		
		int dif = (n - pos + 1);
	
		if(dif > m)
			pos += (dif - m);
		
		if(pos > n)
			break;
		
		m -= (n - pos + 1);
		
		sum += pre[n] - pre[pos - 1];
		sum += (n - pos + 1) * v[i];
	}
	
	if(m == 0)
		return sum;
	
	return -1;
}

main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int a, b, k;
	cin >> a >> b >> k;
	
	a -= k;
	
	if(a < 0)
	{
		b += a;
		a = 0;
	}
	
	if(b <= 0)
		b = 0;
	
	cout << a << ' ' << b;
}

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

using namespace std;

int main(){
	string s;
	cin >> s;
	set<char> a;
	for(int i = 0 ; i < 4 ; i++){
		a.insert(s[i]);
	}
	if(a.size() == 2) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
import numpy as np


def main():
    A0 = [int(x) for x in input().split()]
    A1 = [int(x) for x in input().split()]
    A2 = [int(x) for x in input().split()]
    A = [A0,A1,A2]

    Ainv = dict()
    for i in range(3):
        for j in range(3):
            Ainv[A[i][j]] = (i,j)

    N = int(input())
    rows = [0]*3
    cols = [0]*3
    cross = [0]*2
    for _ in range(N):
        b = int(input())
        if b not in Ainv:
            continue
        row, col = Ainv[b]
        rows[row]+=1
        cols[col]+=1
        if row==col:
            cross[0] += 1
        if row+col==2:
            cross[1] += 1
        if any([rows[row]==3, cols[col]==3, cross[0]==3, cross[1]==3]):
            print("Yes")
            return
    print("No")
    return



if __name__ == '__main__':
    main()

Measured memory_bytes: 21476
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
using ll = long long;

const long double PI = acos(-1);
const int MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    n = n % 10;

    if(n == 3) cout << "bon" << endl;
    else if(n == 0 || n == 1 || n == 6 || n == 8) cout << "pon" << endl;
    else cout << "hon" << endl;
    

    return 0;
}

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

signed main()
{
    int N; cin>>N;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    if(a[0]==0 and a[N-1]==0){
        cout<<"Yes"<<endl;
        return 0;
    }

    if(N%3!=0){
        cout<<"No"<<endl;
        return 0;
    }

    map<int,int> cnt;
    for(int i=0;i<N;i++){
        cnt[a[i]]++;
    }
    if(cnt.size()==2){
        if(cnt[0]==N/3){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }else if(cnt.size()==3){
        int X=0; 
        for(auto p:cnt){
            X^=p.first;
            if(p.second!=N/3){
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<(X==0? "Yes":"No")<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 5632
N,K=map(int,input().split())
if K==1:
  if N==0:
    print("1")
    exit()
  else:
    print("0")
    exit()
if N > K :
  N-=(N//K)*K
if abs(K-N) < N:
  print(abs(K-N))
else:
  print(N)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
long n;
bool judge(long n)
{
    long x=n,sum=0;
    while(x) {sum+=x%10;x/=10;}
    if (n%sum) return false;
    return true;
}
void solve()
{
    if (judge(n)) cout<<"Yes";
    else cout<<"No";
    cout<<endl;
}
int main()
{
    while(cin>>n)
        solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int k,a,b;
int main() {
    cin >> k >> a >> b;
    for(a;a<=b;a++){
        if(a%k==0){
            cout << "OK" << endl;
            return 0;
        }
    }cout << "NG" << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string num;
    cin>>num;
    long long x=0;
    char ch1;
    for(int i=0; i<num.length(); i++) {
        ch1 = num[i] - '0';
        x+=ch1;
    }
    
    if(x%9==0) 
        cout<<"Yes";
    else
        cout<<"No";

    return 0;
}

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

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

template<typename T>
struct SegmentTree {
    int n;
    vector<T> addv;

    void init(int n) {
        this->n = n;
        addv.assign(2 * n - 1, 0);
    }

    template<typename ParameterType>
    void buildup(vector<ParameterType>& A) {
        n = A.size();
        init(n);
        for (int i = 0; i < n; i++)
            addv[i + n - 1] = A[i];
    }

    void add_value(int x, int y, T val) {
        x += n - 1;
        y += n - 1;
        while (x <= y) {
            if (x % 2 == 0) {
                addv[x++] += val;
            } else if (y % 2) {
                addv[y--] += val;
            } else {
                x = (x - 1) / 2;
                y = (y - 1) / 2;
            }
        }
    }

    void pushdown() {
        for (int i = 0; i < n - 1; i++) {
            addv[2*i+1] += addv[i];
            addv[2*i+2] += addv[i];
            addv[i] = 0;
        }
    }

    T query_value_after_pushdown(int x) {
        x += n - 1;
        return addv[x];
    }

    T query_value(int x) {
        x += n - 1;
        T ans = addv[x];
        while (x) {
            x = (x - 1) / 2;
            ans += addv[x];
        }
        return ans;
    }

    vector<T> unwind() {
        vector<T> A(n);
        for (int i = 0; i < n; i++)
            A[i] = query_value(i);
        return A;
    }
};

SegmentTree<int> segment;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, m;
    cin >> n >> m;
    segment.init(n);
    // cout << "segment: " << segment.unwind() << endl;
    for (int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;
        segment.add_value(l - 1, r - 1, 1);
    }
    // cout << "segment: " << segment.unwind() << endl;
    segment.pushdown();
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (segment.query_value_after_pushdown(i) == m) {
            ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#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 FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }



int main() {
  ll k,a,b;
  scanf("%lld%lld%lld", &k,&a,&b);
  
  ll ans = ((k-(a-1))/2)*(b-a) + a + (k-(a-1))%2;

  chmax(ans,k+1);

  cout << ans << endl;

}



Measured memory_bytes: 256
ss = []
N = int(input())
for n in range(N):
    s = sorted(input())
    ss.append(s)

ss = sorted(ss)

total = 0
count = 0
for n in range(N):
    if n==0:
        continue
    # print("ss["+str(n-1)+"]="+str(ss[n-1]))
    # print("ss["+str(n)+"]="+str(ss[n]))
    if ss[n-1]==ss[n]:
        count += 1
    else:
        total += int(count*(count+1)/2)
        count = 0
    # print("===")
total += int(count*(count+1)/2)
count = 0

print(int(total))


Measured memory_bytes: 25548
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

const int INF = 2100000000;

struct segtree
{
	static const int DEPTH = 19;
	static const int N = 1 << DEPTH;
	int val[2 * N];

	segtree() {
		for (int i = 0; i < 2 * N; ++i) val[i] = INF;
	}
	void update(int p, int v) {
		p += N; val[p] = v; p >>= 1;
		while (p) {
			val[p] = min(val[p * 2], val[p * 2 + 1]);
			p >>= 1;
		}
	}
	int query(int L, int R) {
		L += N; R += N;
		int ret = INF;
		while (L < R) {
			if (L & 1) ret = min(ret, val[L++]);
			if (R & 1) ret = min(ret, val[--R]);
			L >>= 1; R >>= 1;
		}
		return ret;
	}
};

segtree seg;
int N, K, P[505050];
bool visited[505050];
int ans[505050], al;

void decide(int idx)
{
	for (;;) {
		int least = seg.query(0, P[idx]);
		if (least >= idx + K) break;
		decide(least);
	}
	ans[idx] = al++;
	visited[idx] = true;
	seg.update(P[idx], INF);
}

int main()
{
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; ++i) {
		scanf("%d", P + i); --P[i];
		visited[i] = false;
		seg.update(P[i], i);
	}
	al = 0;
	for (int i = 0; i < N; ++i) if (!visited[i]) decide(i);
	for (int i = 0; i < N; ++i) printf("%d\n", ans[i] + 1);
	return 0;
}


Measured memory_bytes: 27648
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;

void main()
{
    auto R = readln.chomp.to!int;
    if (R < 1200) {
        writeln("ABC");
    } else if (R < 2800) {
        writeln("ARC");
    } else {
        writeln("AGC");
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int p[N];
  for(int i=0; i < N; i++){
    cin >> p[i];
  }

  sort(p, p+N);

  int price = 0;
  for(int i=0; i < N-1; i++){
    price += p[i];
  }
  price += p[N-1]/2;
  cout << price << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        String S = sc.next();
        String[] s = S.split("");
        s[K-1] = s[K-1].toLowerCase();
        String ans = "";
        for(int i = 0; i < N; i++) {
            ans += s[i];
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
const long long M =1e6+10,MOD=1000000000;
typedef long long ll;
int h, w, k, z, ans=1e9, c[15];
string a[15];
bool f(int j) {
  int i, id=0, fl=0;
  for(i=0; i<h; i++) {
    c[id] += a[i][j]=='1';
    if(c[id]>k) fl = 1;
    if(z>>i & 1) id++;
  }
  return fl;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int i, j, cnt, re;
  cin >> h >> w >> k;
  for(i=0; i<h; i++) cin >> a[i];
  for(z=0; z<1<<h-1; z++) {
    memset(c, 0, sizeof(c));
    cnt = __builtin_popcount(z);
    re = 0;
    for(j=0; j<w; j++) {
      if(f(j)) {
        cnt++;
        memset(c, 0, sizeof(c));
        re = f(j);
      }
    }
    if(!re) ans = min(ans, cnt);
  }
  cout << ans;
    return 0;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
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; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


ll risoku(ll x) {
    return((x-(x%100))/100);
}

int main() {
    ll X;
    cin >> X;
    ll cnt = 0;
    ll kane = 100;
    while(kane < X) {
        kane += risoku(kane);
        cnt++;
    }
    cout << cnt << endl;


}

Measured memory_bytes: 3624
S = input()

ans = 0
white = [0]*len(S)
w = 0

for i in range(len(S)):
  if S[i] == "W":
    white[w] += i
    w += 1
for i in range(len(S)):
  if white[i] > 0:
    ans += white[i]-i
print(ans)

Measured memory_bytes: 11240
#include<stdio.h>

int main(int argc, char* argv[])
{
  int h4[4][3][10];
  int n, b, f, r, v;
  int i, j, k;

  for(i = 0; i < 4; i++){
    for(j = 0; j < 3; j++){
      for(k = 0; k < 10; k++){
        h4[i][j][k] = 0;
      }
    }
  }

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d %d %d %d", &b, &f, &r, &v);
    h4[b-1][f-1][r-1] += v;
  }

  for(i = 0; i < 4; i++){
    for(j = 0; j < 3; j++){
      for(k = 0; k < 10-1; k++){
        printf(" %d", h4[i][j][k]);
      }
      printf(" %d\n", h4[i][j][k]);
    }
    if(i < 3){
      printf("####################\n");
    }
  }  

  return(0);
}

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

std::string str(const std::set<std::string>& set,int n){
    auto itr = set.begin();
    for(int i=0;i<n;i++)itr++;
    return *itr;
}
 
int main()
{
    int h,w;
    std::cin>>h>>w;
    std::vector<std::vector<bool>> map(h+2,std::vector<bool>(w+2));
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            char t;
            std::cin>>t;
            map[i][j] = (t == '#');
        }
    }
    bool res = true;
    std::vector<std::pair<int,int>> dir = {{1,0},{0,1},{-1,0},{0,-1}};
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(!map[i][j])continue;
            bool tmp = false;
            for(auto k : dir){
                if(map[i + k.first][j + k.second])tmp = true;
            }
            if(!tmp)res = false;
        }
    }
    std::cout<<(res ? "Yes" : "No")<<std::endl;
}

Measured memory_bytes: 384
n=int(input())
s=len(str(n))
if n<10:
    print(n)
else:
    if s%2==0:
        s=s-1
        x=''
        for i in range(s-1):
            if i%2==0:
                x+='9'
            else:
                x+='0'
        x+='9'
        print(x)
    else:
        z=s-2
        x = ''
        for i in range(z - 1):
            if i % 2 == 0:
                x += '9'
            else:
                x += '0'
        x += '9'
        x=int(x)
        x+=n-int('9'*(z+1))
        print(x)

Measured memory_bytes: 3064
// 相手がP回パーを出して、自分が全てグーを出したとすると、
// 得点は-P点、
// グーのうちどれか一つをパーにすると、
// そのターンの相手の手がグーのとき、得点は+1増える
// そのターンの相手の手がパーのとき、得点は+1増える
// なので、得点は(自分がパーを出した回数) - (相手がパーを出した回数)になる。
// できるだけパーを出すようにしたら最適
// グー、パー、グー、パー、...とするのが最適？
#include <bits/stdc++.h>
using namespace std;

int main() {
    string s;
    cin >> s;
    int P;
    for (char ch : s) {
        if (ch == 'p') ++P;
    }
    int N = s.size();
    cout << N / 2 - P << endl;
    return 0;
}

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

vector<string> opr{"->", "+", "*", "-"};
vector<string> num{"1", "2", "3", "4"};

bool calc(string exp, int bits) {
    // cout << exp << endl;
    if (exp == "T") return true;
    if (exp == "F") return false;
    if ('a' <= exp[0] && exp[0] <= 'k') return (bits & (1 << (exp[0] - 'a')) ? true : false);
    if (exp[0] == '4') return !calc(string(exp.begin() + 1, exp.end()), bits);

    int idx = -1;
    for (int i = (exp[0] == '(' ? 1 : 0), count = 0, len = exp.size() - (exp[0] == '(' ? 1 : 0);
         i < len;
         i++
        ) {
        if (exp[i] == '(') count++;
        else if (exp[i] == ')') count--;
        if (count == 0 && '1' <= exp[i] && exp[i] <= '3') {
            idx = i;
            break;
        }
    }

    if (exp[0] == '(') {
        auto exp1 = string(exp.begin() + 1, exp.begin() + idx);
        auto exp2 = string(exp.begin() + idx + 1, exp.end() - 1);
        if (exp[idx] == '1') return !(calc(exp1, bits) && !calc(exp2, bits));
        if (exp[idx] == '2') return calc(exp1, bits) | calc(exp2, bits);
        if (exp[idx] == '3') return calc(exp1, bits) & calc(exp2, bits);
    }
}

void solve(string str) {
    bool flag = true;
    for (int i = 0, len = opr.size(); i < len; i++) {
        auto idx = str.find(opr[i]);
        while (idx != string::npos) {
            str.replace(idx, (int)opr[i].size(), num[i]);
            idx = str.find(opr[i]);
        }
    }
    int eq_idx = str.find("=");

    string exp1 = string(str.begin(), str.begin() + eq_idx);
    string exp2 = string(str.begin() + eq_idx + 1, str.end());
    for (int i = 0; i < (1 << 11); i++) {
        if (calc(exp1, i) != calc(exp2, i)) {
            flag = false;
            break;
        }
    }

    if (flag) cout << "YES" << endl;
    else cout << "NO" << endl;
}

int main() {
    string str;
    while (cin >> str, str != "#") solve(str);

    return 0;
}

Measured memory_bytes: 3780
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
#include<boost/math/common_factor_rt.hpp>
  
using namespace std;
using namespace boost::multiprecision;  
using namespace boost::math;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
//#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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

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

    int n;
    cin >> n;
    vector<int> a(n);

    rep(i,n){
        cin >> a[i];
    }

    rep(i,n){
        if(a[i] % 2 == 0){
            if(a[i] % 3 != 0 && a[i] % 5 != 0){
                return cout << "DENIED\n",0;
            }
        }
    }

    cout << "APPROVED\n";

    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
A = map(int,input().split())
B = list(A)
C = sorted(B,reverse=True)
S = sum(B)
#print(S)
#print(C)
if C[M-1]>= S/(4*M) :
    print("Yes")
else :
    print("No")
    

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define ll long long
#define ull unsigned long long
#define dd double
#define oo 1001007000
#define ff float
#define ooo 4223352036854775007
#define iii pair<ll,ll>
#define vii vector<ll>
#define viii vector<iii>
#define sss pair<str,str>
#define str string
#define sii set<ll>
#define siii set<iii>
#define r0 return 0
#define pb push_back
#define sz size
using namespace std;

const char E='\n';
const int N=21105;
const int NN=20005;
const ll md=998244353;


int main(){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while (a>0 && c>0){
        c-=b;
        if (c<=0)break;
        a-=d;
    }
    if (a>0){
        cout << "Yes" << E;
    }else {
        cout << "No" << E;
    }
    r0;
}
/*


1
5
2 3 4 5 1


1
4
4 2 3 1








*/


Measured memory_bytes: 3652
#include<stdio.h>
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==5&&b==5&&c==7)
	printf("YES");
	else if(a==5&&b==7&&c==5)
	printf("YES");
	else if(a==7&&b==5&&c==5)
	printf("YES");
	else 
	printf("NO");
	return 0;
 } 

Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>
 
int main() {
 
  double d1,d2,d3,d4;
  int i,j,k,l,n;
  double x[1020] = {0};
  double y[1020] = {0};
  double z[1020] = {0};
  double o,p,q,max;
  max = -1;
  o=0;
  p=0;
  q=0;
  d1 = 0;
  d2 = 0;
  d3 = 0;
  d4 = 0;
 
  scanf("%d",&n);
 
  for(i=0; i<n; i++) {
    scanf("%lf",&x[i]);
  }
 
  for(i=0; i<n; i++) {
    scanf("%lf",&y[i]);
  }
 
  for(i=0; i<n;i++) {
 
    o = (x[i] - y[i]) * (x[i] - y[i]);
    p = (x[i] - y[i]) * (x[i] - y[i]) * (x[i] - y[i]);
    p = p*p;
    p = sqrt(p);
   
    d3 = d3 + p;
    d2 = d2+o;
    d1 = d1 + sqrt(o); 
 
    if(max < sqrt(o)) {
      max = sqrt(o);
    }
 
    
  }
 
  d2 = pow(d2,1.0/2);
  d3 = pow(d3,1.0/3);
  d4 = max;
 
  printf("%.11lf\n%.11lf\n%.11lf\n%.11lf\n" ,d1,d2,d3,d4);
 
  return 0;
 
}


Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
int main()

{
  vector<int> v;
  for(int i=1;i<=3;i++) v.push_back(i);
int a,b;
  cin>>a>>b;
  for(int i=0;i<v.size();i++)
  {
  if(v[i]==a || v[i]==b)
  {
   v[i]=0;
  }
  }
  cout<<*max_element(v.begin(),v.end())<<endl;
  
}

Measured memory_bytes: 3588
import java.util.*;
class Main {
	public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
		
		while(true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			
			if(H == 0 && W == 0) break;
			
			for(int i = 0; i < H; i++) {
				for(int j = 0; j < W; j++) {
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 37864
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(n)-1;i>=a;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define mod 1000000007
#define INF 1000000000000000000
/****************************/
vector<ll> ans;
void dfs(ll a,int b,bool b2)
{
	if(b==11)
	{
		ans.pb(a);
		return;
	}
	int l,r;
	if(b2)
	{
		l=max(0ll,a%10-1);
		r=min(9ll,a%10+1)+1;
	}
	else
	{
		l=0;
		r=10;
	}
	rep3(i,l,r)
	{
		ll c=a;
		c*=10;
		c+=i;
		if(i==0)
			dfs(c,b+1,b2);
		else
			dfs(c,b+1,true);
	}
	return;
}
int main()
{
	int k;
	cin>>k;
	dfs(0,1,0);
	cout<<ans[k];
    return 0;
}

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

using ll = long long;
static const ll MOD = 1e9 + 7;

// 繰り返し自乗法(x^nをmで割った余り) O(logn)
ll power(ll x, ll n, ll m) {
  ll res = 1;
  if(n > 0){
    res = power(x, n / 2, m);
    if(n % 2 == 0) res = (res * res) % m;
    else res = (((res * res) % m) * x) % m;
  }
  return res;
}

// 階乗を利用した順列
ll nPr(int n, int r) {
  if (n < r) return 0;
  if (n < 0 || r < 0) return 0;
  ll ret = 1;
  for(int i = 0; i < r; i++){
    ret *= n;
    ret %= MOD;
    n--;
  }
  return ret;
}

// 組合せを素数で割った値を求める
const int MAX = 510000;
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 nPr(n, k) * (finv[k] % MOD) % MOD;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, a, b;
  cin >> n >> a >> b;
  
  ll ans = power(2, n, MOD) - 1;
  
  ans += 2 * MOD;
  COMinit();
  ans -= COM(n, a) + COM(n, b);
  ans %= MOD;
  
  cout << ans << '\n';
}

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

struct Benri {
    Benri() {
        std::cin.tie(0); ios::sync_with_stdio(false);
        cout << fixed << setprecision(12);
    }
} benri;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MOD 1000000007
#define MOD2 998244353




int main() {
    int N; cin >> N;
    if(N == 1) cout << "Hello World" << endl;
    else{
        int A,B; cin >> A >> B;
        cout << A+B << endl;
    }
}




Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main () {
  int N;
  cin >> N;
  int a[N+1];
  int b[N+1]; // 0 or 1
  vector<int> fillbox(0);
  for (int i = 1; i < N+1; i++) {
    cin >> a[i];
    if (i > N/2) {
      b[i] = a[i];
      if (b[i]==1) {
	fillbox.push_back(i);
      }
    } else {
      b[i] = -1;
    }
  }

  int div = 2;
  while (div <= N) {
    for (int i = N/div; i > N/(div+1) ; i--) {
      int bsum = 0;
      for (int j = 2; j <= (N/i); j++) {
	bsum += b[j*i];
      }
      if (b[i]=!-1) {
	if (b[i] != (a[i] + bsum) % 2) {
	  cout<<-1<<endl;
	  return 0;
	}
      } else {
	b[i] = (a[i] + bsum) % 2;
	if (b[i]==1) {
	  fillbox.push_back(i);
	}
      }
    }
    div++;
  }
  
  cout<<fillbox.size()<<endl;
  for (int i = 0; i < fillbox.size(); i++) {
    cout<<fillbox[i]<<" ";
  }
  
  return 0;
}


Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<map>
#include<tuple>
using namespace std;
#define INF 11000000000
#define MAX 110000
#define MOD 998244353
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

ll C[110000];

ll f(ll x,ll r){
    ll ret=1;
    for(ll i=0;i<r;i++){
        ret*=x;
        ret%=MOD;
    }
    return ret;
}

int main(){
    int N,D[110000],num=0;
    cin>>N;
    for(int i=1;i<=N;i++){
        cin>>D[i];
        C[ D[i] ]++;
        num=max(num,D[i]);
    } 
    if(D[1]!=0 || C[0]>=2){
        cout<<0<<endl;
        return 0;
    }
    ll ans=1,pre=C[1];
    for(int i=2;i<=num;i++){
        if(C[i]==0){
            cout<<0<<endl;
            return 0;
        }
        ans*=f(pre,C[i]);
        ans%=MOD;
        pre=C[i];
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 1408
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    ans = 0
    sumn = lambda x: x*(x+1)//2
    for i in range(1,n+1):
        r = n//i
        ans += i*(sumn(r))
    print(ans)


if __name__ == '__main__':
    main()

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

int main(){
	int x,y ;
	while(1){
		cin >> x >> y ;
		if(x==0&&y==0) break ;
		if(x>y){
			x = x-y ;
			y = y+x ;
			x = y-x ;
		}
		cout << x << " " << y << endl ;
	}
}


Measured memory_bytes: 3004
#include <iostream>
#include <algorithm>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
#include <string>
#include <iostream>
using namespace std;

int main() {
	string S, M;
	cin >> S >>M;
	int ans = 0;
	for (int i = 0; i < 3; i++) {
		if (S.at(i) == M.at(i)) {
			ans++;
		}
	}
		cout << ans << endl;
	}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define EPS (1e-10)

using namespace std;

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

template<class T>
struct point{
	T x, y;
	point &operator+=(const point &a ){ x += a.x; y += a.y; }
	point &operator-=(const point &a ){ x -= a.x; y -= a.y; }
	point operator+(const point &a )const{ return (point){x+a.x, y+a.y }; }
	point operator-(const point &a )const{ return (point){x-a.x, y-a.y }; }
	operator point<double>()const{ return (point<double>){x, y }; }
};

template<class T>
point<T> operator*(T c, const point<T> &a ){ return (point<T>){c*a.x, c*a.y }; }
point<double> &operator/=(point<double> &a, double c ){ a.x /= c; a.y /= c; return a; }
template<class T>
point<double> operator/(const point<T> &a, double c ){ return (point<double>){ a.x/c, a.y/c }; }

template<class T>
struct line{
	point<T> a, b;
	operator line<double>()const{ return (line<double>){a, b}; }
};


//  for real number
bool operator<(const point<double> &a, const point<double> &b ){
	return (a.x + EPS < b.x || (abs (a.x - b.x ) < EPS && (a.y + EPS < b.y ) ) );
}

bool operator==(const point<double> &a, const point<double> &b ){
	return abs (a.x - b.x) < EPS && abs (a.y - b.y ) < EPS;
}

bool operator!=(const point<double> &a, const point<double> &b ){
	return abs (a.x - b.x ) > EPS || abs (a.y - b.y ) > EPS;
}

// inner product
template<class T>
T dot(const point<T> &a, const point<T> &b ){ return a.x*b.x + a.y*b.y; }

// outer product
template<class T>
T cross(const point<T> &a, const point<T> &b ){ return a.x*b.y - a.y*b.x; }


template<class T>
T abs2(const point<T> &a ){ return a.x*a.x + a.y*a.y; }


// 点 p を直線 L 上に射影した点を求める
// 	Verified: AOJ 0081 A Symmetric Point
template<class T>
point<double> proj(const point<T> &p, const line<T> &L ){
	return L.a + dot (p-L.a, L.b-L.a )/abs2 (L.b - L.a )*(L.b - L.a );
}

int main()
{
	ios_base::sync_with_stdio(0);
	double xp0, yp0, xp1, yp1; cin >> xp0 >> yp0 >> xp1 >> yp1;
	line<double> L;
	L.a.x = xp0, L.a.y = yp0;
	L.b.x = xp1, L.b.y = yp1;

	int q; cin >> q;
		
	rep (i, q ){
		double xp2, yp2; cin >> xp2 >> yp2;
		line<double> l = L;
		point<double> p2; p2.x = xp2; p2.y = yp2;
		point<double> res = proj (p2, l );
		printf ("%.9lf %.9lf\n", res.x, res.y );
	} // end rep
		
	return 0;
}

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

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> p(n,k-q);
  rep(i,q) {
    int a;
    cin >> a;
    a--;
    p[a]++;
  }
  rep(i,n) {
    puts(p[i] > 0? "Yes":"No");
  }
  return 0;
}


Measured memory_bytes: 3784
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String S = in.readLine();
		Map<Character, Integer> counts = new HashMap<>();
		for (int i = 0; i < S.length(); ++i) {
			Character c = S.charAt(i);
			if (counts.containsKey(c)) {
				counts.put(c, counts.get(c) + 1);
			} else {
				counts.put(c, 1);
			}
		}
		boolean result = true;
		for (Integer num : counts.values()) {
			if (num != 2) {
				result = false;
				break;
			}
		}
		String r = result ? "Yes" : "No";
		System.out.println(r);

		in.close();
	}

}

Measured memory_bytes: 20948
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)){
			int initialAmount = Integer.parseInt(scanner.nextLine());
			int aAmount = Integer.parseInt(scanner.nextLine());
			int bAmount = Integer.parseInt(scanner.nextLine());
			System.out.println((initialAmount-aAmount)%bAmount);
		}
	}
}


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

int main() {
    int n;cin>>n;
    long a[n],b[n],ans=0,tmp=1;
    for(int i=0;i<n;++i){
        cin>>a[i];
        if(a[i]>=0)b[i]=1;
        else b[i]=-1;
        
        a[i]=abs(a[i]);
        tmp*=b[i];
    }
    sort(a,a+n);
    if(tmp==-1)a[0]*=-1;
    for(int i=0;i<n;++i){
        ans+=a[i];
    }
   cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+20;
const int M=2e2+20;
ll v[N];
ll C[M][M]; 
void init()
{
	memset(C,0,sizeof(C));
	C[0][0]=1;
	for(int i=1;i<=50;i++)
	{
		C[i][0]=1;
		for(int j=1;j<=i;j++)
			C[i][j]=C[i-1][j-1]+C[i-1][j];
	}
}
int main()
{
	int n,A,B;
	init();
	while(cin>>n>>A>>B)
	{
		double ave=0;
		for(int i=0;i<n;i++)
			cin>>v[i];
		sort(v,v+n);
		reverse(v,v+n);
		for(int i=0;i<A;i++) 
			ave+=v[i];
		ave/=A;
		int num=0,k=0;
		for(int i=0;i<n;i++)
		{
			if(v[i]==v[A-1])
			{
				num++;
				if(i<A)
					k++;
			}
		}	
		ll ans=0; 
		if(k==A)
		{
			for(int i=A;i<=B;i++)
				ans+=C[num][i];
		}
		else
			ans+=C[num][k];

 		cout.precision(20);
 		cout<<fixed<<ave<<endl;
 		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#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 int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(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 ul = unsigned long;
 
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;
 
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; }
 
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

const ll mod=998244353;

ll cnt[100100];

signed main()
{
  ll n; cin>>n;
  vi D(n);
  ll maxd=0;
  ll firstD=-1;
  rep(i,n){
    ll d; cin>>d;
    if(i==0) firstD=d;
    cnt[d]++;
    chmax(maxd,d);
  }
  // cout<<firstD<<endl;
  if(firstD!=0||cnt[0]>1||cnt[0]==0){
    cout<<0<<endl;
    return 0;
  }
  
  ll ans=1;
  reps(i,maxd-1){
    // cout<<cnt[i]<<endl;
    if(cnt[i]==0){
      ans=0;
      break;
    }
    ll p = 1;
    rep(j,cnt[i+1]){
      p=(p*cnt[i])%mod;
    }
    ans=(ans*p)%mod;
  }
  // cout<<cnt[maxd]<<endl;
  cout<<ans<<endl;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

template <typename T>
struct SegmentTreeLazy //デフォルトは区間変更区間合計
{
    int n;
    const T ex = 0; //dat 初期値(合計なので)
    const T em = 1ll << 60; //lazy 初期値(updateするので)
    //lazyで一括更新をもって、datでqueryに対応する。
    vector<T> dat, lazy, weight; //tree本体
    SegmentTreeLazy(vector<T> v){
        int x = 1;
        int i;
        n = v.size();
        while(x < n) x <<= 1;
        n = x; 
        dat.resize(2*n-1, ex); //tree本体
        lazy.resize(2*n-1, em); //遅延評価
        weight.resize(2*n-1, 0); //何node持ってるか
        for(i = 0;i < v.size();++i){
            dat.at(i + n - 1) = v.at(i);
            weight.at(i + n - 1) = 1;
        }
        for(i = n-2;i >= 0;--i){
            dat.at(i) = fx(dat.at(2*i+1), dat.at(2*i+2));
            weight.at(i) = weight.at(2*i + 1) + weight.at(2*i + 2);
        }
    }
    
    T fx(T a, T b){ //dat上での計算
        return a + b; //区間加算なので加算
    }

    T fm(T a){ //lazy上での計算
        return min(a, em);
    }
    
    void eval(int now){ //区間下は全て影響を受ける。(受ける時しか呼ばれない)
        if(lazy.at(now) == em) return;
        if(now < n - 1){ //区間加算なので値を代入する。
            lazy.at(2*now + 1) = fm(lazy.at(now));
            lazy.at(2*now + 2) = fm(lazy.at(now));
        }
        //**********************ここが大事
        dat.at(now) = lazy.at(now)*weight.at(now); //区間加算する。
        //**********************
        lazy.at(now) = em;
    }
    
    void update(int a, int b, T x, int now, int l, int r){
        eval(now);
        if(a <= l && r<= b){ //区間内に全部いる。
            lazy.at(now) = x; //上から書き換える。区間最小なので同じ値を足す。
            eval(now);
        }else if(a < r && l < b){
            update(a, b, x, 2*now + 1, l, (l + r)/2);
            update(a, b, x, 2*now + 2, (l + r)/2, r);
            dat.at(now) = fx(dat.at(2*now + 1), dat.at(2*now + 2));
        }
    }
    void update(int a, int b, T x){update(a, b, x, 0, 0, n);}
    
    T query(int a, int b){return query_sub(a, b, 0, 0, n);}
    T query_sub(int a, int b, int now, int l, int r){
        eval(now);
        if(r <= a || b <= l) return ex;
        else if(a <= l && r <= b) return dat.at(now);
        else{
            T vl = query_sub(a, b, 2*now + 1, l, (l + r)/2);
            T vr = query_sub(a, b, 2*now + 2, (l + r)/2, r);
            return fx(vl, vr);
        }
    }

    inline T operator[](int a) { return query(a, a + 1); }
    void print() {
        for (int i = 0; i < 2 * n - 1; ++i) {
            cout << (*this)[i];
            if (i != n) cout << ",";
        }
        cout << endl;
    }
};

int main()
{
    ll i,j;
    ll n,q;
    cin >> n >> q;
    vector<ll> a(n, 0);
    SegmentTreeLazy<ll> seg(a);
    for(i = 0;i < q;++i){
        ll com;
        cin >> com;
        if(com == 0){
            ll s,t,x;
            cin >> s >> t >> x;
            seg.update(s, t+1, x);
        }else{
            ll s,t;
            cin >> s >> t;
            cout << seg.query(s, t+1) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 10540
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int X,n,m[100009];

    int count=0;
    cin>>n>>X;
    for(int i=0;i<n;i++)
        cin>>m[i];
    sort(m,m+n);
    int total=0;
        for(int i=0;i<n;i++)
            {
                total=total+m[i];
                if(total<X)
                    count++;
                else{
                    total=total-m[i];
                break;
                }
            }
    int remaining=X-total;
    count=count+remaining/m[0];
    cout<<count<<endl;
}


Measured memory_bytes: 256
N = int(input())
H = [int(i) for i in input().split()]

ans = 0
count = 0
for i in range(N - 1):
    if H[i] >= H[i + 1]:
        count += 1
    else:
        if count > ans:
            ans = count
        count = 0

if count > ans:
    ans = count
print(ans)


Measured memory_bytes: 14224
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22)
        cout<<"bust";
    else
        cout<<"win";
    return 0;
}


Measured memory_bytes: 256