akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXN = 100 + 5;

int n, m;
char gra[MAXN][MAXN];
short sum[MAXN][MAXN];
int ex, ey;
short f[MAXN][MAXN][MAXN][MAXN];

int get_sum(int x1, int y1, int x2, int y2)
{
	if(x1 > x2 || y1 > y2)
		return 0;
	return sum[x2][y2] - sum[x1 - 1][y2] - sum[x2][y1 - 1] + sum[x1 - 1][y1 - 1];
}

int dp(int x1, int y1, int x2, int y2)
{
	if(x1 > x2 || y1 > y2)
		return 0;
	if(f[x1][y1][x2][y2] != -1)
		return f[x1][y1][x2][y2];
	int ret = 0;
	// cut left
	ret = max(ret, dp(x1, y1 + 1, x2, y2) + 
		(y1 + m - y2 < ey ? 0 : get_sum(max(x1, ex - n + x2), y1, min(x2, ex + x1 - 1), y1)));
	// cut right
	ret = max(ret, dp(x1, y1, x2, y2 - 1) +
		(y2 + 1 - y1 > ey ? 0 : get_sum(max(x1, ex - n + x2), y2, min(x2, ex + x1 - 1), y2)));
	// cut up
	ret = max(ret, dp(x1 + 1, y1, x2, y2) + 
		(x1 + n - x2 < ex ? 0 : get_sum(x1, max(y1, ey - m + y2), x1, min(y2, ey + y1 - 1))));
	// cut up
	ret = max(ret, dp(x1, y1, x2 - 1, y2) + 
		(x2 + 1 - x1 > ex ? 0 : get_sum(x2, max(y1, ey - m + y2), x2, min(y2, ey + y1 - 1))));
	// cout << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << ' ' << ret << endl;
	return f[x1][y1][x2][y2] = ret;
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		cin >> (gra[i] + 1);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
		{
			sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + (gra[i][j] == 'o');
			if(gra[i][j] == 'E')
				ex = i, ey = j;
		}
	// cout << sum[n][m] << endl;

	memset(f, -1, sizeof(f));

	int ans = dp(1, 1, n, m);

	cout << ans << endl;

	return 0;
}


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

using namespace std;

const int N = 2000 + 5;

int n;
long long a[N];
long long b[N];

int solve() {
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    int k = 0;
    for (int j = 1; j < n; ++j) {
      if (a[j] > a[k]) {
        k = j;
      }
    }
    if (a[k] < n) {
      break;
    }
    ++cnt;
    a[k] -= n + 1;
    for (int i = 0; i < n; ++i) {
      a[i]++;
    }
  }
  return cnt;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n; 
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  memcpy(b, a, sizeof(a));
  long long sum = 0;
  for (int i = 0; i < n; ++i) {
    sum += a[i];
  }
  long long ans = LLONG_MAX;
  for (int i = 0; i < n + 1; ++i) {
    long long det = 0;
    for (int j = 0; j < n; ++j) {
      det += (b[j] + i) % (n + 1);
    }
    long long t = sum - det;
    if (t % (n + 1) == i) {
      memcpy(a, b, sizeof(a));
      for (int k = 0; k < n; ++k) {
        a[k] = (a[k] + t) % (n + 1);
      }      
      ans = min(ans, solve() + t);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
import time
import math
from collections import deque
import heapq
import itertools
from decimal import Decimal
import bisect
from operator import itemgetter
MAX_INT = int(10e18)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

K = int(input())

ans = ""
p = K
while p > 0:
  p -= 1
  q = p%26
  ans += chr(q + ord("a"))
  p = p//26
print(ans[::-1])

Measured memory_bytes: 77348
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1024)

func readLine() string {
	buf := make([]byte, 0, 1024)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func atoi(s string) int {
	i, e := strconv.Atoi(s)
	if e != nil {
		panic(e)
	}
	return i
}

func readStringArray() []string {
	return strings.Split(strings.TrimSpace(readLine()), " ")
}

func readInt() int {
	return atoi(readLine())
}

func readIntArray() []int {
	var a []int
	sa := readStringArray()
	for _, s := range sa {
		a = append(a, atoi(s))
	}
	return a
}

func Pow(x, y, mod int64) int64 {
	var ret int64 = 1
	var i int64
	for i = 0; i < y; i++ {
		ret *= x
		ret %= mod
	}
	return ret
}

func main() {
	N := readInt()
	D := readIntArray()
	var MOD int64 = 998244353
	var cnt [100005]int64
	var ans int64
	for i := 0; i < N; i++ {
		cnt[D[i]]++
	}
	if D[0] != 0 || cnt[0] != 1 {
		fmt.Println(0)
		os.Exit(0)
	}
	li := 0
	ans = 1
	for i := 1; i < N; i++ {
		li = i
		if cnt[i] == 0 {
			break
		}
		ans *= Pow(cnt[i-1], cnt[i], MOD)
		ans %= MOD
	}
	for i := li + 1; i < N; i++ {
		if cnt[i] > 0 {
			fmt.Println(0)
			os.Exit(0)
		}
	}
	fmt.Println(ans)
}


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

int const N = 200000;
int n, k, x[N], y[N];

bool sad(){
	f(i, 0, n)if (x[i] < n)return true;
	return false;
}

void ad(int i, int v) { i = max(i, 0); if (i < n)x[i] += v; }

void up(){
	f(i, 0, n)y[i] = x[i], x[i] = 0;
	f(i, 0, n){
		ad(i - y[i], 1);
		ad(i + y[i] + 1, -1);
	}
	f(i, 1, n)x[i] += x[i - 1];
}

int main(){
	scanf("%d%d", &n, &k);
	f(i, 0, n)scanf("%d", x + i);
	while (k && sad())up(), --k;
	f(i, 0, n)printf("%d%c", x[i], " \n"[i + 1 == n]);
}

Measured memory_bytes: 5408
#include<bits/stdc++.h>
typedef long long i64;
const int N=100007,P=1e9+7;
int n,fa[N],in[N],q[N],ql=0,qr=0,md[N],ss[N][2],t[N];
i64 pw2[N],fac[N],fiv[N],ans=1;
i64 pw(i64 a,i64 n){
	i64 v=1;
	for(;n;n>>=1,a=a*a%P)if(n&1)v=v*a%P;
	return v;
}
int main(){
	scanf("%d",&n);
	for(int i=pw2[0]=1;i<=n;++i)pw2[i]=pw2[i-1]*2%P;
	for(int i=fac[0]=1;i<=n;++i)fac[i]=fac[i-1]*i%P;
	fiv[n]=pw(fac[n],P-2);
	for(int i=n;i;--i)fiv[i-1]=fiv[i]*i%P;
	for(int i=1;i<=n;++i)scanf("%d",fa+i),++in[fa[i]];
	for(int i=1;i<=n;++i)if(!in[i])q[++qr]=i;
	while(ql!=qr){
		int w=q[++ql],f=fa[w];
		if(md[f])return puts("0"),0;
		md[f]=md[w]+1;
		if(!--in[f])q[++qr]=f;
	}
	for(int i=1;i<=n;++i)if(in[i]){
		int c=0,sp=0;
		for(int w=i;in[w];in[w]=0,w=fa[w]){
			++c;
			if(md[w])ss[++sp][0]=md[w],ss[sp][1]=c;
		}
		if(sp){
			ss[0][1]=ss[sp][1]-c;
			for(int j=1;j<=sp;++j){
				int d=ss[j][1]-ss[j-1][1],d0=ss[j][0];
				if(d<d0)return puts("0"),0;
				if(d>d0)ans=ans*2%P;
			}
		}else ++t[c];
	}
	for(int i=1;i<=n;++i)if(t[i]){
		i64 s1=1,s2=0;
		if(i>1&&(i&1))
		for(int j=0,c=t[i];j<=c;j+=2){
			s2=(s2+s1*pw2[c-j]%P*fiv[j/2])%P;
			s1=i64(c-j)*(c-j-1)/2%P*s1%P*i%P;
		}
		else
		for(int j=0,c=t[i];j<=c;j+=2){
			s2=(s2+s1*fiv[j/2])%P;
			s1=i64(c-j)*(c-j-1)/2%P*s1%P*i%P;
		}
		ans=ans*s2%P;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 5248
#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;

int a;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a;
	cout << (a + a * a + a * a * a) << "\n";
	return 0;
}


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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

// clang-format off
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

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

// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    auto v = ivec<double>(n);
    sort(all(v));
    double prev = v[0];
    rep (i, n)
        prev = (prev + v[i]) / 2;
    print(prev);

    return 0;
}


Measured memory_bytes: 256
import math

a, b, h, m = map(int, input().split())

ancleA = 30 * h + 0.5 * m
ancleB = 6 * m

ancle = min(abs(ancleA - ancleB), 360 - abs(ancleA - ancleB))

ans = (a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(ancle))) ** 0.5
print(ans)

Measured memory_bytes: 9536
import java.io.PrintStream;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = null;
		PrintStream out = null;
		try {
			sc = new Scanner(System.in);
			out = System.out;
			exec(sc, out);
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			if(out != null) {
				out.close();
			}
			if(sc != null) {
				sc.close();
			}
		}
		System.exit(0);
	}
	public static void exec(final Scanner sc, final PrintStream out) throws Exception{
		long A = sc.nextLong();
		long B = sc.nextLong();
		final HashSet<Long> Aset = new HashSet<>();
		final HashSet<Long> Bset = new HashSet<>();
		Aset.add(1L);
		Bset.add(1L);
		final long AMax = 1000000;//(long)Math.sqrt((double)A)+1;
		final long BMax = 1000000;//(long)Math.sqrt((double)B)+1;
		for(long i=2;i<=AMax;i++) {
			if(A < i) {
				break;
			}
			if(A%i!=0) {
				continue;
			}
			Aset.add(i);
			A = A/i;
			while(A%i==0) {
				A = A/i;
			}
		}
		Aset.add(A);
		for(long i=2;i<=BMax;i++) {
			if(B < i) {
				break;
			}
			if(B%i!=0) {
				continue;
			}
			Bset.add(i);
			B = B/i;
			while(B%i==0) {
				B = B/i;
			}
		}
		Bset.add(B);
//		System.err.println(Aset);
//		System.err.println(Bset);
		Aset.retainAll(Bset);
		out.println(Aset.size());
	}

}


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

int main(){
	int root[5][51], i, j;
	for (i = 0; i < 5; i++) {
		for (j = 0; j < 51; j++)
			root[i][j] = 0;
	}
	for (i = 0; i < 10; i++) {
		root[1][i] = 1;
	}
	for (i = 1; i < 5; i++) {
		root[i][0] = 1;
	}
	for (i = 2; i < 5; i++) {
		for (j = 1; j < 51; j++) {
			for (int k = j; k >= 0 && k > j - 10; k--) {
				root[i][j] += root[i - 1][k];
			}
		}
	}
	while (true) {
		int n;
		cin >> n;
		if (cin.eof()){
			break;
		}
		cout << root[4][n] << endl;
	}
	return 0;
}

Measured memory_bytes: 3024
#include<stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 1000

int top;
int S[MAX];

int initialize(){
       return top=0;
       }

int isempty(){
       return top==0;
       }

int isfull(){
       return top>=MAX-1;
       }

void push(int n){
       if (isfull()){return;}

       top++;
       S[top]=n;
       }

int pop(){
       if (isempty()){return;}

       top--;
       return S[top+1];
       }

int main(){
       int i,j,x,y;
       char op[MAX];
       top=0;
       while(scanf("%s",&op) != EOF){
                   if(op[0]=='+'){
                               x=pop();
                               y=pop();
                               push(y+x);
                               }
                   else if(op[0]=='-'){
                               x=pop();
                               y=pop();
                               push(y-x);
                               }
                   else if(op[0]=='*'){
                               x=pop();
                               y=pop();
                               push(y*x);
                               }
                   else {push(atoi(op));}
                   }
          printf("%d\n",pop());
          return 0;
          }




Measured memory_bytes: 2080
#include <iostream>
#include <cstring>
using namespace std;
const int maxn = 55;

int N, M;
int a, b, in[maxn];
int main(){
    cin>>N>>M;
    memset(in, 0, sizeof(0));
    for(int i = 0; i < M; i ++){
        cin>>a>>b;
        in[a] ++;
        in[b] ++;
    }
    for(int i = 1; i <= N; i ++){
        cout<<in[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

  if (a < b) return gcd(b, a);

  return gcd(b, a % b);
}

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

  int n, m;
  cin >> n >> m;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  bool ok = true;
  for (int i = 1; i < n; i++) {
    int cntX = 0, cntY = 0;

    int x = a[i];
    int y = a[i - 1];
    while (x % 2 == 0) {
      x /= 2;
      cntX++;
    }

    while (y % 2 == 0) {
      y /= 2;
      cntY++;
    }

    if (cntX != cntY) {
      ok = false;
      break;
    }
  }

  ll mul = 1;
  for (int i = 0; i < n; i++) {
    mul = mul * (a[i] / 2) / gcd(mul, a[i] / 2);
    if (mul > m) {
      ok = false;
      break;
    }
  }

  if (ok) {
    ll ans = 0;
    for (ll i = mul; i <= m; i += 2 * mul) {
      ans++;
    }
    cout << ans << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define ll long long
#define lld long double
#define MOD 1000000007
#define CAP 10000000
#define inf 1000000000000000000LL
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define sz(v) v.size()
#define all(v)    v.begin(),v.end()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
ll power(ll x,ll y, ll md=MOD){ll res = 1;x%=md;while(y>0){if(y&1)res = (res*x)%md;x = (x*x)%md;y = y>>1;}return res%md;}

#define int ll
#define endl '\n'

signed main() {
	fast;

	int n;
	cin>>n;

	int sum = 0, s1 = 0;

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

	sort(all(v));

	vector<int> dp(n+2,0);
	vector<int> fact(n+2,1);
	for(int i=1;i<=n+1;i++) fact[i] = (fact[i-1]*i)%MOD;

	int f = fact[n-1];

	for(int i=0;i<n-1;i++) {
		dp[i] = -fact[i];
		dp[i] *= f;
		f *= power(i+2,MOD-2)%MOD;
		f %= MOD;
		dp[i] %= MOD;
		// cout<<dp[i]<<endl;
		s1 -= dp[i];
		s1 %= MOD;
	}

	for(int i=0;i<n-1;i++) {
		sum = (sum + dp[i]*v[i]%MOD)%MOD;
	}
	sum = (sum+s1*v[n-1])%MOD;
	sum += MOD;
	sum %= MOD;
	cout<<sum;
}

Measured memory_bytes: 2560
#include <iostream>
#include <math.h>
#include <algorithm>
#define ll long long int
#define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n)

using namespace std;

int main()
{
    int n, highest, ans = 1;
    cin >> n;
    int h[n];
    cin >> h[0];
    highest = h[0];
    REP1(i,n){
        cin >> h[i];
        if(highest <= h[i]){
            ans += 1;
            highest = h[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/*
Look at the star
Look at the shine for U
*/ 

#include<bits/stdc++.h>
#define sl(x) scanf("%lld",&x)
using namespace std;
typedef long long ll;
const int N = 1e6+5;
const ll mod = 1e9+7;
const ll INF = 0x3f3f3f3f;
struct node{
	ll x,y;
}p[N];

bool cmp(node a,node b)
{
	return a.y < b.y;
}

int main()
{
	ll i,j,k,n,m,x,y;
	sl(n);sl(m);
	for(i = 0;i < m;i++)
	{
		sl(p[i].x);sl(p[i].y);
	}
	sort(p,p+m,cmp);
	ll l = 0,sum = 0;
	for(i = 0;i < m;i++)
	{
		if(p[i].x >= l)
		{
			l = p[i].y;
			sum++;
		}
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 1792
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

    long N;

    public void solve() {
        N = nextLong();

        for(int h = 1;h <= 3500;h++) {
            for(int n = 1;n <= 3500;n++) {
                if(4 * h * n - h * N - n * N == 0)continue;
                long a = (h * n * N);
                long b = (4 * h * n - h * N - n * N);

                if(b > 0 && a % b == 0) {
                    out.println(h + " " + n + " " + (a / b));
                    return;
                }
            }
        }
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 23508
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
// #include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n)*(n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;



int main() {
  map<string, int> rsp;
  string sss[] = {"Rock", "Fire", "Scissors", "Snake", "Human", "Tree", "Wolf", "Sponge", "Paper", "Air", "Water", "Dragon", "Devil", "Lightning", "Gun"};
  REP(i, 15){
    rsp[sss[i]]=i;
  }

  int n;
  while(cin>>n,n){
    set<int> rsps;
    vi suffer(15);
    REP(i, n){
      string s;
      cin >> s;
      int k = rsp[s];
      rsps.insert(k);
      REP(d, 7){
        suffer[(k+1+d)%15]++;
      }
    }
    if (rsps.size() <= 1){
      cout << "Draw" << endl;
      continue;
    }
    bool flg = false;
    for(auto i:rsps){
      if (suffer[i] == 0){
        cout << sss[i]<< endl;
        flg = true;
        break;
      }
    }
    if (!flg) cout<<"Draw"<< endl;
  }
}

Measured memory_bytes: 1216
#include<stdio.h>
int main(void){
  int N,i;
  int A[200000];
  int B[200000]={0};
  scanf("%d",&N);
  for(i=0;i<N-1;i++){
    scanf("%d",&A[i]);
    B[A[i]-1]=B[A[i]-1]+1;}
  for(i=0;i<N;i++)
    printf("%d\n",B[i]);
  return 0;
}

Measured memory_bytes: 3256
n = int(input())
a = list(map(int,input().split()))
cnt=0
arr=[]
for i in range(n):
  color=a[i]//400
  if color>=8:
    cnt+=1
  else:
    arr.append(color)
b=max(1,len(set(arr)))
c=len(set(arr))+cnt
print(b,c)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            return Array().Select(int.Parse).ToArray();
        }
        public long[] LongArray()
        {
            return Array().Select(long.Parse).ToArray();
        }
    }

    struct P
    {
        public int X, Y;
        public P(int x, int y)
        {
            X = x;
            Y = y;
        }
    }

    class Program
    {
        private void Scan()
        {
            var sc = new Scanner();
            for (int i = 0; i < 3; i++)
            {
                Console.Write(sc.Next()[i]);

            }
            Console.WriteLine();
        }

        public void Solve()
        {
            Scan();

        }

        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define mp make_pair
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define de(a) cout<<#a<<"="<<a<<endl;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
//--------

const int N=105;
int a[N][N];

int main() {
	int h,w,n;
	while(~scanf("%d%d%d",&h,&w,&n)) {
		int now=0;
		rep(i,1,n+1) {
			int c;scanf("%d",&c);
			rep(j,0,c) {
				int x=now/w,y=now%w;
				a[x][y]=i;
				++now;
			}
		}
		for(int i=0;i<h;i+=2) {
			for(int l=0,r=w-1;l<r;++l,--r) swap(a[i][l],a[i][r]);
		}
		rep(i,0,h) {
			rep(j,0,w) printf("%d%c",a[i][j],(j==w-1)?'\n':' ');
		}
	}
	return 0;
}

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

using namespace std;

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	vector<int> dp(201, 0);
	REPU(i, 1, 201) {
		REPU(j, 1, i + 1) if (i % j == 0) {
			dp[i]++;
		}
		if (dp[i] == 8 && i % 2 == 1) dp[i] = 1;
		else dp[i] = 0;
	}
	REPU(i, 1, 201) dp[i] += dp[i - 1];
	int n; cin >> n;
	cout << dp[n] << endl;

	return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    A = [list(map(int, input().split())) for i in range(n)]
    p = 10**9+7
    DP = [0 for s in range(1 << n)]
    DP[0] = 1
    for s in range(1, 1 << n):
        l = bin(s).count('1')
        for i in range(n):
            if ((1 << i) & s) * A[l-1][i]:
                DP[s] += DP[~(1 << i) & s]
    print(DP[(1 << n)-1] % p)


main()


Measured memory_bytes: 123496
/*
map : count()返回被查找元素的个数 有返回1 无返回0  注意map中不存在相同元素 (下标，即first)
		find()返回位置 若没有则返回map.end()
拆点
*/
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
#include<map>
using namespace std;
#define LL long long
#define MAXN 100005
#define INF 1000000000
int N,M,cnt;
map<int,int> id[2*MAXN];//id[u][c]:u属性为c的虚点编号
vector< pair<int,int> > G[5*MAXN];
int dist[5*MAXN];
bool vis[5*MAXN];
void mg()
{
	for(int i=0;i<M;i++)
	{
		int u,v,c;
		scanf("%d %d %d",&u,&v,&c);
		/*if(!id[u].count(c)) 
		{
			id[u][c]=cnt++;
			G[u].push_back(make_pair(cnt,1));
		}
		if(!id[v].count(c)) 
		{
			id[v][c]=cnt++;
			G[v].push_back(make_pair(cnt,1));
		}*/
		if(!id[u].count(c)) 
			id[u][c]=cnt++;
		if(!id[v].count(c)) 
			id[v][c]=cnt++;
		G[id[u][c]].push_back(make_pair(id[v][c],0));
		G[id[v][c]].push_back(make_pair(id[u][c],0));
	}
	for(int i=1;i<=N;i++)
		for(map<int,int>::iterator it=id[i].begin();it!=id[i].end();it++)
		{
			int idd=it->second;
			G[i].push_back(make_pair(idd,1));
			G[idd].push_back(make_pair(i,1));
		}
}
void sp()
{
	fill(dist,dist+5*MAXN,INF);
	dist[1]=0;
	vis[1]=1;
	queue<int> que;
	que.push(1);
	while(!que.empty())
	{
		int u=que.front();
		que.pop();
		for(int i=0;i<G[u].size();i++)
		{
			int v=G[u][i].first,l=G[u][i].second;
			if(dist[v]>dist[u]+l)
			{
				dist[v]=dist[u]+l;
				if(!vis[v])
				{
					vis[v]=1;
					que.push(v);
				}
			}
		}
		vis[u]=0;
	}
}
int main()
{
	scanf("%d %d",&N,&M);
	cnt=N+1;
	mg();
	sp();
	if(dist[N]==INF) printf("-1\n");
	else printf("%d\n",dist[N]/2);
	return 0;
}

Measured memory_bytes: 61056
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>
#include <stack>

using namespace std;

vector<long long> sq;

//int memo[1<<15][200][4];

int dfs(long long sum,int pos,int num)
{

	if(sum==0) return 1;
	else if(num==4 || sum<0) return 0;

//	if(memo[sum][pos][num]!=0) return memo[sum][pos][num];

	int res=0;
	for(int i=pos;sq[i]<=sum;i++) res+=dfs(sum-sq[i],i,num+1);

//	return memo[sum][pos][num]=res;
	return res;
}

int main()
{

	for(int i=1;i*i<(1<<15);i++) sq.push_back(i*i);

	long long n;
	while(cin>>n,n){
		cout<<dfs(n,0,0)<<endl;
	}

	return 0;
}

Measured memory_bytes: 1216
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			long a = sc.nextInt();
			long b = sc.nextInt();
			long gcd = gcd(a,b);
			System.out.println(gcd + " " + (a*b/gcd));
		}
		
	}
	public static long gcd(long a,long b) {
		while(b!=0) {
			long r = a%b;
			a = b;
			b = r;
		}
		return a;
	}
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<bool> v(n, 0);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        v[a] = !v[a];
        v[b] = !v[b];
    }
    string ans = "YES";
    for (int i = 0; i < n; i++) {
        if (v[i]) {
            ans = "NO";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  ll x;cin>>x;
  for(i=1;;i++){
    if(i*(i+1)>=2*x){
    cout<<i<<endl;
    break;
    }
  }


  return 0;
}

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

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	int n;
	cin >> n;
	ld s = 0.;
	for(int i = 1; i <= n; i ++)
	{
		ld x;
		cin >> x;
		s += 1./x;
	}
	s = 1./s;
	cout << setprecision(9) << fixed << s;





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define ll long long
ll gcd(ll u, ll v){
	if (v==0) return u;
	else return gcd(v,u%v);
}
int main() {
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	ll t=gcd(c,d);
	t = (c*d)/t;
	ll x1 = b/c;
	ll x2 = (a-1)/c;
	ll y1 = b/d;
	ll y2 = (a-1)/d;
	ll z1 = b/t;
	ll z2 = (a-1)/t;
	cout << b-x1-y1+z1-(a-1)+x2+y2-z2;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <utility>
#include <string>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	for (string r, a; scan(r, a), r != "0";) {
		int h = 0, b = 0;
		for (int i = 0; i < 4; i++)
			if (r[i] == a[i])
				h++;
			else
				for (int j = 0; j < 4; j++)
					if (i != j && r[i] == a[j]) {
						b++;
						break;
					}
		outl(h, ' ', b);
	}
}


Measured memory_bytes: 2596
#include <iostream>
#include <stack>
#include <string>
#include <utility>

using namespace std;

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

  stack<int> s;

  for (int i = 0; i < N; ++i) {
    if (c[i] == 'R') {
      s.push(i);
    }
  }

  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    if (c[i] == 'W' && !s.empty()) {
      int j = s.top();
      s.pop();
      if (i < j) {
        swap(c[i], c[j]);
        cnt++;
      }
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3968
N, W = map(int, input().split())
items = [list(map(int, input().split())) for _ in range(N)]
dp = [[0] * (W+1) for _ in range(N+1)]
for i in range(N):
  for w in range(W+1):
    if w >= items[i][0]:
      dp[i+1][w] = max(dp[i][w-items[i][0]]+items[i][1], dp[i][w])
    else:
      dp[i+1][w] = dp[i][w]
print(dp[N][W])


Measured memory_bytes: 121580
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int[] nums = new int[n];
		for(int i=0;i<n;i++) nums[i]=sc.nextInt();
		Arrays.sort(nums);
		
		System.out.println(nums[n/2]-nums[n/2-1]);
	}
}


Measured memory_bytes: 50600
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
// typedef long  l;
typedef pair<int,int> P;
const int INF=10000001;
const double PI=3.141592653589;


int main(){
  string s; cin>>s;
  rep(i,3){
    if(s[i]=='1')
    s[i]='9';
    else if(s[i]=='9')
    s[i]='1';
  }
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;

int main()
{
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  
  int maxv;
  maxv=max(max(a,b),c);
  
  int ans;
  if(maxv==a) ans=b*c/2;
  if(maxv==b) ans=c*a/2;
  if(maxv==c) ans=a*b/2;
  
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
n = int(input())
S = [input() for i in range(n)]
m = int(input())
T = [input() for i in range(m)]

import collections 
CS = collections.Counter(S)
CT = collections.Counter(T)

ans = 0

sS = set(S)

for i in sS:
    x = CS[i]
    if i in T:
        x -= CT[i]
    ans = max(ans,x)
    
print(ans)

Measured memory_bytes: 3316
//BUGSBUNNY
//IIT ROORKEE
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std; 
using namespace __gnu_pbds;
#define int long long
#define ll long long
#define double long double
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define vl vector<long long>
#define vpii vector<pii>
#define vpipii vector<pipii>
#define vb vector<bool>
#define pb push_back
#define pob pop_back
#define mp make_pair
#define pii pair<int,int>
#define pipii pair<int,pii>
#define piipi pair<pii,int>
#define pld pair<long double,long double>
#define mod 1000000007 
// #define mod 998244353
#define rep(i,n) for (ll i = 0; i < n; i++)
#define repp(i,a,b) for(ll i = a ; i<b ; i++)
#define reppr(i,a,b) for(ll i = a-1 ; i>=b ; i--)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define ff first
#define ss second
#define pc putchar_unlocked
#define gc getchar_unlocked
#define inf 9223372036854775807
#define infn -9223372036854775807
#define pi 3.14159265358979323846
#define eps 0.0000000001
#define sp << " " << 
#define setprec(x) cout << fixed << setprecision(x);
#define REVERSE(a) reverse(all(a));
#define SORT(a) sort(all(a));
#define all(n) n.begin(),n.end()

//GCD and LCM
    int gcd (int a, int b) { return b ? gcd (b, a % b) : a; }
    int lcm (int a, int b) { return a / gcd(a, b) * b; }

//Modular Exponentiation
    int powmod(int x,int y) 
    { 
        if (y == 0) return 1; 
        int p = powmod(x, y/2) % mod; 
        p = (p * p) % mod;   
        return (y%2 == 0)? p : (x * p) % mod; 
    }

//Modular Inverse
    int inverse(int a) 
    { 
       return powmod(a,mod-2); 
    }

//Binomial Coefficients
    int fact[200010], factinv[200010] , first = 0;
    void Util_nCr()
    {
        fact[0] = 1 , factinv[0] = 1;
        repp(i,1,200010)
        {
            fact[i] = (fact[i-1] * i)%mod;
            factinv[i] = (factinv[i-1] * inverse(i))%mod;
        }
    }
    int nCr(int n , int r)
    {
        if(!first) first = 1 , Util_nCr();             
        return ((fact[n] * inverse(fact[n-r]) % mod * inverse(fact[r]))%mod) ;
    }

void solve();
signed main()
{
    //-------------------------------------------------------------------------------   
        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
        clock_t clk = clock();
        
    //-------------------------------------------------------------------------------   

    //-------------------------------------------------------------------------------
        int t = 1;
        // cin >> t;
        while(t--)
            solve();
    //-------------------------------------------------------------------------------
        clk = clock() - clk;
        cerr << fixed << setprecision(12) << "Time: " << ((double)clk)/CLOCKS_PER_SEC;
    //-------------------------------------------------------------------------------
}

void solve()
{
    string s;
    cin >> s;
    if(s[0]=='7' || s[1]=='7' || s[2]=='7')
        cout << "Yes\n";
    else
        cout << "No\n";
} 



Measured memory_bytes: 3840
#include <iostream>
#include <cmath>

#define B 600

int f(int x);

using namespace std;

int main(void) {
  int d, S = 0;
  while(cin >> d) {
    for(int i = 0; i < B/d; i++) {
      S = S + d*f(i*d);
    }
    cout << S << '\n';
    S = 0;
  }

  return 0;
}

int f(int x) {
  return pow(x,2);
}

Measured memory_bytes: 3012
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  vector<int>a(2*n);
  rep(i,n*2)cin>>a[i];
  sort(all(a));
  ll sum=0;
  rep(i,n){
    sum+=a[i*2];
  }
  cout<<sum<<endl;

  return 0;

}


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

//Euclid's algorithm
ll gcd(ll a , ll b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
}

int main(){
    ll n,m;
    cin>>n>>m;
    ll t=0;
    ll temp;
    for(ll i=0;i<m;i++){
        cin>>temp;
        t+=temp;
    } 
    if(t>n){
        cout<<"-1";
        return 0;
    }
    else{
        cout<<(n-t);
        return 0;
    }
}

    

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

int main()
{
	double a;
	double n;
	double max,min,sum;

	cin>>n;	
	sum=0;
	max=-1000000;
	min=1000000;
	for( int i=0; i<n; i++ ) {
		cin>>a;
		sum+=a;
		if( max < a ) {
			max=a;
		}
		if( a < min ) {
			min=a;
		}
	}
	
	cout <<setprecision(12)<<min<<" "<<max<<" "<<sum<<endl;  
    return 0;
}

Measured memory_bytes: 1284
/*{{{*/
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

#ifdef LOCAL
int c_ = 0;
#define cout (c_?cerr:cout)
#define debug(...) \
{if(!c_++)cerr<<"\033[96;1m"; \
__VA_ARGS__; \
if(!--c_)cerr<<"\033[0m";}
#define assrt(...)  debug( \
if (not (__VA_ARGS__)) \
{ \
    print(__LINE__, ':', #__VA_ARGS__); \
    exit(1); \
} \
)
#else
#define debug(...) {}
#define assrt(...)
#endif

#define st first
#define nd second
#define all(...) (__VA_ARGS__).begin(), (__VA_ARGS__).end()

using namespace std;
using ll = long long;
using ld = long double;
template < typename t >
using V = vector< t >;

template< typename t > 
int size(const t& c)
{return c.size();}

void print()
{cout << '\n';}

template< typename t, typename... v >
void print(const t& a, const v&... b)
{cout << a << (sizeof...(b)?" ":""); print(b...);}

template< typename a, typename b >
inline ostream& operator<<(ostream& os, const pair< a, b > p)
{return os << '(' << p.st << ", " << p.nd << ')';}

template< typename t >
void print_range(t a, const t& b)
{while (a != b) cout << (*a++) << ' '; cout << '\n';}

#define flag() __LINE__"| "__PRETTY_FUNCTION__
#define dump(...) debug(print(#__VA_ARGS__,'=',__VA_ARGS__))
#define dump_range(...) debug(cout<<#__VA_ARGS__": ";print_range(__VA_ARGS__))
/*}}}*/

constexpr int nax = 1e5, alf = 26, mod = 1e9 + 7;

int n, zl[alf];
string s;

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> s;

    for (char c : s)
        ++zl[c - 'a'];

    int res = 1;

    for (int i = 0; i < alf; ++i)
        res = ((ll)res * (zl[i] + 1)) % mod;

    --res;
    if (res < 0) res += mod;

    cout << res << '\n';
    
}

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

ans = 0
a =[]
b =[]

for i in range(N):
    a1, b1 = [int(i) for i in input().split()]
    a.append(a1)
    b.append(b1)

for i in range(N):
    if a[i] >= H and b[i] >= W:
        ans += 1

print(ans)

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

int main(){
    int n;
    cin >> n;
    vector<int>  p(n);
    for (int i = 0; i < n; i++){
        cin >> p.at(i);
    }
    int count = 0;
    for (int i = 0; i < n - 2; i++){
        if (p.at(i) < p.at(i+1) && p.at(i+1) < p.at(i+2)){
            count++;
        }
        else if (p.at(i) > p.at(i+1) && p.at(i+1) > p.at(i+2)){
            count++;
        }
    }
    cout << count << endl;
}


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

int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> count(M, 0);
  rep(i, N)
  {
    int K;
    cin >> K;
    rep(j, K)
    {
      int A;
      cin >> A;
      count[A - 1]++;
    }
  }
  sort(count.rbegin(), count.rend());
  int ans = 0;
  rep(i, M)
  {
    if (count[i] != N)
      break;
    ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( [ $ t : ty ] ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; ( [ $ t : ty ] ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( [ $ t ] ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}
fn solve() {
    let n = get!(usize);
    let mut ps = get!(u64; n);

    ps.sort();

    let sum = ps[..ps.len() - 1].iter().sum::<u64>() + ps.last().unwrap() / 2;

    println!("{}", sum);
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    string a, b; cin >> a >> b;
    int jud = -1;
    if(a.size() > b.size()) cout << "GREATER" << endl;
    if(a.size() < b.size()) cout << "LESS" << endl;
    if(a.size() == b.size()){
        rep(i,a.size()){
            if(a[i] > b[i]){
                jud = 1;
                break;
            }
            if(a[i] < b[i]){
                jud = 2;
                break;
            }
        }

        if(jud == 1) cout << "GREATER" << endl;
        if(jud == 2) cout << "LESS" << endl;
        if(jud == -1) cout << "EQUAL" << endl; 
    }
}

Measured memory_bytes: 256