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

#define mp make_pair
#define F first
#define S second
#define B begin
#define E end
#define PB push_back
#define endl "\n"

#define FORS(i, j, k, step) for (int i=j; i<k; i+=step)
#define FOR(i, j, k) for (int i=j; i<k; i++) 
#define RFORS(i, j, k, step) for (int i=j; i>=k; i-=step)
#define RFOR(i, j, k, step) for(int i=j; i>=k; i--)
#define REP(i, k) for(int i = (0); i < (k); i++ )
#define RREP(i, k) for(int i = j; i >= (k); i-- )

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

template<typename T>
void read_vec(vector<T>& v, int n){
    T tmp;
    REP(i, n){
        cin>>tmp;
        v.push_back(tmp);
    }
}

void solve(){
	string s;
	cin>>s;
	string res = "";

	if(s[s.size()-1] == 's')
		res = s+"es";
	else
		res = s+"s";

	cout<<res<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int TC =1;
    //cin>>TC;

    REP(tc, TC){
    	solve();
    }

}

Measured memory_bytes: 3620
import java.util.*;
import java.util.Arrays;
import java.util.Collections;

public class Main {
public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	// 整数の入力
	int n = sc.nextInt(); // 種類
	int m = sc.nextInt(); // 人気商品数
	Integer[] a = new Integer[n]; // 投票状況
    double border = 0; // 投票数ボーダー
	double total = 0; // 得票数合計
	int flg = 1; // 陳列可否
	
	// 投票状況取得
    for(int i=0; i<n; i++) {
        a[i] = sc.nextInt();
        total += a[i];
    }
    
    border = total / (4 * m);
    Arrays.sort(a, Collections.reverseOrder());
    
    // 人気商品陳列可否チェック
    for(int i=0; i<m; i++) {
        if(a[i] < border) flg = 0;
    }
    
	// 出力
    if(flg == 0) {
        System.out.print("No");
	} else {
        System.out.print("Yes");
	}
}
}


Measured memory_bytes: 21844
(function(input) {
  var p = input.replace(/\n$/, '').split('\n');
  var n = p.length;
  for (var i = 0; i < n; i++) {
    var a = p.shift().split(',').map(Number);
    var r = {};
    for (var j = 0; j < a.length; j++) {
      if (a[j] in r) {
        r[a[j]]++;
      } else {
        r[a[j]] = 1;
      }
    }
    var c = [];
    for (var k in r) {
      if (r[k] in c) {
        c[r[k]].push(k);
      } else {
        c[r[k]] = [k];
      }
    }
    console.log(check(c));
  }
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

function check(c) {
  if (c[4]) {
    return 'four card';
  }
  if (c[3] && c[2]) {
    return 'full house';
  }
  if (c[1] && c[1].length === 5) {
    var a = c[1];
    a = a.map(Number).sort(function (a, b) {
      return a - b;
    });
    //console.log(a);
    if (a[0] > 9) {
      return 'null';
    }
    if (a[1] === 10) {
      return 'straight';
    }
    if (a[1] === a[0] + 1 &&
      a[2] === a[1] + 1 &&
      a[3] === a[2] + 1 &&
      a[4] === a[3] + 1
    ) {
      return 'straight';
    }
  }
  if (c[3]) {
    return 'three card';
  }
  if (c[2] && c[2].length === 2) {
    return 'two pair';
  }
  if (c[2]) {
    return 'one pair';
  }
  return 'null';
}

Measured memory_bytes: 7640
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long n, m, i, j, k, ans, MOD = 1000000007;

	cin >> n >> m;
	if (n == m) {
		ans = 1;
		for (i = 1; i <= n; i++) ans = (ans * i) % MOD;
		for (i = 1; i <= n; i++) ans = (ans * i) % MOD;
		ans = (ans * 2) % MOD;
	}
	else if (abs(n - m) == 1) {
		ans = 1;
		for (i = 1; i <= n; i++) ans = (ans * i) % MOD;
		for (i = 1; i <= m; i++) ans = (ans * i) % MOD;
	}
	else ans = 0;

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
    Scanner scn= new Scanner(System.in);
    long k=scn.nextLong();
    int n =scn.nextInt();
    long [] arr =new long[n];
    for(int i=0;i<n;i++){
    	arr[i]=scn.nextLong();
    	
    }
    long max=0;
    for(int i=1;i<arr.length;i++){
      max=Math.max(Math.abs(arr[i-1]-arr[i]),max);
      
    }
    max = Math.max((Math.abs(arr[arr.length-1]-(arr[0]+k))), max);
    System.out.println(Math.abs(k-max));
    }

}

Measured memory_bytes: 85264
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define files(name) name!=""?freopen(name".in","r",stdin),freopen(name".out","w",stdout):0
#define all(a) a.begin(),a.end()
#define len(a) (int)(a.size())
#define elif else if
#define mp make_pair
#define pb push_back
#define fir first
#define sec second

using namespace std;
#define int long long

typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;

const int arr=2e5+10;
const int ar=2e3+10;
const ld pi=acos(-1);
const ld eps=1e-10;
const ll md=1e9+7;
const ll inf=1e18+10;

///---program start---///

int a[arr];
int best[arr];

main()
{
    #ifdef Barik
        files("barik");
        freopen("debug.txt","w",stderr);
    #endif
    
    int n,x;
    cin>>n>>x;
    for (int i=0;i<n;i++){
        cin>>a[i];
        best[i]=inf;
    }
    int ans=inf;
    for (int j=0;j<n;j++){
        for (int i=0;i<n;i++){
            best[i]=min(best[i],a[(i-j+n)%n]);
        }
        int sum_best=0;
        for (int i=0;i<n;i++){
            sum_best+=best[i];
        }
        ans=min(ans,j*x+sum_best);
    }
    cout<<ans<<"\n";
}



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

#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;

signed main(void)
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  if (fopen("A.INP", "r")){
    freopen("A.INP", "r", stdin);
    freopen("A.OUT", "w", stdout);
  }
  string s, t; cin >> s >> t;
  int n = s.size(), m = t.size();
  s = " " + s, t =  " " + t;
  vector<int> s1(n + 5), s2(m + 5);
  for (int i = 1; i <= n; ++i){
    if (s[i] == 'A') s1[i] = s1[i - 1] + 2;
    else s1[i] = s1[i - 1] + 1;
  }
  for (int i = 1; i <= m; ++i){
    if (t[i] == 'A') s2[i] = s2[i - 1] + 2;
    else s2[i] = s2[i - 1] + 1;
  }
  int q; cin >> q;
  while (q--){
    int l1, r1, l2, r2;
    cin >> l1 >> r1 >> l2 >> r2;
    int ss = s1[r1] - s1[l1 - 1];
    int ts = s2[r2] - s2[l2 - 1];
    if (ss % 3 == ts % 3) cout << "YES\n";
    else cout << "NO\n";
  }
}


Measured memory_bytes: 1644
n = int(input())
b = list(map(int, input().split()))
ans = 0

for i in range(n):
    if i == 0:
        ans += b[i]
    elif 0 < i and i < n-1:
        ans += min(b[i-1], b[i])
    else:
        ans += b[i-1]
print(ans)

Measured memory_bytes: 3060
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n = ir()
csf = [lr() for i in range(n-1)]
ans = []
for i in range(n):
    time = 0
    for j in range(i,n-1):
        c,s,f = csf[j]
        if time >= s:
            k = time%f
            if k != 0:
                time = (time//f+1)*f+c
            else:
                time = time+c
        else:
            time = s+c
    ans.append(time)
for num in ans:
    print(num)

Measured memory_bytes: 78792
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

	int K, N;

	cin >> K >> N;

	vi A(N);

	REP(i, N) {

		cin >> A[i];

	}

	int maximum = 0;
	int index = 0;

	REP(i, N-1) {
		if (A[i + 1] - A[i] > maximum) {
			maximum = A[i + 1] - A[i];
			index = i;
		}
	}
	if (K+A[0] - A[N - 1] > maximum) {
		cout << A[N-1]-A[0] << endl;
		return 0;
	}

	cout << K-(A[index+1]-A[index]) << endl;




	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;

int main(){
  int n; cin >> n;
  vector<ll> a(n),b(n);

  rep(i,n)  cin >> a.at(i) >> b.at(i);
  ll ans = 0;

  for(int i=n-1;i>=0;i--){
    if((a.at(i)+ans)%b.at(i))ans += b.at(i)-((a.at(i)+ans)%b.at(i));
  }

  cout << ans << endl;
}


Measured memory_bytes: 4844
n=int(input())

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

a=divisor(n)
a.sort()

b=sorted(a,reverse=True)

c=[]
for i in range(len(a)//2+1):
    d=a[i]-1+b[i]-1
    c.append(d)

print(min(c))

Measured memory_bytes: 9560
def main():
    N = int(input())
    A = list(map(int, input().split()))

    if A.count(0) == N:
        print("Yes")
    elif N % 3 == 0:
        A.sort()
        ans = True
        for i in range(N//3):
            if A[i] ^ A[i+(N//3)] != A[i+(N//3)*2]:
                ans = False
        if ans:
            print("Yes")
        else:
            print("No")
    else:
        print("No")



if __name__ == "__main__":
    main()

Measured memory_bytes: 14116
import java.util.*;
public class Main {
    private static Scanner sc;
    public static void main(String[] args){
        sc = new Scanner(System.in);
        List<Integer> list = new ArrayList<Integer>();
        int a, i=0, judge;
        while ((judge=sc.nextInt())>0){
            for (int j=1; j<judge+1; j++){
                list.add(a = sc.nextInt());
                i++;
            }
            Collections.sort(list);
            int sum = 0;
            for (int k=1; k<i-1; k++){
                sum = sum+list.get(k);
            }
            System.out.println((sum/(i-2)));
            i=0;
            list.clear();
        }
             
    }
     
}

Measured memory_bytes: 29016
#include <bits/stdc++.h>
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rep1(i,a,b) for(int i=(a);(i)<=(b);(i)++)
#define rep(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define ll long long
#define mpi map<int,int>
#define N 500005
#define pql priority_queue<ll>
#define all(v) (v).begin(),(v).end()
#define str stringstream
using namespace std;
int n,k,a[N],cnt;
vector<int> g[N];
mpi mp; 
void dfs(int x) {
	for(auto v:g[x])
    	dfs(v);
    cnt++;
	a[x]=cnt;
}
int main() {
	cin>>n>>k;
	rep1(i,1,n)cin>>a[i];
	rep1(i,1,n) {
    	if(i>k)mp.erase(a[i-k]);
    	g[(mp.upper_bound(a[i]))->second].push_back(i);
		mp[a[i]]=i;
	}
	dfs(0);
	rep1(i,1,n)cout<<a[i]<<"\n";
	return 0;
}

Measured memory_bytes: 48768
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    S=input()
    S=S.replace("BC","D")
    S+="Z"
    N=len(S)
    ans=0
    cnta=0

    
    for i in range(N):
        if S[i]=="D":
            ans+=cnta
        elif S[i]=="A":
            cnta+=1
        else:
            cnta=0
                
    print(ans)
            

main()


Measured memory_bytes: 68968
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <deque>

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

using namespace std;

int main(){
    int N, C, K;
    cin >> N >> C >> K;
    deque<int> qs(N, 0);
    rep(i, N){
        cin >> qs[i];
    }
    sort(qs.begin(), qs.end());

    int cnt = 1;
    int ans = 1;
    int front = qs.front();
    qs.pop_front();
    while(! qs.empty()){
        int tmp = qs.front();
        if(tmp > K + front || cnt + 1 > C){
            front = tmp;
            ans ++;
            cnt = 0;
        }
        cnt ++;
        qs.pop_front();
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
from collections import Counter
s = input()[::-1]
n = len(s)
ans = 0
tmp_3, tmp_673 = 0, 0
c = Counter()
c[(0, 0)] = 1
for i in range(n):
	tmp_3 += int(s[i]) * pow(10, i, 3)
	tmp_3 %= 3
	tmp_673 += int(s[i]) * pow(10, i, 673)
	tmp_673 %= 673
	ans += c[(tmp_3, tmp_673)]
	c[(tmp_3, tmp_673)] += 1
print(ans)


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

using namespace std;

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int N;
    cin >> N;
    vector <int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    vector <int> PrefGcd(N);
    vector <int> SufGcd(N);
    PrefGcd[0] = A[0];
    for (int i = 1; i < N; i++) {
        PrefGcd[i] = __gcd(PrefGcd[i - 1], A[i]);
    }
    SufGcd[N - 1] = A[N - 1];
    for (int i = N - 2; i > -1; i--) {
        SufGcd[i] = __gcd(SufGcd[i + 1], A[i]);
    }
    int Ans = 1;
    for (int i = 1; i < N - 1; i++) {
        Ans = max(Ans, __gcd(PrefGcd[i - 1], SufGcd[i + 1]));
    }
    Ans = max(Ans, PrefGcd[N - 2]);
    Ans = max(Ans, SufGcd[1]);
    cout << Ans;
    return 0;
}



Measured memory_bytes: 1408
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#define unsigned long long 
#define rep(i,a,b) for(ull (i)=(a);(i)<(b);i++)
void dfs(int w, int h);
using namespace std;
int field[50][50];
int x, y;
int cnt;
int main(void){
	while (true){
		cin >> x >> y;
		if (x == 0)
			break;
		cnt = 0;
		for (int i = 0; i < y; i++){
			for (int j = 0; j < x; j++){
				cin >> field[i][j];
			}
		}
		for (int i = 0; i < y; i++){
			for (int j = 0; j < x; j++){
				if (field[i][j] == 1){
					cnt++;
					dfs(i, j);
				}
			}
		}
		cout << cnt << endl;
	}
	return 0;
}


void dfs(int h, int w){
	field[h][w] = 0;

	if (w < x - 1){
		if (field[h][w + 1] == 1){
			dfs(h, w + 1);
		}
	}
	if (w < x - 1&&h<y-1){
		if (field[h+1][w + 1] == 1){
			dfs(h+1 ,w + 1);
		}
	}
	if (h<y - 1){
		if (field[h+ 1][w ] == 1){
			dfs(h +1 ,w );
		}
	}
	if (h<y - 1&&w>0){
		if (field[h + 1][w-1] == 1){
			dfs(h + 1, w-1);
		}
	}
	if (w>0){
		if (field[h ][w - 1] == 1){
			dfs(h , w - 1);
		}
	}
	if (w>0&&h>0){
		if (field[h-1][w - 1] == 1){
			dfs(h-1, w - 1);
		}
	}
	if (h>0){
		if (field[h - 1][w] == 1){
			dfs(h - 1, w);
		}
	}
	if (h>0&&w<x-1){
		if (field[h - 1][w+1] == 1){
			dfs(h - 1, w+1);
		}
	}
}

Measured memory_bytes: 1384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  int n,m,a,max;
  ll s = 0;
  cin >> n >> m;
  priority_queue<int>  q;
  for(int i = 0;i<n;i++)
  {
    cin >> a;
    q.push(a);
  }
  for(int i = 0;i<m;i++)
  {
    max = q.top();
    q.pop();
    max /= 2;
    q.push(max);
  }
  for(int i = 0;i<n;i++)
  {
      max = q.top();
      q.pop();
      s += max;
  }
  cout << s << endl;
  return 0;
}



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

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main(){
	int K, N;
	cin >> K >> N;
	int A[200010];
	rep(i,N) cin >> A[i];
	sort(A,A+N);
	int maxdif=A[0]+K-A[N-1];
	rep(i,N-1){
		int dif=A[i+1]-A[i];
		maxdif=max(maxdif,dif);
	}
	cout << K-maxdif << endl;

	return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    A = list(map(int, input().split()))

    s = sum(A)
    ans = 0
    mod = 10**9 + 7
    for i in A:
        ans = (ans + i * (s - i))
    print((ans // 2) % mod)


if __name__ == "__main__":
    main()


Measured memory_bytes: 31564
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

using namespace std;
typedef long long int64;

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  string s;
  cin>>s;
  vector<int64> value(s.size()+1,-1);
  if(s[0]=='<'){
    value[0]=0;
  }
  if(s.back()=='>'){
    value[s.size()]=0;
  }
  for(int i=0;i<s.size()-1;i++){
    if(s[i]=='>'&&s[i+1]=='<'){
      value[i+1]=0;
    }
  }

  for(int i=0;i<s.size();i++){
    if(s[i]=='<'){
      value[i+1]=value[i]+1;
    }
  }

  for(int i=s.size()-1;i>=0;i--){
    if(s[i]=='>'){
      if(value[i]>value[i+1]) continue;
      else value[i]=value[i+1]+1;
    }
  }

  int64 result=0;
  for(auto v:value){
    result+=v;
  }
  cout<<result<<endl;




  return 0;
}

Measured memory_bytes: 4728
def main():
    N,K,Q=map(int,input().split())
    C=[0]*N
    P=[0]*N
    for j in range(Q):
        idx=int(input())-1
        C[idx]+=1

    for i in range(N):
        P[i]=K-Q+C[i]
        if P[i]>0:
            print("Yes")
        else:
            print("No")

main()


Measured memory_bytes: 8520
#include <bits/stdc++.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()
 
#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>
 
#define debug(x) {cerr <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}
 
#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue
 
#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
 
 
using namespace std;

const int max_n = 1e6 + 10;


int main() {
	make(n);
	makev(v, n);
	int mybest = 1e9;
	FOR(i,-100,101) {
		int mycost = 0;
		FOR(j,0,n) mycost += (v[j]-i) * (v[j]-i);
		mybest = min(mybest, mycost);
	}
	printf("%d\n", mybest);
}


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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> h(n+k, 1e9);
    rep(i, n) cin >> h[i];
    //n+k作っちゃって，とんでもない高さにすれば登れない
    vector<int> dp(n+k, 0);
    dp[n-1] = 0;

    for(int i=n-2;i>=0;i--){
        int tmp=1e9;
        for(int j = 1;j <= k;j++){
            tmp = min(tmp, abs(h[i] - h[i+j]) + dp[i+j]);
        }

        dp[i] = tmp;
    }

    cout << dp[0] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
using namespace std;

int main(void)
{
	int n, hit = 0 , blow = 0;
	int num1[4], num2[4];
	while(scanf("%d",&num1[0]) != EOF){
		hit = 0;
		blow = 0;
		for(int f1 = 1; f1 < 4; f1++)
		{
			scanf("%d", &num1[f1]);
		}
		for(int f1 = 0; f1 < 4; f1++)
		{
			scanf("%d", &num2[f1]);
		}
		for(int f1 = 0; f1 < 4; f1++)
		{
			if(num1[f1] == num2[f1])
			{
				hit++;
			}
			else
			{
				for(int f2 = 0; f2 < 4; f2++)
				{
					if(num1[f1] == num2[f2])
					{
						blow++;
						break;
					}
				}
			}
		}
	printf("%d %d\n", hit, blow);
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s;
	cin >> s;
	rep(i, 4) cout << s[i];
	cout << " ";
	rep(i, 8) cout << s[i+4];
	cout << endl;
	return 0;
}


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

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

    int n, k;
    cin >> n >> k;
    vector<bool> snuckes(n);
    for (int i = 0; i < k; ++i) {
        int di;
        cin >> di;
        for (int j = 0; j < di; ++j) {
            int snuke;
            cin >> snuke;
            snuckes[snuke - 1] = true;
        }
    }
    int ans = n;
    for (int i = 0; i < n; ++i) {
        ans -= (int)(snuckes[i]);
    }
    cout << ans << '\n';

    return 0;
}


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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef struct data{
	int now;
	int cost;
}data;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};

int gcd(int a, int b){
	int tmp = 0;

	while(b != 0){
		if(b < a){
			tmp = a;
			a = b;
			b = tmp;
		}
		b %= a;
	}
	return a;
}

int main(){
	int n, x;
	cin >> n >> x;
	int ans;
	for(int i = 0; i < n; i++){
		int in;
		cin >> in;
		if(i == 0) ans = abs(in-x);
		else ans = gcd(ans, abs(in-x));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in);) {
			
			StringBuilder sb = new StringBuilder();
			
			while(true) {
				int m = sc.nextInt();
				int f = sc.nextInt();
				int r = sc.nextInt();
				
				if(m == -1 && f == -1 && r == -1) break;
				
				if(m == -1 || f == -1) {
					sb.append("F\n");
					continue;
				}
				
				int total = m + f;
				
				if(80 <= total) {
					sb.append("A\n");
					continue;
				}
				if(65 <= total && total < 80) {
					sb.append("B\n");
					continue;
				}
				if(50 <= total && total < 65) {
					sb.append("C\n");
					continue;
				}
				if(30 <= total && total < 50) {
					if(50 <= r) {
						sb.append("C\n");
					} else {
						sb.append("D\n");
					}
					continue;
				}
				if(total < 30) {
					sb.append("F\n");
				}
			}
			
			System.out.print(sb.toString());
		}
	}
}


Measured memory_bytes: 26364
from _collections import deque

s = input()
stack = deque()
for i in range(len(s)):
    stack.append(s[i])
    while len(stack) > 1:
        x = stack.pop()
        y = stack.pop()
        if x == y:
            stack.append(x)
            stack.append(y)
            break
print(len(s) - len(stack))

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	ll N, M; cin >> N >> M;
	vll A(N); cin >> A; sort(begin(A), end(A));
	vector<Pl> dat(M);
	for (int i = 0; i < M; i++) {
		cin >> dat[i].second >> dat[i].first;
	}
	sort(rbegin(dat), rend(dat));
	int k = 0;
	for (int i = 0; i < M; i++) {
		int j = 0;
		while (j < dat[i].second && k < N && A[k] < dat[i].first) {
			A[k++] = dat[i].first; j++;
		}
	}
	cout << accumulate(begin(A), end(A), 0ll) << el;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
 using namespace  std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
const long double pi=3.1415926535897932384626433832;
const long long mod=1e9+7;
//long long primeset[5000000]={};
typedef complex<double> cd;
typedef long long ll;
//#define For(i,0,n) for(long long i = 0 ; i<n ;i++) 
cd fast_exp(cd a, long long b)
{
	if (b == 0)
		return 1;
	
	cd res = fast_exp(a, b / 2);
		
	res = res * res;
	
	if (b % 2 == 1)
		res = res * a;
	
	return res;
}

long long fastexpon(long long a,long long b,long long mod)
{
	if(b==0)
		return 1;
	
	long long res=fastexpon(a,b/2,mod);
	
	res=(res*res)%mod;
	if(b%2==1)
		res= (res * a)%mod;

	return res;
}



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,m;
	cin>>n>>m;
	int a[n+1][m+1];
	int maxdist=0;
	for(int i=1 ;i<=n ;i++)
	{
		for(int j=1 ; j<=m ; j++)
		{
			
			char c;
			cin>>c;
			if(c=='#')
				a[i][j]=1;
			else
				a[i][j]=0;

		}
	}

	int visited[n+1][m+1]={};
	int numvis=0;
	int tot=0;
	queue <pair<int,int>> q;
	for(int i=1 ; i<=n ;i++)
	{
		for(int j=1 ;j<=m ;j++)
		{
			if(a[i][j]==1)
			{
				q.push(mp(i,j));
				numvis++;
				visited[i][j]=1;
				tot++;
			}
		}
	}
	int time=0;
	int dirx[4]={0,0,-1,1},diry[4]={1,-1,0,0};
	int cur=0;
	int iter = 0;
	while(!q.empty())
	{
		
		pair<int,int> top = q.front();
		q.pop();

		for(int j=0 ; j<4 ;j++)
		{
			int y=top.ff+diry[j];
			int x=top.ss+dirx[j];

			if(1<=y && y<=n && 1<=x && x<=m)
			{
				if(visited[y][x]==0)
				{
					visited[y][x]=1;
					a[y][x]=1;
					cur++;
					numvis++;
					// cerr << "pushing " << y << " , " << x << "\n";
					q.push({y, x});
				}
			}
		}

		tot--;
		if(tot==0)
		{
			tot=cur;
			cur=0;
			time++;
		}		
		// cerr << "iteration " << iter++ << " top : " << top.ff << " " << top.ss << "\n";
	}
	
	--time;
	cout << time << "\n";

	//cout<<'\n'<<"time elapsed: "<<clock()*1000.0 / CLOCKS_PER_SEC<<" ms"<<'\n';
	return 0;
}

Measured memory_bytes: 16272
#include <stdio.h>

int main()
{
    int n,m,sub,min,max,add,rest;

    scanf("%d %d", &n,&m);

    add = n + m;

    if(n==m){
        printf("Yay!\n");
        return 0;
    }

    if(n<m){
        min = n;
        max = m;
    }
    else{
        min = m;
        max = n;
    }

    sub = max - min;

    rest = 16 - add;

    if(rest > 2*sub){
        printf("Yay!\n");
    }
    else{
        printf(":(\n");
    }

    return 0;
}


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

int main(){
    int A,B,C=0;
    cin >> A >> B;
    for(int i=A;i<=B;i++){
        if(( i/10000 == i%10 ) && ( i/1000%10 == i/10%10))
        C++;
    }
    cout << C <<endl;
}

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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
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; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define endl "\n"
#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007
//グリッドグラフの範囲チェック
bool range_validation(int y,int x,int h,int w){
    return y>=0 && y<h && x>=0 && x < w;
}
//ビットカウント
int popcount(long bits){
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int gcd(ll a, ll b){
  if(b == 0){
    return a;
  }else{
    return gcd(b,a%b);
  }
}

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);

  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  REP(i,n)cin >> h[i];

  vector<ll> dp(n,INF);

  dp[0] = 0;
  REP(i,n){
    FOR(j,1,k+1){
      if(i+j < n){
        chmin(dp[i+j],dp[i] + abs(h[i] - h[i+j]));
      }
    }
  }


  cout << dp[n-1] << endl;
  return 0;
}


Measured memory_bytes: 4512
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=1e5,inf=0x3f3f3f3f;
typedef int fuko[yuzu];
int n,m,cnt,s,t;
namespace maxflow{
fuko dep,head,cur;
struct edge{int to,next,f;}e[yuzu];

void add(int u,int v,int f){
e[cnt]=edge{v,head[u],f},head[u]=cnt++;
e[cnt]=edge{u,head[v],0},head[v]=cnt++;
}

int bfs(){
queue<int> q;
memset(dep,-1,sizeof dep);
dep[s]=0,q.push(s);
for (;!q.empty();){
  int i,u=q.front();q.pop();
  for (i=head[u];~i;i=e[i].next){
    int v=e[i].to;
    if (!~dep[v]&&e[i].f){
      dep[v]=dep[u]+1;
	  q.push(v);	
	  }
    }
  }return ~dep[t];
}

ll dfs(int u,int flow,ll tflow=0){
if (u==t||!flow) return flow;
for (int &i=cur[u];~i;i=e[i].next){
  int v=e[i].to;
  if (dep[v]==dep[u]+1){
    int nf=dfs(v,min(flow,e[i].f));
    e[i].f-=nf,e[i^1].f+=nf;
    tflow+=nf,flow-=nf;
    if (!flow) break;
    }
  }return tflow;
}

ll dinic(){
ll ans=0;
for (;bfs();ans+=dfs(s,inf)) memcpy(cur,head,sizeof cur);
return ans;
}

int main(){
  int i,j;ll sum=0;
  memset(head,-1,sizeof head);
  n=read(),s=n+1,t=n+2;
  for (i=1;i<=n;++i){
    int a=read();
	if (a>0) add(i,t,a),sum+=a;
	else add(s,i,-a);
    }
  for (i=1;i<=n;++i)
    for (j=i;j<=n;j+=i)
      add(i,j,inf);
  write(sum-dinic());
  }
}

int main(){
maxflow::main();
}

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

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
template<typename T> using vv = vector<vector<T>>;
template<typename T> using vvv = vector<vector<vector<T>>>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define siz(x) int((x).size())
#define pow2(x) (1ll << (x))
#define bit(x, n) ((x) >> (n) & 1)
#define prt(x) cout << (x) << endl
#define dbg(x) dbgn(#x, x)

template<typename T, typename U> inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U> inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }
template<typename T> inline void errv(T& v) { for (auto x: v) cerr << x << " "; cerr << endl; }
inline void errv(vb& v) { for (auto x: v) cerr << (x ? 1 : 0) << " "; cerr << endl; }
template<typename T> inline void dbgn(string n, T x) { cerr << n << ": " << x << endl; }
template<typename T> inline void dbgn(string n, vector<T>& v) { cerr << n << ": "; errv(v); }
template<typename T> inline void dbgn(string n, vv<T>& m) { cerr << n << ":" << endl; for (auto& v: m) errv(v); }


int main() {
    string s, t;
    cin >> s >> t;

    ll ans = 0;

    rep(i, siz(s) - siz(t) + 1) {
        ll cnt = 0;
        rep(j, siz(t)) {
            if (s[i + j] == t[j])
                cnt++;
        }
        umax(ans, cnt);
    }

    prt(siz(t) - ans);

    return 0;
}


Measured memory_bytes: 3624
import std;

long upper_bound(alias F)(size_t len) {
	long left = -1;
	long right = len;
	while (right - left > 1) {
		long mid = left + (right - left) / 2;
		bool succ = F(mid);
		if (succ) right = mid;
		else left = mid;
	}
	return right;
}

void main(){ 
	long x;
	scanf("%ld", &x);
	foreach(a;0L..6200L) {
		long a5 = pow(a, 5L);
		long bp = upper_bound!(idx => a5 - pow(idx, 5L) <= x)(6200L);
		if (a5 - pow(bp, 5L) == x) {
			writefln("%d %d", a, bp);
			return;
		}
		long bm = upper_bound!(idx => a5 + pow(idx, 5L) >= x)(6200L);
		if (a5 + pow(bm, 5L) == x) {
			writefln("%d %d", a, -bm);
			return;
		}
	}
}


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


int main()
{
    int n;
    std::cin >> n;
    std::vector<int> a(n), b(n);
    for(int i = 0; i < n; i++)std::cin >> a[i] >> b[i];
    std::map<std::pair<int,int>,int> map;

    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            map[{a[i] - a[j], b[i] - b[j]}]++;
            map[{a[j] - a[i], b[j] - b[i]}]++;
        }
    }
    int max = 0;
    for(auto i : map){
        max = std::max(i.second,max);
    }
    if(n == 1)std::cout << 1 << std::endl;
    else std::cout << n - max << std::endl;
    return 0;
}

Measured memory_bytes: 384
s=str(input())
n1=int(s[:2])
n2=int(s[2:])
if(1<=n1<=12 and 1<=n2<=12 ):
    print("AMBIGUOUS")
elif(1<=n1<=12):
    print("MMYY")
elif(1<=n2<=12):
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
const int N = 2e5 + 5, MOD = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, h[N], dp[N];

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin>>n;
    cout<<(n*(n - 1LL))/2LL;



    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
using namespace std;

typedef complex<double> P;
typedef vector<P> G;

const double eps = 1e-10;

double dot(P a, P b) { return a.real()*b.real() + a.imag()*b.imag(); }
double norm(P a) { return dot(a, a); }
double cross(P a, P b) { return a.real()*b.imag() - a.imag()*b.real(); }

int ccw(P p0, P a, P b) {
  a -= p0;
  b -= p0;
  if(cross(a, b) > eps) return 1;
  if(cross(a, b) < -eps) return -1;
  if(dot(a, b) < -eps) return 2;
  if(norm(a) < norm(b)) return -2;
  return 0;
}

P getCrossP(P a1, P a2, P b1, P b2) {
  P a = a2 - a1;
  P b = b2 - b1;
  return a1 + a * cross(b, b1 - a1)/cross(b, a);
}

G convex_cut(G ps, P p1, P p2, int dir = -1) {
  G v;
  for(int i = 0; i < ps.size(); ++i) {
    P a = ps[i];
    P b = ps[(i+1)%ps.size()];
    if(ccw(p1, p2, a) != dir) v.push_back(a);
    if(ccw(p1, p2, a)*ccw(p1, p2, b) == -1)
      v.push_back(getCrossP(a, b, p1, p2));
  }
  return v;
}

int main() {
  int n;
  while(cin >> n && n) {
    vector<G> g[2];
    {
      G tmp;
      tmp.push_back(P(-100,-100));
      tmp.push_back(P(100,-100));
      tmp.push_back(P(100,100));
      tmp.push_back(P(-100,100));
      g[0].push_back(tmp);
    }
    P a, b;
    for(int i = 0; i < n; ++i) {
      cin >> a.real() >> a.imag() >> b.real() >> b.imag();
      g[(i+1)%2].clear();
      for(int j = 0; j < g[i%2].size(); ++j) {
	G tmp;
	tmp = convex_cut(g[i%2][j], a, b, -1);
	if(tmp.size() >= 3) g[(i+1)%2].push_back(tmp);
	tmp = convex_cut(g[i%2][j], a, b, 1);
	if(tmp.size() >= 3) g[(i+1)%2].push_back(tmp);
      }
    }
    cout << g[n%2].size() << endl;
  }
  return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  if (b - a == c - b)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3616
#define _GLIBCXX_DEBUG
    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef pair<int, int> pii;
    typedef map<int, int> mii;
    typedef map<char,int> mci;
    typedef vector<int> vi;
    typedef vector<vi> vvi;
    typedef vector<ll> vll;
    typedef vector<pair<int,int>> vii;
    typedef vector<char> vc;
    typedef vector<vc> vcc;
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()
    #define pb push_back
    #define mp make_pair
    #define F first
    #define S second
    #define in insert
    #define sz(v) v.size()
    #define mina(a,b) (a)=min((a),(b));
    #define maxa(a,b) (a)=max((a),(b));
    const int INF = 1e9 + 5;
    
    void solve(){
        int a,b,ans; cin>>a>>b;
        if(a>=13) ans=b;
        else if(a>=6) ans=b/2;
        else ans=0;
        cout<<ans;
    }
    int main(){
        int T=1;
        //cin>>T;
        for(int i = 0; i < T; i++) solve(); 
    }

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

s = [t for t in range(1,N+1)]
for i in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    for i in range(len(A)):
        if A[i] in s:
            s.remove(A[i])
print(len(s))

Measured memory_bytes: 9080
#include<stdio.h>
#define N 100
int main(){
  int i,j,n,A[N],flag,a,b=0,m,minj,k;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }for(j=0;j<n;j++){
    minj=j;
    for(k=j;k<n ;k++){
      if(A[k]<A[minj]){
        minj=k;
      }
    }if(j!=minj){a=A[j];
    A[j]=A[minj];
    A[minj]=a;
    b++;
    }
  }for(m=0;m<n-1;m++){
    printf("%d",A[m]);
    printf(" ");
  }printf("%d\n",A[n-1]);
  printf("%d\n",b);
}



Measured memory_bytes: 2048
#include<stdio.h>
main()
{
    int i,n;
    int x=1;
    scanf("%d",&n);
    int arr[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
    }
    for(i=0;i<n;i++)
    {
        if(arr[i]%2==0&&arr[i]%5!=0&&arr[i]%3!=0)
        {
            x=0;
            break;
        }
    }
        if(x==1)
        printf("APPROVED");
        else if(x==0)
        printf("DENIED");
}

Measured memory_bytes: 128
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;
use std::collections::VecDeque;

const MOD:usize = 1e9 as usize + 7;

fn main() {
    input!{
      h: usize,
      w: usize,
      aa: [chars; h],
    }
    let mut dp = vec![vec![0; w+1]; h+1];
    dp[0][0] = 0;
    dp[0][1] = 1;
    dp[1][0] = 0;

    let mut q = VecDeque::new();
    q.push_back((1, 1));

    while let Some((x, y)) = q.pop_front() {
        if aa[x-1][y-1] == '#' {
            continue;
        }
        if dp[x][y] != 0 {
            continue;
        }
        dp[x][y] = (dp[x-1][y] + dp[x][y-1]) % MOD;

        if x+1 <= h {
            q.push_back((x+1, y));
        }
        if y+1 <= w {
            q.push_back((x, y+1));
        }
    }
    println!("{}", dp[h][w]);
}


Measured memory_bytes: 16636
n = int(input())
l = list(map(int,input().split()))
k = 0
p = 0
for i in l:
    if i < 0:
        k += 1

for i in l:
    p += abs(i)
if k % 2 ==0:
    print(p)
else:
    print(p-(2*min(list(map(abs,l)))))

Measured memory_bytes: 14332
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n,p; cin >> n >> p;
  int odd = 0, even = 0;
  rep(i,n){
    int a; cin >> a;
    even += a%2^1;
    odd += a%2;
  }
  if(even == n){
    if(p == 0) cout << (1ll<<n);
    else cout << 0;
  }else cout << (1ll<<n-1);
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int d; cin >> d;
    if(d == 25) cout << "Christmas" << endl;
    else if(d == 24) cout << "Christmas Eve" << endl;
    else if(d == 23) cout << "Christmas Eve Eve" << endl;
    else cout << "Christmas Eve Eve Eve" << endl;
}

Measured memory_bytes: 256
function Main(i) {
    var n = 0;
    i[0] == 1 ? n++ : null;
    i[1] == 1 ? n++ : null;
    i[2] == 1 ? n++ : null;
    console.log(n);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09 + 7;

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

  int w, a, b;
  cin >> w >> a >> b;

  int ans;
  if(b - (a + w) >= 0) ans = b - (a + w);
  else if(a - (b + w) >= 0) ans = a - (b + w);
  else ans = 0;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
int main(){
    string s;
    cin >> s;
    string pls;
    if(s[s.size()-1]=='s') {
        pls = "es";
    }
    else {
        pls = "s";
    }
    cout << s+pls << endl;
}


Measured memory_bytes: 3600