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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main() {
    int n, ans = 0;
    bool flg = 0;
    cin >> n;
    int p[n], q[n];
    rep(i, n) {
        cin >> p[i];
    }
    rep(i, n) {
        cin >> q[i];
    }

    int perm = 0;
    rep(i, n) {
        if(p[i] < q[i])
            perm = 1;
        else if(p[i] > q[i])
            perm = -1;
        else if(i < n - 1)
            continue;
        else {
            cout << 0 << endl;
            return 0;
        }
        break;
    }
    if(perm == 1) {
        do {
            for(int i = 0; i < n; i++) {
                if(p[i] != q[i])
                    break;
                else if(i == n - 1)
                    flg = 1;
            }
            if(flg) break;
            ans++;
        } while(next_permutation(p, p + n));
    } else if(perm == -1) {
        do {
            for(int i = 0; i < n; i++) {
                if(q[i] != p[i])
                    break;
                else if(i == n - 1)
                    flg = 1;
            }
            if(flg) break;
            ans++;
        } while(next_permutation(q, q + n));
    }

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

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 256
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  string S; cin >> S;
  int cnt = 0;
  for (int i = 0; i < S.length(); i++) {
    if (S[i] == 'o') cnt++;
  }
  if (15-S.length()+cnt >= 8) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() {
  long long A;
  long double B;
  cin >> A >> B;
  //B *= 100;
  //ll Ans = A * (ll)(floor(B)+0.001);
  //cout << Ans / 100 << endl;
  cout << (ll)(A * B) << endl;
}

Measured memory_bytes: 3744
n = int(input())
ab = [list(map(int,input().split())) for i in range(n)]
ab = sorted(ab, key=lambda x:x[1])
ans = "Yes"
time = 0
for i in range(n):
    time += ab[i][0]
    if time > ab[i][1]:
        ans = "No"
print(ans)

Measured memory_bytes: 91864
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  vector<ll> a(n);
  map<ll, int> mp;
  ll sumv = 0;
  rep(i, 0, n) {
    ll t;
    cin >> t;
    sumv += t;
    mp[t]++;
  }

  int q;
  cin >> q;
  rep(i, 0, q) {
    ll b, c;
    cin >> b >> c;
    sumv -= b * mp[b];
    sumv += mp[b] * c;
    cout << sumv << endl;
    ll t = mp[b];
    mp[b] = 0;
    mp[c] += t;
  }
}


Measured memory_bytes: 10024
N = int(input())
h_list = list(map(int, input().split(' ')))


def mizuyari(h_list, l, r):
    num_mizuyari = min(h_list[l:r+1])
    h_list = [h - num_mizuyari if l <= x and x <= r else h for x, h in enumerate(h_list)]
    zero_posi = h_list[l:].index(0) + l
    if l == zero_posi:
        first_non_zero_posi = [x for x, h in enumerate(h_list) if h != 0]
        if not first_non_zero_posi:
            print(sum_mizuyari + num_mizuyari)
            exit()
        l = first_non_zero_posi[0]
        if list(range(l, len(h_list))) == first_non_zero_posi:
            return h_list, num_mizuyari, l, len(h_list)
        zero_posi = h_list[l:].index(0) + l
    new_r = zero_posi - 1
    return h_list, num_mizuyari, l, new_r
l = 0
r = len(h_list) - 1
sum_mizuyari = 0
while True:
    h_list, num_mizuyari, l, r = mizuyari(h_list, l, r)
    sum_mizuyari += num_mizuyari

Measured memory_bytes: 3064
N,K = map(int,input().split())
ans = 0
count_0 = 0
count_K_2 = 0
for i in range(1,N+1):
    if K % 2 != 0:
        if i % K == 0:
            count_0 += 1
        else:
            pass
    else:
        if i % K == 0:
            count_0 += 1
        elif i % K == K / 2:
            count_K_2 += 1

ans = pow(count_0,3) + pow(count_K_2,3)

print(ans)
            

Measured memory_bytes: 3064
#include<iostream>
#include<cstdlib>
#include<cmath>
#define ll long long
#define int long long

using namespace std;

int x;

signed main()
{
	cin >> x;
	int ans = 0;
	/*
	for (int i = 357; i <= x; i+=2) {
		bool a, b, c;
		a = false;
		b = false;
		c = false;
		for (int j = 0; j < 9; j++) {
			int p;
			p = pow(10, j);
			int y;
			y = i / p % 10;
			if (y == 3) {
				a = true;
			}
			else if (y == 5) {
				b = true;
			}
			else if (y == 7) {
				c = true;
			}
		}
		if (a&&b&&c) {
			ans++;
		}
	}
	cout << ans << endl;
	*/

	int y;
	y = x;
	int j = 0;
	int z;

	for (int i = 0; y > 0; i++) {
		y = y / 10;
		j++;
	}

	for (int i = 3; i < j; i++) {
		ans += pow(3, i) - 3 * pow(2, i) + 3;
	}
	
	int a[10] = {};


	for (int i = 1; i <= j; i++) {


		z = x / pow(10, j - i);
		z = z % 10;

		int k;
		k = j - i;
		if (z <= 2) {
			break;
		} else if (z == 3) {
			a[3] = 1;
		}
		else if (z == 4){
			int A;
			a[3] = 1;
			if (a[3] + a[5] + a[7] == 1) {
				ans += pow(3, k) - pow(2, k + 1) + 1;
			}
			if (a[3] + a[5] + a[7] == 2) {
				ans += pow(3, k) - pow(2, k);
			}
			if (a[3] + a[5] + a[7] == 3) {
				ans += pow(3, k);
			}
			break;
		}
		else if (z == 5) {
			if (1 + a[5] + a[7] == 1) {
				ans += pow(3, k) - pow(2, k + 1) + 1;
			}
			if (1 + a[5] + a[7] == 2) {
				ans += pow(3, k) - pow(2, k);
			}
			if (1 + a[5] + a[7] == 3) {
				ans += pow(3, k);
			}
			a[5] = 1;
		}

		else if (z == 6) {
			if (1 + a[5] + a[7] == 1) {
				ans += pow(3, k) - pow(2, k + 1) + 1;
			}
			if (1 + a[5] + a[7] == 2) {
				ans += pow(3, k) - pow(2, k);
			}
			if (1 + a[5] + a[7] == 3) {
				ans += pow(3, k);
			}
			if (1 + a[3] + a[7] == 1) {
				ans += pow(3, k) - pow(2, k + 1) + 1;
			}
			if (1 + a[3] + a[7] == 2) {
				ans += pow(3, k) - pow(2, k);
			}
			if (1 + a[3] + a[7] == 3) {
				ans += pow(3, k);
			}
			break;

		}
		else if (z == 7) {
			if (1 + a[5] + a[7] == 1) {
				ans += pow(3, k) - pow(2, k + 1) + 1;
			}
			if (1 + a[5] + a[7] == 2) {
				ans += pow(3, k) - pow(2, k);
			}
			if (1 + a[5] + a[7] == 3) {
				ans += pow(3, k);
			}
			if (1 + a[3] + a[7] == 1) {
				ans += pow(3, k) - pow(2, k + 1) + 1;
			}
			if (1 + a[3] + a[7] == 2) {
				ans += pow(3, k) - pow(2, k);
			}
			if (1 + a[3] + a[7] == 3) {
				ans += pow(3, k);
			}
			a[7] = 1;
		}
		else {
			if (1 + a[5] + a[7] == 1) {
				ans += pow(3, k) - pow(2, k + 1) + 1;
			}
			if (1 + a[5] + a[7] == 2) {
				ans += pow(3, k) - pow(2, k);
			}
			if (1 + a[5] + a[7] == 3) {
				ans += pow(3, k);
			}
			if (1 + a[3] + a[7] == 1) {
				ans += pow(3, k) - pow(2, k + 1) + 1;
			}
			if (1 + a[3] + a[7] == 2) {
				ans += pow(3, k) - pow(2, k);
			}
			if (1 + a[3] + a[7] == 3) {
				ans += pow(3, k);
			}
			if (1 + a[3] + a[5] == 1) {
				ans += pow(3, k) - pow(2, k + 1) + 1;
			}
			if (1 + a[3] + a[5] == 2) {
				ans += pow(3, k) - pow(2, k);
			}
			if (1 + a[3] + a[5] == 3) {
				ans += pow(3, k);
			}
			break;
		}
		
		if (i == j) {
			if (a[3] + a[5] + a[7] == 3) {
				ans += 1;
			}
		}

	}
	

	cout << ans << endl;

    return 0;
}


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


using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 2e3 + 5;
bool isPrime[MAXN];

void sevie() {
    memset(isPrime, 1, sizeof(isPrime));
    isPrime[0] = isPrime[1] = 0;
    for (ll i = 2; i * i <= MAXN; i++) {
        if (isPrime[i]) {
            for (ll j = i * 2; j <= MAXN; j += i) {
                isPrime[j] = 0;

            }
        }
    }
}

ll fastPow(ll x, ll b) {
    if (b == 0)
        return 1;
    else if (!(b & 1)) {
        return fastPow(x * x, b / 2);
    } else
        return x * fastPow(x * x, (b - 1) / 2);
}

//__builtin_popcount ();
bool isPrim(int n) {
    if (n == 1 || n == 0)
        return false;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0)
            return false;
    }
    return true;
}

int main() {
    FAST
    int n;
    cin >> n;
    string a, b;
    int arr[n];
    for (int i = 1; i <= n; i++)
        arr[i - 1] = i;
    for (int i = 0; i < n; i++) {
        string aa;
        cin >> aa;
        a += aa;
    }
    for (int i = 0; i < n; i++) {
        string aa;
        cin >> aa;
        b += aa;
    }
    int ind1 = 0, ind2 = 0;
    int c = 1;
    do {
        string comp;
        for (int i = 0; i < n; i++) {
            comp.push_back((char) (arr[i] + '0'));
        }

        if (comp == a)
            ind1 = c;
        if (comp == b)
            ind2 = c;
        c++;
    } while (next_permutation(arr, arr + n));
    cout << abs(ind1 - ind2) << endl;
    return 0;
}


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

int partition(vector<pair<string,int>> &arr, int p, int r){
    int x = arr.at(r).second;
    int i = p - 1;
    for(int j=p;j<r;j++){
        if(arr.at(j).second <= x){
            i++;
            swap(arr.at(i),arr.at(j));
        }
    }
    swap(arr.at(i+1),arr.at(r));
    return i+1;
}

void quicksort(vector<pair<string,int>> &arr,int p,int r){
    if(p < r){
        int idx = partition(arr,p,r);
        quicksort(arr,p,idx-1);
        quicksort(arr,idx+1,r);
    }
}

void merge(vector<pair<string,int>> &arr,int left,int right,int mid){
    int n = mid - left;
    int m = right - mid;
    vector<pair<string,int>> left_array(n),right_array(m);
    for(int i=0; i<n; i++){
        left_array.at(i) = arr.at(left+i);
    }
    for(int i=0;i<m;i++){
        right_array.at(i) = arr.at(mid+i);
    }
    pair<string,int> last_pair = make_pair("a",2147483647);
    left_array.push_back(last_pair);
    right_array.push_back(last_pair);
    int i=0,j=0;
    for(int k=0; k<right-left;k++){
        if(left_array.at(i).second <= right_array.at(j).second){
            arr.at(left+k) = left_array.at(i);
            i++; 
        }else{
            arr.at(left+k) = right_array.at(j);
            j++;
        }
    }
}

void mergesort(vector<pair<string,int>> &arr,int left,int right){
    if(left + 1 < right){
        int mid = (left + right) / 2;
        mergesort(arr,left,mid);
        mergesort(arr,mid,right);
        merge(arr,left,right,mid);
    }
    
}

int main(){
    int n;
    cin >> n;
    vector<pair<string,int>> array(n),copy(n);

    for(int i=0;i<n;i++) cin >> array.at(i).first >> array.at(i).second ;
    copy = array;
    mergesort(copy,0,n);
    quicksort(array,0,n-1);
    if(copy == array){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }
    for(int i=0;i<n;i++){
        cout << array.at(i).first << " " << array.at(i).second << endl; 
    }
}


Measured memory_bytes: 13848
#include<cstdio>
#include<cstring>
#define M 1046527
#define NIL -1
#define L 14
char H[M][L];

int getChar(char ch);
long long getKey(char str[]);
int h1(int key) { return key % M; }
int h2(int key) { return 1 + (key % (M-1) ); } //if collision
int find(char str[]);
void insert(char str[]);

int main() {
    for (int i = 0; i < M; i++) H[i][0] = '\0';
    int n;
    scanf("%d", &n);
    char com[7], str[L]; //7 for insert
    for (int i = 0; i < n; i++) {
        scanf("%s %s", com, str); //like insert AAA
        if (com[0] == 'i') insert(str);
        else {
            if (find(str) ) printf("yes\n");
            else printf("no\n");
        }
    }
    return 0;
}
void insert(char str[]) {
    long long key, h;
    key = getKey(str);
    for (int i = 0;; i++) {
        h = (h1(key) + i * h2(key) ) % M;
        if (strcmp(H[h], str) == 0) return;
        else if (strlen(H[h]) == 0) {
            strcpy(H[h], str);
            return;
        }
    }
    return;
}
int find(char str[]) {
    long long key, h;
    key = getKey(str);
    for (int i = 0;; i++) {
        h = (h1(key) + i * h2(key) ) % M;
        if (strcmp(H[h], str) == 0) return 1;
        else if (strlen(H[h]) == 0) return 0;
    }
    return 0;
}
long long getKey(char str[]) { //input of hash function should be a number
    long long sum = 0, p = 1;
    for (int i = 0; i < strlen(str); i++) {
        sum += p * (getChar(str[i]) );
        p *= 5; //because getChar has less than 4, unique
    }
    return sum;
}
int getChar(char ch) {
    if (ch == 'A') return 1;
    else if (ch == 'C') return 2;
    else if (ch == 'G') return 3;
    else if (ch == 'T') return 4;
    else return 0;
}



Measured memory_bytes: 16980
using System;

class Program
{
  static void Main(string[] args)
  {
    string[] input = Console.ReadLine().Split(' ');
    int a = int.Parse(input[0]);
    int b = int.Parse(input[1]);
    
    if(a + b < 10) Console.WriteLine("{0}", a + b);
    else Console.WriteLine("error");
  }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define FOR(i, n) for(ll i = 0; i < n; i++)
#define FORR(i, n) for(ll i = n; i >= 0; i--)
#define FORS(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) accumulate(v.begin(),v.end(),0)
#define SORT(v) sort(v.begin(),v.end())
#define OUT(n) (cout << n << endl)
#define IN1(a) (cin >> a)
#define IN2(a,b) (cin >> a >> b)
#define IN3(a,b,c) (cin >> a >> b >> c)
#define IN4(a,b,c,d) (cin >> a >> b >> c >> d)
using namespace std;
typedef long long ll;

int main(){
  int a,b,ans;
  IN2(a,b);
  ans = max(a+b,max(a-b,a*b));
  OUT(ans);
}

Measured memory_bytes: 256
inf = float('inf')
n = int(input())
g = []
for i in range(n):
    line = list(map(int, input().split()))
    k = line[1]
    c = [inf] * n
    for j in range(k):
        v = line[2 + 2 * j]
        c[v] = line[3 + 2 * j]
    g.append(c)

distance = [inf] * n
distance[0] = 0
visited = [False] * n
current = 0

while not all(visited):
    visited[current] = True
    min_i = 0
    min_d = inf
    for i in range(n):
        if not visited[i]:
            if distance[current] + g[current][i] < distance[i]:
                distance[i] = distance[current] + g[current][i]
            if distance[i] < min_d:
                min_i = i
                min_d = distance[i]
    current = min_i

for i in range(n):
    print(i, distance[i])

Measured memory_bytes: 5860
(* O(n) *)
let find_fold_int f a n =
  let rec find a i =
    if i >= n then
      a, false
    else
      let (res, detected) as r = f a i in
        if detected then r else find res (i + 1)
  in
    find a 0

(* O(N^2) *)
let solve n y =
  find_fold_int
    (fun sofar_a a ->
      find_fold_int
        (fun sofar_b b ->
          let c = n - a - b in
          if c >= 0 && 10000 * a + 5000 * b + 1000 * c = y then (* cが負の場合は除外 *)
            (a, b, c), true
          else
            sofar_b, false)
        sofar_a
        (n + 1))
    (-1, -1, -1)
    (n + 1) |> fst

let read_ints () = read_line () |> Str.split (Str.regexp " ") |> List.map int_of_string

let _ =
  match read_ints () with
  | [n; y] -> let (a, b, c) = solve n y in Printf.printf "%d %d %d\n" a b c
  | _ -> ()

Measured memory_bytes: 4608
#include<iostream>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>

#define rep(i, a) for(int i = 0; i < a; i++)
#define llint long long int
using namespace std;

const int MAX_x = 100005;
const llint INF = 999999999999999;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << (a - 1) * (b - 1);
}    


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
	int N, cnt['R'+1] = {0}, bad = 0;
	string str;
	cin >> N >> str;
	for(int i=0; i<N; i++)
		cnt[str[i]]++;
	for(int i=0; i<N; i++)
		for(int d=1; i+d+d<N; d++)
			if(str[i] != str[i+d] && str[i+d] != str[i+d+d] && str[i] != str[i+d+d])
				bad ++;
	cout << (long long)cnt['R'] * cnt['G'] * cnt['B'] - bad << endl;
}
	
	


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include<limits.h>
#include<stdio.h>
#include<cstring>
#include<string>
using namespace  std;
typedef long long ll;
typedef long double ld;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define fi first
#define se second
#define rsz(a,n) a.resize(n)
#define test(t) ll t;cin>>t;while(t--)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define fillv(a,k) memset(a,k,sizeof(a))
#define leadzero(a) __builtin_clz(a) //count leading zeros
#define trailzero(a) __builtin_ctz(a) //count trailing zeros
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln cout<<"\n"
// #define sp cout<<" "
#define spaceprint(a,i,s,n) {forsn(i,s,n) { cout<<a[i]; sp;}}
#define lineprint(a,i,s,n) {forsn(i,s,n) {cout<<a[i]; ln;}}
#define maxe(a) *max_element(a.begin(),a.end())
#define maxi(a) max_element(a.begin(),a.end())-a.begin()
#define mine(a) *min_element(a.begin(),a.end())
#define mini(a) min_element(a.begin(),a.end())-a.begin()
#define all(c) c.begin(),c.end()
#define trav(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element)  (find(all(container),element) != container.end())// check the presence of element
//copy(from_begin, from_end, to_begin); copy function
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<string> vs;
typedef vector<int> v32;
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
typedef map<ll,ll> m64;
const int LIM = 1e5+5, MOD =  1e9;
#define sumv(v) accumulate(all(v),ll(0))
#define productv(v) accumulate(all(v), ll(1), multiplies< ll >())
ll gcd(ll a, ll b) { if(b == 0) return a; return gcd(b, a % b); }
ll mod=998244353;
ll fastpowMOD(ll a, ll p,ll MOD){ if(p==0) return 1; ll z = fastpowMOD(a,p/2,MOD); z = (z*z)%MOD; if(p%2) z = (z*a)%MOD; return z; }


int main()
{
	fast;
	set <string> s;
	ll n;
	cin>>n;
	for (ll i=0;i<n;i++)
	{
		string x;
		cin>>x;
		s.insert(x);
	}
	cout<<s.size();
}



Measured memory_bytes: 19144
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T> int len(const T &v) { return v.size(); }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main() {
  int q = in();
  multiset<int> s;
  while (q--) {
    int t = in();
    if (t == 0) {
      s.emplace(in());
      cout << s.size() << endl;
    }
    if (t == 1) cout << s.count(in()) << endl;
    if (t == 2) s.erase(in());
    if (t == 3) {
      int l, r;
      cin >> l >> r;
      for (auto it = s.lower_bound(l), end = s.upper_bound(r); it != end; it++) cout << *it << endl;
    }
  }
}



Measured memory_bytes: 12356
#include <cstdio>
#include <map>

using namespace std;

map<string, int> smap;
char tmp[11];

int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%s", tmp);
        smap[tmp]++;
    }

    int m;
    scanf("%d", &m);
    for (int i = 0; i < m; i++)
    {
        scanf("%s", tmp);
        smap[tmp]--;
    }

    int maxn = 0;
    for (auto i : smap)
    {
        if (i.second > maxn)
        {
            maxn = i.second;
        }
    }

    printf("%d", maxn);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>                                 
using namespace std;                                
                                                    
int main(){                                         
        char forecast[3];                           
        for (int i = 0; i < 3; i++){                
                cin >> forecast[i];                 
        }                                           
        char result[3];                             
        for (int i = 0; i < 3; i++){                
                cin >> result[i];                   
        }                                           
        int ans = 0;                                
        for (int i = 0; i < 3; i++) {               
                if (forecast[i] == result[i]) ans++;
        }                                           
        cout << ans << endl;                        
}                                                   

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<ll,ll> P;
//ll const INF=1001001001;
//ll const INF=1001001001001001001;
ll const MOD=1000000007;

ll K;

int main(){
    cin>>K;

    ll val=0;
    ll ans=-1;
    rep(i,K){
        val=val*10+7;
        val%=K;
        if(val==0){
            ans=i+1;
            break;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3568
N, M = [int(i) for i in input().strip().split()]
s_ids = []
for i in range(M):
  line = [int(i) - 1 for i in input().strip().split()]
  s_ids.append(line[1:])
p = [int(i) for i in input().strip().split()]

cnt = 0
res = 0
while True:
  cnt2 = cnt
  s = [0] * N
  for i in range(N):
    s[i] = cnt2 % 2
    cnt2 = cnt2 // 2
  are_light = True
  for i in range(M):
    n_on = sum([s[s_id] for s_id in s_ids[i]])
    if n_on % 2 != p[i]:
        are_light = False
  if are_light:
    res += 1
  if cnt == (2 ** N) - 1:
    break
  cnt += 1
print(res)


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
    ll n; cin >> n;
    ll a[n], sum = 0;
    REP( i, n){
        cin >> a[i];
        sum += a[i];
    }

    ll tmp = 0, minv = 1000000000000000000LL;
    for( ll i = 0; i < n; i++ ) {
        tmp += a[i];
        if(i+1 < n) minv = min( minv, abs(sum - tmp*2));
    }
    // cout << sum << endl;
    cout << minv << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

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

    int ans = 1;
    for(int i=1; i*i<=M; i++){
        if(M%i == 0){
            if(M/i >= N) ans = max(ans, i);
            if(i >= N) ans = max(ans, M/i);
        }
    }

    cout << ans << endl;
}

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

#define rep(i, n) for(int (i) = 0; i < (n); ++(i))

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int N;
  std::cin >> N;
  std::cout << (N - 1) / 2 << '\n';
}


Measured memory_bytes: 256
/*  ***  In The Name of God ... ***  */
/* ye state o ye stack o in hame moshtari ? :)) */ 
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int long long
#define all(v) v.begin() , v.end()
#define pb push_back
template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

const int N = 2e5 + 100 ;

int n , k , a [ N ] , cnt [ N ] ; 

int32_t main() {
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin >> n >> k ;
	for ( int i = 0 ; i < n ; i++ )
		cin >> a [ i ] , cnt [ a [ i ] ] ++ ;
	sort ( cnt + 1  , cnt + n + 1 ) ;
	int t = 0 ; 
	for ( int i = 1 ; i <= n ; i++ )
		t += ( cnt [ i ] > 0 ) ;
	int ans = 0 ; 
	for ( int i = 1 ; i <= n ; i++ ) {
		if ( t <= k )
			break ;
		if ( cnt [ i ] ) 
			t--;
		ans += cnt [ i ] ; 
	}
	cout << ans << '\n' ; 
}


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

int main(void)
{
	int N, K;
	while (cin >> N >> K, N && K){
		int blood[128];
		int eat[128];
		fill (blood, blood + 128, 0);
		fill (eat, eat + 128, 0);
		for (int i = 0; i < K; i++){
			cin >> blood[i];
		}
		int tmp;
		for (int i = 0; i < N; i++){
			for (int j = 0; j < K; j++){
				cin >> tmp;
				eat[j] += tmp;
			}
		}
		bool flag = true;
		for (int i = 0; i < K; i++){
			if (blood[i] < eat[i]) flag = false;
		}
		if (flag) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	
	return 0;
}

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

using namespace std;
#define int long long
const int N = 5e5 + 10;
int a[N];

int32_t main()
{
    string s; cin >> s;
    int n = s.size();
    a[0] = 0;
    int l = 0, ans = 0, car = 0;
    for (int i = 1; i <= n; i ++) {
        if (s[i - 1] == '>') {
            a[i] = min(0ll, a[i - 1] - 1);
            if (a[i] < 0) a[i]++, ans += i - l - 1, car++;
            if (car > a[l]) ans++;
        }
        else a[i] = a[i - 1] + 1, l = i, car = 1;
        ans += a[i];
    }
    cout << ans << "\n";
}


Measured memory_bytes: 4740
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

long long solve(long long a){
    if(a%4==3)return 0;
    if(a%4==0)return a;
    if(a%4==1)return 1;
    if(a%4==2)return a+1;
    return 0;
}
int main(){
long long a,b;cin>>a>>b;
long long ans=solve(b)^solve(a-1);
cout<<ans;
}

Measured memory_bytes: 632
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int a[105],b[105];
bool cmp(const int &a,const int &b){
	return a>b;
}
int main(){
	int n,m;
	cin>>n>>m;
	int p,q;
	cin>>p>>q;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n,cmp);
	for(int i=0;i<m;i++)
		cin>>b[i];
	sort(b,b+m);
	int flag=0;
	for(int i=p+1;i<=q;i++){
		if(i>a[0]&&b[0]>=i){
			flag=1;
			break;	
		}
	}
	if(flag)
	printf("No War");
	else
	printf("War");
} 

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;
typedef long long  ll;

#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))

int main() {
    ll A,B,Q;
    cin>>A>>B>>Q;
    vector<ll>s;
    vector<ll>t;
    vector<ll>x;
    
    s.push_back(-INF);
    t.push_back(-INF);
    for(ll i=0;i<A;i++){
        ll a;
        cin>>a;
        s.push_back(a);
    }
    s.push_back(INF);
    for(ll i=0;i<B;i++){
        ll b;
        cin>>b;
        t.push_back(b);
    }
    t.push_back(INF);
    for(ll i=0;i<Q;i++){
        ll c;
        cin>>c;
        x.push_back(c);
    }
    ll p[2],q[2];
   for(ll i=0;i<A;i++){
        //cout<<x[i]<<' '<<t[i]<<endl;
    }
    ll res=INF;
    for(ll i=0;i<Q;i++){

         p[0]=*lower_bound(s.begin(),s.end(),x[i]);
         p[1]=*(lower_bound(s.begin(),s.end(),x[i])-1);
         q[0]=*lower_bound(t.begin(),t.end(),x[i]);
         q[1]=*(lower_bound(t.begin(),t.end(),x[i])-1);
         res=INF;
         //cout<<p[1]<<endl;
        for (ll n=0;n<2;n++){
            for(ll r=0;r<2;r++){

            ll d1=abs(p[n]-x[i])+abs(p[n]-q[r]);
            ll d2=abs(q[r]-x[i])+abs(p[n]-q[r]);
            ll d3=min(d1,d2);
               res=min(res,d3);
            //cout<<res<<endl;
            }
        }


        cout<<res<<endl;
        //cout<<*upper_bound(s.begin(),s.end(),x[i])<<endl;

    }

    return 0;
}

Measured memory_bytes: 3828
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define Debug printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define debug(x) cerr<<#x<<'='<<x<<endl
#define mem(x,val) memset(x,val,sizeof x)
namespace mine
{
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
    template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
    bool IN(ll x,ll l,ll r){return l<=x and x<=r;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=4e5+10;

    ll n,a[N],b[N];vc<int> ans;
    bool isp(int num){if(num==1)return 0;fo(i,2,sqrt(num))if(num%i==0)return 0;return 1;}
    bool check(int p)
    {
        fo(i,0,n-1) b[i]=a[i+1];
        fd(i,n-1,p-1) (b[i-(p-1)]-=1ll*(p-1)*b[i])%=p,b[i]=0;
        fo(i,0,p-2) if(b[i]) return 0;return 1;
    }
    void main()
	{
        n=qread();int d=0;fd(i,n,0) a[i]=qread(),d=gcd(d,a[i]);d=abs(d);
        fo(p,1,sqrt(d)) if(d%p==0) {if(isp(p)) ans.PB(p);if(isp(d/p)) ans.PB(d/p);}
        fo(p,1,n) if(isp(p) and a[0]%p==0 and check(p)) ans.PB(p);
        sort(all(ans));ans.resize(unique(all(ans))-ans.begin());for(auto t:ans) write2(t);
	}
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main(){
    Hello
    ll r, d, x2000;
    cin >> r >> d >> x2000;
    for(int i = 1; i <= 10; i++){
        x2000 = r * x2000 - d;
        cout << x2000 << endl;
    }
    return 0;
}


Measured memory_bytes: 3608
#include <algorithm>
#include <iostream>
#include <set>
#include <utility>
using int_t = long long int;
using std::cin;
using std::cout;
using std::endl;
const int_t LARGE = 2e5;
int n, m;
int_t seq[LARGE + 1];
bool visited[LARGE + 1];
struct Pair {
    int_t a, b;
} pairs[LARGE + 1];
int main() {
    scanf("%d%d", &n, &m);

    for (int_t i = 1; i <= n; i++) pairs[i] = Pair{i, i};

    int_t var0 = 0;

    for (int_t i = 1; i <= m; i++) {
        int_t x;
        scanf("%lld", &x);
        pairs[x].b = var0;
        var0 -= 1;
    }
    std::sort(pairs + 1, pairs + 1 + n,
              [](const Pair& a, const Pair& b) -> bool { return a.b < b.b; });
    for (int_t i = 1; i <= n; i++) printf("%lld\n", pairs[i].a);
    return 0;
}


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

    int n;
    cin>>n;

    int arr[n];
    int abb[n];
    int acc[n];

    for(int i=0;i<n;i++){
        cin>>arr[i];
    }

    abb[0] = arr[0];

    for(int i=1;i<n;i++){
        abb[i] = abb[i-1]+arr[i];
    }

    acc[n-1] = arr[n-1];

    for(int i = n-2;i>=0;i--){
        acc[i] = acc[i+1] + arr[i];
    }

    int sum1=0,sum2=0;

    int ans = INT_MAX;

    for(int i=0;i<n-1;i++){
        ans = min(ans,abs(abb[i]-acc[i+1] ));
    }

    cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n,max,min,i,a;
  long int sum=0;
//  max = -1000000;
//  min = 1000000;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%",&a);
    if(i==0){ max=a; min=a; }
    if(max<a) max = a;
    if(min>a) min = a;
    sum+=a;
  }
  printf("%d %d %ld\n",min,max,sum);

  return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
    const int MAX = 200000;
    int r[MAX], n;

    cin >> n;
    for (int i = 0; i < n; i++) cin >> r[i];

    int maxv = -2 * pow(10, 9);
    int minv = r[0];

    for (int i = 1; i < n; i++) {
        maxv = max(maxv, r[i] - minv);
        minv = min(minv, r[i]);
    }

    cout << maxv << endl;
}



Measured memory_bytes: 3888
#include<stdio.h>
#define N 102

int g[N][N];
int d[N],f[N];
int t=0,n=0;
 
int D(int x){
  t++;
  int i;
  for(i=1;i<=n;i++){
    if(d[x]==0)
      d[x] = t;
    if(g[x][i]==1 && f[i]==0){
      g[x][i]=0;
      if(d[i]==0){
    D(i);
    t++;
      }
    }
    if(i==n && f[x]==0){
      f[x] = t+1;
    }
  }
  return 0;
}
 
int main(){
  scanf("%d", &n);
  int i,j;
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      g[i][j] = 0;
    }
    d[i]=0;
    f[i]=0;
  }
 
  int l,k;
  for(i=0;i<n;i++){
    scanf("%d %d", &l,&k);
    for(j=0;j<k;j++){
      int v;
      scanf("%d", &v);
      g[l][v] = 1;
    }
  }
 
  for(i=1;i<=n;i++){
    if(f[i]==0){
      D(i);
      t++;
    }
  }
  for(i=1;i<=n;i++){
    printf("%d %d %d\n", i, d[i], f[i]);
  }
  return 0;
}

Measured memory_bytes: 636
// D - Lucky PIN
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N; string S; cin>>N>>S;
	int ans = 0;
	for(int i=0; i<1000; i++){
		int d = 100;
		for(int j=0; j<N; j++)
			if(S[j] == i/d%10+'0'){
				if(d == 1){ ans++; break; }
				d /= 10;
			}
	}
	cout<< ans <<endl;
}

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

int main() {
  int h, w;
  scanf("%d %d", &h, &w);
  vector<vector<char>> s(h, vector<char>(w));
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) cin >> s[i][j];
  }
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      if(s[i][j] == '#') cout << '#';
      else {
          int bakudan = 0;
          if(0<i && 0<j && s[i-1][j-1] == '#') bakudan++;
          if(0<i && s[i-1][j] == '#') bakudan++;
          if(0<i && j<w-1 && s[i-1][j+1] == '#') bakudan++;
          if(0<j && s[i][j-1] == '#') bakudan++;
          if(j<w-1 && s[i][j+1] == '#') bakudan++;
          if(i<h-1 && 0<j && s[i+1][j-1] == '#') bakudan++;
          if(i<h-1 && s[i+1][j] == '#') bakudan++;
          if(i<h-1 && j<w-1 && s[i+1][j+1] == '#') bakudan++;
          cout << bakudan;
      }
    }
    cout << "\n";
  }
}

Measured memory_bytes: 3668
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int[] cnt = new int[N+1];
		for(int i=0;i<=N;i++) cnt[A[i]]++;
		int t = -1;
		for(int i=0;i<=N;i++) if(cnt[i] == 2) t = i;
		List<int> LR = new List<int>();
		for(int i=0;i<=N;i++) if(A[i] == t) LR.Add(i);
		int l = LR[0], r = LR[1];
		int outside = l + N - r;
		for(int i=1;i<=N+1;i++){
			
			long tot = nCrMod(N+1,i);
			if(l + N-r >= i-1){
				tot = (tot + mod - nCrMod(l + N-r,i-1))%mod;
			}
			Console.WriteLine(tot);
			
		}
		
	}
	int N;
	int[] A;
	public Sol(){
		N = ri();
		A = ria();
	}
	
	
	
	const long mod = (long) 1e9 + 7;
	long ModPow(long n,long k){
		
		if(k==0)return 1;
		if(n==0)return 0;
		long ret=1;
		long x=n;
		while(k>0){
			if((k&1)==1){ret*=x;ret%=mod;}
			
			x*=x;x%=mod;
			k>>=1;
		}
		return ret;
		
	}
	public long InvMod(long n){
		return ModPow(n,mod-2);
	}
	
	long[] FM = new long[100010];
	long FactorialMod(long n){
		
		if(FM[(int)n]!=0)return FM[(int)n];

		if(n<2)return FM[(int)n] = 1;
		long ret = n * FactorialMod(n-1);
		ret %= mod;
		return FM[(int)n] = ret;
	}
	
	public long nCrMod(long n,long r){
		if(n < r) return 0;
		if(n < 0) return 0;
		if(r < 0) return 0;
		if(n == 0 || r == n || r == 0) return 1;
		long a = FactorialMod(n);
		long b = InvMod(FactorialMod(r));
		long c = InvMod(FactorialMod(n-r));
		long ans = (((a*b)%mod)*c)%mod;
		return ans;
	}
	
	

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 34908
#include <stdio.h>

int main(){

 int s, m, h;
 
 scanf("%d", &s);
 h = s / 3600;
 m = (s / 60) - h * 60;
 s = s - m * 60 - h * 3600;
 printf("%d:%d:%d\n", h, m, s);
 
return 0;
}

Measured memory_bytes: 592
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<set>
// #define Kongxiangzhouye
#define sd(x) scanf("%d",&x)
#define ss(x) scanf("%s",x)
#define sc(x) scanf("%c",&x)
#define sf(x) scanf("%f",&x)
#define slf(x) scanf("%lf",&x)
#define slld(x) scanf("%lld",&x)
#define me(x,b) memset(x,b,sizeof(x))
#define pd(d) printf("%d\n",d);
#define plld(d) printf("%lld\n",d)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAX_N=100000;
const int INF = 0x3f3f3f3f;


int main()
{
	#ifdef Kongxiangzhouye
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	stack<ll> s;
	string n;
	while(cin>>n){
		if(n[0]>='0'&&n[0]<='9'){
			ll ans=0;
			for(int i=0;i<n.length();i++){
				ans=ans*10+(n[i]-'0');
			}
			s.push(ans);
		}
		else{
			ll a=s.top();
			s.pop();
			ll b=s.top();
			s.pop();
			if(n[0]=='+')
				s.push(a+b);
			else if(n[0]=='-')
				s.push(b-a);
			else if(n[0]=='*')
				s.push(a*b);
			else
				s.push(b/a);
		}	
	}
	ll ans=s.top();
	s.pop();
	cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 3236
//AOJ 0200

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<deque>
using namespace std;
#define INF 1 << 20
#define MAX_B 101
 
int a, b, i, j, k, money[MAX_B][MAX_B], time[MAX_B][MAX_B], n, m, c, d;
bool judge;
stack<int> left, right;
 
 
int main(){
  while(1){
    scanf("%d %d", &n, &m);
    if(n == 0 && m == 0) return 0;
    for(i = 1; i <= m; i++){
      for(j = 1; j <= m; j++){
    money[i][j] = INF;
    time[i][j] = INF;
      }
    }
    for(i = 1; i <= m; i++){
      money[i][i] = 0;
      time[i][i] = 0;
    }
    for(i = 0; i < n; i++){
      scanf("%d %d %d %d", &a, &b, &c, &d);
      money[a][b] = c;
      money[b][a] = c;
      time[a][b] = d;
      time[b][a] = d;
    }
    scanf("%d", &a);
    for(i = 1; i <= m; i++){
      for(j = 1; j <= m; j++){
    for(k = 1; k <= m; k++){
      if(money[j][k] > money[j][i] + money[i][k]){
        money[j][k] = money[j][i] + money[i][k];
        money[k][j] = money[j][i] + money[i][k];
      }
      if(time[j][k] > time[j][i] + time[i][k]){
        time[j][k] = time[j][i] + time[i][k];
        time[k][j] = time[j][i] + time[i][k];
      }
    }
      }
    }
    for(i = 0; i < a; i++){
      scanf("%d %d %d", &b, &c, &d);
      if(d == 1)
    printf("%d\n", time[b][c]);
      if(d == 0)
    printf("%d\n", money[b][c]);
    }
  }
  return 0;
}

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

using namespace std;

int n, k;
int freq[102];
int main()
{
    cin.tie(NULL);
    ios_base::sync_with_stdio(0);

    cin >> n >> k;


    while (k > 0)
    {
        int d;
        cin >> d;

        for (int i = 0; i < d; i++)
        {
            int f;
            cin >> f;
            freq[f]++;
        }

        k--;
    }
    int ans = 0;

    for (int i = 1; i <= n; i++)
        if (freq[i] < 1)
            ans++;

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

Measured memory_bytes: 3616
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<math.h>
#include<vector>
#include<string>
using namespace std;

int main() {
	string a;

	cin >> a;
	if (a == "ARC")
		cout << "ABC";
	else if (a == "ABC")
		cout << "ARC";
	return 0;
}

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

using namespace std;

int main()
{
    //system("chcp 65001");

    int A,B;
    cin >> A >> B;
    if(A <= 8 && B <= 8)
    {
        cout << "Yay!";
    }
    else
    {
        cout << ":(";
    }
    
    //cout << N;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int ax[500];
int main(){
    int N;
    scanf("%d",&N);
    for(int i = 1;i<=N;i++)scanf("%d",&ax[i]);
    int ans = 1;
    for(int i = 2;i<=N;i++){
        bool flag = 1;
        for(int j = 1;j<=i-1;j++)if(ax[j]>ax[i])flag = 0;
        ans+=flag;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#define maxn 100010
int cnt[2][maxn], M[2], Q[2], m[2], q[2];
int n;
int main() {
    scanf("%d", &n);
    for (int i = 1, x, p; i <= n; i++) {
        scanf("%d", &x); p = i % 2;
        cnt[p][x]++;
        if (M[p] < cnt[p][x]) M[p] = cnt[p][x], Q[p] = x;
    }
    if (Q[0] != Q[1]) {
        printf("%d\n", n - M[0] - M[1]);
        return 0;
    }
    for (int i = 1; i <= 100000; i++) {
        if (m[0] < cnt[0][i] && i != Q[0]) m[0] = cnt[0][i], q[0] = i;
        if (m[1] < cnt[1][i] && i != Q[1]) m[1] = cnt[1][i], q[1] = i;
    }
    if (M[0] - m[0] > M[1] - m[1]) printf("%d\n", n - M[0] - m[1]);
    else printf("%d\n", n - m[0] - M[1]);
    return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
#include <algorithm>
int cod[100005];
int main ()
{
	int m,n;
	while(~scanf ("%d%d",&m,&n)){
		for (int i = 1;i <= m; i++)
			scanf ("%d",&cod[i]);
		int ans = 0;
		while (m){
			ans++;
			m -= n;
			if (m <= 0)
				break;
			m++;

		}
		printf ("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<set>
#include<map>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m;
int pow_(int a,int b){
    int sum=1;
    for(int i=1;i<=b;i++)
        sum*=a;
        return sum;
}
int main()
{
    int number[15];
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>number[i];
        int sum=0;
        int flag=1;
        int next[3]={-1,0,1};
        for(int i=1;i<=n;i++)
        {
            int t=0;
            int a=number[i]-1,b=number[i],c=number[i]+1;
            if(a%2!=0)
                t++;
            if(b%2!=0)
                t++;
            if(c%2!=0)
                t++;
              flag*=t;
        }
        sum=pow_(3,n)-flag;
        cout<<sum<<endl;


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

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

    vector<int> H;

    for(int i = 0;i < N;i++) {
        int h;
        cin>>h;
        H.push_back(h);
    }

    bool flag = true;
    for(int i = N-2;i >= 0;i--) {
        if(H[i+1] >= H[i]) {
            
        } else if(H[i] - H[i+1] == 1) {
            H[i]--;
        } else {
            flag = false;
        }
    }

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

    return 0;
}




Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define L_T_S_K ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);  
const int mod = 1e9 + 7;
const int N = 3e5;

int solve(){
  int n,a,b;
    cin>>n>>a>>b;
    int m = (a+b)/(int)2;
    int ans1 = -1,ans2,ans3,ans4,ans5;
    if(m-a == b-m)
        ans1 = m-a;
    ans2 = b-1;
    ans3 = n-a;
    int posa = 1,posb = b-(a-1);
    ans4 = a-1;
    if((posb-posa)%2)
    {
       ans4++;
       posb--;
    }
    int mid = (posb+posa)/2;
        ans4+=mid-1;
    posa = a+(n-b);
    posb = n;
    ans5 = n-b;
    if((posb-posa)%2)
    {
       ans5++;
       posa++;
    }
    mid = (posb+posa)/2;
        ans5+=n-mid;
    if(ans1 == -1)
        return min(ans2,min(ans3,min(ans4,ans5)));
    else
    {
        return min(ans1,min(ans2,min(ans3,min(ans4,ans5))));
    }
    
}

int32_t main(){
 L_T_S_K;
  int t; t = 1;
  while(t--)
  cout << solve() << "\n";
  return 0;
}



Measured memory_bytes: 256