akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
# Your code here!


H,W,M = input().rstrip().split(' ')

H = int(H)
W = int(W)
M = int(M)

hcount = [0 for _ in range(H)]
wcount = [0 for _ in range(W)]

#L = [[0 for i in range(W)]for j in range(H)]
L = {}
for i in range(M):
    ij = input().rstrip().split(' ')
    i = int(ij[0])-1
    j = int(ij[1])-1
    #L[i][j] = 1
    L[(i,j)] = 1
    hcount[i] += 1
    wcount[j] += 1
 
hmax = max(hcount)
wmax = max(wcount)
count = hmax+wmax-1

hin = [i for i, x in enumerate(hcount) if x == hmax]
win = [i for i, x in enumerate(wcount) if x == wmax]

for i in hin:
    for j in win:
      if (i, j) not in L:
            count = hmax+wmax
            break
print(count)


Measured memory_bytes: 198280
from collections import deque

L = deque()

n = int(input())

for i in range(n):
    input_com = input()

    if input_com == "deleteFirst":
        L.popleft()
    elif input_com == "deleteLast":
        L.pop()
    else:
        com, num = input_com.split()

        if com == "insert":
            L.appendleft(num)
        elif com == "delete":
            try:
                L.remove(num)
            except:
                pass

print(*L)


Measured memory_bytes: 69732
#include<iostream>

int n,q;
int m,num;
int A[2000];
bool flg=false;

void cal(int x){
	if(num!=m){
		for(int i=x;i<n;i++){
			if(num+A[i]<=m){
				num+=A[i];
				if(num==m) flg=true;
				if((i+1)<n) cal(i+1);
				num-=A[i];
			}
		}
	}
}

int main(){
	std::cin>>n;
	for(int i=0;i<n;i++){
		std::cin>>A[i];
	}
	std::cin>>q;
	for(int i=0;i<q;i++){
		std::cin>>m;
		num=0;
		flg=false;
		cal(0);
		if(flg) std::cout<<"yes"<<'\n';
		if(!flg) std::cout<<"no"<<'\n';
	}
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
//struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


void solve(long long A, long long B){
	ll res = lcm(A, B);
	cout << res << "\n";
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

bool check(vector<ll> &v, ll p, ll K){
    ll c = 0;
    for(auto &e : v){
        c += e / p;
        if(e % p == 0) c--;
    }
    return c <= K;
}

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> A(N);
    for(int i=0;i<N;i++) cin >> A[i];
    ll sp = 0;
    ll ep = 1e9+1;
    while(sp+1<ep){
        ll p = (sp+ep)/2;
        if(check(A,p,K)){
            ep = p;
        }else{
            sp = p;
        }
    }
    cout << ep << endl;
    return 0;
}

Measured memory_bytes: 4684
#include <iostream>
using namespace std;
using ll = long long;

int main(){
	ll array[100010];
	array[0]=1;
	for(int i=1;i<100010;i++){
		array[i] = (i*array[i-1])%1000000007;
	}
	
	int N;
	cin >> N;
	cout << array[N] << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right){
  int i, j, k;

  int n1 = mid - left;
  int n2 = right - mid;
  for ( i = 0; i < n1; i++ ) L[i] = A[left + i];
  for ( i = 0; i < n2; i++ ) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  i = j = 0;
  for ( k = left; k < right; k++ ){
    cnt++;
    if ( L[i] <= R[j] ){
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[], int n, int left, int right ){
  int mid;
  if ( left+1 < right ){
    mid = (left + right)/2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

main(){
  int A[MAX], n, i;
  scanf("%d", &n);
  cnt = 0;
  for ( i = 0; i < n; i++ ) {
    scanf("%d", &A[i]);
    if (A[i] >= SENTINEL ){
      return 1;
    }
  }
  mergeSort(A, n, 0, n);

  for ( i = 0; i < n; i++ ) {
    if ( i ) printf(" ");
    printf("%d", A[i]);
    }
  printf("\n");

  printf("%d\n", cnt);

  return 0;
}



Measured memory_bytes: 5588
#include <iostream>

int binarySearch(int s[],int n, int key){

    int head = 0;
    int tail = n-1;

    int center;

    while(head != tail){
        center = (head + tail) / 2;
        if(s[center] == key){
            return center;
        }else if(s[center] < key){
            head = center + 1;
        }else{
            tail = center;
        }

    }

    if(s[head] == key){
        return head;
    }

    return -1;
}

int main(){

    int n, q;
    int cnt = 0;

    std::cin >> n;

    int s[n];

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

    std::cin >> q;

    int key;

    for(int i = 0; i < q; i++){
        std::cin >> key;

        if(binarySearch(s, n, key) >= 0){
            cnt++;
        }
    }

    std::cout << cnt << "\n";

}


Measured memory_bytes: 3468
s = input().strip()

if s[:7]=="keyence" or s[0]+s[-6:]=="keyence" or s[:2]+s[-5:]=="keyence" or s[:3]+s[-4:]=="keyence" or s[:4]+s[-3:]=="keyence" or s[:5]+s[-2:]=="keyence" or s[:6]+s[-1]=="keyence" or s[-7:]=="keyence":
  print("YES")
else:
  print("NO")

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

using namespace std;

#define forn(i, x, n) for (int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for (int i = int(n); i >= int(x); --i)
#define F first
#define S second
#define pb push_back

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

const int N = 2e6 + 10;
const int B = 1e9 + 9;
const int P = 31;

int f[N];

void u(int x, int d) {
    for (; x < N; x |= x + 1) f[x] += d;
}

int g(int x) {
    int ans = 0;
    for (; x >= 0; x = (x & (x + 1)) - 1) ans += f[x];
    return ans;
}

set <int> st;
    
void add(int x) {
    if (!st.size() || !st.count(x)) {
        st.insert(x);
        if (x < N) u(x, 1);
        return;
    }
    assert(x != 0);
    st.erase(x);
    u(x, -1);
    add(x - 1);
}

int main() {
    #ifdef black
    freopen("in", "r", stdin);
    //freopen("out", "w", stdout);
    #endif
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin >> n;
    forn(i, 1, n) {
        if (st.count(0)) {
            cout << "No\n";
            continue;
        }
        int x;
        cin >> x;
        if (!st.size() || x > N) {
            add(x);
            cout << "Yes\n";
            continue;
        }    
        bool shit = 0;
        if (g(x) == x && st.size() > x) shit = 1;
        if (!shit) add(x);
        cout << (shit ? "No" : "Yes") << "\n";
    }
    
    
    return 0;
}


Measured memory_bytes: 23632
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  map<int,int> memo;
  rep(i,N){
    int a;
    cin >> a;
    memo[a]++;
  }

  vector<int> v;
  FOR(it,memo){
    if(it->second >= 4){
      v.push_back(it->first);
      v.push_back(it->first);
    }
    else if(it->second >= 2){
      v.push_back(it->first);
    }
  }
  sort(ALLOF(v));
  reverse(ALLOF(v));

  if(v.size() <= 1){
    cout << 0 << endl;
  }else{
    cout << v[0] * (ll)v[1] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 4992
k,a,b=map(int, input().split()) 

if b-a<=2 or k<=a:
    print(1+k)

else:
    x=k-(a-1)
    if x%2==0:
        print(x//2*(b-a)+a)
    else:
        print(x//2*(b-a)+a+1)
        
        
    
        

                
            
        
        
        

Measured memory_bytes: 2940
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main()
{
        int a,b;
        cin>>a>>b;
        int ans =-1;
       for(double i=0;i<=20000;i++)
       {
           double c=  floor(i*0.08);
           double t = floor(i*0.1);
           if(c==a && b==t)
           {
               ans = int(i);
               break;
           }
       }
       cout<<ans<<endl;
        return 0;
}


Measured memory_bytes: 256
from collections import deque


m1 = input().split()
n = int(m1[0])
Q = int(m1[1])
q = deque()
number = deque()
time = 0
sum = 0
for i in range(n):
    m2 = input().split()
    a = int(m2[1])
    number.append(str(m2[0]))
    q.append(a)
    sum += a
j = 0
while time < sum:
    if q[j] < Q:
        time += q[j]
        print(number[j],time)
        if time == sum:
            break
        q.popleft()
        number.popleft()
    elif q[j] == Q:
        time += q[j]
        print(number[j],time)
        if time == sum:
            break
        q.popleft()
        number.popleft()
    else:
        number.append(number.popleft())
        q.append(q.popleft() - Q)
        time += Q
        if time == sum:
            break


Measured memory_bytes: 9884
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(i=a; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define foreach(it,x) for(typeof(x.begin()) it=x.begin(); it!=x.end(); it++)

typedef long long ll;
/*
  (px + q)(rx + s)
  p > 0
  r > 0
  (p > r) or (p = r and q >= s)

  prx^2 + (ps + qr)x + qs
  a = pr
  b = ps + qr
  c = qs
 */
int main(){
    ll a,b,c,p,q,r,s,i,j,k;

    while( scanf("%lld %lld %lld",&a,&b,&c), a|b|c ){
        bool ok = false;

        for(i=1; i*i<=a; i++){
            if( a%i != 0 ) continue;
            p = a/i, r = i;

            for(int sign=-1; sign <=1; sign+=2){
                for(k=0; k*k<=abs(c); k++){
                    j = k * sign;
                    if( (j == 0 && c != 0) || (j != 0 && abs(c)%abs(j) != 0) ) continue;
                    if( j != 0 ){
                        q = c/j, s = j;
                        if( p*s + q*r != b ) q = j, s = c/j;
                        if( p*s + q*r != b ) continue;
                    }
                    else{
                        q = b/r, s = 0;
                        if( p*s + q*r != b ) q = 0, s = b/p;
                        if( p*s + q*r != b ) continue;
                    }

                    //printf(":: %lld %lld %lld %lld\n",p,q,r,s);
                    if( !( p*r == a && q*s == c && (p*s + q*r == b || p*r + q*s == b) ) ) continue;

                    ok = true;
                    if( p == r ){
                        printf("%lld %lld %lld %lld\n", p,max(q,s),r,min(q,s));
                    }
                    else{
                        if( p*s + q*r == b ){
                            printf("%lld %lld %lld %lld\n", p,q,r,s);
                        }
                        else{
                            printf("%lld %lld %lld %lld\n", p,s,r,q);
                        }
                    }
                    break;
                }
                if( ok ) break;
            }
            if( ok ) break;
        }
        if( !ok ) puts("Impossible");
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define double long double
#define int long long
#define low lower_bound
#define upp upper_bound
#define mod 1000000007 //10^9+7
#define inf 10000000000000000 //10^16
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
#define cend cout<<endl;
using namespace std;
int n,w,a[100],b[100],dp[314][314514];
signed main() {
	cin>>n>>w;
	rep(i,n)cin>>a[i]>>b[i];
	dp[0][a[0]]=b[0];
	for(int i=1;i<n;i++){
		for(int j=0;j<=w;j++){
			dp[i][j]=max(dp[i][j],dp[i-1][j]);
			dp[i][j+a[i]]=max(dp[i][j+a[i]],dp[i-1][j]+b[i]);
		}
	}
	int ta=0;
	for(int i=0;i<=w;i++)ta=max(ta,dp[n-1][i]);
	cout<<ta<<endl;
}



Measured memory_bytes: 243968
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll    long long
#define PR    pair<int, int>

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int vis[N], cost[N], parent[N];
vector<int> g[N];

void bfs(int n) {
    queue<int> q;
    q.push(1);
    vis[1] = 1;
    cost[1] = 1e9;
    for (int i = 2; i <= n; i++) {
        cost[i] = 1e9;
    }
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (auto v : g[u]) {
            if (vis[v]) {
                if (cost[u] + 1 < cost[v]) {
                    q.push(v);
                    parent[v] = u;
                    cost[v] = cost[u] + 1;
                }
            } else {
                q.push(v);
                vis[v] = 1;
                parent[v] = u;
                cost[v] = cost[u] + 1;
            }
        }
    }
}

int main() {
//    ios::sync_with_stdio(false);
//    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    bfs(n);
    cout << "Yes\n";
    for (int i = 2; i <= n; i++) {
        cout << parent[i] << '\n';
    }
    return 0;
}


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

class Cmondai
{
    static void Main()
    {
        var line = new List<decimal>();
        decimal N = 0;
        for (int i = 0; i < 6; ++i)
        {
            var a = decimal.Parse(Console.ReadLine());
            if (i == 0) N = a;
            else line.Add(a);
        }
        var min = line.Min();
        decimal ans = 0;
        if (min <= N) ans = Math.Ceiling(N /min) + 4;
        else ans = 5;
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13268
n = gets.chop.to_i
a = gets.chop.split.map(&:to_i)

#aを後ろから見ていく ソートしないほうが良さそう
ans = []

m_r = 0
result = []


n.times do |i|
  cur_idx = n-i-1

  if cur_idx+1 <= n/2

    # 一時的なaの和を格納する
    tmp_sum_a = 0
    # 2倍、3倍と見ていくためにidxを用意する
    num = 2

    while 1
      if (cur_idx + 1) * num <= n
        tmp_sum_a += ans[ (cur_idx + 1) * num - 1]
      else
        break
      end

      num += 1
    end

    ans[cur_idx] = tmp_sum_a % 2 == a[cur_idx] ? 0 : 1
  else
    ans[cur_idx] = a[cur_idx] == 1 ? 1 : 0
  end

  if ans[cur_idx] == 1
    m_r += 1
    result << cur_idx + 1
  end

end

p m_r
puts result

Measured memory_bytes: 21644
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
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);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    string N;
    cin >> N;
    for (auto x : N) {
        if (x == '9') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

int main(){
    int n, k;
    cin >> n >> k;

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

    if(s[k-1]=='A'){
        s[k-1]='a';
    }
    else if(s[k-1]=='B'){
        s[k-1]='b';
    }
    else if(s[k-1]=='C'){
        s[k-1]='c';
    }

    for(int i=0; i<n; i++){
        cout << s[i];
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int inf = 2e17;
const int mod = 1e9 + 7;

signed main() {
    int M, K;
    cin >> M >> K;
    if (M == 0 && K == 0) {
        cout << "0 0" << endl;
    } else if (M == 1 && K == 0) {
        cout << "0 0 1 1" << endl;
    } else if (M >= 2 && K < (1<<M)) {
        for (int i = 0; i < (1<<M); i++) {
            if (i == K) continue;
            cout << i << " ";
        }
        cout << K << " ";
        for (int i = (1<<M) - 1; i>= 0; i--) {
            if (i == K) continue;
            cout << i << " ";
        }
        cout << K << endl;
    } else {
        cout << -1 << endl;
    }
}


Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	s := getString()

	s = strings.Replace(s, ",", " ", -1)

	fmt.Println(s)
}

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

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 640
(defmacro input []
  '(->> (clojure.string/split (read-line) #"\s")
     (map #(Integer/parseInt %))))

(defn PalindromicNumbers [[A B]]
  (->> (range A (inc B))
    (filter
      #(let [n (str %)] (= n (clojure.string/reverse n))))
    count))

(-> (input)
  PalindromicNumbers
  println)

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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MAX = 999999;
const static int MOD = 1000000007;
const static int IINF = INT_MAX;
const static llong LINF = LLONG_MAX;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

template<typename T> T my_gcd(T a, T b) {
    return (a ? my_gcd(b % a, a) : b);
}
template<typename T> T my_lcm(T a, T b) {
    return a * b / my_gcd(a, b);    
}

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, r;
    cin >> n >> r;
    if (n >= 10) cout << r << endl;
    else cout << r + 100 * (10 - n) << endl;

    return 0;
}

Measured memory_bytes: 256
def count_divisor(n):
    count = 0
    for i in range(1, n+1):
        if n % i == 0:
            count += 1
    return count


def main():
    n = int(input())
    ans = 0
    for i in range(1, n+1, 2):
        if count_divisor(i) == 8:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38512
n,m,*a=map(int,open(0).read().split())
dp=[-1]*(n+1)+[0]
for i in a:
    dp[i]=0
dp[0]=1
for i in range(1,n+1):
    if dp[i]==-1:
        dp[i]=dp[i-1]+dp[i-2]
print(dp[-2]%1000000007)

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

int add(int x, int y){
    return x+y;
}

int main (){
    int a, b;
    cin >> a >> b;
    if (add(a,b)%3==0 || a%3 ==0 || b%3==0){
        cout << "Possible" << endl;
    }else {
        cout << "Impossible" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int i,x,y,z;
	
	scanf("%d",&x);
	
	int v[x];
	
	y = (x-1)/2;
	z = x-1;
	for(i = 0;i < x;i++){
		scanf("%d",&v[i]);
	}
	
	for(i = z;i > -1;i--){
		printf("%d", v[i]);
		if ( i ) printf(" ");
	}
	
	printf("\n");

return 0;	
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    ll ans = 0;
    ll right = 0;
    ll sum = 0;
    for (ll left = 0; left < n; left++)
    {
        while (right < n && (sum + a[right]) == (sum ^ a[right]))
        {
            sum += a[right];
            right++;
        }

        ans += right - left;

        if (right == left)
        {
            right++;
        }
        else
        {
            sum -= a[left];
        }
    }

    cout << ans << endl;
}

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

using namespace std;

int main(){
	long long n, a, b, ans = 0;
	cin >> n >> a >> b;
	vector<long long> h(n);
	for(int i = 0; i < n; i++){
		cin >> h[i];
	}
	long long l = 0, r = 1000000000, m;
	m = (l + r) / 2;
	while(l < r){
		long long t = 0;
		for(int i = 0; i < n; i++){
			t += max((h[i] - b * m + a - b - 1) / (a - b), 0LL);
		}
		if(t > m){
			l = m + 1;
		}else{
			r = m;
		}
		m = (l + r) / 2;
	}
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 1024
import numpy as np

def fill_zeros_with_last(A):
    for i in range(len(A)):
        arr = A[i]
        prev = np.arange(arr.size)
        prev[arr == 0] = 0
        np.maximum.accumulate(prev, out=prev)
        A[i] = arr[prev]
    return A

H, W, K = map(int, input().split())
cake = np.zeros((H, W), dtype=int)
cnt = 1
for i in range(H):
    for j, S in enumerate(input()):
        if S == "#":
            cake[i][j] = cnt
            cnt += 1

for i in [1,2,3,2]:
    cake = np.rot90(cake, k=i)
    cake = fill_zeros_with_last(cake)

for c in cake:
    print(*c)

Measured memory_bytes: 14272
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#define FAST ios::sync_with_stdio(false)
typedef long long ll;
const int maxn = (int)1e5 + 5;
const int mod = (int)1e9 + 9;
const int inf = 0x3f3f3f3f;
using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

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

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    ll n;
    string a;
    cin >> a;
    n = a.size();
    ll s[n];
    rep(i, n) s[i] = a[i] - '0';
    ll ans = INF;
    for(ll i = 2; i < n; i++){
        ll k = s[i-2]*100 + s[i-1]*10+s[i];
        ans = min(ans, abs(k - 753));
    }
    cout << ans;
}
main(){
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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 end

template<unsigned mod>struct mint {
   static int get_mod(){return mod;}
   int val;
   int inv() const{
      int tmp,a=val,b=mod,x=1,y=0;
      while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
      if(x<0)x+=mod; return x;
   }
   mint():val(0){}
   mint(ll x):val(x>=0?x%mod:mod+(x%mod)){}
   mint pow(ll t){mint res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;}return res;}
   mint& operator+=(const mint& x){if((val+=x.val)>=mod)val-=mod;return *this;}
   mint& operator-=(const mint& x){if((val+=mod-x.val)>=mod)val-=mod; return *this;}
   mint& operator*=(const mint& x){val=(ll)val*x.val%mod; return *this;}
   mint& operator/=(const mint& x){val=(ll)val*x.inv()%mod; return *this;}
   mint operator+(const mint& x)const{return mint(*this)+=x;}
   mint operator-(const mint& x)const{return mint(*this)-=x;}
   mint operator*(const mint& x)const{return mint(*this)*=x;}
   mint operator/(const mint& x)const{return mint(*this)/=x;}
   bool operator==(const mint& x)const{return val==x.val;}
   bool operator!=(const mint& x)const{return val!=x.val;}
};
using Mint=mint<1000000007>;
struct factorial {
   vector<Mint> Fact, Finv;
public:
   factorial(int maxx){
      Fact.resize(maxx+1),Finv.resize(maxx+1); Fact[0]=Mint(1); rep(i,0,maxx)Fact[i+1]=Fact[i]*(i+1);
      Finv[maxx]=Mint(1)/Fact[maxx]; rrep(i,maxx,0)Finv[i-1]=Finv[i]*i;
   }
   Mint fact(int n,bool inv=0){if(inv)return Finv[n];else return Fact[n];}
   Mint nPr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[n-r];}
   Mint nCr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[r]*Finv[n-r];}
};

Mint dp[22][1010];
factorial fact(201000);

int main(){
   int n,k; scanf("%d%d",&n,&k);
   vector<int> a(k); rep(i,0,k)scanf("%d",&a[i]);
   dp[0][0]=fact.fact(n);
   rep(i,0,k)rep(j,0,n+1)if(dp[i][j].val){
      rep(add,0,n-j+1){
         dp[i+1][j+add]+=dp[i][j]*fact.nCr(n-add,a[i]-add)*fact.fact(add,1);
      }
   }
   printf("%d\n",dp[k][n].val);
   return 0;
}

Measured memory_bytes: 1920
//
// Created by matteo on 29/03/19.
//
#include <bits/stdc++.h>

using namespace std;
vector<long> h;
vector<long> DP;
int K = 0;

long d(long i, long j) {
   if (i >= h.size() || j >= h.size() || i < 0 || j < 0)
      throw invalid_argument("Index are longer thant the vectot h");
   return abs(h[i] - h[j]);
}

long frog(long indx) {
   if (DP[indx] == -1) {
      long minValue = numeric_limits<long>::max();
      for (int i = 1; i <= K; i++) {
         minValue = min(minValue, d(indx, indx - i) + frog(indx - i));
      }
      DP[indx] = minValue;
   }
   return DP[indx];
}

int main() {
   //input parsing
   unsigned long N = 0;
   scanf("%ld", &N);
   scanf("%d", &K);
   DP.resize(N, -1);
   h.reserve(N);
   for (int i = 0; i < N; ++i) {
      long value;
      scanf("%ld", &value);
      h.emplace_back(value);
   }
   //initialization
   DP[0] = 0;
   for (int j = 1; j <= K && j < N; ++j) {
      DP[j] = d(j, 0);
   }
   //calculations
   long minPath = frog(N - 1);
   printf("%ld", minPath);
}


Measured memory_bytes: 8064
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cmath>
#include<queue>
#include<cstring>
#include<climits>
#include<sstream>
#include<deque>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>

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

using namespace std;

typedef long long ll;

int main() {
  ll x;
  cin >> x;
  ll sum = 0;
  int cnt = 0;
  for(ll i=1;sum<x;i++) {
    sum += i;
    ++cnt;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
k = int(input())
n = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(n[k-1])


Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
using Edge = pair<int, ll>;
using Graph = vector<vector<Edge> >;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };

void printvll(vll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) cout << v[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}
void printvvll(vvll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) {
		rep(j, v[i].size()) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void prints(string s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) cout << s[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}

void printvs(vs s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) {
		rep(j, s[i].size()) {
			cout << s[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Yes(bool x) {
	if (x) cout << "Yes\n";
	else cout << "No\n";
}

void YES(bool x) {
	if (x) cout << "YES\n";
	else cout << "NO\n";
}

void yes(bool x) {
	if (x) cout << "yes\n";
	else cout << "no\n";
}

void Yay(bool x) {
	if (x) cout << "Yay!\n";
	else cout << ":(\n";
}
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}



ll  d, n, r, l, k, ans = 0, ret = M;
bool flag = false, flag2 = false, flag3 = false;
string s, t;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b, c;
	cin >> a >> b >> c;
	if (a > b) {
		Yes(a > c && c > b);
	}
	else {
		Yes(b > c && c > a);
	}
}


Measured memory_bytes: 256
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    c = []
    for _ in range(3):
        c.append(tuple(map(int, input().split())))
    for i1 in range(101):
        for i2 in range(101):
            if i1 - c[0][0] == i2 - c[0][1]:
                i3 = c[0][2] - (c[0][0] - i1)
                if i1 - c[1][0] == i2 - c[1][1] == i3 - c[1][2]:
                    if i1 - c[2][0] ==i2 -c[2][1] == i3 - c[2][2]:
                        print('Yes')
                        sys.exit()
    print('No')
if __name__ == '__main__':
    main()

Measured memory_bytes: 9192
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
ll v[200010];
// bool edge[20010][20010];
set<int> st[200010];
bool visited[200010];
int N;

void dfs(int n, int value)
{
    // if (n==0)
    // {
    //     for(auto itr = st[0].begin(); itr != st[0].end(); ++itr)
    //     {
    //         cout << *itr << " ";
    //     }
    //     cout << endl;
    // }


    if (visited[n]) return;
    visited[n] = true;
    v[n] += value;
    
    for(auto itr = st[n].begin(); itr!=st[n].end(); ++ itr)
    {
        dfs(*itr, v[n]);
    }
    return;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int q;
    cin >> N >> q;
    // rep(i,N) rep(j,N) edge[i][j] = 0;
    rep(i,N)
    {
        visited[i] = false;
    }
    // visited[0] = true;
    rep(i,N-1)
    {
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        // edge[a][b] = 1;
        // edge[b][a] = 1;
        st[a].insert(b);
        st[b].insert(a);
    }
    rep(i,N) v[i] = 0;
    rep(i,q)
    {
        int p,x;
        cin >> p >> x;
        p--;
        v[p] += x;
    }
    dfs(0, 0);
    rep(i,N)
    {
        cout << v[i];
        if (i!=N-1) cout << " ";
    }
    cout << endl;
}


Measured memory_bytes: 38528
MOD = (int) (1e9+7)

def power(a,n):
    if a == 0: return 0
    if n == 0: return 1

    res = 1
    while n > 0:
        if n % 2 == 1: res = res * a % MOD
        a = a * a % MOD
        n //= 2

    return res

def inverse(n):
    return power(n, MOD-2)

N, K = map(int,input().split())
A = list(map(int,input().split()))

B = []
pos, neg = 0, 0
for a in A:
    if a > 0:
        B.append([a,1])
        pos += 1
    if a < 0:
        B.append([-a,-1])
        neg += 1
    if a == 0:
        B.append([0,0])
B.sort(reverse=True)

ans, sign  = 1, 1
if N == neg and K % 2 == 1:
    for i in range(K):
        ans *= B[N-1-i][0] 
        ans %= MOD
    print(-ans % MOD)
    exit()

for i in range(K):
    ans *= B[i][0]
    ans %= MOD
    sign *= B[i][1]

if N == K:
    if sign >= 0: print(ans)
    else: print(-ans % MOD)
    exit()

if sign < 0:
    out_neg, out_pos = 0, 0
    in_pos, in_neg = 0, 0

    for i in range(K):
        if B[K-1-i][1] < 0:
            out_neg = B[K-1-i][0]
            break
    
    for i in range(K):
        if B[K-1-i][1] > 0:
            out_pos = B[K-1-i][0]
            break
    
    for i in range(N-K):
        if B[K+i][1] > 0:
            in_pos = B[K+i][0]
            break
    
    for i in range(N-K):
        if B[K+i][1] < 0:
            in_neg = B[K+i][0]
            break
    

    if in_neg == 0 or out_pos == 0:
        ans = (ans * in_pos % MOD) * inverse(out_neg) % MOD
    elif in_pos == 0 or out_neg == 0:
        ans = (ans * in_neg % MOD) * inverse(out_pos) % MOD
    else:
        if out_pos * in_pos < out_neg * in_neg:
            ans = (ans * in_neg % MOD) * inverse(out_pos) % MOD
        else:
            ans = (ans * in_pos % MOD) * inverse(out_neg) % MOD
            
print(ans)


Measured memory_bytes: 41204
#include<bits/stdc++.h>
using namespace std;
typedef complex < double > P;
typedef vector< P > G;
vector< G > g;
const double EPS = 1e-8;
const double INF = 1e12;
double cross(const P& a,const P& b){ //??????
  return imag(conj(a) * b);
}
double dot(const P& a,const P& b){ // ??????
  return real(conj(a) * b);
}
struct L: vector < P >{
  L(const P& a,const P& b){
    push_back(a);
    push_back(b);
  }
};
int ccw(P a,P b,P c){
  b -= a; c -= a;
  if(cross(b,c) > 0) return 1;
  if(cross(b,c) < 0) return -1;
  if(dot(b,c) < 0) return 2; // c--a--b
  if(norm(b) < norm(c)) return -2; // a--b--c
  return 0; // a--c--b
}
bool intersectSS(const L& s,const L& t){ //???????????? ??????:??????
  return ccw(s[0],s[1],t[0]) * ccw(s[0],s[1],t[1]) <= 0 &&
    ccw(t[0],t[1],s[0]) * ccw(t[0],t[1],s[1]) <= 0;
}
#define curr(P,i) P[i]
#define next(P,i) P[(i+1)%P.size()]
bool conteins(const G& Q, const P& p){
  bool in = false;
  for(int i = 0 ; i < Q.size() ; i++ ){
    P a = curr(Q,i) - p, b = next(Q,i) - p;
    if(imag(a) > imag(b)) swap(a,b);
    if(imag(a) <= 0 && 0 < imag(b) && cross(a,b) < 0) in = !in;
    if(cross(a,b) == 0 && dot(a,b) <= 0) return true;
  }
  return in;
}
bool intersect( int x, int y){ //???????????? g[x] == g[y]
  // g[x] or g[y] ?????????
  for(int i = 0 ; i < 4 ; i++ ){
    if(conteins(g[y],g[x][i]) || conteins(g[x],g[y][i])) return true;
  }
  // g[x] ??¨ g[y]???????????????
  for(int i = 0 ; i < 4 ; i++ ){
    for(int j = 0 ; j < 4 ; j++ ){
      if(intersectSS(L(curr(g[x],i),next(g[x],i)),L(curr(g[y],j),next(g[y],j)))) return true;
    }
  }
  return false;
}
//UnionFind
vector< int > rank, p;
void link(int x,int y){
  if(rank[x] > rank[y]) p[y] = x;
  else{
    p[x] = y;
    if(rank[x] == rank[y]) rank[y]++;
  }
}
void init(int size){
  rank.resize(size);
  p.resize(size);
  for(int i = 0 ; i < size ; i++ ){
    p[i] = i, rank[i] = 0;
  }
}
int findSet(int x){
  if(x != p[x]) p[x] = findSet(p[x]);
  return p[x];
}
void Union(int x,int y){
  link(findSet(x),findSet(y));
}
bool isSame(int x,int y){
  return findSet(x) == findSet(y);
}
 

int main()
{
  int N;

  while(cin >> N, N) {
    while(N--) {
      int M;
      cin >> M;
      init(M);
      g.resize(M);
      for(int i = 0; i < M; i++) {
        g[i].resize(4);
        for(int j = 0; j < 4; j++) {
          cin >> g[i][j].real() >> g[i][j].imag();
        }
      }
      for(int i = 0; i < M; i++) {
        for(int j = i + 1; j < M; j++) {
          if(intersect(i, j) && !isSame(i, j)) Union(i, j);
        }
      }
  
      int ret = 0;
      for(int i = 0; i < M; i++) {
        ret += i == findSet(i);
      }
      cout << ret << endl;
    }
  }
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;


int main() {
  string s ;
  cin >> s ;
  string ans = "AC";
  int count = 0;
  
  if(s.at(0) != 'A')
    ans = "WA";
   
  
  for(int i=2;i<s.size()-1 ;i++){
    if(s.at(i) == 'C')
      count ++;
  }
  
  rep(i,s.size()){
    if((int)s.at(i) < 97){
      if(!(s.at(i) == 'A' || s.at(i) =='C')) 
       ans = "WA";
    }
  }
      

  
  if(!(count == 1)) 
    ans = "WA";
    
  cout << ans ;
  
  
  
  
  
  
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int N;

    while (cin >> N, N) {
        int S = 0;

        for (int i = 1; i * i <= N; ++i) {
            if (N % i == 0 && i != N) {
                S += i;
                if (i != N / i && N / i != N)
                    S += N / i;
            }
        }

        if (N == S)
            cout << "perfect number\n";
        else if (N > S)
            cout << "deficient number\n";
        else
            cout << "abundant number\n";
    }

    return 0;
}

Measured memory_bytes: 1116
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a+b<=16)
	{
		if(a>8 || b>8)
		cout<<":(";
		else 
		cout<<"Yay!";
	}
	else 
	cout<<":(";
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            int iM = int.Parse(sS[1]);
            List<ClsPos> lstC = new List<ClsPos>();
            for (int i = 0; i < iM; i++)
            {
                sS = System.Console.ReadLine().Trim().Split(' ');
                ClsPos oneUsr = new ClsPos();
                oneUsr.iX = i;                                      // No
                oneUsr.iP = int.Parse(sS[0]);                       // 県番号
                oneUsr.iY = int.Parse(sS[1]);                       // 年
                oneUsr.iJ = -1;                                     // 番
                oneUsr.sS = "";                                     // 識別番号
                lstC.Add(oneUsr);
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            lstC.Sort(delegate (ClsPos mca1, ClsPos mca2) { return mca1.iP - mca2.iP == 0 ? mca1.iY - mca2.iY : mca1.iP - mca2.iP; });  // 県番号、年で昇順
            int iP = 0;                                             // 県番号
            int iJ = 0;                                             // 県内番号
            for (int i = 0; i < lstC.Count; i++)
            {
                if (iP != lstC[i].iP) { iJ = 1; }
                lstC[i].iJ = iJ;
                lstC[i].sS = lstC[i].iP.ToString("000000") + iJ.ToString("000000");
                iJ += 1;
                iP = lstC[i].iP;
            }
            lstC.Sort(delegate (ClsPos mca1, ClsPos mca2) { return mca1.iX - mca2.iX; });  // Noで昇順

            // 出力
            for (int i = 0; i < lstC.Count; i++)
            {
                System.Console.WriteLine("{0}", lstC[i].sS.ToString().Trim());
            }

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

        // 情報
        private class ClsPos
        {
            public int iX { get; set; } = 0;                    // No
            public int iP { get; set; } = 0;                    // 県番号
            public int iY { get; set; } = 0;                    // 年
            public int iJ { get; set; } = -1;                   // 番
            public string sS { get; set; } = "";                // 識別番号
        }

}


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

#define int long long
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n, d;
    cin >> n >> d;
    int ans = 0;
    for(int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        if(x * x + y * y <= d * d) {
            ans ++;
        }
    }
    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 3656
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
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; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{

    ll N,K;
    vector<ll> H;
    cin >> N >> K;
    for (int i=0; i<N; ++i)
    {
        ll tmp;
        cin >> tmp;
        H.push_back(tmp);
    }

    sort(H.begin(),H.end(),greater<ll>());

    ll ans = 0;
    for(int i=0; i<N; ++i)
    {
        if(i<K) continue;
        ans += H[i];
    }

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

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,k;cin >> n;
  int a[n] = {};
  for(i=0;i<n-1;i++){
    cin >> k;a[k-1]++;
  }
  for(auto x:a) cout << x << endl;
}

Measured memory_bytes: 4400
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 
 using namespace std;
 
 const int MAX_N=10+2;
 int count1;
 int perm[MAX_N];
 bool used[MAX_N];
 int n,s,sum;
 
 void permutation1(int pos,int n,int sum)
 {
   if(sum>s) return;
   int b=9;
   int sum2=0;
   for(int i=n;i>pos;i--)
   {
     while(used[b]) b--; 
     sum2+=(i*b);
     //cout<<sum2<<endl;
             
   }
   if((s-sum)>sum2) return;
   //if(s>sum2) return;
   
   if(pos==n)
   {
     if(sum==s)
     { 
       count1++;
       //for(int i=0;i<n;i++) cout<<perm[i]<<" ";
       //cout<<endl;
     }
     return;          
   }     
   for(int i=0;i<=9;i++)
   {
     if(!used[i])
     {
       perm[pos]=i;
       used[i]=true;
       permutation1(pos+1,n,sum+i*(pos+1));
       used[i]=false;            
     }        
   }
   return;
 }
 
 int main()
 {
   while(cin>>n>>s)
   {
     //for(int i=0;i<=n;i++) perm[i]=i;
     //used[MAX_N]={false};
     int b=9;
     int sum_max=0;
     int sum_min=0;
     for(int i=n;i>=1;i--)
     {
       sum_max+=(b*i);
       sum_min+=(9-b)*i;
       b--;        
     }
     if(s>sum_max||s<sum_min) cout<<"0"<<endl;
     else
     {
       count1=0;
       sum=0;
       permutation1(0,n,0);
       cout<<count1<<endl;
     }
   }
   //while(1); 
   return 0;
 }

 
  

Measured memory_bytes: 3056
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  string a, b, c;
  cin >> a >> b >> c;
  if(a.back() == b[0] && b.back() == c[0]) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int i,n;
    int cnt = 0;
    int p[21];
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&p[i]);
    for(i=1;i<n-1;i++){
        if(((p[i-1]<p[i]) && (p[i]<p[i+1])) || ((p[i-1]>p[i]) && (p[i]>p[i+1]))) cnt++; 
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 128
A,B,C,X,Y=map(int,input().split())
if X<Y:
    P=X
    R=Y-X
    if B<2*C:
        Q=B
    else:
        Q=2*C
else:
    P=Y
    R=X-Y
    if A<2*C:
        Q=A
    else:
        Q=2*C
if (A+B)<2*C:
    O=A+B
else:
    O=2*C
print(O*P+Q*R)


Measured memory_bytes: 3060
import sys
N = float(input())
a = list(map(int, input().split()))
sum = 0.0
avg = 0.0

for i in a:
    sum += i
# print(N)
# print(sum)

avg = sum / N
# print(avg)
result = sys.maxsize
answer = 0
for i in a:
    if result > abs(i - avg):
        result = abs(i - avg)
        answer = a.index(i)

print(answer)

Measured memory_bytes: 3064