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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;

vvi f;
int h,w,c;

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

int dfs(int col, int num, const vvi &field)
{
    //BFS
    vvi vis(h,vi(w,0));
    //?????????????????????
    int lu=field[0][0];
    queue<pi> que;
    vis[0][0]=1;
    que.push(pi(0,0));
    while(!que.empty())
    {
        pi now=que.front();
        que.pop();
        rep(i,4)
        {
            int nx=now.se+dx[i], ny=now.fi+dy[i];
            if(0<=nx&&nx<w && 0<=ny&&ny<h)
            {
                if(!vis[ny][nx] && field[ny][nx]==lu)
                {
                    vis[ny][nx]=1;
                    que.push(pi(ny,nx));
                }
            }
        }
    }

    //????????????
    vvi nf(field);
    rep(i,h)rep(j,w)
    {
        if(vis[i][j]) nf[i][j]=col;
    }

    int ret=0;
    if(num==6)
    {
        //???????????????
        int ct=0;
        rep(i,h)rep(j,w) ct+=vis[i][j];
        return ct;
    }
    else if(num==5)
    {
        //???????????????
        //???????????§dfs
        ret=max(ret,dfs(col,num+1,nf));
    }
    else if(num==4)
    {
        //????????????c??????????????¨????????????
        ret=max(ret,dfs(c,num+1,nf));
    }
    else
    {
        //?¬???????????????¶
        for(int i=1; i<=6; ++i)
        {
            //????????????????§?
            if(i==col) continue;

            ret=max(ret,dfs(i,num+1,nf));
        }
    }

    return ret;
}

int main()
{
    while(scanf(" %d %d %d",&h,&w,&c),h|w|c)
    {
        f=vvi(h,vi(w));
        rep(i,h)rep(j,w) scanf(" %d", &f[i][j]);

        int ans=0;
        for(int i=1; i<=6; ++i) ans=max(ans,dfs(i,1,f));

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

Measured memory_bytes: 3248
#https://qiita.com/masashi127/items/88436e16e3672b387a58
#--------------------------------------------
import math

def sieve_of_erastosthenes(num):
    input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0  else True for i in range(num)]
    input_list[0] = input_list[1] = False
    input_list[2] = input_list[3] = input_list[5] = True
    sqrt = math.sqrt(num)

    for serial in range(3, num, 2):

        if serial >= sqrt:
            return input_list

        for s in range(serial ** 2, num, serial): 
            input_list[s] = False

n=100000
input_list = sieve_of_erastosthenes(n)
prime_list = [i for i, b in enumerate(input_list) if b == True]
#print(prime_list)
#print(sum(prime_list))

#--------------------------------------------

count=[0 for i in range(100002)]
for i in prime_list:
  count[i]=1
#print(count)

nitakazu_count=[0 for i in range(50001)]
for i in range(50001):
  if count[2*i+1]==1 and count[i+1]==1:
    nitakazu_count[i]=1
  
  
ruiseki_count=[0 for i in range(50001)]
for i in range(50000):
  ruiseki_count[i+1]=ruiseki_count[i]+nitakazu_count[i+1]
#print(ruiseki_count)

nn=int(input())

for i in range(nn):
  aa,bb=[int(i) for i in input().split()]
  print(ruiseki_count[int((bb-1)/2)]-ruiseki_count[max(int((aa-1)/2)-1,0)])





Measured memory_bytes: 7396
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef unsigned int uint;
typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

const int MX = 5005;
const int MM = 1000000007;

ll dp[MX][MX];
ll F[MX*2], I[MX*2], FI[MX*2], C[MX];
int cnt[MX];
vector<int> T[MX];
int N;

int dfs(int x, int p){
	int tdp[MX] = {};
	cnt[x] = 1;
	dp[x][1] = 1;
	for(int c : T[x]){
		if(c == p) continue;
		dfs(c, x);
		for(int i = 0; i <= cnt[x] + cnt[c]; i++) tdp[i] = 0;
		for(int i = 0; i <= cnt[x]; i++){
			for(int j = 0; j <= cnt[c]; j++){
				tdp[i+j] = (tdp[i+j] + dp[x][i] * dp[c][j]) % MM;
				if(j%2 == 0){
					tdp[i] = (tdp[i] + MM - dp[x][i] * dp[c][j] % MM * C[j/2] % MM) % MM;
				}
			}
		}
		for(int i = 0; i <= cnt[x] + cnt[c]; i++) dp[x][i] = tdp[i];
		cnt[x] += cnt[c];
	}
}

int main()
{
	scanf("%d", &N);
	F[0] = I[1] = FI[1] = 1;
	for(int i = 1; i <= 2*N; i++) F[i] = F[i-1] * i % MM;
	for(int i = 2; i <= 2*N; i++){
		I[i] = (MM - MM/i) * I[MM%i] % MM;
		FI[i] = FI[i-1] * I[i] % MM;
	}
	ll m = 1;
	for(int i = 1; i <= N; i++){
		m = I[2] * m % MM;
		C[i] = F[i*2] * FI[i] % MM * m % MM;
	}
	for(int i = 1; i < N; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		T[a].push_back(b);
		T[b].push_back(a);
	}
	dfs(1, -1);
	ll ans = 0;
	for(int i = 2; i <= N; i++) ans = (ans + dp[1][i] * C[i/2]) % MM;
	printf("%lld\n", ans);
}


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

int main()
{
  int a;
  std::cin >> a;
  
  std::vector<int> v;
  while(std::find(v.begin(), v.end(), a) == v.end())
  {
    v.push_back(a);
    if(a % 2 == 0)
    {
      a /= 2;
    }
    else
    {
      a = a * 3 + 1;
    }
  }
  std::cout << (static_cast<int>(v.size()) + 1) << std::endl;
  return 0;
}

Measured memory_bytes: 256
program flip
  implicit none
  integer :: n, m, k, i, j
  read(*,*) n, m, k
  do i = 0, n
    j = 0
    if (n-2*i.ne.0) j = (k-i*m)/(n-2*i)
    if ((j.ge.0).and.(j.le.m).and.(j*(n-i)+(m-j)*i.eq.k)) then
      write(*,'(a)') "Yes"
      stop
    end if
  end do
  write(*,'(a)') "No"
  stop
end program flip

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

void initialize();
int isEmpty();
int isFull();
void push(int);
int pop(void);

int stack[MAX];
int top;

int main(){
  int i=1;
  int a,b,x;
  char s[100];

  while(scanf("%s", s) != EOF){
   
    if(s[0] == '+'){
      push(pop()+pop());
    }
    else if(s[0] == '-'){
      a=pop();
      b=pop();
     push(b-a);
    }
    else if(s[0] == '*'){
     push(pop()*pop());
    }
    else{
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",stack[1]);
  return 0;
}

void initialize(){
  top = 0;
}

int isEmpty(){
  if(top==0) return 0;
  else return 1;
}

int isFull(){
  if(top >= MAX - 1) return 0;
  else return 1;
}

void push(int x){
  if(isFull()==0) {printf("error\n");
 
  }
  else{
    top++;
    stack[top] = x;
  }
}

int pop(void){
  if(isEmpty()==0) {
    printf("error\n");
    return 1;
  }
  else{
    top--;
    return stack[top+1];
  }
}




Measured memory_bytes: 2056
#include<bits/stdc++.h>
using namespace std;
int main(){
	string x,y="CODEFESTIVAL2016";
	cin>>x;
	int s=16;
	for(int i=0;i<y.size();i++){
		if(x[i]==y[i])
		--s;
	}
	cout<<s;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
const int MAXN = 100000;
ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a % b);
}
void get(ll &a, ll &b) {
	ll d = gcd(a, b);
	a /= d, b /= d;
}
ll ans1, ans2;
void update(ll a, ll b) {
	get(a, b);
	if( 1.0*ans1/ans2 < 1.0*a/b )
		ans1 = a, ans2 = b;
}
struct node{
	int A, B, C;
	friend bool operator < (node a, node b) {
		return a.C < b.C;
	}
}a[MAXN + 5];
ll sum[MAXN + 5], SA;
int main() {
	int N; scanf("%d", &N);
	for(int i=1;i<=N;i++)
		scanf("%d%d", &a[i].A, &a[i].B), a[i].C = max(a[i].A, a[i].B);
	sort(a + 1, a + N + 1);
	for(int i=N;i>=1;i--)
		sum[i] = sum[i + 1] + a[i].C, SA += a[i].A;
	ans1 = 0, ans2 = 1;
	for(int i=1;i<=N;i++) {
		if( SA - (sum[1] - a[i].C) > a[i].B )
			continue;
		int le = 1, ri = N + 1;
		while( le < ri ) {
			int mid = (le + ri + 1) >> 1;
			if( mid <= i ) {
				if( SA - (sum[mid] - a[i].C) <= a[i].B ) le = mid;
				else ri = mid - 1;
			}
			else {
				if( SA - sum[mid] <= a[i].B ) le = mid;
				else ri = mid - 1;
			}
		}
		if( le <= i ) {
			if( SA - (sum[le] - a[i].C) <= a[i].B && SA - (sum[le] - a[i].C) >= 0 )
				update(1LL*le*a[i].B - (SA - (sum[le] - a[i].C)), 1LL*N*a[i].B);
		}
		else  {
			if( SA - sum[le] <= a[i].B && SA - sum[le] >= 0 )
				update(1LL*(le-1)*a[i].B - (SA - sum[le]), 1LL*N*a[i].B);
		}
	}
	printf("%lld %lld\n", ans1, ans2);
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

const long double PI=(long double)acos(-1);

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    long double a,b,h,m;
    cin >> a >> b >> h >> m;
    long double x = (double)30*h + 1.0*m/2;
    long double y = (double)m*6;
    // if ( x>=360 ) {
    //     x-=360;
    // }
    // if ( y>=360 ) {
    //     y-=360;
    // }
    long double z;
    if ( x>y ) {
        z=x-y;
    } else {
        z=y-x;
    }
    // if ( z>180 ) {
    //     z-=180;
    // }
    // cout << x << ' ' << y << ' ' << z << endl;
    long double ans=a*a + b*b - 2*a*b*cos(z*PI/180);
    ans=sqrt(ans);
    cout << fixed << setprecision(18) << ans << endl;
    return 0;
}

Measured memory_bytes: 4172
#include<stdio.h>

int binarySearch(int [],int,int);

int main()
{
  int S[100000],key,n,q,i,c=0;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&S[i]);
    }
  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d",&key);
      if(binarySearch(S,n,key)!=0)c++;
    }
  printf("%d\n",c);

  return 0;
}

int binarySearch(int S[],int n,int key)
{
  int left=0,right=n,mid;
  while(left<right)
    {
      mid=(left+right)/2;
      if(S[mid]==key)return mid;
      else if(key<S[mid])right=mid;
      else left=mid+1;
    }
  return 0;
}

Measured memory_bytes: 992
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N = int(sys.stdin.buffer.readline())
A = list(map(int, sys.stdin.buffer.readline().split()))

c = 0
for a in A:
    c += a & 1
if c % 2 == 0:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 56816
def resolve():
    h, w = map(int, input().split())
    s = [list(input()) for i in range(h)]
    L= [[0 for i in range(w)] for j in range(h)]
    M= [[0 for i in range(w)] for j in range(h)]
    bom=0
    a=[]
    ans=0
    for  i in range(h):
        for j in range(w):
            if s[i][j]==".":
                bom += 1
                a.append(j)
            else:
                for k in a:
                    L[i][k]=bom
                bom=0
                a=[]
        for k in a:
            L[i][k] = bom
        bom=0
        a=[]
    for j in range(w):
        for i in range(h):
            if s[i][j]==".":
                bom += 1
                a.append(i)
            else:
                for k in a:
                    M[k][j]=bom
                bom=0
                a=[]
        for k in a:
            M[k][j] = bom
        bom=0
        a=[]

    for i in range(h):
        for j in range(w):
            ans=max(ans,L[i][j]+M[i][j]-1)
    print(ans)
resolve()

Measured memory_bytes: 248712
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = [0] + list(map(int, input().split()))
    B = [0] * (n + 1)
    res = []

    for i in reversed(range(1, n + 1)):
        if B[i] % 2 != A[i]:
            res.append(i)
            for j in range(1, int(pow(i, 0.5)) + 1):
                if i % j == 0:
                    B[j] += 1
                    if j != i // j:
                        B[i // j] += 1

    print(len(res))
    if len(res) != 0:
        print(*res[::-1])


def resolve2():
    n = int(input())
    A = [0] + list(map(int, input().split()))
    B = [0] * (n + 1)

    for i in reversed(range(1, n + 1)):
        cnt = 0
        for j in range(i, n + 1, i):
            cnt += B[j]
        if cnt % 2 != A[i]:
            B[i] += 1

    print(sum(B))
    if sum(B) != 0:
        print(*[i for i, ball in enumerate(B) if ball])


if __name__ == '__main__':
    resolve2()


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

struct Card{char suit, value;};

void bubble(struct Card A[], int N){
    for(int i = 0; i < N; i++){
        for(int j = N - 1; j >= i; j--){
            if(A[j].value < A[j - 1].value){
                Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
            }
        }
    }
}

void selection(struct Card A[], int N){
    for(int i = 0; i < N; i++){
        int minj = i;
        for( int j = i; j < N; j++){
            if(A[j].value < A[minj].value) minj = j;
        }
        Card t = A[i]; A[i] = A[minj]; A[minj] = t;
    }
}

void print(struct Card A[], int N){
    for(int i = 0; i < N; i++){
        if(i > 0)cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

//バブルソートと選択ソートの結果を比較
bool isStable(struct Card C1[], struct Card C2[], int N){
    for(int i = 0; i < N; i++){
        if(C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main(){
    int N;
    cin >>N;
    Card C1[N], C2[N];
    for(int i = 0; i < N; i++){
        cin >>C1[i].suit >>C1[i].value;
    }

    for(int i = 0; i < N; i++)C2[i] = C1[i];

    bubble(C1, N);
    selection(C2, N);

    print(C1,N);
    cout << "Stable" << endl;
    print(C2, N);
    cout << (isStable(C1, C2, N) ? "Stable" : "Not stable") << endl;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int main(){
	string s;
	cin >> s;
	int sz = s.size()-8;
	cout << s.substr(0,sz) << endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<utility>
#include<map>
#include<climits>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
#include<cmath>
#include<iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<int,P>MP;
typedef vector<vector<int>> MX;

const ll MOD=1e9+7;
const int INF = 1000000000;


int main()
{
	int N,M;
	vector<int>X;
	priority_queue<int>Q;
	cin>>N>>M;
	vector<int>MP(M,INF);
	for(int i=0;i<M;i++)
	{
		int t;
		cin>>t;
		X.push_back(t);
	}
	sort(X.begin(),X.end());
	for(int i=0;i<M-1;i++)
	{
		Q.push(abs(X[i]-X[i+1]));
	}
	for(int i=0;!Q.empty()&&i<(N-1);i++)Q.pop();

	int res=0;
	while(!Q.empty())
	{
		int t=Q.top();Q.pop();
		res+=t;
	}
	cout<<res<<endl;
	

}




Measured memory_bytes: 4588
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <deque>
#include <set>
#include <numeric>
using namespace std;
using ll = long long;
using ld = long double;

const ll MOD = 998244353;
const ld PI = acos((long double)(-1));

#define no "no"
#define No "No"
#define NO "NO"
#define yes "yes"
#define Yes "Yes"
#define YES "YES"
#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(elem, _list) for(auto& (elem) : (_list))
#define view(_list) foreach(e, _list){ cout << e << sp; } cout << next
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define ALL(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e)
#define INF 1e+9
#define EPS 0.00000001

int main() {
    ll a;
    string sb, ssb;
    cin >> a >> sb;
    rep(i, size(sb)){
        if(sb[i] != '.') {
            ssb += sb[i];
        }
    }

    ll ans = (a * stoi(ssb)) / 100;
    println(ans);
}


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

namespace ConsoleApp1
{
    public class node {
        public int parent = -1;
        public int depth = 0;
        public int height = 0;
        public int numChildren = 0;
        public int brother = -1;
        public string nodeType;
        public List<int> children = new List<int>();
    }
    class Program
    {
        static void SetDepth(node[] nodes, int id)
        {
            for (int i = 0; i < nodes[id].children.Count; i++)
            {
                nodes[nodes[id].children[i]].depth = nodes[id].depth + 1;
                SetDepth(nodes, nodes[id].children[i]);
            }
        }
        static void SetHeight(node[] nodes, int height, int parent)
        {
            nodes[parent].height = Math.Max(nodes[parent].height, height + 1);
            if (nodes[parent].parent != -1) SetHeight(nodes, height + 1, nodes[parent].parent);
        }
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            node[] nodes = new node[n];
            for (int i = 0; i < n; i++) nodes[i] = new node();
            for (int i = 0; i < n; i++)
            {
                var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
                var id = a[0];
                var left = a[1];
                var right = a[2];
                if (left != -1)
                {
                    nodes[id].children.Add(left);
                    nodes[id].numChildren++;
                    nodes[left].parent = id;
                }
                if (right != -1)
                {
                    nodes[id].children.Add(right);
                    nodes[id].numChildren++;
                    nodes[right].parent = id;
                }
                if (left != -1 && right != -1)
                {
                    nodes[left].brother = right;
                    nodes[right].brother = left;
                }
            }
            for (int i = 0; i < n; i++)
            {
                if (nodes[i].parent == -1)
                {
                    nodes[i].nodeType = "root";
                    SetDepth(nodes, i);
                }
                else if (nodes[i].children.Count != 0)
                {
                    nodes[i].nodeType = "internal node";
                }
                else
                {
                    nodes[i].nodeType = "leaf";
                }
            }
            if(n > 1)
                for (int i = 0; i < n; i++)
                {
                    if (nodes[i].numChildren == 0) SetHeight(nodes, 0, nodes[i].parent);
                }

            for (int i = 0; i < n; i++)
            {
                Console.WriteLine("node {0}: parent = {1}, sibling = {2}, degree = {3}, depth = {4}, height = {5}, {6}", i, nodes[i].parent, nodes[i].brother, nodes[i].numChildren, nodes[i].depth, nodes[i].height, nodes[i].nodeType);
            }
        }
    }
}



Measured memory_bytes: 18424
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int N, D;
	cin >> N >> D;
	vector<vector<int>>co(N, vector<int>(D));
	for (int i = 0;i < N;++i) {
		for (int j = 0;j < D;++j) {
			cin >> co[i][j];
		}
	}
	int ans = 0;
	for (int i = 0;i < N;++i) {
		for (int j = i + 1;j < N;++j) {
			int sq = 0;
			for (int k = 0;k < D;++k) {
				int sum = abs(co[i][k] - co[j][k]);
				sq += sum * sum;
			}
			for (int k = 0;k <= sq;++k) {
				if (k * k == sq) {
					++ans;
				}
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int *tree[100001];

int main(void) {

  int n,m;
  scanf("%d %d", &n, &m);
  int p[n+1];
  for (int i = 1; i <= n; i++) {
    scanf("%d", &p[i]);
  }
  int tree_s[n+1];
  for (int i = 1; i <= n; i++) {
    tree_s[i] = 0;
  }
  int x,y;
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &x, &y);
    tree_s[x]++;
    tree[x] = realloc(tree[x], sizeof(int)*(tree_s[x]+1));
    tree[x][tree_s[x]] = y;
    tree_s[y]++;
    tree[y] = realloc(tree[y], sizeof(int)*(tree_s[y]+1));
    tree[y][tree_s[y]] = x;
  }
  int vertice[n+1];
  vertice[1] = 1;
  for (int i = 2; i <= n; i++) {
    vertice[i] = 0;
  }
  int visited[n+1];
  visited[1] = 1;
  for (int i = 2; i <= n; i++) {
    visited[i] = 0;
  }
  int head = 1;
  int tail = 1;
  int tail_cur = 1;

  int group = 1;
  int group_head = 1;
  int cur,next;
  int flag;

  while (1) {
    flag = 0;
    for (int i = head; i <= tail; i++) {
      cur = visited[i];
      for (int j = 1; j <= tree_s[cur]; j++) {
        next = tree[cur][j];
        if (vertice[next] != 0) {
          continue;
        }
        vertice[next] = group;
        tail_cur++;
        visited[tail_cur] = next;
        flag = 1;
      }
    }
    if (flag == 0) {
      for (int i = group_head+1; i <= n; i++) {
        if (vertice[i] == 0) {
          group++;
          vertice[i] = group;
          tail_cur++;
          visited[tail_cur] = i;
          group_head = i;
          break;
        }
      }
    }
    head = tail+1;
    tail = tail_cur;
    if (tail >= n) {
      break;
    }
  }
  int answer = 0;
  for (int i = 1; i <= n; i++) {
    if (vertice[p[i]] == vertice[i]) {
      answer++;
    }
  }
  printf("%d\n", answer);

  return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define maxn 100000
#define INF 99999999
int n, mn = INF, mx, cnt, a[maxn], b[maxn];

int read()
{
    int x = 0, k = 1;
    char c; c = getchar();
    while(c < '0' || c > '9') { if(c == '-') k = -1; c = getchar(); }
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c= getchar();
    return x * k;
}

int main()
{
    n = read();
    for(int i = 1; i <= n; i ++)
    {
        a[i] = read();
        mn = min(mn, a[i]), mx = max(mx, a[i]);
    }
    for(int i = 1; i <= n; i ++)
        if(a[i] == mn) cnt ++;
    if(cnt != (mx & 1) + 1) { printf("Impossible\n"); return 0; }
    for(int i = 1; i <= n; i ++) b[a[i]] ++;
    for(int i = mn + 1; i <= mx; i ++)
        if(b[i] < 2) { printf("Impossible\n"); return 0; }
    printf("Possible\n");
    return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  
  int numlane,numdata,i,swap;

  int lane[30];
  int data[2];

  scanf("%d",&numlane);
  scanf("%d",&numdata);
  
  for(i = 0; i < numlane; i++){
    lane[i] = i + 1;
  }

  for(i = 0; i < numdata; i++){
    scanf("%d,%d",&data[0],&data[1]);
    swap = lane[data[0] - 1];
    lane[data[0] - 1] = lane[data[1] - 1];
    lane[data[1] - 1] = swap;
  }

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

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    vector<int> l(n);
    vector<int> m(n-1);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }
    for(int i = 0; i < n-1; i++){
        cin >> m[i];
    }

    long ans = 0;
    long tmp = -10;
    for(int i = 0; i < n; i++){
        if(tmp+1 == v[i]){
            ans += m[tmp-1];
        }
        ans += l[v[i]-1];
        tmp = v[i];
        //cout << ans << endl;
    }

    cout << ans << endl;




}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ST first
#define ND second
#define ll long long
#define ld long double
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using namespace std;

const ll  INF = 1e9 + 9;
const ll  MOD = 1e9 + 7;
const long long LINF = (ll)1e18 + 3;
 
// secik.insert({x, t++});
// secik.erase(secik.lower_bound({x,-1}));
// *secik.find_by_order(x)).first << "\n";
// secik.order_of_key(x)
 
//random_device device;
//mt19937 gener(device());
//uniform_int_distribution<ll > gen(0,n-1);
//gen(gener); // generate random number

const int SIZE = 5e5 + 5;
ll fact[SIZE];

ll pot(ll a, ll wyk){
	if(wyk == 0) return 1;
	if(wyk % 2) return (a * pot(a,wyk-1)) % MOD;
	ll tmp = pot(a,wyk/2);
	return (tmp*tmp) % MOD;
}

ll inv(ll x){
	return pot(x,MOD-2);
}

ll npoka(ll x, ll y){
	return (((fact[x] * inv(fact[y])) % MOD) * inv(fact[x-y])) % MOD;
}

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

	ll n,m; cin >> n >> m;
	fact[0] = 1;
	for(ll i = 1; i < SIZE; i++) fact[i] = (fact[i-1] * i) % MOD;
	
	ll res = (fact[n] * fact[n]) % MOD;
	res = ((res * npoka(m,n)) % MOD * npoka(m,n)) % MOD;

	//cout << res << endl;

	if(res < 0) res += MOD;

	for(ll i = 1; i <= n; i++){
		ll pom = 0;
		pom = npoka(m,i);
		pom = (pom * npoka(n,i)) % MOD;
		pom = (pom * fact[i]) % MOD;
		pom = (pom * npoka(m-i,n-i)) % MOD;
		pom = (pom * npoka(m-i,n-i)) % MOD;
		pom = (pom * fact[n-i]) % MOD;
		pom = (pom * fact[n-i]) % MOD;
		if(pom < 0) pom += MOD;
		if(i % 2 == 0){
			res = (res + pom) % MOD;
		} else {
			res = (res - pom) % MOD;
		}
	}

	res = res % MOD;
	if(res < 0) res += MOD;

	cout << res;




	
}

Measured memory_bytes: 7528
A, B, K = map(int, input().split())
for i in range(K):
  if i % 2 == 0:
    if A % 2 == 1:
      A -= 1
    B += A // 2
    A //= 2
  else:
    if B % 2 == 1:
      B -= 1
    A += B // 2
    B //= 2
print(A, B)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args){
        PrintWriter out = new PrintWriter(System.out);
        FastScanner sc = new FastScanner();

        long W = sc.nextLong();
        long H = sc.nextLong();
        long x = sc.nextLong();
        long y = sc.nextLong();

        long A = W * H;
        double ans = ((double) A) / 2;
        int flag = (W == x * 2) && (H == y * 2) ? 1 : 0;

        out.printf("%f %d\n", ans, flag);

        out.flush();
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }

        int[] nextIntArray(int N) {
            int a[] = new int[N];
            for (int i=0;i<N;i++) {
                a[i] = this.nextInt();
            }

            return a;
        }

        long[] nextLongArray(int N) {
            long a[] = new long[N];
            for (int i=0;i<N;i++) {
                a[i] = this.nextLong();
            }

            return a;
        }

        double[] nextDoubleArray(int N) {
            double a[] = new double[N];
            for (int i=0;i<N;i++) {
                a[i] = this.nextDouble();
            }

            return a;
        }

        String[] nextTokenArray(int N) {
            String a[] = new String[N];
            for (int i=0;i<N;i++) {
                a[i] = this.nextToken();
            }

            return a;
        }
    }
}

Measured memory_bytes: 21204
#include <iostream>
using namespace std;
int main()
{
  int n,ans;
  string str;
  cin>>n>>str;
  ans=n;
 
  for(int i=0;i<n-1;i++){
    if(str[i]==str[i+1])ans--;
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 512
import java.util.*

fun main(args: Array<String>) {
    val (A, B) = readLine()!!.split(" ").map { it.toInt() }
    if (A > 0 && A <= 9 && B > 0 && B <= 9 ) {
        print(A * B)
    } else {
        print(-1)
    }
}


Measured memory_bytes: 37824
=begin
N
X1 ... Xn
=end

n = gets.chomp.to_i
xs = gets.chomp.split(" ").map(&:to_i)

xs.sort!

min = xs[0]
max = xs[-1]

score = (100 * 100) * 100 * 10

(min..max).each do |i|
  s = 0

  xs.each do |x|
    s = s + (x - i) * (x - i)
  end

  if score > s
    score = s
  end
end

puts score


Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
//#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


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

  
  int h,w;
  cin>>h>>w;
  set<PII> st;
  multiset<int> x;
  rep(i,w){
    st.insert(make_pair(i+1,i+1));
    x.insert(0);
  }
  st.insert({-1,(-1)*INF});
  x.insert(INF);
  st.insert({w+1,w+1});
  rep(i,h){
    int a,b,p;
    cin>>a>>b;
    while(1){
      auto itr=st.lower_bound({a,0});
      if(itr->F > b) break;
      if(next(itr)->F <= b+1){
	x.erase(x.find(itr->F - itr->S));
	st.erase(itr);
      }else{
	p=itr->S;
	x.erase(x.find(itr->F - itr->S));
	st.erase(itr);
	st.insert({b+1,p});
	x.insert({b+1-p});
      }
    }
    p=(*x.begin())+i+1;
    if(p>=h+w) p=-1;
    cout<<p<<endl;
  }
		  

  return 0;
}


Measured memory_bytes: 22380
//
//  sublime text 3,
//  emre yazicioglu
//

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;
typedef vector <ll> vll;
typedef vector <pll> vpll;
#define pb push_back
#define fi first
#define se second
#define INF (ll) (1e18 + 7)
#define MOD (ll) (1e9 + 7)

const int N = 2e6 + 7;
ll mn = INF, mx = -INF;
ll n, m, k, s, q, t;
ll a, b, c, d, e;
ll ans, cur, sum, cnt;
ll ar[N], p[N], dp[N];
string str; bool h[N];
pll pp[N]; vll v;

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

  // freopen("../in.txt","r",stdin);
  // freopen("../out.txt","w",stdout);

  cin >> n;
  cout << n * n * n;

}

Measured memory_bytes: 2304
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


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

class ERedAndGreenApples {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll x,y,a,b,c;
        in >> x >> y >> a >> b >> c;
        vector<pair<int,string>> al(a+b+c);
        rep(i,a+b+c){
            in >> al[i].first;
            if(i<a){
                al[i].second="r";
            }else if(i<a+b){
                al[i].second="g";
            }else{
                al[i].second="c";
            }
        }
        sort(al.begin(),al.end(),greater<pair<int,string>>());
        vector<pair<int,string>> ans;
        int i=0;
        int r=0,g=0;
        while(ans.size()<x+y){
            if(al[i].second=="r"){
                if(r<x){
                    ans.push_back(al[i]);
                    r++;
                }
            }else if(al[i].second=="g"){
                if(g<y){
                    ans.push_back(al[i]);
                    g++;
                }
            }else{
                ans.push_back(al[i]);
            }
            i++;
        }
        ll ret=0L;
        rep(k,x+y){
            ret+=ans[k].first;
        }
        out << ret << endl;
	}
};


int main() {
	ERedAndGreenApples solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 24688
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007
int gsu(int val) {
	int ret = 0;
	while(val) {
		ret+=val%10;
		val/=10;
	}
	return ret;
}
void solve(int test_case) {//221
	int n,a,b;
	cin>>n>>a>>b;
	ll sum = 0;
	REP(i,1,n) {
		int gs = gsu(i);
		if(gs>=a&&gs<=b)sum+=i;
	}
	cout<<sum;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3612
// author: gary
// 2018/04/07 14:05:39
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) ( (int) (x).size() )
typedef pair<int, int> pii;
typedef long long ll;
template<class T> bool cmax(T& a, T b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool cmin(T& a, T b) { if(a > b) { a = b; return true; } return false; }


const int N = 55;

struct data {
  int a, b, c;
};

int dist[N][N][N];
queue<data> q;

void check(int a, int b, int c, int d) {
  if(a >= N || b >= N || c >= N || a < 0 || b < 0 || c < 0) {
    return;
  }
  if(dist[a][b][c] != -1) {
    return;
  }
  dist[a][b][c] = d;
  q.push({a, b, c});
}

int main() {
  int a, b, c;
  while(cin >> a >> b >> c) {
    memset(dist, -1, sizeof dist);
    check(a, b, c, 0);

    while(!q.empty()) {
      data p = q.front();
      q.pop();
      int a = p.a, b = p.b, c = p.c;
      int d = dist[p.a][p.b][p.c];
      if(a == b && b == c) {
        printf("%d\n", d);
        break;
      }
      check(a - 1, b, c, d + 1);
      check(a + 2, b, c, d + 1);

      check(a, b - 1, c, d + 1);
      check(a, b + 2, c, d + 1);

      check(a, b, c - 1, d + 1);
      check(a, b, c + 2, d + 1);
    }
  }
  return 0;
}


Measured memory_bytes: 896
using System;
using System.Linq;

namespace ABC047
{
    class Program
    {
        static void Main(string[] args)
        {
            var abc = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

            var children = new int[2];
            foreach (var pack in abc.OrderByDescending(i => i))
            {
                if (children[0] < children[1])
                {
                    children[0] += pack;
                }
                else
                {
                    children[1] += pack;
                }
            }

            var result = children[0] == children[1]
                ? "Yes" : "No";

            Console.Write(result);
        }
    }
}


Measured memory_bytes: 3160
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n-2):
    if (p[i] < p[i+1] and p[i+1] < p[i+2]) or (p[i] > p[i+1] and p[i+1] > p[i+2]):
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
typedef tree<string,null_type,less<string>,rb_tree_tag,tree_order_statistics_node_update> indexed_set2;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);

int main()
{    
    ll x;
    cin>>x;
    if(x >= 30) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

int main() {
  string S;
  cin >> S;
  
  string d[4] = {"dream", "dreamer", "erase", "eraser"};
  reverse(S.begin(), S.end());
  for(int i=0; i<4; i++){reverse(d[i].begin(), d[i].end());}
  
  bool can = true;
  
  for(int i=0; i<S.size(); ){
    bool can2 = false;
    for(int j=0; j<4; j++){
      if(S.substr(i,d[j].size()) == d[j]){
        i += d[j].size();
        can2 = true;
        break;
      }
    }
    if(!can2){
      can = false;
      break;
    }
    
  }
  if(can) cout << "YES" << endl;
  else cout << "NO"<< endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <numeric>

//#include <map>

using namespace std;

class HW{
public:
	int H, W;
};

int main()
{
	vector<HW> vData;

	while (1)
	{
		int H, W;
		cin >> H >> W;
		if (H == 0 && W == 0)break;

		HW thw;
		thw.H = H;
		thw.W = W;
		vData.push_back(thw);
	}

	for (int i = 0; i < vData.size(); i++)
	{
		int H, W;
		H = vData.at(i).H;
		W = vData.at(i).W;
		for (int y = 0; y < H; y++)
		{
			for (int x = 0; x < W; x++)
			{
				char ch;
				(y % 2 == 0) ? (x % 2 == 0) ? ch = '#' : ch = '.' : (x % 2 == 0) ? ch = '.' : ch = '#';
				cout << ch;
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int MAXN = 1e5  + 10;
long long dp[MAXN];
long long W[120], V[120];

int main() {
	int n, w;
	cin >> n >> w;
	for (int i = 1; i <= n; i++) {
		cin >> W[i] >> V[i];
	}
	
	for (int i = 0; i <= 100000; i++) {
		dp[i] = INF;
	}
	dp[0] = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 100000; j >= 0; j--) {
			if (j - V[i] >= 0 && dp[j - V[i]] + W[i] <= w) {
				dp[j] = min(dp[j], dp[j - V[i]] + W[i]);
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= 100000; i++) {
		if (dp[i] <= w) {
			ans = i;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
//              _      _                 
//             (_)    | |                
//    _ __ ___  _  ___| |__   __ _  ___  
//   | '_ ` _ \| |/ __| '_ \ / _` |/ _ \ 
//   | | | | | | | (__| | | | (_| | (_) |
//   |_| |_| |_|_|\___|_| |_|\__,_|\___/ 
//                                       
// 
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
/*#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
using namespace std;
const int MAX=1e6+5;
int tab[MAX];
int32_t main()
{
  BOOST;
  int ans=0;
  int n,k;
  cin>>n>>k;
  for (int i=1;i<=n;i++)cin>>tab[i];
  sort(tab+1,tab+n+1);
  for (int i=1;i<=k;i++)ans+=tab[i];
  cout<<ans;
  return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>

typedef long long ll;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

int main(){

    ll n,m;
    cin>>n>>m;

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

    sort(a.begin(),a.end());

    if((double)a[n-m]>=(sum/(double)(m*4))){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<pair<int,int>>>;
#define MOD 1000000007
#define INF 1000000000

int main(){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll x=max<ll>({a*c,a*d,b*c,b*d});
  if((b<0&&0<c)||(d<0&&0<a)){
    cout<<x<<endl;
  }else{
    x=max<ll>(0,x);
    cout<<x<<endl;
  }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int n;
string s[2];
int num[2];
map<char,int> mp;
map<int,char> imp;

int func(string s) {
  int n = s.size();
  int i = 0;
  int res = 0;
  while (i < n) {
    if (isdigit(s[i])) {
      int d = s[i]-'0';
      i++;
      res += d*mp[s[i]];
    } else {
      res += mp[s[i]];
    }
    i++;
  }
  return res;
}

string inv_func(int x) {
  string res;
  int k = 1000;
  while (x > 0) {
    int d = x/k;
    if (d != 0) {
      if (d == 1) {
        res += string(1,imp[k]);
      } else {
        res += string(1,char(d+'0'))+string(1,imp[k]);
      }
    }
    x -= d*k;
    k /= 10;
  }
  return res;
}

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

  mp['m'] = 1000;
  mp['c'] = 100;
  mp['x'] = 10;
  mp['i'] = 1;
  imp[1000] = 'm';
  imp[100] = 'c';
  imp[10] = 'x';
  imp[1] = 'i';
  cin >> n;
  REP(i,n) {
    REP(j,2) cin >> s[j], num[j] = func(s[j]);
    string ans = inv_func(num[0]+num[1]);
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3000
#include <iostream>
using namespace std;
int main(){
    int S,h,m,s,a;
    cin>>S;
    h=S/3600;
    a=S-h*3600;
    m=a/60;
    s=a-m*60;
    
    cout<<h<<":"<<m<<":"<<s<<endl;
    return 0;
}



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

using namespace std;

int main() {
	string dot = "...";
	int k;
	string s;
	cin >> k >> s;
	if (k >= s.length()) {
		cout << s << endl;
	}
	else {
		cout << s.substr(0, k) + dot << endl;
	}
}

Measured memory_bytes: 3108
#include <stdio.h>
int main()
{
int a, b, c;
scanf("%d %d %d", &a, &b, &c);

if (a <= b&&a <= c)
{if (b <= c)
printf("%d %d %d\n", a, b, c);
else
printf("%d %d %d\n", a, c, b);
}
else if (b <= a&&b <= c)
{if (a <= c)
printf("%d %d %d\n", b, a, c);
else
printf("%d %d %d\n", b, c, a);
}
else if (c <= b&&c <= a)
{if (b <= a)
printf("%d %d %d\n", c, b, a);
else
printf("%d %d %d\n", c, a, b);
}

return 0;
}

Measured memory_bytes: 2692
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define ALL(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
  ll N;cin >> N;
  vector<ll> V;
  ll sum=0,l=1,A=N,r=2;
  while(1){
    if(abs(N)%r!=0){
      sum+=l;
      V.push_back(1);
      N-=l;
    }
    else{
      V.push_back(0);
    }
    l*=-2;
    r*=2;
    if(sum==A){
      break;
    }
  }
  reverse(ALL(V));
  rep(i,V.size()){
    cout << V[i];
  }
  cout << endl;
}

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

#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define pqMax priority_queue<int>
#define pqMin priority_queue<int, vector<int>, greater<int>>
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie();                        \
    cout.tie()
int n, t, i, j, k;
const int N = 3005;
int dp[N][N];

void solve() {
    cin >> n;
    vi a(n);
    for (int &i : a) cin >> i;
    for (i = n - 1; i >= 0; i--) {
        for (j = i; j < n; j++) {
            dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1]);
        }
    }
    cout << dp[0][n - 1] << '\n';
}

int32_t main() {
    FAST;
    solve();
}

Measured memory_bytes: 70016